{"data":{"slug":"modelcontextprotocol-python-sdk","name":"python-sdk","tagline":"Python SDK for Model Context Protocol","github_url":"https://github.com/modelcontextprotocol/python-sdk","owner":"modelcontextprotocol","repo":"python-sdk","owner_avatar_url":"https://avatars.githubusercontent.com/u/182288589?v=4","primary_language":"Python","stars":23555,"forks":3618,"topics":[],"archived":false,"github_pushed_at":"2026-07-07T13:26:12+00:00","url":"https://www.graphcanon.com/tools/modelcontextprotocol-python-sdk","markdown_url":"https://www.graphcanon.com/tools/modelcontextprotocol-python-sdk.md","api_url":"https://www.graphcanon.com/api/graphcanon/tools/modelcontextprotocol-python-sdk","graph_url":"https://www.graphcanon.com/api/graphcanon/graph?tool=modelcontextprotocol-python-sdk","description":"The official Python SDK for Model Context Protocol servers and clients","homepage_url":"https://py.sdk.modelcontextprotocol.io/","license":"MIT","open_issues":529,"watchers":173,"ai_summary":"Official Python implementation of Model Context Protocol (MCP) for server and client interactions.","readme_excerpt":"# MCP Python SDK\n\n<div align=\"center\">\n\n<strong>Python implementation of the Model Context Protocol (MCP)</strong>\n\n[![PyPI][pypi-badge]][pypi-url]\n[![MIT licensed][mit-badge]][mit-url]\n[![Python Version][python-badge]][python-url]\n[![Documentation][docs-badge]][docs-url]\n[![Protocol][protocol-badge]][protocol-url]\n[![Specification][spec-badge]][spec-url]\n\n</div>\n\n> [!CAUTION]\n> **This README documents v2 of the MCP Python SDK — a pre-release (alpha/beta) line under active development. Do not use v2 in production.** Pre-releases are published to PyPI as `2.0.0aN` / `2.0.0bN`, and **each pre-release may contain breaking changes from the previous one**. Pin an exact version and expect to update your code when you bump the pin.\n>\n> **v1.x is the only stable release line and remains recommended for production.** It lives on the [`v1.x` branch](https://github.com/modelcontextprotocol/python-sdk/tree/v1.x) and continues to receive critical bug fixes and security patches; see [the v1.x README](https://github.com/modelcontextprotocol/python-sdk/blob/v1.x/README.md) for its documentation. `pip` and `uv` don't select a pre-release unless you explicitly request one, so existing installs are unaffected. **If your package depends on `mcp`, add a `<2` upper bound to your version constraint (for example `mcp>=1.27,<2`) before the stable release lands.**\n>\n> v2 is a major rework of the SDK, both to support the [2026-07-28 MCP specification release](https://blog.modelcontextprotocol.io/posts/2026-07-28-release-candidate/) and to fix long-standing architectural issues. See [What's new in v2](https://py.sdk.modelcontextprotocol.io/v2/whats-new/) for the tour of what changed, and the [migration guide](https://py.sdk.modelcontextprotocol.io/v2/migration/) for every breaking change. Stable v2 is targeted for 2026-07-27, alongside the spec release. Try the pre-releases and [tell us what breaks](https://github.com/modelcontextprotocol/python-sdk/issues/new?template=v2-feedback.yaml), or discuss in [#python-sdk-dev on the MCP Contributors Discord](https://discord.gg/6CSzBmMkjX).\n\n## Documentation\n\n**The documentation lives at <https://py.sdk.modelcontextprotocol.io/v2/>.**\n\nIt has a [Get started guide](https://py.sdk.modelcontextprotocol.io/v2/get-started/), [What's new in v2](https://py.sdk.modelcontextprotocol.io/v2/whats-new/), the [API reference](https://py.sdk.modelcontextprotocol.io/v2/api/mcp/), and the [migration guide](https://py.sdk.modelcontextprotocol.io/v2/migration/).\n\n## What is MCP?\n\nThe [Model Context Protocol](https://modelcontextprotocol.io) 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:\n\n- **Build MCP servers** that expose tools, resources, and prompts to any MCP host\n- **Build MCP clients** that connect to any MCP server\n- Speak every standard transport: stdio, Streamable HTTP, and SSE\n\n## Requirements\n\nPython 3.10+.\n\n## Installation\n\n```bash\nuv add \"mcp[cli]==2.0.0b1\"          # or: pip install \"mcp[cli]==2.0.0b1\"\n```\n\nThe pin matters while v2 is in pre-release: an unpinned install resolves to the latest stable v1.x, which this README does not describe. Check [PyPI](https://pypi.org/project/mcp/#history) for the newest pre-release, and use `uv run --with \"mcp==2.0.0b1\"` for one-off commands.\n\n## A server in 15 lines\n\nCreate a `server.py`:\n\n\n```python\nfrom mcp.server import MCPServer\n\nmcp = MCPServer(\"Demo\")\n\n\n@mcp.tool()\ndef add(a: int, b: int) -> int:\n    \"\"\"Add two numbers.\"\"\"\n    return a + b\n\n\n@mcp.resource(\"greeting://{name}\")\ndef greeting(name: str) -> str:\n    \"\"\"Greet someone by name.\"\"\"\n    return f\"Hello, {name}!\"\n```\n\n_Full example: [docs_src/index/tutorial001.py](https://github.com/modelcontextprotocol/python-sdk/blob/main/docs_src/index/tutorial001.py)_\n\n\nThat's a complete MCP server: one tool, one templated resource. Open it in the [MCP Inspector](https://github.com/mode","github_created_at":"2024-09-24T21:01:35+00:00","created_at":"2026-07-07T22:36:51.685804+00:00","updated_at":"2026-07-07T22:36:51.809924+00:00","categories":[{"slug":"developer-tools","name":"Developer Tools","url":"https://www.graphcanon.com/categories/developer-tools","markdown_url":"https://www.graphcanon.com/categories/developer-tools.md","api_url":"https://www.graphcanon.com/api/graphcanon/categories/developer-tools"}],"tags":[{"slug":"documentation-api","name":"documentation-api"},{"slug":"pre-release","name":"pre-release"},{"slug":"model-context-protocol","name":"model-context-protocol"},{"slug":"alpha-beta","name":"alpha-beta"},{"slug":"python-sdk","name":"python-sdk"},{"slug":"mcp","name":"mcp"}]}}