Skip to content
AI Engineer Guide.

concept · concepts · intermediate · concept 3 of 16

MCP

0 of 16 complete

Why it matters

An AI application that can act needs the same short list of capabilities as every other AI application: read files, query a database, search a ticket tracker, send a message, open a pull request. Before a shared protocol, each application implemented each of those integrations itself, against each vendor's API, with its own schema, retry policy, authentication flow and error format.

That is an N×M problem. N applications times M systems, and every pair is a separate piece of code that drifts independently. MCP (Model Context Protocol), introduced by Anthropic in late 2024, factors the integration into a protocol boundary. A system exposes its capability once, as an MCP server. A host — an IDE, a chat client, an agent runtime — implements an MCP client once, and connects to any server.

The value is not the message format. JSON-RPC is old and unremarkable. The value is that tool discovery, invocation, error reporting and authorisation become uniform, so the host can treat every integration the same way: list it, describe it, gate it, log it, and revoke it.

The cost is real. You add a process or a network hop, a new trust boundary, a schema layer you do not control, and a dependency on a specification that is still moving quickly.

Mental model

MCP is USB-C for AI applications. One connector shape for many devices, without a bespoke driver for each one.

The analogy breaks in the place that matters most. USB-C standardises the physical connector and some power negotiation, but it says nothing about what a device does or whether it is safe to plug in. MCP standardises the message shape and the discovery handshake, not the meaning of a tool, the quality of its description, or the permission policy around it. A tool called query can run a read-only report or drop a production table. The host still has to sandbox, authorise and evaluate.

How it works

One call, no sessionInteractive

MCP 2026-07-28. There is no initialize and no session: every request carries protocolVersion and clientCapabilities in _meta, and a retry is simply another request.

Model

proposes

Host

policy

Client

1 link

Server

tools

Step 1/6 · propose
1 · propose · issues_searchin-process · Model → Host
{ "name": "issues_search",
  "arguments": { "query": "timeout on upload" } }

The model chose from the descriptors the host
placed in its context. It never sees the full
server inventory.

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

Figure. MCP 2026-07-28 is stateless: the stale call is refused with -32022, and the retry succeeds because the protocol version and client capabilities travel in _meta on the request, not in a handshake. The host, not the model, turns a proposal into tools/call and decides what enters context.

What to notice. The failure is version skew, and it is recoverable without reconnecting: the error names the versions the server serves. A request missing a required _meta field is refused as invalid params, and a tools/list cache reused past ttlMs can advertise a tool the server has replaced; neither is visible to the model, which sees only the host's filtered list. Ids and payload text are illustrative; discovery and tools/list are omitted because they are drawn on /learn/protocols/mcp-architecture.

Text version

Sequence across four lifelines: Model, Host (policy and context), Client (one connection) and Server (capability owner), in MCP revision 2026-07-28. Step 1, propose: an in-process Model to Host row carrying the model's call issues_search with arguments query 'timeout on upload'; the model chose from the descriptors the host placed in its context. Step 2, route: an in-process Host to Client row listing the checks that pass — the namespaced name resolves to this client, the arguments match the cached descriptor, and the allowlist plus consent rule allow it. Step 3, stale call: Client to Server tools/call with id 2, name issues_search and _meta naming protocolVersion 2025-06-18 and clientCapabilities {}. Step 4, refusal: Server to Client a JSON-RPC error with code -32022, message 'Unsupported protocol version' and data supported ['2026-07-28'] and requested '2025-06-18'. Step 5, retry: Client to Server tools/call with the same tool and new id 3, _meta naming 2026-07-28. Step 6, result: Server to Client resultType complete, content text '3 issues match timeout on upload', structuredContent matches 3 and isError false. Step 7, context: an in-process Client to Host row that puts the result into the prompt as untrusted third-party data. Step 8, invalidate: Server to Client notification notifications/tools/list_changed with _meta subscriptionId 7, on a subscriptions/listen stream opened earlier; the host must refresh tools/list before the next call.

  1. The host opens a connection per server. The host is the application the user interacts with. For each configured server it creates one MCP client, over one transport: stdio for a locally launched subprocess, Streamable HTTP for a remote endpoint.
  2. Every request is self-describing. The request body carries the protocol version and the client's capabilities in _meta, under io.modelcontextprotocol/* keys. There is no connection-level negotiation to rely on in the current revision.
  3. The client discovers the server. server/discover is optional to call but mandatory for every server to implement; it returns the versions the server accepts, its capability object, its identity, and cache hints. A client can also send a normal request first and handle a version error.
  4. The client lists what it can use. tools/list, resources/list, resources/templates/list and prompts/list return descriptors: name, description, and for tools a JSON Schema for arguments plus an optional output schema.
  5. The host assembles a tool list for the model. It filters by policy, formats the descriptors into the provider's tool-calling schema, and sends them with the conversation.
  6. The model requests a call; the host validates it. The arguments must satisfy the tool's inputSchema. The host applies whatever consent, allowlist or approval rule it has before executing anything.
  7. The server returns content, not just text. tools/call returns a content array — text, image, audio, resource links, embedded resources — plus optional structuredContent matching the tool's output schema.
  8. Slow or interactive work uses a round trip. A server that needs user input returns resultType: "input_required" with elicitation/create requests; the client gathers the answers and retries with inputResponses and the echoed requestState. The Tasks extension covers durable long-running work.
  9. Changes arrive by subscription. A client opens a subscriptions/listen stream naming the notifications it wants, and the server sends notifications/tools/list_changed and similar events on that stream.

What MCP does not solve

  • Tool quality. A server with vague descriptions or overlapping tools will be misused. Discovery makes bad tools visible, not good.
  • Authorisation policy. The protocol defines how to obtain and present a token. It does not decide which user may call which tool with which arguments.
  • Trust. A server is executable code, and its outputs are untrusted input. Connecting one is a supply-chain decision, not a configuration detail.
  • Context management. MCP moves data; it does not decide what belongs in the window. That remains an application concern.
Encoding
JSON-RPC 2.0, UTF-8
Transports
stdio, Streamable HTTP
Server primitives
Tools, resources, prompts
Current revision
2026-07-28
HTTP auth
OAuth 2.1

Trade-offs

ApproachGood forCostFails when
In-process function callingA fixed set of tools you ownOne codebase, no protocol boundaryEvery new integration touches your application code
MCP server per systemReuse across hosts and teamsProcess or network hop, versioning, trust reviewTool count grows faster than the model can choose well
REST + generated OpenAPI toolsExisting APIs with good specsSpec-to-tool translation loses intentEndpoints are chatty or designed for humans
Vendor-hosted connectorFast start, managed authLess control over schema and data pathYou need self-hosting or custom scopes
Trade-off mapInteractive

Good for

A fixed set of tools you own

Cost

One codebase, no protocol boundary

Fails when

Every new integration touches your application code

  1. Every new integration touches your application code
  2. Tool count grows faster than the model can choose well
  3. Endpoints are chatty or designed for humans
  4. You need self-hosting or custom scopes

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: In-process function calling is good for A fixed set of tools you own, costs One codebase, no protocol boundary, and fails when Every new integration touches your application code. MCP server per system is good for Reuse across hosts and teams, costs Process or network hop, versioning, trust review, and fails when Tool count grows faster than the model can choose well. REST + generated OpenAPI tools is good for Existing APIs with good specs, costs Spec-to-tool translation loses intent, and fails when Endpoints are chatty or designed for humans. Vendor-hosted connector is good for Fast start, managed auth, costs Less control over schema and data path, and fails when You need self-hosting or custom scopes

Failure modes

  • Tool sprawl. The host registers every tool from every connected server, the prompt grows, and selection accuracy falls. Debug: logging the number of registered tools and their token cost per request, then replaying a fixed evaluation set of user requests against a pruned list.
  • Silent schema drift. A server adds a required field or renames one, and calls start failing or, worse, silently succeed with wrong defaults. Debug: snapshotting each tools/list response per server version and diffing on deploy.
  • Version mismatch. The client assumes a capability the server never declared. Debug: logging the negotiated protocol version and both capability objects, and by surfacing UnsupportedProtocolVersionError with the server's supported list instead of a generic failure.
  • Trusting tool output as instructions. A tool result is data written by a third party, and it enters the model's context. Debug: tracing which tool result preceded a suspicious action, and by treating fetched content as untrusted at the prompt layer.

In production

Latency is additive and serial: each tool call is a full round trip plus the server's own work, and the model waits. A local stdio server is cheap; a remote server adds network latency and its upstream API's latency. Budget the number of sequential calls, not just the per-call average.

Cost has two shapes. Tool definitions consume input tokens on every request, so a large server inventory is a permanent tax; use list caching (ttlMs, cacheScope) and progressive disclosure of tools. Execution cost is the server's, but you still pay for the tokens that carry results back into context.

Operationally, monitor per server: discovery success, error rate by tool, p95 call latency, and how often the model retries or abandons a call. Keep an audit log keyed by user, server, tool and a hash of the arguments — arguments may contain sensitive data, so log the hash and the shape, not the payload. Pin server versions, health-check them at startup, and degrade to a clear "capability unavailable" message rather than silently omitting tools the prompt still references.

Common misconceptions

People think: MCP is how you give a model tools.

Actually: MCP is how a host sources and executes tools. The model still emits tool calls in the provider's own format; the host translates between that format and MCP, and decides what to expose and what to approve.

People think: If a server is in the registry, it is safe to connect.

Actually: A server runs code with the privileges you grant it, and returns content that reaches the model. Vetting a server is a supply-chain review: who wrote it, what it can reach, and what it can do without asking.

People think: MCP replaces function calling.

Actually: It complements it. Function calling is a model capability; MCP is an integration boundary. You can use MCP with no function calling, and function calling with no MCP.

Interview angle

Expect the question "why does MCP exist, and what does it actually standardise?" The weak answer lists primitives. The strong answer names the N×M integration problem, then separates what the protocol fixes (message shape, discovery, capability declaration, transport-level auth) from what it leaves to the host (exposure policy, consent, context budgeting, trust). Then name a cost: a new hop, a new trust boundary, and a specification that changed shape in 2026. Finish with a failure you have seen — tool sprawl or schema drift — and how you would detect it. See hosts, clients and servers and the protocols interview category.

Sources