FastMCP
A Pythonic framework for building Model Context Protocol servers and clients — decorator-based tools, resources, and prompts, with auth and deployment built in.
FastMCP is a high-level, Pythonic framework for building Model Context Protocol servers (and clients). Instead of hand-wiring JSON-RPC and transports, you decorate plain Python functions — @mcp.tool, @mcp.resource, @mcp.prompt — and FastMCP turns them into a compliant server, generating the schemas the client advertises to the model from your type hints and docstrings.
It is aimed at Python developers who want to expose a capability as an MCP server with minimal ceremony, then grow it toward production. FastMCP's original version (1.0) was incorporated into the official MCP Python SDK; the actively developed standalone framework — now FastMCP 3.x — adds the surrounding machinery: authentication, deployment, server composition, proxying, and generating servers from existing OpenAPI/FastAPI apps.
Highlights
- Decorator-based —
@mcp.tool,@mcp.resource, and@mcp.prompton ordinary functions; schemas are derived from type hints and docstrings. - Transports built in — run over stdio for local use or Streamable HTTP for remote, without rewriting your handlers.
- Auth & deployment — built-in authentication patterns and deployment helpers for taking a server remote and production-ready.
- Composition & proxying — mount sub-servers and proxy other MCP servers to assemble larger surfaces from smaller ones.
- Generate from existing APIs — produce an MCP server from an OpenAPI spec or a FastAPI app, so an existing service becomes model-accessible.
In an AI-assisted workflow
Define a tool as a typed function and run the server:
from fastmcp import FastMCP
mcp = FastMCP("weather")
@mcp.tool
def get_weather(city: str, units: str = "c") -> str:
"""Get the current weather for a city. Returns temperature and conditions."""
data = fetch_weather(city, units)
return f"{data.temp}° — {data.conditions}"
if __name__ == "__main__":
mcp.run() # stdio by default; switch to Streamable HTTP for remoteTIP
The function's name, type hints, and docstring become the tool's name, schema, and description — the model's routing signal. Write the docstring for the model: what the tool does, what it returns, and when to use it. Test it with the MCP Inspector before connecting a client.
Good to know
FastMCP is free and open source under Apache-2.0. It's the fast path to an MCP server in Python; for the conceptual model see Building an MCP Server, and for taking the result remote and scalable, Deploying a Remote MCP Server.
Related
- Building an MCP ServerAn accurate introduction to the Model Context Protocol: server anatomy, transports, and connecting a tool to Claude Code.
- MCP Server EngineerUse this agent to build, harden, or productionize a Model Context Protocol (MCP) server — designing tools/resources/prompts, choosing stdio vs. Streamable HTTP, taking a server remote with OAuth and stateless scaling, and testing it with the MCP Inspector. Examples — "wrap our internal API as an MCP server with three tools", "take our stdio server remote so the team can share it", "our tools confuse the model — fix the names, schemas, and descriptions".
- MCP InspectorThe official open-source visual tool for testing and debugging Model Context Protocol servers — connect, list, and call tools, resources, and prompts.
- Deploying a Remote MCP Server: Stateless, Streamable HTTP, and Horizontal ScalingTake an MCP server from local stdio to a remote, multi-user HTTP service — Streamable HTTP, stateless vs. stateful sessions, OAuth, and horizontal scaling.
- MCP Server ScaffolderScaffold a new Model Context Protocol (MCP) server from a description — pick the SDK and transport, generate a typed first tool with a strict schema, and wire up MCP Inspector testing and the client-registration command. Use when starting a new MCP server and you want a correct, runnable skeleton instead of copying a README.