MCP Python SDK
Documentation
The documentation lives at https://py.sdk.modelcontextprotocol.io/.
It has a Get started guide, What's new in v2, the API reference, and the migration guide.
What is MCP?
The Model Context Protocol lets you build servers that expose data and functionality to LLM applications in a secure, standardized way. Think of it like a web API, but designed for LLM interactions. With this SDK you can:
- Build MCP servers that expose tools, resources, and prompts to any MCP host
- Build MCP clients that connect to any MCP server
- Speak every standard transport: stdio, Streamable HTTP, and SSE
Requirements
Python 3.10+.
Installation
uv add "mcp[cli]" # or: pip install "mcp[cli]"
The cli extra adds the mcp command-line tool (mcp dev, mcp run, mcp install) on top of the SDK; install plain mcp if you don't need it. For one-off commands, uv run --with "mcp[cli]" mcp ... works without a project.
A server in 15 lines
Create a server.py:
from mcp.server import MCPServer
mcp = MCPServer("Demo")
@mcp.tool()
def add(a: int, b: int) -> int:
"""Add two numbers."""
return a + b
@mcp.resource("greeting://{name}")
def greeting(name: str) -> str:
"""Greet someone by name."""
return f"Hello, {name}!"
Full example: docs_src/index/tutorial001.py
That's a complete MCP server: one tool, one templated resource. Open it in the MCP Inspector:
uv run mcp dev server.py
Call add with a=1, b=2 and you get 3 back.
Notice what you did not write: no JSON Schema (a: int, b: int is the schema), no request parsing, no validation code, no protocol handling. Two type-hinted Python functions and a docstring.
Get started takes it from here.
A client in 10 lines
The same package is a full MCP client. Serve server.py over HTTP:
uv run mcp run server.py --transport streamable-http
then point a Client at it:
import asyncio
from mcp import Client
async def main() -> None:
async with Client("http://localhost:8000/mcp") as client:
result = await client.call_tool("add", {"a": 1, "b": 2})
print(result.structured_content) # {'result': 3}
asyncio.run(main())
A URL means Streamable HTTP, the transport you deploy. Client can also launch a local server as a stdio subprocess or take any custom transport; Clients has the rest.
Contributing
We are passionate about supporting contributors of all levels of experience and would love to see you get involved in the project. See the contributing guide to get started.
License
This project is licensed under the MIT License. See the LICENSE file for details.
Metadata
Release files for mcp 2.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| mcp-2.3.0.tar.gz | 4.2 MB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| mcp-2.3.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 4.5 MB
Release files / mcp-2.3.0.tar.gz
| Download URL | mcp-2.3.0.tar.gz |
|---|---|
| Size | 4.2 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8b147a50441cf059dc88c684e0aeed3687f0aa0f39c6cde7b90330effd2b34d8
|
|
BLAKE2b-256 checksum How to use checksums |
9d8de0d339616f4810e9051d4aba6887afab289ab1f81875fe908b606cdfd0e3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 2, 2026.
Transparency logRelease files / mcp-2.3.0-py3-none-any.whl
| Download URL | mcp-2.3.0-py3-none-any.whl |
|---|---|
| Size | 368.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
dd0c44c089d16453e8ae31a3877a0054d7a2314caaa81f5e0541b9b1734b2377
|
|
BLAKE2b-256 checksum How to use checksums |
20d74a2878f128df729db3ca04e71bfce26405cc2e0c9ebe19c592feeb4c61b9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 2, 2026.
Transparency log