Skip to main content

Crate mcplease

Crate mcplease 

Source
Expand description

A simple framework for writing Model Context Protocol servers.

The types and headers modules are unconditional — both sides of the protocol need all of them, and they cost nothing but serde. headers is shared rather than split because a client deriving what to send and a server checking what arrived are the same derivation; splitting them is how they drift. Everything else sits behind a feature naming either a side of the protocol or a transport; see the [features] table in Cargo.toml. The default is everything.

A server that speaks a transport this crate does not implement wants default-features = false, features = ["server"]: that is traits, the tools! macro, and handle_request, which answers a decoded request without doing any I/O.

A client wants default-features = false, features = ["client"]: the client module, which is the same split from the other side — it builds requests and classifies the messages that arrive, and leaves framing, connections, and authorization to the transport. It pulls no dependencies this crate does not already have.

The dependencies re-exported at the root are there for the macros to name and for a downstream tool to use without duplicating the version requirement. Each is present only under the features that pull it.

Re-exports§

pub use anyhow;server or session
pub use clap;cli
pub use dirs;cli or session
pub use fieldwork;server
pub use log;
pub use schemars;server
pub use serde;
pub use serde_json;
pub use shellexpand;cli or session

Modules§

clientclient
Transport-agnostic client protocol — the mirror of handle_request.
headers
The standard request headers HTTP transports carry from 2026-07-28 onward (SEP-2243), and the validation a server owes them.
sessionsession
traitsserver
types
Serialization types for the Model Context Protocol.

Macros§

server_infoserver
structured_outputserver
Implement ToolOutput for types that derive JsonSchema and Serialize, using the spec’s recommended lossless shape.
toolsserver

Structs§

ServerConfigserver
Everything the serve loop needs beyond the tools themselves.

Constants§

DEFAULT_TOOLS_TTL_MSserver
How long a client may consider a tools/list result fresh.

Functions§

handle_requestserver
Answer one request. Dispatch is stateless: every supported revision’s entry points are answerable at any time, so both the initialize handshake (revisions through 2025-11-25) and the stateless server/discover flow (2026-07-28) work against the same loop.
runcli
servestdio
Read messages from stdin until EOF, answering each request on stdout.