Skip to main content
Version: 1.1.0 (latest)

How It Works

Before diving into reference docs, understand the big picture.

Architectureโ€‹

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” JSON-RPC over โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ โ”‚ โ—„โ”€โ”€โ”€ transport โ”€โ”€โ”€โ”€โ”€โ”€โ–บ โ”‚ โ”‚
โ”‚ MCP Client โ”‚ (stdio / HTTP / โ”‚ MCP Server โ”‚
โ”‚ (LLM host) โ”‚ Streamable HTTP) โ”‚ (your code) โ”‚
โ”‚ โ”‚ โ”‚ โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
โ”‚ โ”‚
โ”‚ "List tools?" โ”‚ "2 tools: say_hello, add"
โ”‚โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–บ โ”‚
โ”‚ โ”‚
โ”‚ "Call say_hello({name: World})" โ”‚
โ”‚โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–บ โ”‚
โ”‚ โ”‚
โ”‚ "Hello, World! ๐Ÿ‘‹" โ”‚
โ”‚ โ—„โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”‚

The client (Claude, ChatGPT, your own code) sends JSON-RPC requests over a transport. The server handles them and returns responses. The SDK manages the protocol layer - you write the handler methods.

Key componentsโ€‹

ComponentWhat it does
TransportHow messages travel: stdio (child process), Streamable HTTP (remote), or SSE (legacy)
ProtocolJSON-RPC 2.0 over the transport - requests, responses, notifications, errors
HandlerYour code: ServerHandler / ClientHandler trait implementations
Macrosmcp_tool, tool_box!, mcp_elicit - generate MCP schemas from Rust structs
McpServer / McpClientTraits injected into handlers - gives access to server/client capabilities

The initialization handshakeโ€‹

Every MCP connection starts with a two-step handshake:

  1. initialize - client sends its identity and capabilities; server responds with its identity, capabilities, and protocol version
  2. initialized - client acknowledges; server's on_initialized() hook fires

After initialization, the client and server know what each other supports and can exchange requests freely.

Server vs Client rolesโ€‹

ServerClient
ProvidesTools, resources, promptsLLM, user interaction, filesystem roots
RequestsList/read resources, elicitation, samplingCall tools, read resources, get prompts
NotifiesResource/tool/prompt list changedLogging level, cancellation, initialized
ImplementServerHandler / ServerHandlerCoreClientHandler / ClientHandlerCore

Transports at a glanceโ€‹

TransportClientsResumableHealth checksBest for
Stdio1NoNoLocal tools, desktop clients
Streamable HTTPManyYesYesServices, agents, production
SSEManyNoNoLegacy compatibility only

Nextโ€‹

Dive into Server Essentials or Client Essentials, or jump to the reference sections for detailed API docs.