Skip to content

MCP Python SDK

Official Python library for building MCP servers and clients that connect AI apps to tools and data.modelcontextprotocol/python-sdk

Stars
24.7k
Forks
4.1k
Licence
MIT
Language
Python
Last update
5 days ago
Type
Library

What it is

MCP (Model Context Protocol) is a standard way for LLM applications to access data and functionality. This Python SDK lets developers write a server that exposes tools, resources, and prompts, or a client that connects to such servers. Plain type-hinted Python functions are turned into MCP tools without writing JSON Schema or protocol code.

  • Expose a function such as add(a, b) as a tool that an AI assistant can call
  • Expose templated data, such as a greeting resource, that an LLM application can read
  • Run a local server with the mcp run command and test it with the MCP Inspector via mcp dev
  • Write a Python client that calls tools on a remote MCP server over Streamable HTTP

Great for

  • Python developers who want to expose their own functions to an LLM app as MCP tools
  • Developers building clients that connect to existing MCP servers
  • Teams who need stdio, Streamable HTTP, or SSE transport support
  • Anyone following the official MCP specification who wants a reference Python implementation

Not ideal for

  • Non-programmers, since it requires writing Python code
  • Projects that must run on Python versions below 3.11, as the README lists Python 3.11+ as a requirement
  • Users looking for a ready-made end-user app rather than a developer library
Step-by-step guide: how to use MCP Python SDKInstall, first run, examples, tips and FAQs

How to get it

  1. 1

    Install with a package manager

    You'll need: Python 3.11+

    Install with uv

    uv add "mcp[cli]"

    Or install with pip

    pip install "mcp[cli]"
  2. 2

    Run it

    • Create a server.py file containing the add tool and greeting resource from the README example
    • Run uv run mcp dev server.py to open it in the MCP Inspector
    • Call add with a=1 and b=2 to confirm it returns 3
    • Optionally serve it with uv run mcp run server.py --transport streamable-http and connect with the Client example
  3. 3

    Get the most out of it

    • Use the Get started guide on the documentation site for a step-by-step path
    • Use mcp dev to test tools interactively in the MCP Inspector before connecting a real host
    • Serve over Streamable HTTP to deploy a server, or use stdio to let Client launch a local server as a subprocess
    • Read the migration guide if you are moving from an earlier version, since the docs include a v2 what's-new page

Downloads

Strengths

  • Type hints and docstrings define the tool interface, so little boilerplate is needed
  • Supports the standard transports: stdio, Streamable HTTP, and SSE
  • Official project under the MIT license with 24k+ stars and documentation hosted on a dedicated site

Trade-offs

  • Requires Python 3.11 or newer
  • The README is truncated and gives little detail beyond the quick-start examples; full details are on the external docs site
  • Optional mcp[cli] extra is needed for the command-line tools

How it compares

ProjectStarsTypeLevelUpdatedBest for
python-sdk (this)24.7kLibraryintermediate5 days agoPython developers who want to expose their own functions to an LLM app as MCP tools
mcp-use10.8kLibraryintermediate6 days agoTypeScript developers who want to build MCP servers
mcp-for-beginners17.6kLearning resourcebeginner4 days agoDevelopers new to MCP who want guided lessons
context764.1kAI model / agentbeginner4 days agoDevelopers who use AI coding agents such as Claude, Cursor, or VS Code for libraries that change often
codebase-memory-mcp48kDev toolintermediate4 days agoDevelopers who use an MCP-capable AI coding agent on a large codebase
github-mcp-server34.2kDev toolintermediate4 days agoDevelopers who already use an MCP-compatible AI tool such as VS Code with Copilot, Claude Desktop, or Cursor

Stats synced from GitHub. The assessment above was drafted with AI from the project's README on 2026-10-29 and may miss recent changes — check the README before relying on a command. MIT licence: free to use, modify and distribute, including commercially, as long as you keep the copyright notice.