FastMCP (standalone)

3.0.2 · active · verified Sun Mar 01

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.

Warnings

Install

Imports

Quickstart

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

view raw JSON →