FastMCP: Python framework for MCP servers and clients
Build Model Context Protocol servers with decorators.
Learn more about fastmcp
FastMCP is a Python framework that simplifies development of Model Context Protocol applications. It uses Python decorators to expose functions as MCP tools and provides built-in support for resources, prompts, and context management. The framework includes authentication integrations, deployment utilities, and client libraries for connecting to MCP servers. Common use cases include building AI agent backends, integrating data sources with LLM applications, and creating composable tool ecosystems.
Decorator-Based Tool Definition
Python decorators expose functions as MCP tools and resources without manual protocol implementation. Reduces boilerplate while maintaining compatibility with the standard Python SDK.
Enterprise Authentication Integrations
Pre-built support for Google, GitHub, WorkOS, Azure, and Auth0 authentication providers. Eliminates custom OAuth implementation for production deployments requiring user authentication.
Server Composition and Proxying
Combine multiple MCP servers, proxy requests between instances, and generate OpenAPI/FastAPI interfaces from MCP definitions. Enables modular architectures and integration with existing web frameworks.
from fastmcp import FastMCP
mcp = FastMCP("My AI Agent")
@mcp.tool()
def calculate_sum(a: int, b: int) -> int:
"""Add two numbers together."""
return a + b
if __name__ == "__main__":
mcp.run()Fixes dependency constraints: bumps py-key-value-aio minimum to 0.2.8 and replaces openapi-core with jsonschema-path.
- –Upgrade py-key-value-aio to at least 0.2.8 to meet the new minimum version requirement.
- –Expect openapi-core removed in favor of jsonschema-path for OpenAPI validation; verify custom validation logic.
Patch release fixing Azure OAuth scope validation bug introduced in 2.13.0.
- –Upgrade immediately if using Azure OAuth provider to restore correct scope handling.
- –Review Azure OAuth configurations after upgrade to confirm scopes are validated as expected.
Breaking: lifespan parameter behavior changed; server-level hooks now run once per instance instead of per client session. Adds pluggable storage backends with encrypted disk persistence, OAuth token introspection (RFC 7662), and response caching middleware.
- –Review lifespan usage—initialization and cleanup hooks now execute once per server instance, not per client connection.
- –Enable response caching middleware to reduce redundant API calls; configure TTLs for tool and resource responses as needed.
See how people are using fastmcp
Related Repositories
Discover similar tools and frameworks used by developers
DeepSpeed
PyTorch library for training billion-parameter models efficiently.
llama_index
Connect LLMs to external data via RAG workflows.
tesseract
LSTM-based OCR engine supporting 100+ languages.
InvokeAI
Node-based workflow interface for local Stable Diffusion deployment.
PentestGPT
AI-assisted Python framework for automated security testing.