Servers
Expose your catalog search as a tool.
@mcp.tool
def search(query: str) -> list:
"""Search the catalog."""
return catalog.search(query)Build MCP servers, clients and interactive apps.
You write the application logic.
FastMCP handles the protocol.
uv add fastmcpfrom 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 httpTeams at these companies build MCP servers with FastMCP
Build tools, connect systems and add interactive interfaces.
Authentication and testing ship in the same package.
Decorate a function and FastMCP serves it as a tool, a resource or a prompt.
@mcp.tool
def search(query: str, limit: int = 10) -> list[Doc]:
"""Search the knowledge base."""
return index.search(query, limit=limit)Shape the tools your agents see. Rename them, simplify their inputs and control what's exposed.
Give users forms, tables and charts they can use directly in compatible MCP clients. The components come from Prefab.
@mcp.tool(app=True)
def team_directory() -> DataTable:
return DataTable(
columns=COLUMNS, rows=members, search=True
)| Name | Role | Office |
|---|---|---|
| Alice Chen | Staff Engineer | San Francisco |
| Bob Martinez | Lead Designer | New York |
| Carol Johnson | Senior Engineer | London |
Connect your identity provider. FastMCP handles the MCP authentication flow.
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)Add logging and rate limits, and move slow work into background tasks.
Test your server in memory, without starting a separate process. Run, inspect and install it from the CLI.
async def test_search_books():
async with Client(mcp) as client:
result = await client.call_tool(
"search_books", {"query": "dune"}
)
assert result.data == ["Dune"]From the FastMCP team at Prefect
Ready to share your server? FastMCP Gateway gives it a live URL. People and agents connect through OAuth. Enterprise plans add SSO, tool-level permissions and audit logs.
Connect a GitHub repo and get a live URL for your server in about a minute. Every push redeploys it.
Learn moreOne list of every server your teams build, import or compose. Each one shows its owner, version and approval status.
Learn moreSet tool-level permissions from the identity provider you already run. Every call is logged.
Learn moreBuild one endpoint per team or agent from the servers you already run. Each one sees only the tools it should.
Learn moreSelf-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.
Give your agent the FastMCP docs and a starting point for your project.
The three examples below share one catalog search. FastMCP handles the protocol so you can focus on your application.
Expose your catalog search as a tool.
@mcp.tool
def search(query: str) -> list:
"""Search the catalog."""
return catalog.search(query)Call that search from your own Python code.
async with Client(URL) as client:
hits = await client.call_tool(
"search",
{"query": "lamp"},
)
print(hits.data)Show the results as a table the user can sort and search.
@mcp.tool(app=True)
def browse(q: str) -> DataTable:
return DataTable(
columns=COLUMNS,
rows=catalog.search(q),
search=True,
)FastMCP's high-level API went into the official MCP Python SDK in 2024. The standalone project has grown with its contributors ever since. It is Apache 2.0 licensed and developed on GitHub.
Pick a route. Each one is a short page in the docs, with code you can paste.
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.