MCP Architecture: Hosts, Clients, Servers, and Transports
- Name the three MCP participants and describe what each one is responsible for
- Explain the difference between stdio and Streamable HTTP transports and when to choose each
- Describe what JSON-RPC 2.0 is and why MCP uses it, without needing to write raw JSON-RPC messages
- Explain why MCP is stateless and what that means for tools that need to maintain state across calls
The Three Participants
Every MCP interaction involves three participants. Understanding which one does what prevents a lot of confusion when things go wrong.
MCP Host: The AI application that owns the conversation and coordinates everything. In this track, your Python agent script is the host. In other setups, the host might be Claude Desktop, VS Code, or Cursor. The host decides which MCP servers to connect to, manages the conversation loop, and passes tool results back to the language model.
MCP Client: A connection object inside the host. For every MCP server the host connects to, it creates one MCP client to manage that specific connection. If your agent connects to three MCP servers (filesystem, fetch, and your custom notes server), it creates three MCP clients. Each client maintains its own dedicated connection and handles the protocol handshake, tool discovery, and tool calls for its server.
MCP Server: A separate process that exposes tools, resources, and prompt templates to any client that connects to it. The server does not know or care what host or LLM is on the other end — it just responds to protocol requests. A local filesystem server, a web-fetch server, and your custom notes server are all MCP servers.
The key point: host creates clients, clients connect to servers. One host, many clients, each pointing at a different server.
Stdio Transport
Stdio (standard input/output) transport is the simplest way to connect an MCP client to an MCP server. The host launches the server as a child process and communicates with it by writing JSON-RPC messages to the process's stdin and reading responses from its stdout.
Stdio transport is the right choice for local servers that run on the same machine as the host. It requires no networking, no port management, and no firewall rules. When you use the official filesystem or fetch MCP servers, they use stdio. When Claude Desktop connects to local MCP servers, it uses stdio.
The lifecycle with stdio: the host spawns the server process when the agent starts, communicates with it over the process's stdin/stdout while the agent is running, and the server process exits when the agent closes the connection or terminates.
Streamable HTTP Transport
Streamable HTTP transport connects a client to a server over the network. The client sends requests to the server via HTTP POST and receives responses, with optional Server-Sent Events for streaming. This transport replaced the older HTTP+SSE transport in the March 2025 MCP specification — if you see older tutorials that mention "SSE transport," they are describing the previous mechanism.
Streamable HTTP is the right choice for:
- Remote servers: MCP servers published by third parties and hosted in the cloud (GitHub's MCP server, Sentry's MCP server, etc.)
- Shared servers: A single MCP server instance serving multiple hosts simultaneously (a team's shared database server)
- Persistent servers: Servers that need to stay running between agent sessions rather than being spawned and killed per session
Authentication for Streamable HTTP servers uses standard HTTP mechanisms: bearer tokens, API keys in headers, or OAuth. Lesson 11 covers HTTP transport and remote servers in depth.
The Protocol Layer: JSON-RPC 2.0
Under both transports, MCP uses JSON-RPC 2.0 as its message format. JSON-RPC is a lightweight remote procedure call protocol that sends requests as JSON objects and returns responses in a matching format. You will not usually write raw JSON-RPC yourself — the Python MCP SDK handles this — but understanding the structure helps when debugging.
A tool discovery request looks like this:
{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/list",
"params": {}
}
And the server responds with:
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"tools": [
{
"name": "read_file",
"description": "Read the contents of a file",
"inputSchema": {
"type": "object",
"properties": {
"path": { "type": "string" }
},
"required": ["path"]
}
}
]
}
}
The method field names the operation (tools/list, tools/call, resources/list, resources/read). The id field links each response to its request. Each request also carries a _meta field with the protocol version and client capabilities, though the Python SDK adds this automatically.
Discovery: How a Client Learns What a Server Offers
When a client first connects to a server, it can send a server/discover request to learn what the server supports — which primitives it exposes (tools, resources, prompts) and which protocol version it speaks. The server responds with its capabilities, and the client stores this for the duration of the connection.
After discovery, the client calls tools/list to get the full list of tool definitions (name, description, parameter schema). It calls resources/list for resources and prompts/list for prompt templates. These listings are dynamic — if a server gains new tools at runtime, it can notify connected clients via a notifications/tools/list_changed message.
In practice, the Python SDK handles all of this automatically when you open a client connection. By the time your code has an open client object, the tool list is already available on it.
Statelessness
MCP is a stateless protocol. Every request carries all the information needed to process it — the protocol version, client identity, and capabilities appear in a _meta field on every request. The server does not maintain per-client session state between requests.
This design decision matters for one practical reason: if a tool needs to maintain state across calls (for example, an open file handle, a database transaction, or a browser session), the server should return an explicit handle from the creation call and require that handle as a parameter on subsequent calls. The language model is responsible for carrying the handle forward through the conversation. Lesson 4 covers stateful tool design patterns.
How This Maps to the Track
In the agent you build in this track:
- Your Python script is the host
- Three Python MCP client objects connect to three servers, one each
- The filesystem and fetch servers run as local child processes over stdio transport
- Your custom notes server also runs locally over stdio
- All JSON-RPC message handling is managed by the Python MCP SDK — you will not write raw JSON-RPC
Lesson 3 sets up this environment and builds the first server. The architecture concepts from this lesson reappear concretely throughout the rest of the track.
- The host creates one MCP client per server — if your agent connects to three servers, it manages three separate client connections, each with its own tool list
- Stdio transport spawns the server as a child process and communicates over stdin/stdout — no ports, no networking, correct for local servers on the same machine
- The older HTTP+SSE transport was replaced by Streamable HTTP in the March 2025 spec — older tutorials may describe the previous mechanism
- MCP is stateless: servers do not maintain per-client session memory between requests; tools that need state should return explicit handles and require them on subsequent calls
Progress is saved in this browser only — clear your cache or switch device and it's gone. Create a free account and it follows you everywhere.