Many apps, many tools
Before MCP, every AI application connected every service in its own way. A chat app wrote its own code for Google Drive, a coding tool wrote different code for the same Drive, and a third app did it again. With many apps and many services, the work multiplies:
without a standard: N × M connectorsEach of N apps needs its own connector for each of M services.
with a standard: N + MEach app learns the protocol once, and each service offers one server.
10 apps, 100 services: 1,000 against 110And a new service works at once in all ten apps.
Anthropic released the Model Context Protocol, MCP, as an open standard in November 2024. Its designers took the idea from the Language Server Protocol, which lets any code editor support any programming language through one shared protocol. During 2025 OpenAI, Google and Microsoft added MCP support to their own products, and in December 2025 Anthropic handed it to the new Agentic AI Foundation at the Linux Foundation, so no single company owns it.
The ecosystem grew fast. A study published in October 2025 collected 67,057 MCP servers from six public registries. In China, Alibaba’s ModelScope opened an MCP marketplace on 15 April 2025 with nearly 1,500 servers for search, maps, file systems and developer tools, among them Alipay’s server for creating and checking payments and MiniMax’s tools for speech, images and video.
Quick check
Hosts, clients and servers
| What it is | Examples | |
|---|---|---|
| Host | The AI application you use. It holds the model, decides what the model sees and asks you before tools run. | Claude Code, Codex CLI, Qwen Code, Cursor, a chat app |
| Client | A connector inside the host. Each client talks to one server. | The host’s connection to the notes server |
| Server | A program that offers tools and data through MCP | A file server, a GitHub server, a database server |
- Modelasks for a tool call
- Hostchecks permissions, may ask you
- MCP clientsends tools/call
- MCP serverruns the tool
- The servicefiles, database, web API
Notice what the model does not do: it never talks to an MCP server. The host turns the server’s tools into ordinary tool definitions, exactly like the ones in the tool-calling lesson. When the model asks for a call, the host’s client sends it to the server and hands the result back. MCP is the link between the host and its servers; the model sees only tools.
Servers are reached in one of two ways, called transports:
- stdio. The host starts the server on your own computer as a child program, and they exchange one JSON message per line through its standard input and output. The server writes its logs to standard error, never to standard output. Credentials come from environment variables.
- Streamable HTTP. The server runs somewhere else, often a company’s service. The client sends each message as an HTTP POST to one address, and the answer comes back either as JSON or as a stream. Signing in uses OAuth: you approve access in your browser, and the client gets a token that is valid for that server alone.
Quick check
The messages, step by step
MCP messages follow JSON-RPC 2.0, a small standard for calling functions with JSON. A request has an id and a method; the response carries the same id and either a result or an error; a notification has no id and gets no reply.
Below is a real exchange with the small notes server you will write later in this lesson, recorded with the official Python SDK, version 2.3.0. The messages are only shortened. Since version 2026-07-28 MCP is stateless: every request carries its protocol version and the client’s capabilities in a _meta field, so the server needs to remember nothing between requests. After the first request, _meta is shortened here to { ... }.
-
MCP client, in the host
The host starts the server as a child program,
python notes_server.py, and asks what it offers.{ "jsonrpc": "2.0", "id": 1, "method": "server/discover", "params": { "_meta": { "io.modelcontextprotocol/protocolVersion": "2026-07-28", "io.modelcontextprotocol/clientInfo": { "name": "lesson-client", "version": "1.0" }, "io.modelcontextprotocol/clientCapabilities": {} } } } -
MCP server
The server names the protocol versions it supports and what it can do.
{ "jsonrpc": "2.0", "id": 1, "result": { "resultType": "complete", "supportedVersions": ["2026-07-28"], "capabilities": { "tools": { "listChanged": true }, ... }, "_meta": { "io.modelcontextprotocol/serverInfo": { "name": "notes" } } } } -
MCP client, in the host
Next, the list of tools.
{ "jsonrpc": "2.0", "id": 2, "method": "tools/list", "params": { "_meta": { ... } } } -
MCP server
Two tools, each with a name, a description and a JSON Schema for its arguments. (The real reply also gives an output schema for each tool.)
{ "jsonrpc": "2.0", "id": 2, "result": { "resultType": "complete", "tools": [ { "name": "add_note", "description": "Save a short note. Returns the note's number.", "inputSchema": { "type": "object", "properties": { "text": { "type": "string" } }, "required": ["text"] } }, { "name": "search_notes", "description": "Return every saved note that contains the query (not case-sensitive).", "inputSchema": { "type": "object", "properties": { "query": { "type": "string" } }, "required": ["query"] } } ] } } -
You
Please remember: exam on 3 November, chapters 4 to 6.
-
Model
The host gave the model both tools as ordinary tool definitions. The model asks for one:
add_note(text="Exam on 3 November: chapters 4 to 6") -
MCP client, in the host
The host allows the call, and its client sends it to the server.
{ "jsonrpc": "2.0", "id": 3, "method": "tools/call", "params": { "name": "add_note", "arguments": { "text": "Exam on 3 November: chapters 4 to 6" }, "_meta": { ... } } } -
MCP server
The result: text for the model, the same value as structured data, and
isError: false.{ "jsonrpc": "2.0", "id": 3, "result": { "resultType": "complete", "content": [{ "type": "text", "text": "Saved as note 1." }], "structuredContent": { "result": "Saved as note 1." }, "isError": false } } -
Model
Saved. It is note 1 in your notes.
Versions up to 2025-11-25 worked differently: the client first sent an initialize request, the two sides agreed on a version and capabilities once, and the connection was then a session with its own state. You will still see that handshake in many servers and older tutorials. The official SDKs speak both versions; the server above also answered an old-style initialize correctly.
Things go wrong in two different ways, and MCP keeps them apart:
// A tool execution error: search_notes was called without its query
{
"jsonrpc": "2.0",
"id": 5,
"result": {
"resultType": "complete",
"content": [{ "type": "text", "text": "Error executing tool search_notes: 1 validation error ... query Field required" }],
"isError": true
}
}
// A protocol error: a request sent without the required _meta fields
{
"jsonrpc": "2.0",
"id": 7,
"error": {
"code": -32602,
"message": "params._meta must be an object carrying the required 'io.modelcontextprotocol/protocolVersion' and 'io.modelcontextprotocol/clientCapabilities' envelope keys"
}
}
- A tool execution error is a normal result with
isError: true. Its text goes back to the model, which can read what went wrong and try again with the right arguments, as in the agent-loop lesson. - A protocol error is a JSON-RPC
error: the request itself was malformed. It is a bug in the host or the server, and the model can rarely fix it. Code-32602means invalid parameters. - The
//lines are notes for you; real JSON has no comments.
Quick check
Tools, resources and prompts
A server can offer three kinds of thing. They differ in who decides to use them:
| Who decides to use it | Example | |
|---|---|---|
| Tools | The model, during its work | search_notes, create_issue, run_query |
| Resources | The application or the user, who choose data to add to the context | A file, a database’s table layout, today’s timetable, each with an address such as file:///… |
| Prompts | The user, often as a slash command | A ready-made “summarise this week’s notes” template |
Tools are by far the most used. A tool’s result can be text, an image, audio, structured JSON, or a link to a resource: an address the host can open later instead of a large file pasted into the context, the restorable compression of the context-engineering lesson.
Sometimes a server needs something from the user in the middle of a call, such as a choice or a missing detail. With elicitation the server asks the host to show the user a small form. In version 2026-07-28 this works without any state on the server: it answers input_required with its questions, and the client sends the original request again together with the answers.
Because the protocol keeps no sessions, a server that needs state across calls, such as a shopping basket or an open browser page, returns a handle: an ID that the model passes back as an ordinary argument in later calls. Longer jobs can use the official tasks extension, which returns a handle at once and lets the client ask for progress. Another extension, MCP Apps, lets a server show interactive charts or forms inside the conversation.
Quick check
Write your own server
The official Python SDK turns ordinary functions into MCP tools. Install it with pip install "mcp[cli]" (Python 3.10 or newer), save this as notes_server.py, and you have a working server:
import json
from pathlib import Path
from mcp.server import MCPServer
NOTES = Path(__file__).with_name("notes.json")
mcp = MCPServer("notes")
def load():
return json.loads(NOTES.read_text(encoding="utf-8")) if NOTES.exists() else []
@mcp.tool()
def add_note(text: str) -> str:
"""Save a short note. Returns the note's number."""
notes = load()
notes.append(text)
NOTES.write_text(json.dumps(notes, ensure_ascii=False), encoding="utf-8")
return f"Saved as note {len(notes)}."
@mcp.tool()
def search_notes(query: str) -> list[str]:
"""Return every saved note that contains the query (not case-sensitive)."""
return [n for n in load() if query.lower() in n.lower()]
if __name__ == "__main__":
mcp.run() # stdio: one JSON message per line on standard input and output
- The docstring becomes the tool’s description, and the type hints become its input schema, exactly as in the
tools/listreply above. The return type becomes an output schema. add_notechanges a file, andsearch_notesonly reads. A host may let read-only tools run freely and ask you before the other.- Errors need no extra code: the SDK turns a wrong or missing argument into a result with
isError: true.
Test it without any model, with a few lines of client code. The client starts the server, lists its tools and calls them, just as a host would:
import asyncio
from mcp import Client, StdioServerParameters
server = StdioServerParameters(command="python", args=["notes_server.py"])
async def main():
async with Client(server) as client:
listed = await client.list_tools()
for tool in listed.tools:
print(tool.name, "-", tool.description)
result = await client.call_tool("add_note", {"text": "Bring the science notebook on Monday"})
print(result.content[0].text)
result = await client.call_tool("search_notes", {"query": "science"})
print(result.structured_content)
asyncio.run(main())
- Run it in the same folder as the server. It prints both tools, then
Saved as note 1., then{'result': ['Bring the science notebook on Monday']}. - This is how you check a server before you trust a model with it: you see exactly what each tool returns.
To give it to a coding agent, register it. In Claude Code, the command is claude mcp add --transport stdio notes -- python notes_server.py. Or put a .mcp.json file in your project, so everyone who works on it gets the same server:
{
"mcpServers": {
"notes": {
"command": "python",
"args": ["notes_server.py"]
}
}
}
- Claude Code asks for approval before it uses servers from a project’s
.mcp.json, because the file could come from anyone who can change the project. - Other harnesses, such as Codex CLI and Qwen Code, keep a similar list in their own settings files; their documentation gives the exact format.
Quick check
Too many tools
Every tool from every connected server is a tool definition, and tool definitions sit at the start of the context on every request (the context-engineering lesson). Connect a few large servers and they fill a good part of the window before you have typed a word.
With all five servers connected, 58 tool definitions take about 55 thousand tokens: over a quarter of the window, on every request, and 58 tools for the model to choose from. Turn on tool search: the model starts with one search tool and loads only the definitions it finds. Now connect only Splunk with its two tools, and see why tool search is not worth it for a small server.
This interactive part needs JavaScript.
Two answers to this problem appeared in November 2025, both from Anthropic’s engineers:
- Tool search. Tool definitions are marked to load later, and the model gets one tool that searches them. In Anthropic’s tests on MCP tasks, this also made tool choice more accurate, because the model faced a few likely tools instead of dozens: one Claude model went from 49 % to 74 % correct. Claude Code offers MCP tool search for the same reason.
- Code instead of calls. The harness presents each server as a folder of small code files. The model reads only the files it needs, then writes a short program that calls the tools, filters the data and returns only the result. In Anthropic’s example of copying a document from one service into another, this cut the tokens from about 150,000 to about 2,000. The price: the model’s code must run in a safe sandbox (the harnesses lesson).
Researchers in China work on the same problem. MCP-Zero (2025) lets the model ask for the kind of tool it needs, which a router then finds among 2,797 tools from 308 servers; on one benchmark it cut the tokens spent on tool definitions by 98 %. LiveMCPBench (August 2025), from the Institute of Software at the Chinese Academy of Sciences, gave agents 70 real servers with 527 tools and 95 everyday tasks. The best model in its first version finished about 79 % of the tasks, and the authors found that finding the right tool among hundreds is a skill of its own.
Quick check
Trust, but check
An MCP server is a program you run, or a service you allow to act for you. The specification states the principles plainly: users must consent to and understand what data is shared and what actions are taken; hosts must ask before exposing user data to a server and before invoking any tool; and a tool’s description is untrusted unless it comes from a server you trust. MCP cannot enforce these rules itself. They are the job of the host, and of you.
Researchers have measured the risks:
- Weak vetting. The October 2025 study of 67,057 servers found that public registries check little about who publishes a server or who owns it, so a fake or taken-over server can reach users. Its scanning tool flagged 833 servers with code weaknesses.
- Descriptions steer the model. A tool’s description is text the model reads and tends to follow. MCPTox (August 2025) built test cases on 45 real servers with 353 tools and tried them on 20 AI agents: harmful descriptions often succeeded, more capable models were often more easily misled because they follow instructions so well, and agents refused less than 3 % of the time.
- Local servers run as you. A stdio server is a program with the same permissions as your user account. The specification asks hosts to show the exact command before they run a new server, and to sandbox servers where possible.
- Tokens must stay put. A remote server must accept only tokens issued for it, and must never pass your token on to another service. The specification forbids this “token passthrough”.
- Prefer servers published by the service itself, or open-source servers you can read.
- Read the tool list and the descriptions before you connect a server, with a client like the one above or your host’s server view.
- Grant the smallest access that works: read-only where possible, one folder instead of your whole disk, the narrowest sign-in permission.
- Keep approval switched on for tools that write, delete, pay or send.
- Never connect a server that reads untrusted content, such as web pages or email, in the same agent as tools that can send your data out, unless a person approves each sending step: the lethal trifecta of the tool-calling lesson.
- Remember that a server’s tool list can change while you use it; the protocol even has a notification for that. What you approved last month is not automatically what runs today.
Is each habit safe, or risky?
-
Reading a server’s tools and descriptions before connecting it
Answer: Safe habit
-
Installing a server from a registry because it has a popular-sounding name
Answer: Risky habit
-
Giving a file server access to one project folder only
Answer: Safe habit
-
Turning off approval for every tool so the agent works faster
Answer: Risky habit
-
Choosing the read-only scope when a service asks what to allow
Answer: Safe habit
-
Pasting your password into a server’s settings file and committing it to git
Answer: Risky habit
-
Running a new local server inside a container first
Answer: Safe habit
-
Letting an agent read your inbox and send email with no one checking
Answer: Risky habit
Remember
- MCP is an open standard that connects AI applications to tools and data: one server works in every host that speaks it.
- The host holds the model and asks for consent; a client in the host talks to one server; the model sees only ordinary tools.
- Messages are JSON-RPC 2.0. Since 2026-07-28 MCP is stateless: each request carries its version and capabilities in
_meta. - Servers offer tools (chosen by the model), resources (chosen by the app or user) and prompts (chosen by the user).
- Tool failures come back as results with
isError: true, so the model can fix them; protocol errors mean a malformed request. - Tool definitions fill the context, so large tool sets need tool search or code that calls tools; good servers keep their output small.
- A server is code that acts for you: check who made it, read its tools, grant the least access, and keep approval on for risky actions.
Words to know
- MCP
- The Model Context Protocol: an open standard for connecting AI applications to tools and data.
- Host
- The AI application that holds the model, connects to MCP servers and asks the user for consent.
- MCP client
- The connector inside a host that talks to one MCP server.
- MCP server
- A program that offers tools, resources and prompts through MCP.
- JSON-RPC
- A small standard for requests, responses and notifications written in JSON, used by MCP.
- stdio transport
- Running a server as a child program and exchanging one JSON message per line through its input and output.
- Streamable HTTP
- Reaching a remote MCP server by sending each message as an HTTP POST and reading the answer as JSON or a stream.
- Resource
- Data a server offers at an address, which the application or user can add to the context.
- Elicitation
- A server asking, through the host, for information from the user in the middle of a request.
- Stateless protocol
- A protocol in which every request carries everything needed to answer it, so the server keeps no session.
- Tool search
- Loading tool definitions only when a search finds them, instead of putting every definition into the context.
- Tool poisoning
- Hiding harmful instructions in a tool’s description, which the model may follow.
- Token passthrough
- A server forwarding a user’s access token to another service. MCP forbids it.
Go to the source
This lesson is built on these papers and documents. Paper links open arxiv.org, a separate site.
-
Model Context Protocol specification, version 2026-07-28
The roles, the base protocol, server and client features, and the security principles.
-
MCP 2026-07-28: Key changes
Why MCP became stateless, server/discover, multi round-trip requests and the deprecations.
-
MCP specification: Tools
tools/list and tools/call, results, handles for state, and the two kinds of error.
-
MCP specification: Security best practices
Token passthrough, local server compromise, scope minimisation and their defences.
-
MCP Python SDK
The official library used for this lesson’s server and client (version 2.3.0).
-
Introducing the Model Context Protocol
The announcement that opened MCP to everyone.
-
Linux Foundation announces the formation of the Agentic AI Foundation
MCP’s move to neutral, shared governance.
-
Introducing advanced tool use on the Claude Developer Platform
The five-server example, tool search and its effect on accuracy.
-
Code execution with MCP: building more efficient agents
Servers as code files, and the drop from about 150,000 to about 2,000 tokens.
-
Claude Code: MCP
Adding servers, the .mcp.json file, scopes, approval and output limits.
-
ModelScope launches its MCP Plaza (Alibaba Cloud developer community, in Chinese)
China’s largest MCP marketplace at launch: nearly 1,500 servers, with Alipay and MiniMax among the first.
-
MCP-Zero: Active Tool Discovery for Autonomous LLM Agents
Letting the model ask for the tools it needs among 2,797 tools from 308 servers.
-
LiveMCPBench: Can Agents Navigate an Ocean of MCP Tools?
95 everyday tasks over 70 real servers and 527 tools.
-
MCPTox: A Benchmark for Tool Poisoning Attack on Real-World MCP Servers
How often 20 agents are misled by harmful tool descriptions, and why stronger models can be more at risk.
-
A First Look at the Security Issues in the Model Context Protocol Ecosystem
67,057 servers from six registries, weak vetting, and a scanner for vulnerable servers.
Check yourself
5 questions. Tap the answer you think is right.
0 of 5 answered
Lesson complete
Answer every question above to complete this lesson.
Your progress is saved on this device only.
Next lessonMulti-agent systems: when many models beat one