Skip to content
agentscamp

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.prompt on 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-28 MCP 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-hosted SKILL.md Skills, and an experimental CodeModeClient.
  • 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 remote

TIP

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