FastMCP is the developer-friendly framework for building MCP servers. Like FastAPI revolutionized web API development, FastMCP makes creating custom tool servers trivial — define a Python function with type hints, and FastMCP handles the MCP protocol, validation, and transport.
FastMCP is to MCP servers what FastAPI is to web APIs. Write a Python function with type hints, decorate it, and FastMCP handles everything — serialization, validation, transport, and the full MCP protocol handshake. With 24k+ stars and backing from Prefect, it’s the standard way to build custom MCP servers.
@mcp.tool() to expose via MCPfrom fastmcp import FastMCP
mcp = FastMCP("My Tools")
@mcp.tool()
def get_weather(city: str) -> str:
"""Get current weather for a city."""
return f"Weather in {city}: 72°F, sunny"
mcp.run()
@mcp.tool()
def check_stock(product_id: str) -> dict:
"""Check inventory levels for a product."""
stock = db.query(f"SELECT * FROM inventory WHERE id = %s", (product_id,))
return {"product": product_id, "quantity": stock.quantity}
AI agents that work well with FastMCP.
Official Anthropic-maintained collection of 20+ MCP server implementations for filesystem, GitHub, Slack, databases, and more.
Secure cloud sandboxes for AI agents to execute code — isolated environments with built-in safety.
Automatically expose FastAPI endpoints as MCP tools — turn any API into an AI-callable tool in one line.