Skip to content
AI Engineer Guide.

concept · concepts · intermediate · concept 4 of 16

Host/client/server

0 of 16 complete

Why it matters

A single-process design would let the application hold a database connection, expose it to the model, and be done. That works until you need to reuse the integration elsewhere, run it under a different user's credentials, or revoke it without redeploying the application.

MCP splits the concern deliberately. The host is the application the user is in: it owns the conversation, the context window, the consent UI, the audit log, and the decision about which capabilities are visible for this turn. The client is a protocol component inside the host that maintains exactly one connection to one server. The server is a program that exposes tools, resources and prompts.

One host, many clients, many servers. The official architecture example is an editor acting as host, instantiating one client for a Sentry server and another for a local filesystem server. Neither server knows the other exists; the host composes them.

This is also where the model fits — and does not. MCP says nothing about how the host prompts the model. It moves capabilities and context to the host's door. Everything after that door, including whether the model ever sees a tool, is application design.

Mental model

Think of the host as an operating system, clients as file descriptors, and servers as processes. The application owns the process table and the permission model; each descriptor is a private channel; each process does one job.

The analogy breaks on multiplexing and identity. A file descriptor is interchangeable and the kernel schedules it; an MCP client is bound to one server, holds credentials for one user, and must be managed by application policy rather than a scheduler. Two clients to the same server are two independent connections with two independent authorisation contexts, not two handles on a shared session. And unlike processes, servers are often remote multi-tenant services, so "restart it" is not yours to do.

How it works

Host → client → server, one callInteractive

Current revision 2026-07-28. Discovery is a cache fill, not session state; every request carries its own version and client capabilities in _meta.

Host

model + policy

Client

one per server

Server

issues API

Step 1/5 · discover
versions + capabilitiesreturn · Server → Client
{ "jsonrpc": "2.0", "id": 1,
  "result": {
    "resultType": "complete",
    "supportedVersions": ["2026-07-28"],
    "capabilities": {
      "tools": { "listChanged": true } },
    "_meta": {
      "io.modelcontextprotocol/serverInfo":
        { "name": "issues", "version": "0.9" } },
    "ttlMs": 300000,
    "cacheScope": "public" } }

Step 1: discover. Hover, tap or tab to any message to inspect its payload.

Figure. The roles are not a chain of proxies: the host owns routing, consent and context; one client owns exactly one server connection; the server owns its declared capabilities. In the 2026-07-28 revision there is no initialize — discovery is a cacheable request, and version plus client capabilities ride in _meta on every request. Every result carries resultType.

What to notice. The failure is version skew. A client that omits _meta, or names a version the server does not serve, is refused before the tool runs; and a tools/list result cached past ttlMs can advertise a descriptor the server has already replaced. Neither failure is visible to the model, which only sees the host's filtered tool list.

Text version

Sequence across three lifelines: Host (model and policy), Client (one per server) and Server (issues API). Step 1, discover: Client to Server server/discover with _meta carrying protocolVersion and clientCapabilities; Server to Client a result with resultType complete, supportedVersions, capabilities, serverInfo under _meta, ttlMs and cacheScope public. Step 2, register: Client to Server tools/list with the same _meta; Server to Client a result with resultType complete, one tool descriptor whose inputSchema defines the query property, ttlMs and cacheScope public, and no nextCursor. Step 3, route: an in-process Host to Client hop, drawn grey and labelled in-process, carrying the model's issues_search call after allowlist, schema and consent checks. Step 4, call: Client to Server tools/call with name, arguments and _meta carrying protocolVersion, clientInfo and clientCapabilities. Step 5, return: Server to Client content plus structuredContent and resultType complete; then an in-process Client to Host hop that puts the result into context as untrusted third-party data.

  1. Configuration. The host reads a list of servers: a launch command and arguments for a local server, or a URL for a remote one. Each entry becomes one client.
  2. Transport establishment. For stdio, the host spawns the subprocess and speaks newline-delimited JSON-RPC over stdin and stdout; stderr is for logs. For Streamable HTTP, each message is an HTTP POST to a single endpoint, and replies arrive either as a JSON object or as a request-scoped SSE stream.
  3. Discovery. The client sends server/discover (or any request) and receives supported protocol versions, a capability object, and server identity. Results are cacheable, so discovery is not a per-request cost.
  4. Registration. The host calls tools/list, resources/list, resources/templates/list and prompts/list as the declared capabilities allow, then filters the results by policy, user permissions and relevance before anything reaches the model.
  5. Routing. When the model emits a tool call, the host finds the client that owns that tool name, validates arguments against the schema, applies consent, and issues tools/call. Names must be namespaced per server; two servers can both define search.
  6. Intermediate states. A server that needs input returns an input_required result. The host collects answers, then retries the original request with inputResponses and the echoed requestState. Nothing about that exchange depends on a shared connection state.
  7. Change notification. The client opens a subscriptions/listen stream for the notification types it cares about, and refreshes its registry when a list_changed event arrives.
  8. Teardown and cancellation. On stdio, the client sends notifications/cancelled and later terminates the subprocess. On Streamable HTTP, it closes the response stream. The host must reap local processes or they accumulate.

A request therefore looks like this — note that the version and capabilities travel with the message, not with the connection:

{
  "jsonrpc": "2.0",
  "id": 7,
  "method": "tools/call",
  "params": {
    "name": "issues_search",
    "arguments": { "query": "timeout on upload" },
    "_meta": {
      "io.modelcontextprotocol/protocolVersion": "2026-07-28",
      "io.modelcontextprotocol/clientInfo": { "name": "editor", "version": "4.2.0" },
      "io.modelcontextprotocol/clientCapabilities": { "elicitation": {} }
    }
  }
}

Trade-offs

DeploymentGood forCostFails when
Local stdio serverFilesystem, git, local databasesOne process per client; no network isolationThe host runs server-side or multi-tenant
Remote Streamable HTTP, single tenantShared internal servicesAuth and network egress to manageEach end user needs their own upstream credentials
Remote HTTP with per-user OAuthSaaS integrations on behalf of usersToken storage, refresh, scope designTokens are cached without a user key
Gateway in front of many serversCentral policy, audit, rate limitsExtra hop, another thing to operateThe gateway becomes a confused deputy
Trade-off mapInteractive

Good for

Filesystem, git, local databases

Cost

One process per client; no network isolation

Fails when

The host runs server-side or multi-tenant

  1. The host runs server-side or multi-tenant
  2. Each end user needs their own upstream credentials
  3. Tokens are cached without a user key
  4. The gateway becomes a confused deputy

Figure. Each choice with what it buys, what it costs, and the case where it loses.

What to notice. The fourth column is the decision: if the losing case describes your situation, the choice is wrong.

Text version

Four trade-offs: Local stdio server is good for Filesystem, git, local databases, costs One process per client; no network isolation, and fails when The host runs server-side or multi-tenant. Remote Streamable HTTP, single tenant is good for Shared internal services, costs Auth and network egress to manage, and fails when Each end user needs their own upstream credentials. Remote HTTP with per-user OAuth is good for SaaS integrations on behalf of users, costs Token storage, refresh, scope design, and fails when Tokens are cached without a user key. Gateway in front of many servers is good for Central policy, audit, rate limits, costs Extra hop, another thing to operate, and fails when The gateway becomes a confused deputy

Failure modes

  • Orphaned stdio processes. The host crashes or a client is replaced, and child processes keep running with open handles. Debug: listing children of the host process after a restart and by asserting a supervisor that kills the process group on disconnect.
  • Token cache keyed by server only. User A authorises a server, user B gets A's token because the cache key omitted the user. Debug: logging the cache key on every token lookup and by asserting that the token's subject matches the request's authenticated user.
  • Stale discovery. Tool lists are cached indefinitely, a server deploys a new schema, and calls fail until the host restarts. Debug: comparing the cached tools/list snapshot against a fresh call after each server deploy, and by honouring ttlMs.
  • Head-of-line blocking. One slow server stalls the host's single event loop and every other server's calls queue behind it. Debug: measuring per-server call latency separately and by putting a timeout and circuit breaker around each client.

In production

Treat each client as a dependency with its own SLO. Bound connect, discover and call timeouts separately; a discovery timeout should not be retried as aggressively as a call timeout. Keep a per-server circuit breaker so one broken integration degrades to "unavailable" instead of exhausting the host's concurrency budget.

Concurrency is per client, and remote servers may enforce their own limits. Fan-out across ten servers is ten parallel calls with ten independent failure modes — collect results with per-call deadlines rather than one overall timeout, or a single slow server will discard nine good results.

Log the boundary, not just the outcome: server identity and version, discovered protocol version, tool name, argument shape, duration, and whether a human approved. That log is what lets you answer "what could this agent have done, and what did it actually do" during an incident.

Common misconceptions

People think: The MCP server is the agent.

Actually: The server has no model and no loop. It exposes capabilities and executes calls. Planning, memory and tool selection belong to the host.

People think: One client can talk to several servers.

Actually: A client maintains one connection to one server. A host creates as many clients as it has servers, which is also why per-server policy is expressible.

People think: Stateless means the server cannot remember anything.

Actually: It means the protocol carries no implicit session. A server can still keep state, but it must hand the client an explicit handle and bind that handle to the authenticated principal.

Interview angle

A common prompt is "walk me through what happens when an agent calls an MCP tool." The answer should move through the roles in order: host selects and filters tools, client sends tools/call with per-request metadata, server validates and executes, result returns as content, host decides what enters context. Then show judgement: where authorisation is enforced, why discovery is cached, what happens when the server needs user input, and which failure you would instrument first. See MCP primitives and the protocols interview category.

Sources