AI agents › Agent basics
What is MCP? A plain guide to the Model Context Protocol
MCP is an open standard for connecting AI apps to outside tools and data. How hosts, clients, and servers fit together, shown with a server you can run.
If you use AI coding tools, you’ve probably run into the letters MCP by now. Claude Code has a claude mcp command for adding servers, and the VS Code and Cursor docs each have a page on connecting MCP servers. Yet the name Model Context Protocol on its own doesn’t tell you much about what actually gets installed when you follow those instructions.
MCP, or Model Context Protocol, is an open standard that defines how AI applications connect to outside tools and data. Anthropic open-sourced it on November 25, 2024 (announcement), and the official docs compare it to a USB-C port for AI applications (What is MCP?). Just as one port lets a laptop take many different devices, MCP gives AI apps one shared way to connect to other systems.
There are reasons you hear the name so often these days. More work is being handed to AI agents, programs in which a model keeps using tools until a task is done, and an agent can only reach the tools it’s connected to. Also, on December 9, 2025, Anthropic donated MCP to the Agentic AI Foundation, a fund under the Linux Foundation that Anthropic co-founded with Block and OpenAI. The same post names ChatGPT, Cursor, Gemini, Microsoft Copilot, and Visual Studio Code among the products that had adopted MCP (Anthropic).
The problem a shared protocol solves
Before MCP, connecting a model to a tool meant writing glue code for that particular pair. Anthropic’s announcement pointed to the same problem: “Every new data source requires its own custom implementation, making truly connected systems difficult to scale.” With five AI apps and ten tools, wiring every pair takes fifty integrations. With MCP, though, each tool is built once as a server and each app adds MCP support once, so fifteen pieces of work let any app use any tool. The specification also says MCP takes some inspiration from the Language Server Protocol, which did something similar for programming languages and code editors.
Hosts, clients, and servers
MCP has three participants (architecture overview). The host is the AI app a person uses, such as Claude Code or VS Code, and the server is a program that offers tools or data. The client is a component inside the host that keeps the connection to one server, so connecting three servers means three clients. The messages they exchange follow JSON-RPC 2.0, a simple format for writing requests and responses in JSON.
A server offers three kinds of things, and they’re easiest to tell apart by who decides to use them (server concepts).
| What a server offers | What it is | Who decides to use it |
|---|---|---|
| Tools | Functions the model can call, such as searching flights | The model |
| Resources | Read-only data for context, such as file contents | The app |
| Prompts | Prepared instruction templates, such as summarizing meetings | The user |
Tools, which the model can call on its own, get the most attention. Prompts, by contrast, wait for a person to pick them, and in Claude Code they show up as slash commands you type yourself (Claude Code docs).
How messages travel
The spec defines two standard transports. With stdio, the host starts the server as a child process on the same machine and exchanges messages through its standard input and output, which is how local servers usually run. With Streamable HTTP, each message goes as an HTTP POST to a single endpoint, which is how you reach a server running somewhere else. One thing has changed recently, though. The initialize handshake you’ll see in older tutorials is gone as of the 2026-07-28 revision, and the protocol is now stateless, with every request carrying its own protocol version and capabilities (changelog).
A server with one tool
Let’s build a server with a single tool that counts the days between two dates, using the official Python SDK (pip install mcp).
from datetime import date
from mcp.server import MCPServer
mcp = MCPServer("dates")
@mcp.tool()
def days_between(start: date, end: date) -> int:
"""Count the days from start to end."""
return (end - start).days
if __name__ == "__main__":
mcp.run(transport="stdio")
MCPServer builds a tool definition from the function’s name, type hints, and docstring, so you don’t write a schema by hand. mcp.run(transport="stdio") waits for messages on standard input, and since replies go out on standard output, a stdio server mustn’t print anything there (server tutorial). If you come across older examples that start with from mcp.server.fastmcp import FastMCP, that’s the version 1 name of the same class, which version 2 of the SDK renamed MCPServer (migration guide).
To see what a host sees, I also wrote a short client with the same SDK. It starts server.py the way a host would, gets the list of tools, and calls the tool once.
import asyncio
import json
from mcp import Client, StdioServerParameters
# Start server.py as a child process and talk to it over stdio.
server = StdioServerParameters(command="python", args=["server.py"])
async def main() -> None:
async with Client(server) as client:
print("protocol:", client.protocol_version)
for tool in (await client.list_tools()).tools:
print("tool:", tool.name, "-", tool.description)
print("input:", json.dumps(tool.input_schema["properties"]))
result = await client.call_tool(
"days_between", {"start": "2024-11-25", "end": "2026-10-27"}
)
print("result:", result.structured_content)
asyncio.run(main())
protocol: 2026-07-28
tool: days_between - Count the days from start to end.
input: {"start": {"format": "date", "title": "Start", "type": "string"}, "end": {"format": "date", "title": "End", "type": "string"}}
result: {'result': 701}
The two sides spoke the 2026-07-28 revision, and the input line is the JSON Schema the SDK built from the type hints. The host passes this name, description, and schema to the model, which uses them to decide when to call the tool. The 701 that came back is the number of days from MCP’s announcement to the day I wrote this.
Connecting it to Claude Code
Now let’s hand the same server to a real host. Claude Code reads its list of servers from a JSON file passed with --mcp-config, and for a stdio server you only write the command that starts it.
{
"mcpServers": {
"dates": {
"command": "python",
"args": ["server.py"]
}
}
}
Inside Claude Code, the tool is named mcp__dates__days_between, joining the server name and the tool name, and --allowedTools permits only that one tool. --output-format stream-json prints each step as a line of JSON and needs --verbose in this mode, while jq picks out just the tool calls and the final answer.
claude -p "Use the days_between tool to count the days from 2024-11-25 to 2026-10-27." \
--mcp-config mcp.json --allowedTools "mcp__dates__days_between" \
--model haiku --output-format stream-json --verbose < /dev/null \
| jq -r 'if .type == "result" then "answer: " + .result
else (.message.content[]? | select(.type == "tool_use")
| "tool call: \(.name) \(.input)") end'
tool call: ToolSearch {"query":"select:mcp__dates__days_between","max_results":1}
tool call: mcp__dates__days_between {"start":"2024-11-25","end":"2026-10-27"}
answer: There are **701 days** from 2024-11-25 to 2026-10-27, according to the `days_between` tool.
I ran this on October 27, 2026 with Claude Code 2.1.304, where --model haiku resolved to claude-haiku-5-5. The first call goes to ToolSearch, one of Claude Code’s own tools, because by default Claude Code loads only the names of MCP tools up front and fetches a full definition when it’s needed (tool search). The second line is the real call. Claude Code passed it to server.py, got {"result":701} back, and the model answered with that number. Of course, model output differs from run to run. When I asked the same question without naming the tool, Haiku answered 701 on its own without calling the tool, since deciding whether to use a tool is up to the model.
How it differs from function calling
Perhaps the most common question is how MCP differs from function calling, or tool use as Anthropic’s docs call it. Tool use is a feature of the model API. Your app sends each tool’s name, description, and input schema with the request, the model replies with a tool_use block naming a tool and its arguments, and your app runs the code and returns the result in a tool_result. The model never runs anything itself.
MCP leaves that exchange as it is and defines where tools live and how the app finds and calls them. According to the architecture overview, a host gathers the tools from its connected servers into one list for the model, and when the model calls one, it routes the call to the right server. In the end the two work as a pair, with tool use between the app and the model, and MCP between the app and the tools.
Security starts with which servers you trust
Connecting an MCP server means letting another program act on your behalf. The specification says tools represent arbitrary code execution and must be treated with caution, and that descriptions of tool behavior should be considered untrusted unless they come from a trusted server. It also says hosts must get explicit user consent before invoking any tool. The security best practices page adds that a local server runs with the same privileges as the client.
Prompt injection is worth knowing about as well. It’s an attack that hides instructions meant to steer the model inside text the model reads, such as a web page or an issue comment, and a server that fetches outside content may bring that text straight into the conversation. That’s why the Claude Code docs ask you to verify you trust each server before connecting it. So I’d suggest installing servers only from sources you trust, allowing only the tools you need as --allowedTools did above, and starting with the narrowest account permission when a remote server asks for access.
When MCP fits and when it doesn’t
MCP fits well when the same tool or data should be available in several AI apps, or when you want to offer your own service to many of them, since a server you build once works in any host that speaks MCP. It suits teams too. In Claude Code, committing a .mcp.json file at the project root gives everyone working in the repository the same servers.
On the other hand, if a single app calls only one or two of your own functions, handing them straight to the model with the API’s tool use may be simpler. Also, tool definitions sent to the model count as input tokens, so every connected tool takes up room in the context. That’s why, even with a host like Claude Code that defers tool definitions, connecting a long list of servers just in case is often not a good choice.
Where to start
If MCP is new to you, I’d start by running the server above and the client that looks inside it. Once you’ve seen the tool definition the SDK builds, the rest of the protocol reads much more easily, and then you can connect the server to a host you already use and watch the model call it. When you build servers of your own, there’s the official MCP Inspector, a developer tool for inspecting them, and the architecture overview is a good next read. I ran these examples on October 27, 2026 with Python 3.13.12, mcp 2.3.0, and Claude Code 2.1.304, and the client and server spoke spec revision 2026-07-28.
AI tools helped with the research for this post.