Model Context Protocol (MCP): Connect AI to Your Tools and DataWhy MCP and how it works · Lesson 2 of 18

MCP architecture: hosts, clients, servers and the protocol

Article · 15 min · 9 min lecture

Video lecture

MCP architecture: hosts, clients, servers and the protocol

14 chapters · about 9 min · full transcript

Coming soon

Chapter 1 of 14

MCP architecture

  • Hosts, clients, servers
  • Data and transport layers
  • Old vs new discovery
  • A tool call end to end

The narrated lecture is in production

Every chapter is scripted and ready. Browse the chapters and read the full transcript now — the video will appear here when it’s published.

Chapters

The three roles

  • Host: the AI application the user interacts with (Claude Desktop, Claude Code, an IDE, ChatGPT, your own agent). It manages the model, the conversation, user consent and security policy.
  • Client: a component inside the host that maintains a connection to one server. A host typically runs many clients, one per connected server.
  • Server: a program that exposes capabilities (tools, resources, prompts) over MCP. It can be a local subprocess or a remote web service.

A key design principle: servers should be easy to build and isolated from each other. A server never sees the whole conversation or other servers' data; the host decides what each server receives. That isolation is a security property; keep it.

The layers

  1. Data layer: JSON-RPC 2.0 messages (requests, results, errors, notifications) with defined methods such as tools/list, tools/call, resources/read, prompts/get.
  2. Transport layer: how messages move. stdio for local subprocesses, Streamable HTTP for remote servers (lesson 5).

Discovery and versions

In the 2025-era specs (2025-06-18, 2025-11-25), a connection starts with an initialize request where client and server exchange protocol versions and capabilities, followed by an initialized notification. Streamable HTTP could carry a session ID.

In 2026-07-28, that handshake is gone. Every request carries its protocol version, client capabilities and (recommended) client identity in _meta; servers identify themselves in each result's _meta. Servers must implement a new server/discover method so clients can learn supported versions and capabilities up front if they want. Protocol-level sessions and the Mcp-Session-Id header are removed; if a server needs state across calls, it mints an explicit handle (for example a cart_id) returned by one tool and passed as an argument to the next, which the model can see and reason about.

Official SDKs handle both eras: the v2 TypeScript and Python SDKs speak 2026-07-28 and serve older clients too. When you evaluate a third-party server or client, check which protocol versions it supports.

Capabilities

Each side advertises what it supports. Servers declare capabilities such as tools, resources, prompts, completions (argument autocompletion) and optional extensions. Clients declare capabilities such as elicitation (and, in older versions, sampling and roots, now deprecated in 2026-07-28). Neither side should use a feature the other hasn't declared.

A request, end to end (Streamable HTTP, 2026-07-28)

POST /mcp HTTP/1.1
Content-Type: application/json
MCP-Protocol-Version: 2026-07-28
Mcp-Method: tools/call
Mcp-Name: search_contacts
Authorization: Bearer eyJ...

{"jsonrpc": "2.0", "id": 7, "method": "tools/call",
 "params": {"name": "search_contacts", "arguments": {"query": "Acme"},
            "_meta": {"io.modelcontextprotocol/clientInfo": {"name": "my-agent", "version": "1.4.0"}}}}

The Mcp-Method and Mcp-Name headers let gateways, rate limiters and WAFs route and authorize without parsing the body. The server replies with a JSON result (or an SSE stream when it sends progress notifications first):

{"jsonrpc": "2.0", "id": 7, "result": {
  "resultType": "complete",
  "content": [{"type": "text", "text": "[{\"id\":\"c_101\",\"name\":\"Sara Khan\"}]"}],
  "structuredContent": {"contacts": [{"id": "c_101", "name": "Sara Khan"}]},
  "isError": false}}

How the host uses the server

  1. The host lists tools from each connected server and passes their names, descriptions and schemas to the model (often namespaced, such as crm__search_contacts).
  2. The model decides to call a tool.
  3. The host checks policy and user consent, then its client sends tools/call to the right server.
  4. The result is added to the model's context.

The spec says there should always be a human in the loop with the ability to deny tool invocations, and hosts should show which tools are exposed and when they are called. That is host behavior, not something a server can guarantee.

Worked example: mapping a real deployment

A UK retailer's customer-insights assistant:

RoleComponent
HostInternal web app with a chat UI and an agent loop
ClientsThree MCP clients inside the web app's backend
Serversorders (remote, Streamable HTTP, OAuth), reviews (remote), analytics-sql (remote, read-only)
PolicyHost allows only read tools for analysts; no write tools exposed

Because servers are isolated, the reviews server never sees order data, and a compromise of one server does not expose the others' credentials.

Hands-on: watch the protocol

Run the demo server from lesson 1 under the Inspector and open its message/history view. Call a tool and read a resource, then inspect the JSON-RPC requests and responses. Identify: the method, the params, _meta fields, structuredContent versus content, and any error objects.

Pitfalls

  • Assuming a server can see the conversation (it cannot, unless the host sends data as tool arguments).
  • Confusing host and client responsibilities; consent and policy live in the host.
  • Ignoring protocol-version mismatches when mixing older clients with newer servers.

Measuring success

For your architecture, document each server's role, transport, auth, data scope and supported protocol versions. An up-to-date inventory is the foundation for security reviews in module 5.

Key takeaways

  • Hosts run the model and policy; each client connects to one server; servers expose capabilities in isolation.
  • MCP uses JSON-RPC 2.0 over stdio or Streamable HTTP.
  • 2026-07-28 removed the initialize handshake and sessions; requests carry version and capabilities in _meta.
  • Mcp-Method and Mcp-Name headers let gateways route and authorize without parsing bodies.
  • Consent and human approval are host responsibilities; servers cannot guarantee them.

Check your understanding

Quick questions to lock in the lesson. They don’t count towards your certificate.

  1. A server needs to remember a shopping cart across several tool calls under the 2026-07-28 spec. What is the recommended approach?
  2. Which component is responsible for asking the user before a tool runs?
  3. What do the Mcp-Method and Mcp-Name headers enable?

Put it into practice

Draw the host, client and server map for an AI assistant you use or plan, including transport, auth and supported protocol versions for each server.

Enrol for free to save your progress

Reading is always free. Enrol to keep your place, take the final assessment and earn a verifiable certificate.