Expand description
mcp — the Model Context Protocol base library.
A reusable, agentd-independent core for speaking MCP across every protocol
revision. Two protocol eras coexist (see version):
- Legacy (
2025-11-25and earlier): aninitializehandshake establishes a session; the negotiated version + capabilities are learned once, and server→client messages ride a session-scoped SSE stream. - Modern (
2026-07-28+, “stateless”): no handshake and no session — every request carries its protocol version, client identity, and capabilities in_meta(mirrored toMCP-Protocol-Version/Mcp-Method/Mcp-Nameheaders on Streamable HTTP), any request can hit any server instance, and long-lived notifications ride asubscriptions/listenresponse stream.
This crate keeps that era logic in one place so a client or server built on it
can be dual-era without branching everywhere. wire holds the message
types and version the era model; the client, http transport, and
server base build on them.
Dependency budget: serde + serde_json only (the agentd minimalism moat).
Modules§
- client
- MCP client over the Streamable HTTP transport. No local process is ever spawned: a server is reached over a socket or not at all.
- http
- The MCP Streamable HTTP client transport.
- http_
server - The Streamable HTTP MCP server: HTTP/1.1 + SSE over TCP (plain, or TLS via
the [
net::tls] acceptor), reusing the sameHandler/ [lifecycle_response] /SubRegistryas the socket servers. This is the serving mirror of the crate’s HTTP client (crate::http) and the transport the HTTPS control plane rides. - inbound
- Server→client requests: the half of MCP a client usually forgets.
- modern
- The modern (stateless,
2026-07-28+) protocol dialect: how a request is constructed when there is noinitializehandshake and no session. modelcontextprotocol.io/specification/draft/basic/transports/streamable-http. - rmcp_
client - The official SDK, wrapped so the rest of agentd stays blocking.
- rmcp_
transport - agentd’s credentialed socket under the SDK’s transport trait. agentd’s socket, under the official SDK’s transport trait.
- rpc
- Shared JSON-RPC 2.0 codec.
- server
- The reusable MCP server base: transport, framing, connection handling, the
lifecycle/version machinery, and the resource-subscription registry — agentd’s
served self-MCP (and any other embedder’s server) builds its domain surface on
top by implementing
Handler. - version
- MCP protocol version + era model, and version negotiation for both eras.
- wire
- MCP wire types — the Model Context Protocol message surface, shared by the client and the served-MCP side.