FastMCP
by jlowin
FastMCP is the Python framework behind official MCP server support: decorate a function with @mcp.tool and it becomes a schema-validated MCP tool.
About
FastMCP handles the parts of building an MCP server that have nothing to do with your actual logic: schema generation from type hints, input validation, and the protocol lifecycle. In practice that means `@mcp.tool` on a typed Python function is enough to expose it as a callable tool, `@mcp.resource` exposes data the same way, and `@mcp.prompt` defines reusable prompt templates, no manual JSON Schema, no boilerplate transport code.
FastMCP 1.0 was folded directly into the official MCP Python SDK; this repository is FastMCP 2.0, a superset now maintained by PrefectHQ that adds a full MCP client, server composition and remote proxying (so you can combine several MCP servers into one), and built-in OpenAPI/FastAPI integration for turning an existing REST API into MCP tools automatically.
Key features
- @mcp.tool turns any typed Python function into a schema-validated MCP tool with one decorator
- @mcp.resource and @mcp.prompt expose data and prompt templates using the same pattern
- Built-in MCP client support for calling and testing other servers, not just building your own
- Server composition and remote proxying let you combine multiple MCP servers into one
- OpenAPI/FastAPI integration auto-generates MCP tools from an existing REST API
- FastMCP 1.0 was merged into the official MCP Python SDK; this is the actively maintained 2.0 superset
Use cases
- Turning an internal Python library or script into an MCP server without hand-writing JSON schemas
- Wrapping an existing FastAPI/OpenAPI service as a set of MCP tools automatically
- Composing several smaller MCP servers into a single server for one client to talk to
- Writing test clients against your own MCP server during development
Available tools
@mcp.tool
Decorator that exposes a typed Python function as an MCP tool with an auto-generated schema.
@mcp.resource
Decorator that exposes data or files as a readable MCP resource.
@mcp.prompt
Decorator that defines a reusable prompt template clients can request.
Client
Built-in MCP client for connecting to, calling, and testing any other MCP server from Python.
Frequently asked questions
Do I need to understand the MCP spec to use it?
No. You write plain, typed Python functions and decorate them; FastMCP generates the schema and handles the protocol lifecycle.
How does this relate to the official MCP Python SDK?
FastMCP 1.0 was merged into the official SDK's server support. This repository is FastMCP 2.0, a separately maintained superset with a full client, composition, and more.