FastMCP is a Python framework for building applications on the Model Context Protocol (MCP), the open standard that connects LLMs to tools and data. It's for developers who want to expose Python functions as tools an LLM can call, without hand-writing protocol boilerplate, schema definitions, or transport handling. It works for anyone building an MCP server, an MCP client, or both.
With FastMCP, you decorate a Python function with @mcp.tool and it becomes a fully described, validated MCP tool. The framework generates the JSON schema, handles input validation, and takes care of the underlying protocol lifecycle. The project describes itself as the framework behind a large share of MCP servers across languages, and an earlier version of it was folded into the official MCP Python SDK.
@mcp.tool, with automatic schema generation from type hints and docstrings.FastMCP fits well if you're building a tool-calling backend for an LLM agent and want to avoid writing raw MCP protocol code. It's a good choice for wrapping existing Python functions, APIs, or internal services so they can be called by Claude, GPT-based agents, or any other MCP-compatible client. It also works well if you need to write an MCP client to talk to third-party MCP servers, since it manages transport and protocol details for you.
It's also a reasonable pick if you want interactive tool UIs rendered inline in a conversation rather than just text responses, or if you're prototyping an MCP integration quickly and want sensible defaults instead of configuring everything by hand.
It's not the right tool if you're not working with the Model Context Protocol at all, or if you need a non-Python implementation (FastMCP is Python-only). If you need enterprise-grade deployment features like branch previews, SSO, tool-level RBAC, audit logs, or a private registry across many MCP servers, the base FastMCP framework doesn't provide those; that's the scope of Prefect Horizon, a separate commercial product built on top of FastMCP.
Install with uv (recommended):
uv pip install fastmcp
Or with pip:
pip install fastmcp
A minimal server looks like this:
from fastmcp import FastMCP
mcp = FastMCP("Demo 🚀")
@mcp.tool
def add(a: int, b: int) -> int:
"""Add two numbers"""
return a + b
if __name__ == "__main__":
mcp.run()
Run the file directly with Python to start the server. If you're upgrading from an earlier FastMCP version or from the MCP Python SDK, dedicated upgrade guides are available in the docs. If import fastmcp fails right after a pip upgrade, running pip install --force-reinstall fastmcp resolves it (this issue doesn't affect uv installs).
Full documentation, including API references and advanced patterns, lives at gofastmcp.com. The docs are also published in llms.txt and llms-full.txt formats for consumption by LLMs directly.