Chapters — Connection Layer (MCP)
MCP·How It Works·7 min read·Sep 5, 2026

How the Pieces Fit Together

The host, client, and server roles in MCP, how they talk over JSON-RPC, and what a full request actually looks like end to end.

Three roles, one connection

MCP splits responsibility across three roles, and it's worth keeping them straight before anything else, since most confusion about the protocol traces back to mixing them up.

Host
The application a person actually uses: a desktop AI assistant, an IDE, a custom internal tool. It decides which servers to connect to.
Client
Lives inside the host and maintains one connection to one server. A host with three servers running has three clients, each talking to exactly one of them.
Server
A lightweight program exposing a specific set of tools, resources, and prompts. It doesn't know or care which host is talking to it.

A server that exposes, say, a project tracker's tools doesn't need to know whether it's being called from a desktop assistant or a custom internal dashboard. That separation is what makes a server reusable across completely different hosts without any changes on either side.

The wire format: JSON-RPC 2.0

Underneath the roles, MCP is built on JSON-RPC 2.0, a lightweight standard for structuring requests and responses as JSON. It gives MCP a few things for free: requests can flow in either direction (a server can ask the AI model for something mid-task, not just respond to requests), connections stay stateful across a whole session instead of resetting every call, and long-running work doesn't have to block the connection while it finishes.

Picking a transport

The same JSON-RPC messages can travel over more than one transport, and the right choice depends on where the server runs:

Transport options
STDIO
The server runs as a local subprocess of the host. Lowest latency, simplest security model (nothing leaves the machine), the default choice for local development and single-user tools.
Streamable HTTP
The server runs remotely and the host connects over the network. Needed for shared or cloud-hosted servers, supports connection reuse and better handles many concurrent clients than the plain HTTP-plus-SSE approach it replaced.

If you're building something only you will run on your own machine, start with STDIO; there's nothing to secure beyond your own filesystem permissions. Move to Streamable HTTP once a server needs to serve more than one person or live somewhere other than a laptop.

What a request actually looks like

Here's the shape of a tool a server might advertise:

{
  "name": "add_calendar_event",
  "description": "Create a calendar event with a title, start time, and optional attendees",
  "inputSchema": {
    "type": "object",
    "properties": {
      "title": { "type": "string" },
      "start_time": { "type": "string" },
      "attendees": { "type": "array", "items": { "type": "string" } }
    },
    "required": ["title", "start_time"]
  }
}

And here's the full sequence from connection to result:

  1. The client connects to the server over the chosen transport.
  2. The server advertises its available tools, resources, and prompts.
  3. The AI model, seeing what's available, decides a tool is relevant to the current task.
  4. The model constructs a call matching that tool's input schema.
  5. The client sends the call to the server as a JSON-RPC request.
  6. The server executes it and returns a result, or an error.
  7. The client hands the result back to the model.
  8. The model incorporates it and continues, or responds to the user.

Every one of the deeper topics in this guide, tool design, security, performance, is really about making one or more of those eight steps work well under real conditions rather than just in a demo.

Part of a free guide

Connection Layer (MCP)

A simple guide to MCP, the protocol that lets AI tools talk to the outside world.

Browse All Guides →