What Is MCP (Model Context Protocol)? A Python Guide
What the Model Context Protocol actually standardizes, how it differs from LangChain or DSPy, and a basic FastMCP server example
Every LLM framework used to invent its own way of connecting a model to external tools and data — a LangChain tool, a DSPy module, a custom function-calling schema, none of them compatible with each other. MCP standardizes that connection instead of leaving every framework to reinvent it.
What MCP actually standardizes
The Model Context Protocol defines a common interface for three things: tools (functions an AI application can call), resources (structured or semi-structured data it can read without modifying), and prompts (reusable prompt templates a server can expose). An MCP server implements that interface once; any MCP-compatible client — Claude, an IDE, a custom agent — can connect to it without server-specific integration code. It’s often described as “USB-C for AI”: one standard connector instead of a different cable for every device.
Where it sits relative to LangChain and DSPy
These solve different layers of the same problem. LangChain and DSPy are frameworks for building the application logic — chains, agents, prompt optimization. MCP standardizes how that application logic reaches external tools and data once it needs to. In practice they compose: a LangChain agent can call tools exposed by an MCP server rather than each tool needing bespoke LangChain integration code.
Building a server with FastMCP
FastMCP (pip install fastmcp) is a standalone Python framework for building MCP servers and clients. It handles protocol details (schema generation, transport, lifecycle) so you write plain Python functions:
from fastmcp import FastMCP
mcp = FastMCP("My Server")
@mcp.tool()
def add(a: int, b: int) -> int:
"""Add two numbers"""
return a + b
if __name__ == "__main__":
mcp.run()@mcp.tool() inspects the function signature and docstring to generate the schema a client needs to call it correctly, with no separate schema file to keep in sync with the implementation. You can test a server without any transport by connecting an in-memory client to it. This runs as written with fastmcp 4.2.0:
import asyncio
from fastmcp import Client, FastMCP
mcp = FastMCP("My Server")
@mcp.tool()
def add(a: int, b: int) -> int:
"""Add two numbers"""
return a + b
async def main():
async with Client(mcp) as client:
tools = await client.list_tools()
print([tool.name for tool in tools]) # ['add']
result = await client.call_tool("add", {"a": 2, "b": 3})
print(result.data) # 5
asyncio.run(main())The official SDK offers the same shape: from mcp.server import MCPServer, then @mcp.tool() on your functions. Use whichever you prefer; both speak the same protocol, so clients can’t tell them apart.
Why this matters now
The protocol is young and still changing. The latest specification revision, 2026-07-28, removed protocol-level sessions and the Mcp-Session-Id header, made the protocol stateless (no initialize handshake; every request carries its version and client capabilities), and added a server/discover call. The official Python SDK shipped v2.0.0 on the same day: pip install mcp now installs 2.x, and its FastMCP class was renamed MCPServer, so from mcp.server.fastmcp import FastMCP raises ModuleNotFoundError on 2.x (pin mcp<2 to keep v1 code running). The standalone fastmcp package is separate and is at 4.x.
That churn is normal for a young standard, but it’s why “is this worth learning yet” is a fair question. The core tool, resource and prompt model has stayed stable while transport and session details changed, which is the part worth understanding now. When you follow a tutorial, check which package and major version it was written for.
Should you build an MCP server
If you’re already building tools for an AI application — internal or public — exposing them via MCP instead of a framework-specific integration means any MCP-compatible client can use them without you writing separate integration code per framework. For a one-off internal script calling a single LLM, it’s more protocol than you need; MCP earns its complexity once multiple clients or tools are involved.
Frequently Asked Questions
What is the Model Context Protocol (MCP)?
MCP is a standard that defines a common interface for tools (functions an AI application can call), resources (structured data it can read), and prompts (reusable templates a server can expose) — so any MCP-compatible client can connect to a server without needing custom integration code.
How does MCP differ from LangChain or DSPy?
LangChain and DSPy are frameworks for building application logic — chains, agents, prompt optimization. MCP standardizes how that logic reaches external tools and data once it needs to. In practice they compose: a LangChain agent can call tools exposed by an MCP server.
What is FastMCP?
FastMCP is a widely used standalone Python framework for building MCP servers and clients (the fastmcp package, version 4.2.0 on 14 November 2026). It handles schema generation, transport and lifecycle, so you write plain Python functions decorated with @mcp.tool(). The official mcp SDK has its own equivalent, MCPServer, which was called FastMCP before version 2.
Should you build an MCP server?
If you’re already building tools for an AI application, exposing them via MCP means any MCP-compatible client can use them without framework-specific integration code. For a one-off script calling a single LLM, it’s more protocol than you need.