← Back to directory
M

MCP Python SDK

Official
The official Python SDK for building MCP servers and clients
GitHub source repository ↗
★ 23.9k Stars Category · Dev Tools Very popular
68FMRS · C
Reliability
9/20
Security and permissions
12/20
Maintenance
18/20
Documentation
16/20
Setup experience
13/20

The officially maintained MCP Python SDK for building servers and clients, not itself a fixed-capability server; documentation, a migration guide, and community support channels are all present, with v2 as the current stable line and v1.x still receiving security patches.

Read the FMRS scoring method →

This is the official Python implementation of the Model Context Protocol (MCP), maintained by the modelcontextprotocol organization. It is not a standalone server with a fixed set of tools, but a development library: it lets developers write MCP servers that expose tools, resources, and prompts, or clients that connect to any MCP server. The SDK supports all three standard transports (stdio, Streamable HTTP, and SSE) and derives JSON Schema automatically from Python type hints, eliminating hand-written protocol parsing. It is currently on the v2 major line (supporting the 2026-07-28 spec revision and all earlier ones), while v1.x continues to receive critical bug fixes and security patches on its own branch. Requires Python 3.10+.

Tools

The tool list has not been reviewed yet.

Setup

Install with uv add "mcp[cli]" or pip install "mcp[cli]" (the cli extra adds the mcp dev/mcp run/mcp install command-line tool; install plain mcp if the CLI isn't needed). Because pip install mcp now installs 2.x by default, projects still relying on v1 behavior should pin an upper bound such as mcp>=1.28,<2 until migrated. After installing, write a server script using @mcp.tool() and @mcp.resource() decorators and run it with uv run mcp dev server.py to debug it in the MCP Inspector.

Fit and risk

Best for

  • Python developers comfortable with type hints who want to quickly build an MCP server or client
  • Teams integrating MCP protocol capabilities (tool calls, resource access) into their own projects
  • Existing v1 users evaluating or migrating to the MCP v2 specification

Not for

  • Users looking for a ready-to-install, end-user-facing MCP server (this repo is an SDK, not a specific service)
  • Projects stuck on Python 3.9 or earlier that cannot upgrade their runtime
  • Projects not yet ready to handle v1-to-v2 breaking changes and needing long-term lock-in to v1 behavior

Required permissions

  • The SDK itself does not request specific system permissions; actual permission needs depend on the server logic developers build with it
  • If a server built with it runs over stdio, the host process can execute arbitrary local code logic defined by the developer's tool functions
  • If a server uses SSE or Streamable HTTP transport, network listening/access is required

Risks and side effects

  • As a development library, the security of any resulting server depends entirely on how the implementer writes tool and resource logic — the SDK cannot guarantee downstream code safety
  • v1 to v2 introduces architectural breaking changes; projects without an upper version bound may unexpectedly pull an incompatible 2.x release on dependency upgrade
  • Tool function parameters and return values may still trigger unintended behavior from malicious or malformed input if the implementer omits extra validation

Troubleshooting

  1. Confirm Python is 3.10 or newer, since install/run will fail on older versions
  2. If the `mcp` CLI (`mcp dev`/`mcp run`/`mcp install`) is needed, verify the `[cli]` extra was installed
  3. If the project depends on v1.x behavior, check that dependency declarations pin an upper bound below 2 to avoid an automatic upgrade to v2
  4. Use `uv run mcp dev server.py` with the MCP Inspector to debug tool call or resource resolution issues
  5. Consult the migration guide at py.sdk.modelcontextprotocol.io for v1-to-v2 upgrade issues

Use cases

Writing a custom MCP server from scratch that exposes tools, resources, and prompts
Writing a Python client that connects to a local or remote MCP server
Connecting directly to an in-memory server object for tests, with no transport layer involved
Switching an existing server between stdio, SSE, and Streamable HTTP transports

Supported clients

Supported clients have not been confirmed yet.