MCP Python SDK
The official Python SDK for the Model Context Protocol, for building MCP servers and clients. Version 2 targets the stateless 2026-07-28 specification, turns type-hinted functions into tools and resources with the MCPServer class, and ships the mcp command for testing servers in the Inspector.
24.4k
GitHub · Sept 2026
mcp 2.2.0
PyPI · Sept 2026
GitHub repo
AI & Machine Learning
Model Context Protocol
A day for a first server
Intermediate
Free
What the SDK gives you
The MCP Python SDK is the official way to build Model Context Protocol servers and clients in Python. Its README sums up the appeal: two type-hinted Python functions and a docstring become a complete server, with no JSON Schema, request parsing or protocol handling written by hand.
A first server looks like this in version 2:
from mcp.server import MCPServerand createMCPServer("Demo").- Decorate functions with
@mcp.tool(),@mcp.resource("greeting://{name}")or@mcp.prompt(). - Open it in the MCP Inspector with
uv run mcp dev server.py, or serve it over Streamable HTTP withuv run mcp run server.py --transport streamable-http.
The same package is also a full client: Client("http://localhost:8000/mcp") connects to any server and calls its tools.
What changed in version 2
Version 2 was reworked for the 2026-07-28 MCP specification, which made the protocol stateless. The high-level class was renamed from FastMCP to MCPServer, host and port settings moved to run(), handlers receive context through a ctx: Context parameter, and Python attributes use snake case. The documentation site has a What's new page and a migration guide, and projects that must stay on version 1 can pin mcp>=1.28,<2. Many tutorials online still show from mcp.server.fastmcp import FastMCP; that is version 1.
Is it worth it?
If you want your data or service to be usable from Claude, ChatGPT, Cursor, VS Code and other MCP hosts, yes. A server is a thin layer over code you already have, and the SDK handles the protocol details that change between specification revisions.
Prerequisites and time
Python 3.10 or newer, comfort with type hints and ideally uv for project management. Building and testing a small server takes a day. Deploying a remote server with authentication takes longer, and the documentation covers OAuth and transports.
Free or paid?
Free and open source. The project is moving from the MIT licence to Apache 2.0 for new contributions, as part of MCP's move to the Agentic AI Foundation under the Linux Foundation.
What you can do after it
Publish an MCP server that exposes tools and resources from a real system, test it in the Inspector, connect it to an MCP host and write a small client that calls it in tests.
Common questions
Where is the full documentation? At py.sdk.modelcontextprotocol.io, linked from the README, with a get started guide, API reference and migration guide.
Stdio or HTTP? Use stdio for a local tool a desktop app launches, and Streamable HTTP for a server many users reach over the network.
Ready to start?
Opens on Model Context Protocol in a new tab.
Stuck on something specific?
Writing only gets you so far. If you want an answer to your situation rather than the general case, book a session and we will work through it together. Sessions are free for approved Sefism members, and a few slots open each week.
Follow along
New writing, resources and project ideas land here first.