Skip to main content

Crate mcp

Crate mcp 

Source
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-25 and earlier): an initialize handshake 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 to MCP-Protocol-Version / Mcp-Method / Mcp-Name headers on Streamable HTTP), any request can hit any server instance, and long-lived notifications ride a subscriptions/listen response 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. Phase 1 provides the wire types and the version 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. RFC 0004; RFC 0012 (no local process spawn).
http
The MCP Streamable HTTP client transport (v2.0.0). RFC 0004 §transport.
http_server
The Streamable HTTP MCP server: HTTP/1.1 + SSE over TCP (plain, or TLS via the [net::tls] acceptor), reusing the same Handler / [lifecycle_response] / SubRegistry as 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 no initialize handshake 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. RFC 0004 (client), RFC 0005 (server).