Registry / web-framework / fastmcp

fastmcp

JSON →
library3.0.2pypypiunverified

The dominant Python framework for building MCP servers and clients. FastMCP 1.0 was incorporated into the official mcp package in 2024, but the standalone project continued evolving independently. Now maintained by Prefect (PrefectHQ/fastmcp), v3.0 shipped February 2026 as a major breaking rewrite. ~1M daily downloads. Powers ~70% of MCP servers across all languages. Critical: minor versions may contain breaking changes — pin aggressively.

web-frameworkhttp-networking
Install & Compatibility
Where this runs
tested against v3.4.2 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
glibc
py 3.10
✓ —
✓ 14.25s
py 3.11
✓ —
✓ 13.5s
py 3.12
✓ —
✓ 11.07s
py 3.13
✓ —
✓ 10.88s
py 3.9
✕ build_error
✕ build_error
132MB installed
● package 132MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Use 'from fastmcp import FastMCP' for standalone package. 'from mcp.server.fastmcp import FastMCP' is FastMCP 1.0 bundled in the official mcp package — a different, older version.

from fastmcp import FastMCP mcp = FastMCP('My Server') @mcp.tool def add(a: int, b: int) -> int: """Add two numbers""" return a + b mcp.run()

Client class replaces any earlier transport-specific client patterns. Handles transport negotiation automatically.

from fastmcp import Client async with Client('http://localhost:8000/mcp') as client: tools = await client.list_tools() result = await client.call_tool('add', {'a': 1, 'b': 2})

Decorators derive tool name, description, and JSON schema from function signature and docstring automatically. mcp.run() defaults to stdio for local use; pass transport='http' for remote deployments.

# Server from fastmcp import FastMCP mcp = FastMCP('Demo') @mcp.tool def add(a: int, b: int) -> int: """Add two numbers""" return a + b @mcp.resource('data://{name}') def get_data(name: str) -> str: """Fetch named data""" return f'Data for {name}' @mcp.prompt def review(code: str) -> str: return f'Review this code:\n{code}' if __name__ == '__main__': mcp.run() # stdio by default # mcp.run(transport='http', host='0.0.0.0', port=8000) # remote # --- # Client import asyncio from fastmcp import Client async def main(): async with Client('http://localhost:8000/mcp') as client: tools = await client.list_tools() result = await client.call_tool('add', {'a': 1, 'b': 2}) print(result) asyncio.run(main()) # --- # CLI usage # fastmcp list http://localhost:8000/mcp # list tools on any server # fastmcp call http://localhost:8000/mcp add a=1 b=2 # call a tool # fastmcp discover # find all locally configured servers
Debug
Known footguns
breakingv3.0 (February 2026) is a major breaking rewrite from v2.x. Anyone not pinning fastmcp was auto-upgraded to v3.0 on pip install. Major changes: provider architecture replaces direct component registration, ctx.set_state()/ctx.get_state() are now async, StreamableHttpTransport replaces older HTTP transport classes, auth providers no longer auto-load config.
breakingIn v3, @mcp.tool decorator returns the original function unchanged (so decorated functions remain directly callable). In v2.x, @mcp.tool returned a FunctionTool object. Code accessing .name, .description, or other FunctionTool attributes on the decorated result will break.
breakingTransport config (host, port) must be passed to mcp.run(), not the FastMCP() constructor. Passing them to the constructor raises TypeError.
breakingfastmcp.server.auth module (introduced v2.12.0) is explicitly exempt from semantic versioning stability guarantees and has breaking changes on minor versions. Auth API changed significantly in v3.
breakingGitHub repository moved from jlowin/fastmcp to PrefectHQ/fastmcp with v3.0. Old GitHub links forward automatically. PyPI package name, import paths, and CLI commands are unchanged.
gotchafastmcp includes the mcp package as a dependency — installing both separately can cause version conflicts if mcp is pinned independently. fastmcp pins its compatible mcp version internally.
gotchaMinor versions may contain breaking changes (explicitly documented in release policy). 'Semantic versioning is pragmatic' — do not assume minor bumps are safe without checking release notes.
gotchafastmcp and the mcp SDK's bundled FastMCP 1.0 (from mcp.server.fastmcp) have the same class name but different behavior. Mixing imports in one project causes silent behavioral differences.
gotchaCVE-2026-24486 (python-multipart) and CVE-2026-0994 (protobuf) were patched in fastmcp 3.0.2. Earlier 3.x and 2.x versions are vulnerable.
breakingfastmcp requires Python 3.10 or newer. Attempting to install fastmcp in an environment with an older Python version (e.g., Python 3.9) will result in pip being unable to find a compatible distribution.
breakingfastmcp v2.x (e.g., 2.14.6) depends on pydocket (e.g., 0.18.2). pydocket 0.18.2 requires `fakeredis>=2.32.1` but its internal code attempts to import `FakeConnection` from `fakeredis.aioredis`, which was removed in `fakeredis 2.32.1` and renamed to `FakeRedisConnection`. This leads to an ImportError, making fastmcp v2.x unusable with `fakeredis>=2.32.1`.
Upgrade
Version history

Breaking-change detection hasn't run for this library yet.

Audit
Security & dependencies

CVE tracking and dependency tree are planned for a later release.

Agent activity
27 hits · last 30 days
claudebot
5
gptbot
4
ahrefsbot
4
bytedance
4
amazonbot
3
dotbot
1
bingbot
1
Resources