The fast, Pythonic way to build MCP servers, clients, and interactive apps based on the Model Context Protocol.
FastMCP is an open-source Python framework maintained by the Prefect team, providing three core capabilities around the MCP (Model Context Protocol) ecosystem:
Server Building: Expose Python functions as MCP components via @mcp.tool, @mcp.resource, and @mcp.prompt decorators with automatic JSON Schema generation, parameter validation, and documentation. Supports STDIO and HTTP (Streamable HTTP) transports with built-in OAuth authentication, Middleware interception chains, dynamic Providers, Tag-Based Filtering, and Strict Input Validation for production use.
Client Connections: Async client API for connecting to any MCP server programmatically or via CLI, with automatic transport negotiation, authentication flows, and protocol lifecycle management.
Interactive Apps (v3): Add visual UI (tables, charts, forms) to tool results using @mcp.tool(app=True) with Prefab components, while tools remain fully functional as standard MCP tools.
Also provides a complete CLI toolchain (run/inspect/install/client/generate-cli/auth), background task system, OpenTelemetry observability integration, and optional LLM SDK integrations (Anthropic/OpenAI/Gemini). Supports free hosted deployment via Prefect Horizon.
Quick Start:
from fastmcp import FastMCP
mcp = FastMCP("My MCP Server")
@mcp.tool
def greet(name: str) -> str:
return f"Hello, {name}!"
if __name__ == "__main__":
mcp.run()
Installation: pip install fastmcp (optional extras: tasks, apps, anthropic, openai, gemini, azure)
Requirements: Python >= 3.10 (supports 3.10/3.11/3.12/3.13)
Versioning: Current main version v3.x (latest v3.2.4, 96 releases total). Uses semantic versioning but may introduce breaking changes in minor versions to keep pace with the rapidly evolving MCP protocol; pinning exact versions is recommended for production.
History: FastMCP 1.0 was incorporated into the official MCP Python SDK in 2024, after which it continued as an independent project (exact timeline unconfirmed).