MCP under the hood: a technical walkthrough
The Model Context Protocol is not magic. It is JSON-RPC 2.0, three primitives, and two transports. Here is what actually flows over the wire.
Most “what is MCP” posts stop at the analogy: “it’s USB-C for AI tools.” That is technically correct and operationally useless. If you actually want to write an MCP server, debug a broken connection, or reason about why your agent is slow, you need the mechanics.
This post is the mechanics. We will look at the wire format, the architecture, the three primitives, and what is changing in the 2026-07-28 release candidate.
What MCP is, precisely
The Model Context Protocol is an open specification, originally released by Anthropic in November 2024 and donated to the Linux Foundation’s Agentic AI Foundation in December 2025. As of early 2026 it has surpassed 97 million monthly SDK downloads and is supported natively by Anthropic, OpenAI, Google, Microsoft, and AWS.
Stripped to essentials, MCP is three things stacked together:
- A wire format: JSON-RPC 2.0
- A three-role architecture: host, client, server
- A typed capability surface: tools, resources, prompts (plus a few extensions)
That is the whole protocol. Everything else is convention, SDKs, or transport choice.
The architecture
Most diagrams of MCP show two boxes, “LLM” and “tool”, connected by an arrow. That diagram is wrong. The real picture has three layers, and the distinction matters because the host and the client are not the same thing:
The asymmetry is intentional. The host can run inside any LLM application — Claude Desktop, Cursor, your agent runtime, a CLI. The host spawns one MCP client per server, and each client maintains an isolated JSON-RPC session. A server has no idea other clients exist; it just answers requests. The host is the only thing that knows the full picture of what tools are available.
This matters because security and consent live in the host, not the server. The server can declare a tool called delete_database, but the host decides whether to surface it to the model and whether to ask the user before invoking it.
The wire format
Every MCP message is a JSON-RPC 2.0 envelope. There are three kinds:
{ "jsonrpc": "2.0", "id": 1, "method": "tools/list" }That is a request. The server replies with a response sharing the same id:
{ "jsonrpc": "2.0", "id": 1, "result": { "tools": [ { "name": "get_weather", "description": "Get the current weather for a location", "inputSchema": { "type": "object", "properties": { "location": { "type": "string" } }, "required": ["location"] } } ] }}Either side can also send notifications — fire-and-forget messages with no id and no reply:
{ "jsonrpc": "2.0", "method": "notifications/tools/list_changed" }That tells the client “my tool list just changed, re-fetch it.” This bidirectionality is one of the underappreciated parts of the protocol. Servers can push updates to clients; servers can also call back to the client for things like sampling/createMessage (asking the host’s LLM to generate something on the server’s behalf).
The three primitives
A server’s job is to expose capabilities. MCP defines three categories:
The control-axis labels are not decorative. They define who decides when each primitive is used:
- Tools are model-controlled: the LLM looks at the user’s request, decides to call
send_email, and the host executes it (optionally after user confirmation) - Resources are application-controlled: the host attaches relevant resources to the context window automatically, like file contents in an IDE
- Prompts are user-controlled: the user explicitly invokes them, typically via a slash command in the host UI
Treating tools and resources as interchangeable is the most common architectural mistake in new MCP servers. A database query that returns text might feel like a tool, but if it has no side effects and you want the host to attach results automatically, it is a resource. The distinction shapes how the host surfaces it to the model.
A real session, message by message
Here is what a complete tool call looks like on the wire. The client connects to a weather server, lists its tools, and calls one:
Every interaction follows this shape. The handshake establishes protocol version and capabilities, then everything else is */list and */call or */read against the three primitives.
The two transports
MCP itself is transport-agnostic — it cares about the JSON-RPC envelope, not how bytes get from A to B. In practice you choose one of two transports:
stdio — the server is a child process of the host. Messages flow over the child’s stdin/stdout. This is what almost every local MCP server uses today (filesystem access, local databases, dev tools). Zero network exposure, trivial to secure, but only works on the same machine.
Streamable HTTP — replaces the older HTTP+SSE transport. The client makes POST requests to a single endpoint, and the server can stream responses back. This is what enables remote MCP servers running as cloud services.
The big news for 2026 is the protocol going stateless at the HTTP layer in the upcoming 2026-07-28 release candidate. Current servers have to hold session state, which prevents horizontal scaling behind load balancers — every request from the same session has to land on the same instance. The new spec standardizes session creation, resumption, and migration so a request can hit any backend behind a load balancer. This is what production deployments have been waiting for.
A minimal server in Python
Here is a complete MCP server that exposes one tool. About 25 lines:
# pip install mcp
from mcp.server.fastmcp import FastMCPimport httpx
mcp = FastMCP("weather")
@mcp.tool()async def get_weather(city: str) -> str: """Get the current weather for a city.""" async with httpx.AsyncClient() as client: resp = await client.get(f"https://wttr.in/{city}?format=3") return resp.text
if __name__ == "__main__": mcp.run()That is it. The FastMCP framework introspects the function signature and docstring to generate the JSON Schema for inputSchema. Connect Claude Desktop or any MCP client to this script and it can now call get_weather.
For a remote server over HTTP, you change one line:
mcp.run(transport="streamable-http", port=8000)What MCP is not
A few common misunderstandings worth correcting:
MCP is not a replacement for REST APIs. It is a protocol layered on top of your existing APIs, designed for LLMs to discover and invoke them.
MCP is not where you put your prompts. The Prompts primitive is for user-invoked templates the host surfaces as slash commands. Your system prompt and few-shot examples still belong in your host application’s orchestration layer.
MCP is not the same as A2A. Agent-to-Agent (released by Google in April 2025) is a sibling protocol for agents talking to other agents. MCP is for an agent talking to its tools. In December 2025, both protocols were donated to the Linux Foundation’s Agentic AI Foundation.
MCP does not solve authentication for you. OAuth 2.1 and OpenID Connect alignment is improving in the new spec, but production deployments still require you to think carefully about scopes and token rotation.
When to build one yourself
Build an MCP server when you have a service or data source that you want multiple LLM applications to access without writing custom adapters for each. The protocol’s value is in the N-to-M reduction: instead of N hosts each writing M tool integrations, every host writes one MCP client and every service writes one MCP server.
Do not build an MCP server when:
- The tool is a single API call you control end-to-end. Just call the API.
- You need streaming token-level output from a model. MCP is for tools, not for model serving.
- The integration is one-off and ephemeral. The boilerplate is not worth it.
The protocol’s power is in being a standard. If you are the only one who will ever use it, it is just JSON over a pipe.
What I would read next
- The MCP specification itself: modelcontextprotocol.io/specification
- The 2026 roadmap and 2026-07-28 release candidate posts on the official blog
- The Python and TypeScript SDK source — both are short and very readable
- The reference servers at github.com/modelcontextprotocol/servers
Next post in this thread: I am going to wire an MCP server into my homelab so I can ask Claude about my own infrastructure.
Comments
Replies use GitHub Discussions. You'll need a GitHub account to post.