Skip to content

The framework for MCP

Build MCP servers, clients and interactive apps.
You write the application logic.
FastMCP handles the protocol.

uv add fastmcp
server.py
from fastmcp import FastMCP

mcp = FastMCP("Bookshop")

BOOKS = ["Dune", "Neuromancer", "Snow Crash", "Hyperion"]


@mcp.tool
def search_books(query: str) -> list[str]:
    """Find books whose title contains the query."""
    return [b for b in BOOKS if query.lower() in b.lower()]
$ uv add fastmcp
$ fastmcp run server.py --transport http

Teams at these companies build MCP servers with FastMCP

Everything you need to build on MCP

Build tools, connect systems and add interactive interfaces.
Authentication and testing ship in the same package.

  • Tools, resources and prompts

    Decorate a function and FastMCP serves it as a tool, a resource or a prompt.

    Read the docs
    @mcp.tool
    def search(query: str, limit: int = 10) -> list[Doc]:
        """Search the knowledge base."""
        return index.search(query, limit=limit)
  • Clients

    Connect to any MCP server, local or remote, from Python or the command line.

    Read the docs
  • Tool transformation

    Shape the tools your agents see. Rename them, simplify their inputs and control what's exposed.

  • Interactive apps

    Give users forms, tables and charts they can use directly in compatible MCP clients. The components come from Prefab.

    Read the docs
    @mcp.tool(app=True)
    def team_directory() -> DataTable:
        return DataTable(
            columns=COLUMNS, rows=members, search=True
        )
    Search
    NameRoleOffice
    Alice ChenStaff EngineerSan Francisco
    Bob MartinezLead DesignerNew York
    Carol JohnsonSenior EngineerLondon
    A searchable team directory table rendered in an MCP client.
  • Authentication

    Connect your identity provider. FastMCP handles the MCP authentication flow.

    Read the docs
    auth = GitHubProvider(
        client_id=os.environ["GITHUB_CLIENT_ID"],
        client_secret=os.environ["GITHUB_CLIENT_SECRET"],
        base_url="https://tools.example.com",
    )
    mcp = FastMCP("Secured app", auth=auth)
  • Composition

    Bring existing APIs and MCP servers together behind one server.

    Read the docs
  • Middleware and background tasks

    Add logging and rate limits, and move slow work into background tasks.

    Read the docs
  • Testing and the CLI

    Test your server in memory, without starting a separate process. Run, inspect and install it from the CLI.

    Read the docsCLI reference
    async def test_search_books():
        async with Client(mcp) as client:
            result = await client.call_tool(
                "search_books", {"query": "dune"}
            )
        assert result.data == ["Dune"]

Enterprise features for your MCP servers

Talk to our team
  • Self-host or serverless

    Run your FastMCP servers on your own infrastructure, or deploy them to FastMCP Gateway. It scales to zero when idle.

  • Use your existing identity provider

    Sign in through SAML SSO and provision users with SCIM. MCP clients connect through managed OAuth.

  • Control access to your servers

    Grant roles per server and per tool. Discovering, using and managing a server are separate permissions.

  • Reach your systems from static IPs

    Gateway calls your upstream services from known IP addresses you can add to an allowlist.

  • Full observability

    Every access attempt is logged with who called what, when, and whether it was allowed.

For coding agents

Build it with your coding agent

Give your agent the FastMCP docs and a starting point for your project.

  • Claude Code
  • Codex
  • T3 Code
  • OpenCode
Agent setup guide

Build servers. Connect clients. Add interfaces.

The three examples below share one catalog search. FastMCP handles the protocol so you can focus on your application.

Servers

Expose your catalog search as a tool.

server.py
@mcp.tool
def search(query: str) -> list:
    """Search the catalog."""
    return catalog.search(query)
Server docs

Clients

Call that search from your own Python code.

client.py
async with Client(URL) as client:
    hits = await client.call_tool(
        "search",
        {"query": "lamp"},
    )
    print(hits.data)
Client docs

Apps

Show the results as a table the user can sort and search.

server.py
@mcp.tool(app=True)
def browse(q: str) -> DataTable:
    return DataTable(
        columns=COLUMNS,
        rows=catalog.search(q),
        search=True,
    )
App docs

Build with FastMCP.
Deploy with FastMCP Gateway.

Deploy your FastMCP server and make it available to the people and agents that need it. Connect a GitHub repo and get a live URL in about a minute.

FastMCP and FastMCP Gateway are built by the same team at Prefect