Model Context Protocol (MCP)
An open standard (Anthropic, Nov 2024) for plugging AI apps into tools and data: servers expose tools, resources and prompts over JSON-RPC, so N apps and M integrations need N+M adapters, not N×M.
Analogy: USB-C for AI apps: instead of a custom cable for every laptop–device pair, each side implements one port and anything plugs into anything.
How it works
- Three roles: the host app, one client per server inside it, and the server exposing capabilities.
- Tools are chosen by the model, resources attached by the app, prompts picked by the user.
- Two transports: stdio for local subprocesses, Streamable HTTP with OAuth 2.1 for remote servers.
- Anthropic measured 58 tools from 5 servers at ~55k tokens of definitions before any conversation.
- It standardizes plumbing, not trust: every server is third-party code and a prompt-injection channel.
Check yourself
Answer to mark it learned; your answers aren't scored.
Your coding agent connects to 5 MCP servers (GitHub, Slack, Sentry, Grafana, Splunk) exposing 58 tools. Before the user types anything, ~55k tokens of tool definitions fill the context, and the model often picks the wrong one of several overlapping tools. Best first move?
Go deeper
Full explanation
MCP is an open protocol (Anthropic, Nov 2024) that standardizes how AI applications connect to external tools and data. Build an integration once as an MCP server and every MCP host can use it.
Three roles:
- Host: the AI app the user runs (Claude Desktop, Cursor, VS Code, ChatGPT).
- Client: a connector inside the host, one per server.
- Server: a program exposing capabilities.
Servers offer three primitives: tools (actions the model decides to call, e.g. create_issue), resources (data the app attaches by URI, e.g. a file) and prompts (templates the user picks). Clients can offer servers elicitation (ask the user a question); sampling (borrow the host's LLM) is deprecated since 2026-07-28.
Messages are JSON-RPC 2.0: tools/list, tools/call, resources/read. Until 2025-11-25 an initialize handshake negotiated capabilities; since 2026-07-28 the protocol is stateless: each request carries version and capabilities in _meta (server/discover for up-front discovery). Two transports: stdio for local servers launched as subprocesses, and Streamable HTTP for remote ones, authorized with OAuth 2.1. The host turns the listed tools into ordinary Tool / function calling schemas for its model.
OpenAI, Google and Microsoft adopted it in 2025; on 9 Dec 2025 Anthropic donated it to the Linux Foundation's Agentic AI Foundation. MCP standardizes the plumbing, not the trust: a server's tool descriptions and results flow straight into your model's context, so every server is third-party code and a Prompt injection (direct & indirect) channel.
Code A minimal MCP server with the Python SDK (MCPServer, ex-FastMCP)
# pip install "mcp[cli]" (official Python SDK v2; v1 was `from mcp.server.fastmcp import FastMCP`)
from mcp.server import MCPServer
mcp = MCPServer("orders")
@mcp.tool()
def get_order_status(order_id: str) -> dict:
"""Status and ETA of one order. Use when the user asks where an order is."""
# The docstring and type hints become the tool description and JSON schema:
# write them for the model, it reads nothing else.
order = orders_db.get(order_id) # read-only access: least privilege
return {"status": order.status, "eta": order.eta.isoformat()}
@mcp.resource("orders://{order_id}/invoice")
def invoice(order_id: str) -> str:
"""Invoice as text. The host app decides when to attach it."""
return render_invoice(order_id)
@mcp.prompt()
def refund_review(order_id: str) -> str:
"""A template the user picks from a menu."""
return f"Review order {order_id} against the refund policy and propose one action."
if __name__ == "__main__":
mcp.run() # stdio for local hosts; mcp.run(transport="streamable-http", port=8000) for remote
# Host config (e.g. Claude Desktop):
# {"mcpServers": {"orders": {"command": "python", "args": ["server.py"]}}}Real example
A platform team supports 4 AI surfaces (an internal chat, Claude Code, Cursor and a support agent) and 6 internal systems (Jira, GitHub, a Postgres read replica, PagerDuty, docs, feature flags). Bespoke connectors would mean 4 × 6 = 24 integrations to build and patch. With MCP it is 6 servers, each owned by the system's team, plus 4 hosts that already speak MCP. Remote servers sit behind company SSO via OAuth, the Postgres server exposes only read-only tools, and a gateway allowlists which servers each host may load and logs every tools/call.
Trade-offs +4 · −4
+ You gain
- Build an integration once; every MCP host can use it (N+M instead of N×M).
- Broad support: Claude, ChatGPT, Gemini CLI, VS Code/Copilot and Cursor all speak it.
- Clear ownership: the team that owns a system ships and versions its server.
- Runtime discovery: tools are listed at connect time, so agents pick up new ones without a redeploy.
− You pay
- Every connected server's tool schemas eat context on every call.
- A new supply-chain and prompt-injection surface: tool poisoning, silent description changes.
- The spec moves fast: transport and auth changed in year one, and the 2026-07-28 revision dropped the initialize handshake, sessions and sampling.
- A thin 1:1 wrapper over a REST API makes a poor agent tool; MCP doesn't fix tool design.
Use it when
When one integration must serve several AI hosts (IDE, chat, your own agents), when you publish tools for other people's agents, or as an internal platform: one governed server per system instead of per-app connectors.
Avoid it when
A single app with two or three private functions: plain in-process tool calling is simpler, faster and has no extra process, transport or auth to run.
Numbers to know 5
- Launched Nov 2024; OpenAI, Google and Microsoft announced support between Mar and May 2025.
- Two standard transports, stdio and Streamable HTTP (since spec 2025-03-26, replacing the original HTTP+SSE), and still the two in the 2026-07-28 revision. Current spec revision: 2026-07-28, the stateless one with no initialize handshake.
- Integration math: 5 apps × 20 systems = 100 bespoke connectors; with MCP, 5 + 20 = 25 implementations.
- Anthropic measured 58 tools from 5 servers (GitHub, Slack, Sentry, Grafana, Splunk) at ~55k tokens of definitions before the conversation starts.
- Anthropic: calling MCP tools from code execution instead of direct tool calls cut one workflow from ~150k to ~2k tokens (~98.7%).
Common pitfalls 4
- Installing unvetted community servers: they run with your credentials, and their descriptions can hide instructions.
- Passing the user's token straight through to downstream APIs; the spec forbids token passthrough.
- Wrapping every REST endpoint as a tool: 80 overlapping tools and a bloated context.
- Trusting tool results: a fetched web page or issue comment can inject instructions into the model.
Interview questions 3
Answer out loud first, then reveal.
What problem does MCP actually solve, and what doesn't it solve?Show answer
It solves integration plumbing: one standard way for any AI host to discover and call tools, read resources and use prompts from any server, so N apps and M systems need N+M adapters instead of N×M. It doesn't solve tool quality, authorization policy or trust. A badly designed tool is still bad over MCP, and a server's descriptions and outputs land in the model's context, so it's a supply-chain and prompt-injection surface. I still need vetting, least-privilege scopes and confirmation on side effects.
How would you roll out MCP safely in an enterprise?Show answer
First, an allowlist: a registry of approved servers with pinned versions, reviewed tool descriptions and an alert when a description changes. Remote servers sit behind OAuth with SSO, short-lived audience-bound tokens and read-only scopes by default. Traffic goes through a gateway that logs every tools/call with the user's identity. Destructive tools require human confirmation. And I never let one session combine private data, untrusted content and an exfiltration channel without controls: that's the lethal trifecta.
MCP or plain function calling?Show answer
Function calling is the model-level mechanism: the model emits a structured call and my code runs it. MCP sits one layer up and standardizes how a host discovers and invokes tools that live elsewhere; under the hood the host still turns them into function-calling schemas. Inside one app with a few private tools, I use plain function calling: no extra process, transport or auth. When the same tools must serve several hosts, or another team owns the system, MCP pays off.