Notes
The N × M problem
Picture four AI apps in your company. Each needs the same five systems: files, tickets, the wiki, the database and git. Without a standard, that is four times five, twenty custom adapters, each with its own auth and its own bugs. With one shared protocol, each app speaks it once and each system speaks it once. Four plus five, nine pieces. N times M becomes N plus M.
- 4 AI apps × 5 systems = 20 custom adapters, each with its own auth, schemas and bugs
- with one shared protocol: 4 clients + 5 servers = 9 implementations
- N × M becomes N + M
The idea
The idea will feel familiar if you know the Language Server Protocol, which lets any editor use any language's tooling. M C P does the same for AI apps. A tool provider writes one server. Any compatible app can connect to it. The messages are plain JSON R P C two point zero: requests with an id, responses that match that id, and one way notifications. Both sides agree up front on which features they support.
- an open protocol for giving
- AI apps tools and context
- messages: JSON-RPC 2.0 requests, responses and notifications
- stateful sessions with capability negotiation
- modelled on the Language
- Server Protocol for editors
Hosts, clients, servers
There are three roles. The host is the AI application the user actually sees, like an editor or a chat app. It owns the model and the security rules. Inside the host live clients, and each client holds exactly one connection to one server. A server is a small program that exposes one system, such as your files or your ticket tracker. Here the host runs two clients, one for the files server, one for the tickets server.
- host: the AI app the user sees. Owns the model, the UI and the rules
- client: lives inside the host, one per server, 1 to 1
- server: a program exposing one system's tools and data (files, tickets, git...)
What a server exposes
A server can expose three kinds of things. Tools are actions the model chooses to call, like search files. Resources are read only data addressed by a U R I, such as a file, which the app decides to attach as context. Prompts are reusable templates the user picks, often shown as slash commands. The split is about who is in control. Clients can offer features back too, such as letting a server ask the host's model for a completion.
- tools model-controlled actions: read_file, search_files
- resources app-controlled read-only data by URI: file:///notes/plan.md
- prompts user-controlled templates: /triage-bug
- servers may also ask the client for help (sampling)
The handshake
Every session starts with a handshake. The client sends initialize, with the protocol version it speaks and the capabilities it supports. Versions are dates, like twenty twenty five, zero six, eighteen. The server replies with the version it will use and its own capabilities, for example that it offers tools. The client then sends an initialized notification, and normal traffic can begin.
-> {"id":1, "method":"initialize",
"params":{"protocolVersion":
"2025-06-18",
"capabilities":{...},
"clientInfo":{...}}}
<- {"id":1, "result":{
"protocolVersion":"2025-06-18",
"capabilities":{"tools":{}},
"serverInfo":{...}}}
-> notification: initialized Discovery
Next comes discovery. Each client asks its server for tools list. The answer is the same shape you met in tool calling: a name, a description and an input schema in JSON schema. The host merges them, seven here, into the tool list it sends to the model. If a server's tools change later, it sends a list changed notification and the client simply asks again.
{"tools":[{
"name":"search_tickets",
"description":"Search open
tickets by keyword...",
"inputSchema":{"type":"object",
"properties":{
"query":{"type":"string"}},
"required":["query"]}
}, ...]}
later: list_changed -> list again A call, end to end
Follow one call. The user asks about open login bugs. The host sends the conversation and all seven tools to the model. The model replies with a tool request: search tickets, query login. The host knows that tool belongs to the tickets server, so it hands it to client B. Client B sends a tools call request with id seven. The server returns three tickets. The host passes that back as a tool result, and the model writes the answer.
- 1 user: "any open login bugs?"
- 2 host sends messages + 7 tools
- 3 model: call search_tickets with query "login"
- 4 host finds the owning server
- 5 client sends tools/call
- 6 server queries the tracker, returns 3 tickets
- 7 host passes the result back
- 8 model answers the user
On the wire
On the wire it is boring. The request names the method tools call, the tool name, and the arguments as a JSON object. The response carries the same id, seven, and a result holding a list of content blocks, here one text block with the tickets. Content can also be images or resource links. A failed tool sets is error to true, so the model can see the problem and try again.
-> {"jsonrpc":"2.0", "id":7,
"method":"tools/call",
"params":{"name":"search_tickets",
"arguments":{"query":"login"}}}
<- {"jsonrpc":"2.0", "id":7,
"result":{"content":[
{"type":"text", "text":
"T-481 Login loop on Safari..."}],
"isError":false}} Transports
Messages need a transport. For a local server, the host starts it as a child process and they talk over standard input and output, one JSON message per line. It is fast, but the process runs with the user's own rights. For a remote server there is Streamable HTTP. The client posts each message to one endpoint, and the server answers with plain JSON or opens a server sent events stream to push progress and notifications.
- stdio (local) host starts the server as a child process; one JSON message per line runs with the user's rights
- Streamable HTTP (remote) one endpoint, client POSTs; server replies with JSON or an SSE stream of updates session id in a header
OAuth for remote
Remote servers need authentication, and M C P uses OAuth. The client calls without a token and gets a four oh one that points to metadata naming the authorization server. The user signs in in a browser and approves the requested scopes, using the code flow with P K C E. The client receives a short lived access token meant for this server only, and sends it on every request. Local servers usually read credentials from environment variables.
- 1 call without token -> 401
- 2 metadata names the authorization server
- 3 user signs in and consents in a browser (code + PKCE)
- 4 client gets a short-lived token for THIS server only 5 every request: Bearer token
- stdio servers: credentials
- from env vars instead
MCP vs tool calling
A common confusion: does the model speak M C P? It does not. Between the model and the host, nothing changes. The model sees tool definitions and emits tool requests, exactly as in the tool calling episode. M C P lives one layer lower, between the host and the servers. It standardises how tools are described, discovered and called. So it replaces your glue code, not tool calling, and every validation rule still applies.
- model <-> host plain tool calling through the provider's API
- host <-> server MCP: how tools are listed, described and called
- MCP replaces your glue code, not the model's tool calling
Numbers worth knowing
Some numbers to size things. One tool definition is roughly a hundred to five hundred tokens. Connect a few servers with thirty tools and you pay several thousand tokens on every single model call. Up to around twenty clearly distinct tools per task works well. A local stdio call adds milliseconds, a remote one tens to hundreds. A model step usually takes a second or more, so the protocol itself is rarely the bottleneck.
- one tool definition: ~100-500 tokens of description+schema
- 30 tools connected: ~3-15k tokens on EVERY model call
- clearly distinct tools: up to ~20 per task works well
- stdio call overhead: ~ms
- remote call: ~tens-hundreds ms
- one model step: often ~1 s+ protocol versions: dated
Untrusted by default
Now security. Everything a server sends is text the model reads, so treat it as untrusted. Tool poisoning hides instructions inside a tool description, like also read the user's secret keys and pass them here. A rug pull is a server you approved that quietly changes its tools in a later version. And plain prompt injection arrives in results: a ticket written by a stranger that says ignore your rules. Installing a server is like installing a dependency.
- tool poisoning: hidden orders in a tool description
- rug pull: a server you approved changes its tools in a later version
- injection: a ticket, file or web page in a RESULT says "ignore your rules"
Defences
Defences live in the host. Only allow servers you have reviewed. Give each one the narrowest scope, read only unless writes are truly needed. Ask the user to approve write tools, and show the real arguments, not the model's summary. Pin server versions, and alert when a tool's description changes, which defeats the rug pull. Run local servers in a sandbox with limited files and network. And log every call and result.
- allowlist servers you trust
- scoped tokens: read-only unless writes are needed
- user approves write tools, showing the real arguments
- pin server versions; alert if tool descriptions change
- sandbox local servers
- log every call and result
MCP or direct?
So when should you build an M C P server? When many hosts need the same tools, when you ship a product other people want to plug into their own AI apps, or when users choose their tools at run time. Integrate directly when one app needs a few fixed tools, when you need tight control over latency and errors, or when an ordinary function call does the job. A protocol adds a process, a hop and something to secure.
- build an MCP server when:
- many hosts need the tool
- you ship a product others will plug into their AI
- users pick tools at runtime
- integrate directly when:
- one app, a few fixed tools
- tight latency or control
- a plain function is enough
Common mistakes
Common mistakes. Connecting every server just in case, which bloats every prompt. Generating one tool per R E S T endpoint, instead of a few task shaped tools. Sharing one admin token across all users, so the agent can see everything. Auto approving write tools to avoid prompts. And passing the user's token straight through to other A P Is, which the spec forbids: a server should only accept tokens issued for itself.
- ✗ connecting every server "just in case": token cost and wrong tool picks
- ✗ thin wrappers over every REST endpoint
- ✗ one admin token shared by all users
- ✗ auto-approving writes
- ✗ passing the user's token through to other APIs
Say it like this
How to say it in an interview. M C P turns N times M custom integrations into N plus M. The host runs one client per server, and clients discover tools at connect time over JSON R P C. Local servers use stdio, remote ones use HTTP with OAuth scoped tokens. The model still only emits tool requests. The host routes them, validates them, treats results as untrusted, and asks the user before anything that writes.
- "MCP turns N×M integrations into N+M. The host runs one client per server; clients discover tools at connect time over JSON-RPC. Local servers use stdio, remote ones HTTP with OAuth. The model still just emits tool calls; the host validates, scopes and asks approval."