
FastMCP
The fast, Pythonic framework for building MCP (Model Context Protocol) servers and clients. Turn any Python function into production-ready LLM tools with zero boilerplate.
Overview
FastMCP is the standard and most widely used Python framework for the Model Context Protocol (MCP) — an open standard that connects Large Language Models (LLMs) to external tools, data, and services in a secure and interoperable way.
It offers a clean, Pythonic API that lets developers focus on business logic while the framework handles schema generation, protocol compliance, authentication, transport negotiation, and more.
FastMCP 1.0 was incorporated into the official MCP Python SDK in 2024. The actively maintained project (now under PrefectHQ) is downloaded millions of times daily and powers ~70% of MCP servers across languages.
Key Features
- Zero-boilerplate Tools: Decorate any Python function with
@mcp.tool— schemas, validation and documentation are auto-generated from type hints and docstrings. - Servers: Expose tools, resources, prompts and rich interactive UIs directly in LLM conversations.
- Clients: Full-featured, type-safe client for connecting to any MCP server.
- Production Ready: Enterprise authentication (Google, GitHub, Azure, Auth0, etc.), server composition, proxying, OpenAPI generation, testing utilities and easy deployment.
- High Performance & Simplicity: Minimal overhead with best practices built-in.
Quickstart
from fastmcp import FastMCP
mcp = FastMCP("My Demo Server")
@mcp.tool
def add(a: int, b: int) -> int:
"""Add two numbers together."""
return a + b
if __name__ == "__main__":
mcp.run()
Install with: pip install fastmcp
Use Cases
- Building custom tool servers for AI assistants (Claude, Cursor, VS Code, etc.)
- Securely connecting internal APIs, databases and services to LLMs
- Creating multi-server compositions and proxies
- Developing production-grade agent backends with auth and monitoring
- Rapid prototyping of MCP-compatible tools
Why FastMCP?
MCP is known as "USB-C for AI". FastMCP makes implementing the protocol effortless in Python while delivering speed, reliability, scalability and enterprise features out of the box.
Links
- Official Docs: https://gofastmcp.com
- GitHub: https://github.com/PrefectHQ/fastmcp
- PyPI:
pip install fastmcp
Developed with ❤️ by the Prefect team and the MCP community.