MCP Python SDK
ActiveDescription
MCP Python SDK is the official Python implementation for building MCP servers and agent-side integrations with a standardized tool protocol.
Key Features
- FastMCP high-level interface — quickly define MCP Server tools, resources and prompts with decorators
- Multi-transport support — supports stdio, SSE and Streamable HTTP standard transport methods
- Structured output — tool return values automatically serialized into structured JSON responses
- Resource and prompt system — expose data via Resources, define interaction templates via Prompts
- OAuth authentication support — built-in OAuth authentication flow in client
- ASGI mounting — mountable into existing FastAPI/Starlette apps as sub-applications
Use Cases
Strengths & Limitations
✅ Strengths
- • Actively maintained, recent updates
- • High community interest (24.0k stars)
- • Permissive open-source license (MIT)
Categories
Quick Start
uv init mcp-server-demo
cd mcp-server-demo
uv add "mcp[cli]"
# server.py
from mcp.server.fastmcp import FastMCP
mcp = FastMCP("Demo", json_response=True)
@mcp.tool()
def add(a: int, b: int) -> int:
"""Add two numbers"""
return a + b
@mcp.resource("greeting://{name}")
def get_greeting(name: str) -> str:
return f"Hello, {name}!"
if __name__ == "__main__":
mcp.run(transport="streamable-http")