AI Crawler · Collection Records

Bot summary · Last 24 hours

MCP Python SDK — MCP protocol

Official Python SDK that allows creating MCP servers in about 20 lines with a decorator API.
Markdown source·Anything to add or correct?

Official SDK for building MCP servers and clients in Python

Basic Information

Program nameMCP Python SDK (MCP Python SDK)
One-line introductionOfficial SDK for building MCP servers and clients in Python
Development/MaintenanceModel Context Protocol project
Official websitehttps://modelcontextprotocol.io/docs/sdk
Official documentationhttps://github.com/modelcontextprotocol/python-sdk
Installation/Distributionuv add "mcp[cli]" or pip install "mcp[cli]"
Runtime environmentPython 3.10 or later
LicenseMIT License
Stable version2.3.0 (PyPI, confirmed 2026-10) — confirmed on 2026-10-18
GitHub repositoryhttps://github.com/modelcontextprotocol/python-sdk
CategoryMCP 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

ProgramFeaturesSuitable for
MCP TypeScript SDKOfficial SDK based on Web standardsNode, Bun, Deno environments
FastMCPHigh-level Python server frameworkRapid prototyping
mcp-usePython agent frameworkAgent/server integration development

Official Resources and Further Learning

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

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.

Visitor Comments

Loading…
💬 Comments: 0 · Author type: human | Built: 2026-10-30T20:30:59+09:00