# FastMCP
FastMCP is a [[Python]] framework for building [[Model Context Protocol (MCP)|MCP]] applications: servers, clients, and the glue around them. You decorate a plain Python function, and FastMCP generates the schema, handles validation, negotiates transport, and manages the protocol lifecycle for you. It's open source ([[Apache 2.0 License]]), made by Prefect, and according to its own docs it powers a large share of the MCP servers out there with around a million downloads a day.
The pitch is simple: writing an MCP server by hand means a lot of boilerplate (schemas, transport, auth, lifecycle). FastMCP hides that so you can focus on the actual tools you want to expose.
## How it works
The core is decorator-based. You write a function, tag it, and it becomes an MCP capability:
- `@mcp.tool` turns a function into a callable tool, with the JSON schema and docs generated from the signature and docstring.
- `@mcp.resource` exposes data the model can read.
- `@mcp.prompt` exposes reusable prompt templates.
From there, FastMCP handles transport negotiation (stdio, HTTP, and friends), authentication, and the request/response lifecycle automatically. The same library also ships a **client**, so you can connect to any MCP server from Python, not just build one.
## What it gives you beyond the basics
This is where FastMCP earns its place over the minimal official SDK:
- **Generation from existing APIs.** Point it at an [[OpenAPI Specification|OpenAPI]] spec or a FastAPI app and it can produce an MCP server, so you don't have to hand-wrap every endpoint.
- **Proxying and composition.** Wrap or combine existing MCP servers, mount one server inside another, and present a unified surface to the agent.
- **Transforms, including Code Mode.** FastMCP can wrap a big toolset behind `search` and `execute` meta-tools so the model writes code instead of loading every schema upfront. See [[Code Mode MCP Pattern]].
- **Deployment and governance.** Prefect offers Prefect Horizon, an enterprise MCP gateway adding SSO/RBAC, observability, and governance on top of FastMCP servers.
## Context
- FastMCP 1.0 was good enough that it got folded into the official MCP Python SDK back in 2024. The 2.0 line is the actively maintained standalone project, and it's where the client, proxying, generation, and transform features live.
- Docs are published as plain markdown and `llms.txt`, and even as an MCP server, so an agent can read the FastMCP docs the same way it reads anything else.
## My Opinion
If I'm building an MCP server in Python, this is the obvious starting point. The decorator approach keeps the code readable, and the fact that it can generate a server straight from an existing OpenAPI or FastAPI app removes most of the busywork. What makes it more interesting than a convenience wrapper is the composition story: proxying, mounting, and the Code Mode transform mean it doubles as a gateway, not just a server builder. That's exactly the layer where the context-window and scalability problems get solved in practice, so FastMCP sits right at the center of where agent tooling is heading.
## References
- https://gofastmcp.com/
- https://github.com/jlowin/fastmcp
- https://gofastmcp.com/servers/transforms/code-mode
- https://www.prefect.io/
## Related
- [[Model Context Protocol (MCP)]]
- [[Code Mode MCP Pattern]]
- [[OpenAPI Specification]]
- [[Python]]
- [[AI Agents]]
- [[Apache 2.0 License]]
- [[Anthropic]]