← all repositories
modelcontextprotocol/python-sdk

Standardized plumbing between Python and LLM clients

The official Python SDK for the Model Context Protocol, letting you expose functions, data, and prompts to any MCP-compatible client instead of building ad-hoc LLM integrations.

23.7k stars Python Coding AssistantsAgents
python-sdk
Velocity · 7d
+13
★ / day
Trend
steady
star history

What it does

Implements the Model Context Protocol, an open standard that separates “providing context” from the actual LLM interaction. You build Python servers that expose resources (read-only data), tools (functions with side effects), and prompts (reusable templates) to any compatible client such as Claude Code. The mental model is deliberately REST-like: resources behave like read endpoints, tools like action endpoints, but the consumer is an LLM rather than a human or frontend.

The interesting bit

The FastMCP class uses decorators—@mcp.tool() on a function is enough to create a protocol-compliant endpoint. It also injects typed lifespan context and request metadata automatically, so your database connection or user session arrives as a typed function argument without manual wiring. If you already run an ASGI app, the SDK can mount onto it instead of demanding a separate process.

Key highlights

  • Decorator-based server definition with @mcp.tool(), @mcp.resource(), and @mcp.prompt()
  • Supports stdio, SSE, and Streamable HTTP transports out of the box
  • Type-safe lifespan context and dependency injection into handlers
  • Mountable onto existing ASGI servers for integration with current infrastructure
  • Full client SDK included for connecting to any MCP server

Caveats

  • The main branch currently hosts pre-alpha v2 code while the README documents v1.x stable, which the maintainers acknowledge is a temporary split.
  • No performance benchmarks or throughput numbers are provided in the documentation.

Verdict

Reach for this if you are building Python backends that need to expose structured capabilities to LLM agents or chat clients. Skip it if you just want a thin wrapper around the OpenAI API—this is protocol plumbing, not a model client.

Frequently asked

What is modelcontextprotocol/python-sdk?
The official Python SDK for the Model Context Protocol, letting you expose functions, data, and prompts to any MCP-compatible client instead of building ad-hoc LLM integrations.
Is python-sdk open source?
Yes — modelcontextprotocol/python-sdk is open source, released under the MIT license.
What language is python-sdk written in?
modelcontextprotocol/python-sdk is primarily written in Python.
How popular is python-sdk?
modelcontextprotocol/python-sdk has 23.7k stars on GitHub and is currently holding steady.
Where can I find python-sdk?
modelcontextprotocol/python-sdk is on GitHub at https://github.com/modelcontextprotocol/python-sdk.

heatdrop uses Google Analytics to see which pages get read — nothing else. Your call. How we handle data.