Favicon of FastMCP

FastMCP

FastMCP is a Python framework for building Model Context Protocol servers, clients, and interactive tool UIs with minimal code.

FastMCP website screenshot
FastMCP GitHub repository preview

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.

Key features

  • Decorator-based tools: turn any Python function into an MCP tool with @mcp.tool, with automatic schema generation from type hints and docstrings.
  • Resources and prompts: expose data and reusable prompt templates to LLMs alongside tools, all through the same server object.
  • Full client support: connect to any MCP server, local or remote, using a client that handles transport negotiation and protocol details for you.
  • Interactive apps: attach UIs to tools so they render directly inside the conversation instead of returning plain text.
  • Authentication handling: built-in support for managing auth flows when connecting to or serving MCP endpoints.
  • Production-ready defaults: best practices for transport, validation, and lifecycle management are baked into the framework rather than left to the developer.
  • CLI and programmatic clients: connect to servers either through code or from the command line.

Ideal use cases

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.

Installation

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.

Frequently asked questions

Share:

Stars
26.9K
Forks
2.2K
Last commit
22 hours ago
Repository age
2 years
License
Apache-2.0
Self-hosted
No
Activity score
83/100
View Repository
Built with:
Ad
Favicon

 

  
 

Similar to FastMCP

Favicon

 

  
 
Favicon

 

  
 
Favicon