🚀 The fast, Pythonic way to build MCP servers and clients. https://gofastmcp.com
Find a file
claude[bot] af786cef46 Add max_sampling_rounds parameter to sample() method
Add configurable max_sampling_rounds parameter to ctx.sample() to allow
users to control the maximum number of tool-calling iterations (defaults
to 100). This prevents infinite loops if the LLM repeatedly calls tools
without converging on a final response.

Co-authored-by: Bill Easton <strawgate@users.noreply.github.com>
2026-01-29 01:45:27 +00:00
.claude/skills Add agent skills for testing and code review (#2846) 2026-01-12 11:24:39 -05:00
.cursor/rules Add agent skills for testing and code review (#2846) 2026-01-12 11:24:39 -05:00
.github Move tests to a reusable action and enable nightly checks (#3017) 2026-01-28 15:00:54 -05:00
docs Add max_sampling_rounds parameter to sample() method 2026-01-29 01:45:27 +00:00
examples fix phue2 import in smart_home example (#2999) 2026-01-28 10:08:33 -05:00
scripts Make duplicate bot less aggressive (#2981) 2026-01-22 09:22:12 -05:00
src/fastmcp Add max_sampling_rounds parameter to sample() method 2026-01-29 01:45:27 +00:00
tests Add max_sampling_rounds parameter to sample() method 2026-01-29 01:45:27 +00:00
v3-notes Add task_meta to prompts and centralize fn_key enrichment (#2751) 2025-12-26 15:04:25 -05:00
.ccignore Update .ccignore 2025-06-30 18:41:04 -04:00
.gitignore Add loq pre-commit hook for file size enforcement (#2847) 2026-01-12 11:37:45 -05:00
.pre-commit-config.yaml Add loq file size limits and clean up type ignores (#2859) 2026-01-13 07:29:12 -05:00
.python-version Initial commit 2024-11-29 16:42:40 -05:00
AGENTS.md refactor: reverse visibility for get_tool/_get_tool methods 2026-01-17 14:38:07 -05:00
CLAUDE.md Consolidate agent instructions into AGENTS.md (#1404) 2025-08-08 11:55:06 -04:00
CODE_OF_CONDUCT.md Create CODE_OF_CONDUCT.md (#1523) 2025-08-16 16:28:15 -04:00
justfile Split transports.py into modular structure (#2921) 2026-01-18 22:11:25 -05:00
LICENSE Basic cleanup 2025-04-05 17:39:51 -04:00
logo.py Update CLI logo (#2220) 2025-10-22 21:29:04 -04:00
loq.toml Refactor OAuthProxy into focused modules (#2935) 2026-01-19 10:10:07 -05:00
pyproject.toml Bump pydocket to >=0.17.2 2026-01-26 11:11:41 -05:00
README.md Restructure README and welcome page with motivated narrative (#2963) 2026-01-20 17:58:10 -05:00
SECURITY.md Add security policy (#2117) 2025-10-16 18:04:43 -04:00
uv.lock Bump pydocket to >=0.17.2 2026-01-26 11:11:41 -05:00

FastMCP Logo

FastMCP 🚀

Move fast and make things.

Made with 💙 by Prefect

Docs Discord PyPI - Version Tests License

jlowin%2Ffastmcp | Trendshift


The Model Context Protocol (MCP) provides a standardized way to connect AI agents to tools and data. FastMCP makes it easy to build MCP applications with clean, Pythonic code:

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()

Why FastMCP

MCP lets you give agents access to your tools and data. But building an effective MCP server is harder than it looks.

Give your agent too much—hundreds of tools, verbose responses—and it gets overwhelmed. Give it too little and it can't do its job. The protocol itself is complex, with layers of serialization, validation, and error handling that have nothing to do with your business logic. And the spec keeps evolving; what worked last month might already need updating.

The real challenge isn't implementing the protocol. It's delivering the right information at the right time.

That's the problem FastMCP solves—and why it's become the standard. FastMCP 1.0 was incorporated into the official MCP SDK in 2024. Today, the actively maintained standalone project is downloaded a million times a day, and some version of FastMCP powers 70% of MCP servers across all languages.

The framework is built on three abstractions that map to the decisions you actually need to make:

  • Components are what you expose: tools, resources, and prompts. Wrap a Python function, and FastMCP handles the schema, validation, and docs.
  • Providers are where components come from: decorated functions, files on disk, OpenAPI specs, remote servers—your logic can live anywhere.
  • Transforms shape what clients see: namespacing, filtering, authorization, versioning. The same server can present differently to different users.

These compose cleanly, so complex patterns don't require complex code. And because FastMCP is opinionated about the details, like serialization, error handling, and protocol compliance, best practices are the path of least resistance. You focus on your logic; the MCP part just works.

Move fast and make things.

Installation

Note

FastMCP 3.0 is currently in beta. Install with: pip install fastmcp==3.0.0b1

For production systems requiring stability, pin to v2: pip install 'fastmcp<3'

We recommend installing FastMCP with uv:

uv pip install fastmcp

For full installation instructions, including verification and upgrading, see the Installation Guide.

📚 Documentation

FastMCP's complete documentation is available at gofastmcp.com, including detailed guides, API references, and advanced patterns.

Documentation is also available in llms.txt format, which is a simple markdown standard that LLMs can consume easily:

  • llms.txt is essentially a sitemap, listing all the pages in the documentation.
  • llms-full.txt contains the entire documentation. Note this may exceed the context window of your LLM.

Community: Join our Discord server to connect with other FastMCP developers and share what you're building.

Contributing

We welcome contributions! See the Contributing Guide for setup instructions, testing requirements, and PR guidelines.