FastMCP
ActiveDescription
FastMCP is a fast, Pythonic library for building MCP servers and clients with over 1 million daily downloads, making it easy to create Model Context Protocol tools.
Key Features
- Decorator-Based Tools — Create MCP tools with Python functions and @mcp.tool decorator, auto-generating schema and docs
- MCP Client — Connect to any MCP server (local or remote) with full protocol handshake and session management
- Interactive Apps — Generate interactive UIs for tools that render directly in conversations
- Auto Transport Negotiation — Automatically handles connection and auth for SSE, stdio, and other transports
- Type-Safe Validation — Auto-generates parameter validation and error handling from Python type annotations
- Production-Grade Deployment — Integrates with Prefect Horizon for SSO, RBAC, audit logs, and observability
Use Cases
Categories
Quick Start
uv pip install fastmcp
from fastmcp import FastMCP
mcp = FastMCP("Demo")
@mcp.tool
def add(a: int, b: int) -> int:
"""Add two numbers"""
return a + b
@mcp.tool
def search_files(query: str) -> str:
"""Search for files matching a query"""
import subprocess
result = subprocess.run(["find", ".", "-name", query], capture_output=True, text=True)
return result.stdout
if __name__ == "__main__":
mcp.run()