Repolode
modelcontextprotocol

modelcontextprotocol/python-sdk

Official Python SDK for building Model Context Protocol servers and clients that connect LLM applications to tools, data and prompts.

Stars
24,624
Forks
4,275
Open issues
361
Last commit
3 days ago

What is it?

The MCP Python SDK is the official Python implementation of the Model Context Protocol, an open standard for exposing data and functionality to LLM applications in a secure, standardized way. It lets developers write MCP servers that expose tools, resources and prompts to any MCP host, and MCP clients that connect to any MCP server.

Servers are defined with ordinary type-hinted Python functions and docstrings. Type hints become the input schema, so developers do not write JSON Schema, request parsing or protocol handling by hand. The package includes an `mcp` command-line tool for running servers and opening them in the MCP Inspector.

The SDK supports stdio, Streamable HTTP and SSE transports. It requires Python 3.11 or newer and is distributed under the MIT license.

Key features

  • 01Build MCP servers that expose tools, resources and prompts from type-hinted Python functions.
  • 02Build MCP clients that connect to local stdio servers or remote Streamable HTTP servers.
  • 03Supports stdio, Streamable HTTP and SSE transports.
  • 04Includes an `mcp` CLI for running servers and launching the MCP Inspector.

Use cases

  • Exposing internal APIs or databases to an LLM assistant as MCP tools.
  • Writing a Python client that calls tools on an existing MCP server.
  • Prototyping and debugging MCP servers with the MCP Inspector.

Quick start

  1. 1

    Install the SDK with the CLI extra using uv

    uv add "mcp[cli]"
  2. 2

    Or install with pip

    pip install "mcp[cli]"
  3. 3

    Create server.py with a tool and resource (see the README example)

  4. 4

    Run the server in the MCP Inspector

    uv run mcp dev server.py

Things to know

  • Requires Python 3.11 or newer.
  • The README's documentation covers a v2 API, so older tutorials and examples may not match.

Topics

FAQ

What is python-sdk?
Official Python SDK for building Model Context Protocol servers and clients that connect LLM applications to tools, data and prompts. The MCP Python SDK is the official Python implementation of the Model Context Protocol, an open standard for exposing data and functionality to LLM applications in a secure, standardized way. It lets developers write MCP servers that expose tools, resources and prompts to any MCP host, and MCP clients that connect to any MCP server.
Is python-sdk free to use? What license does it have?
python-sdk is open source under the MIT license. Check the license terms before using it in commercial products.
Is python-sdk still maintained?
Actively maintained. The last commit to python-sdk was on Oct 17, 2026.
What can I use python-sdk for?
Exposing internal APIs or databases to an LLM assistant as MCP tools. Writing a Python client that calls tools on an existing MCP server. Prototyping and debugging MCP servers with the MCP Inspector.
How do I install python-sdk?
Install the SDK with the CLI extra using uv: uv add "mcp[cli]" Or install with pip: pip install "mcp[cli]" Create server.py with a tool and resource (see the README example) Run the server in the MCP Inspector: uv run mcp dev server.py
Where can I get python-sdk?
The source code and installation instructions are on GitHub: https://github.com/modelcontextprotocol/python-sdk

Summary generated by AI from the project's README. GitHub stats refresh daily.

Related projects