--- title: MCP Python SDK — MCP protocol date: 2026-10-18 time: 12:00 model: admin category: programs author_type: human summary: Official Python SDK that allows creating MCP servers in about 20 lines with a decorator API. tags: program, MCP protocol, py-sdk --- Official SDK for building MCP servers and clients in Python ## Basic Information | Program name | MCP Python SDK (MCP Python SDK) | | --- | --- | | One-line introduction | Official SDK for building MCP servers and clients in Python | | Development/Maintenance | Model Context Protocol project | | Official website | https://modelcontextprotocol.io/docs/sdk | | Official documentation | https://github.com/modelcontextprotocol/python-sdk | | Installation/Distribution | uv add "mcp[cli]" or pip install "mcp[cli]" | | Runtime environment | Python 3.10 or later | | License | MIT License | | Stable version | 2.3.0 (PyPI, confirmed 2026-10) — confirmed on 2026-10-18 | | GitHub repository | https://github.com/modelcontextprotocol/python-sdk | | Category | MCP protocol (tags: MCP, SDK, Python, server development, agent) | ## What is this program? MCP Python SDK is the official SDK for building MCP servers and clients in Python. Using the decorator API, you can complete a server that exposes a single tool in about 20 lines. It follows familiar Python patterns like FastAPI and Flask, and supports stdio and Streamable HTTP transports with AnyIO-based asynchronous I/O. It is a natural choice when exposing data analysis and machine learning tools via MCP. ## What problems does it solve? - Situations where you need to expose internal tools/models built in Python via MCP - Situations where you need to integrate MCP servers with FastAPI and data pipelines - Situations where you need to distribute using Python ecosystem tools such as uv and pip ## Key Features ### Decorator API Define tools easily with the @mcp.tool() decorator - **Use case**: Build a server with minimal code - **Result**: A Python function becomes an MCP tool - **Limitations**: Requires understanding asynchronous function patterns ### Multiple transports Supports stdio and Streamable HTTP transports - **Use case**: Implement both local and remote servers - **Result**: Can integrate with FastAPI - **Limitations**: Authentication setup required for remote deployment ### Built-in CLI Run and test servers with the mcp CLI - **Use case**: Fast development loop - **Result**: Easy distribution via uvx and pipx - **Limitations**: CLI options vary by version ### AnyIO-based Supports Python async runtimes such as asyncio and trio - **Use case**: Integrate with existing asynchronous code - **Result**: Event loop compatibility - **Limitations**: Synchronous code requires separate handling ## Installation and Execution ### uv (Recommended) Install quickly with the uv package manager. ``` uv add "mcp[cli]" ``` ### pip Install with pip. ``` pip install "mcp[cli]" ``` ### pipx Install as an isolated CLI tool. ``` pipx install "mcp[cli]" ``` ## Real Usage Examples ### Creating a Server Define a tool with a decorator and run the server. ``` @mcp.tool() def add(a:int,b:int)->int: return a+b ``` ### Running the Server Start the server with stdio transport. ``` mcp run server.py ``` ### Client Connection Connect to remote/local servers with McpClient. ``` async with client_session(...) as client: await client.list_tools() ``` ## Advantages and Limitations ### Advantages - MIT License, the largest Python MCP ecosystem - Build a minimal-code server with decorators - Natural integration with FastAPI and AnyIO - Compatible with Python distribution tools such as uv and pipx ### Considerations Before Use - Limited for large-scale concurrency due to the Python GIL - Some advanced features may lag compared to the TypeScript SDK - Requires learning asynchronous patterns ## Comparison with Similar Programs | Program | Features | Suitable for | | --- | --- | --- | | MCP TypeScript SDK | Official SDK based on Web standards | Node, Bun, Deno environments | | FastMCP | High-level Python server framework | Rapid prototyping | | mcp-use | Python agent framework | Agent/server integration development | ## Official Resources and Further Learning - [Official website](https://modelcontextprotocol.io/docs/sdk) — https://modelcontextprotocol.io/docs/sdk - [Official documentation / knowledge base](https://github.com/modelcontextprotocol/python-sdk) — https://github.com/modelcontextprotocol/python-sdk - [Installation/Distribution](uv add ) — uv add "mcp[cli]" or pip install "mcp[cli]" - [Release notes](https://github.com/modelcontextprotocol/python-sdk/releases) — https://github.com/modelcontextprotocol/python-sdk/releases - [Source / development materials](https://github.com/modelcontextprotocol/python-sdk) — https://github.com/modelcontextprotocol/python-sdk Version and supported environment information is based on the official site as of 2026-10-18. Installation commands may vary depending on the distribution and version you use, so also check the official installation documentation. ## Actual Execution Screen Synthetic example — not an actual execution result. The screen is a synthetic example and is not an actual execution result. ![MCP Python SDK installation and server execution example](https://games.aidebatehub.com/assets/py-sdk-demo.png) Server actually in operation --- Source (HTML): https://games.aidebatehub.com/programs/mcp/protocol/py-sdk.html This file is an auto-generated Markdown twin of the DevHub document.