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 Pythonic framework for Model Context Protocol servers and clients: decorate functions with @mcp.tool, @mcp.resource, or @mcp.prompt to generate schemas from type hints and docstrings. v1.0 was folded into the official MCP Python SDK (now MCPServer in SDK v2); standalone FastMCP 4.x adds sessionless protocol support, auth, MCP Apps, and Skills.
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 1.0 version was incorporated into the official MCP Python SDK (which renamed its embedded FastMCP class to MCPServer in SDK v2); the actively developed standalone framework — now FastMCP 4.x (4.0.0 shipped August 31, 2026; 4.2.6 as of November 2026) — builds on MCP Python SDK v2 and the sessionless 2026-07-28 MCP protocol revision, adding authentication, deployment, interactive MCP Apps, server-hosted Skills, 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. - Sessionless protocol & dual-era negotiation — FastMCP 4 runs stateful apps (follow-up input requests, auth state, background tasks) over the sessionless
2026-07-28MCP revision behind standard load balancers, negotiating legacy and new protocol eras per connection across stdio and Streamable HTTP. - Auth, MCP Apps & Skills — built-in authentication, deployment helpers, interactive apps (
FastMCPApp), server-hostedSKILL.mdSkills, and an experimentalCodeModeClient. - 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 (~29k GitHub stars, v4.2.6 as of November 2026), with a TypeScript sibling (@prefecthq/fastmcp-ts) for Node teams. 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.
Frequently asked questions
- What is FastMCP?
- 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 with @mcp.tool, @mcp.resource, or @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.
- Is FastMCP free?
- Yes — FastMCP is free and open source under Apache-2.0. Its original 1.0 version was folded into the official MCP Python SDK (which renamed its embedded class to MCPServer in SDK v2); the actively developed standalone framework is FastMCP 4.x (v4.2.6 as of November 2026), adding sessionless 2026-07-28 MCP protocol support, auth, MCP Apps, server-hosted Skills, composition, and OpenAPI/FastAPI generation.
- How do I build an MCP server with FastMCP?
- Create a FastMCP instance, decorate a typed function with @mcp.tool, and call mcp.run() — stdio by default, or Streamable HTTP for remote use. The function's name, type hints, and docstring become the tool's name, schema, and description, so write the docstring for the model: what the tool does, what it returns, and when to use it.
Filed under
mcp · python · sdk · open-source
Related
- GuideDeploying 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.
- ToolMCP InspectorThe official open-source visual tool for testing and debugging Model Context Protocol servers — connect, list, and call tools, resources, and prompts.
- GuideBuilding an MCP ServerAn accurate introduction to the Model Context Protocol: server anatomy, transports, and connecting a tool to Claude Code.
- AgentMCP 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".
- SkillMCP 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.
- GuideThe 2026 AI Agent Protocol Stack: MCP, ACP, A2A, AG-UI, A2UI, and MCP AppsHow MCP, MCP Apps, ACP, A2A, AG-UI, and A2UI fit together in 2026: boundaries, wire formats, Zed/JetBrains setup, governance, and which layers you need.
- Guide7 Best Claude Skills for MCP Server DevelopmentClaude skills, commands, and agents for building MCP servers: scaffolding, tool schemas, Inspector testing, safe registration, config audits, code review, and plugins.