The Model Context Protocol (MCP) is an open protocol that lets an AI application connect to external tools and data in a standard way. You write a server once, exposing tools, resources or prompts, and any MCP-capable application can use it. The current specification is version 2026-07-28, which made the protocol stateless and differs in important ways from tutorials written before it.
Key takeaways
- MCP has three roles: a host (the AI application), a client (the connector inside the host) and a server (which provides tools and data).
- Servers offer three kinds of feature: tools the model can call, resources that supply data, and prompts that users can pick.
- There are two standard transports: stdio for a local subprocess, and Streamable HTTP for a remote service.
- Version 2026-07-28 removed the
initializehandshake and protocol-level sessions. Each request now carries its own version and capabilities. - Authorisation is optional, applies to HTTP transports and is based on OAuth 2.1. MCP standardises the connection; it does not make a tool safe.
This article is part of the guide to AI agents. Read that first if the agent loop is new to you.
What problem does MCP solve?
Without a shared protocol, every AI application defines tools in its own format, so a "search our tickets" tool built for one assistant has to be rebuilt for the next. MCP separates the two sides. The specification compares itself to the Language Server Protocol, which let one language plugin work across many code editors.
Who are the host, client and server?
The specification defines three roles, and all messages between them use JSON-RPC 2.0:
- Host: the LLM application that starts connections, for example a chat application or an IDE.
- Client: a connector inside the host that talks to a server.
- Server: a service that provides context and capabilities.
The model is not one of the roles. The host shows the server's tools to the model and decides whether to send each requested call to the server.
What can an MCP server offer?
| Feature | What the specification says it is | Typical methods | Example |
|---|---|---|---|
| Tools | Functions for the AI model to execute | tools/list, tools/call | Create a ticket, run a query |
| Resources | Context and data, for the user or the AI model to use | resources/list, resources/read | A file, a database schema |
| Prompts | Templated messages and workflows for users | prompts/list, prompts/get | A "review this pull request" template |
Tools are described as model-controlled: the model discovers them and decides when to call them. A tool definition has a name, an optional description and an inputSchema written in JSON Schema. A result contains content, optionally structuredContent, and an isError flag for failures the model can try to fix.
Clients can offer one feature back to servers: elicitation, where a server asks the user for more information. Roots, sampling and protocol-level logging were deprecated in the 2026-07-28 revision, so new servers should not depend on them. Optional extensions, such as Tasks for long-running operations, need support from both sides.
Which version of MCP is current, and what changed?
MCP versions are dates in YYYY-MM-DD form, marking the last backwards-incompatible change. The current version is 2026-07-28. The previous one was 2025-11-25.
The 2026-07-28 revision changed the shape of the protocol:
- No handshake. The
initializeandnotifications/initializedexchange was removed. Every request now carries its protocol version and client capabilities in a_metafield. - No protocol sessions. The
Mcp-Session-Idheader is gone. A server that needs state across calls returns an explicit handle, such as a basket ID, and takes it back as a normal tool argument. - Discovery by request. Servers must implement
server/discover, which returns supported versions, capabilities and identity. Calling it is optional for clients. - No server-initiated requests. When a server needs input mid-call, it returns a result marked
input_required, and the client retries the original request with the answers.
The practical consequence: a code sample that shows an initialize call or session IDs describes an older version. Clients and servers can support several versions at once, and the specification defines how a new client falls back for an old server. Check which version your SDK and host implement.
Which transports does MCP use?
| stdio | Streamable HTTP | |
|---|---|---|
| Where the server runs | A subprocess the client launches | An independent process, local or remote |
| How messages travel | Newline-delimited JSON-RPC on stdin and stdout | Each message is an HTTP POST to a single MCP endpoint |
| Replies | One line per message on stdout | A JSON object, or a Server-Sent Events stream scoped to that request |
| Credentials | Taken from the environment | OAuth-based authorisation |
| Fits | Local tools on a developer machine | Shared services used by many clients |
One stdio rule deserves attention: the server must not write anything to stdout that is not a valid MCP message. A stray print() breaks the connection, so log to stderr instead.
For Streamable HTTP, servers must validate the Origin header to prevent DNS rebinding attacks, and local servers should bind only to localhost. Every POST carries MCP-Protocol-Version and Mcp-Method headers, so gateways can route without parsing the body. The older HTTP+SSE transport is deprecated.
What does a minimal MCP server look like?
The official "Build an MCP server" tutorial uses the Python SDK, requires Python 3.10 or higher and Python MCP SDK 2.0.0 or higher, and installs it with uv add "mcp[cli]". The server below uses the same imports and calls as that tutorial, with one tool.
import logging
from mcp.server import MCPServer
from mcp.server.mcpserver.exceptions import ToolError
logger = logging.getLogger(__name__) # logging writes to stderr, not stdout
mcp = MCPServer("orders")
ORDERS = {"A-1042": "shipped", "A-1043": "processing"}
@mcp.tool()
async def get_order_status(order_id: str) -> str:
"""Look up the current status of a customer order.
Args:
order_id: The order ID, for example A-1042
"""
logger.info("Looking up order %s", order_id)
if order_id not in ORDERS:
raise ToolError(f"No order found with ID {order_id}.")
return f"Order {order_id} is {ORDERS[order_id]}."
if __name__ == "__main__":
mcp.run(transport="stdio")
The MCPServer class generates the tool definition from the type hints and docstring, so write the docstring with the same care as a prompt. To use the server from a desktop host, you register the command that starts it. The tutorial's example for Claude for Desktop adds this to claude_desktop_config.json:
{
"mcpServers": {
"orders": {
"command": "uv",
"args": ["--directory", "/ABSOLUTE/PATH/TO/orders", "run", "orders.py"]
}
}
}
SDK class names have changed between major versions, so check the SDK documentation for the version you install.
How does authorisation work in MCP?
Authorisation is optional. A stdio server should not use the MCP authorisation flow; it takes credentials from the environment. An HTTP server should follow the specification, which is based on OAuth 2.1: the MCP server acts as a resource server, the MCP client as an OAuth client, and a separate authorisation server issues tokens. The steps are:
- The client calls the server without a token and receives HTTP 401 with a
WWW-Authenticateheader. - The client fetches the server's Protected Resource Metadata (RFC 9728), which names the authorisation server.
- The client registers. The preferred method is a Client ID Metadata Document; Dynamic Client Registration is deprecated but still allowed.
- The user approves access in a browser, using PKCE. The client includes a
resourceparameter (RFC 8707) naming the MCP server. - The client sends the access token in an
Authorization: Bearerheader on every request.
Two rules matter for security. Servers must check that a token was issued specifically for them, and must not accept or pass on any other tokens.
What are the limits and risks of MCP?
- It does not judge safety. The specification says tools represent arbitrary code execution, that there should always be a human in the loop able to deny tool invocations, and that tool descriptions and annotations from an untrusted server must themselves be treated as untrusted.
- A third-party server is third-party code. Review it as you would any dependency.
- Tool results can carry prompt injection. Text returned by a tool may contain instructions aimed at the model. See guardrails for AI agents.
- The protocol is still moving. The 2026-07-28 revision was a breaking one, so SDKs and hosts may support different versions.
Common questions
Is MCP the same as function calling?
No. Function calling (or tool use) is how a model asks for a tool inside one API request. MCP is how an application discovers and reaches tools that live in another process. A host typically turns MCP tools into function-calling definitions for its model.
Do I need MCP for a single application?
Not necessarily. If your tools live in the same codebase as your agent and nothing else uses them, plain functions are simpler. MCP pays off when several applications share tools, or when another team or vendor provides them.
How is MCP different from the A2A protocol?
MCP connects an application to tools and data. The Agent2Agent protocol addresses a different link, from one agent to another. See the A2A protocol explained.
Free download: The AI agents field guide
What an agent is, when a simple workflow is the better choice, how MCP connects tools, when several agents help, and the guardrails every agent needs, with working Python. See what’s inside.



