Servers
Expose your catalog search as a tool.
@mcp.tool
def search(query: str) -> list:
"""Search the catalog."""
return catalog.search(query)Share your Skills over MCP. Try now free
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", "Hyperion"]
@mcp.tool
def search_books(query: str) -> list[str]:
"""Find books by title."""
q = query.lower()
return [b for b in BOOKS if q 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):
"""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["GH_CLIENT_ID"],
client_secret=os.environ["GH_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"]Copying skill folders onto every laptop leaves everyone with a slightly different version. Serve them from a FastMCP server instead and the whole team works from one copy.
Distribute once
Publish a skill to the server and every teammate whose agent connects reads it there. Nobody copies folders between machines.
Keep every copy current
Edit a SKILL.md and redeploy. Anyone reading from the server gets the new version, with no pull or reinstall.
Decide who sees which skills
Discovery lists only the skills a caller can read, so the server's auth rules decide which teams get which skills.
Stop broken skills at the door
Each skill is checked against the Agent Skills spec when the server loads it, so a bad edit fails fast instead of reaching an agent.
import hashlib
import json
from pathlib import Path
from mcp.server import MCPServer
mcp = MCPServer("Team Skills")
SKILLS = Path("skills")
@mcp.resource(
"skill://release-notes/SKILL.md",
mime_type="text/markdown",
description="Write release notes from merged pull requests.",
)
def release_notes() -> str:
return read("release-notes/SKILL.md")
@mcp.resource("skill://release-notes/template.md", mime_type="text/markdown")
def release_notes_template() -> str:
return read("release-notes/template.md")
@mcp.resource("skill://release-notes/_manifest", mime_type="application/json")
def release_notes_manifest() -> str:
return manifest("release-notes", ["SKILL.md", "template.md"])
@mcp.resource(
"skill://triage/SKILL.md",
mime_type="text/markdown",
description="Label and assign new issues.",
)
def triage() -> str:
return read("triage/SKILL.md")
@mcp.resource("skill://triage/labels.md", mime_type="text/markdown")
def triage_labels() -> str:
return read("triage/labels.md")
@mcp.resource("skill://triage/_manifest", mime_type="application/json")
def triage_manifest() -> str:
return manifest("triage", ["SKILL.md", "labels.md"])
@mcp.resource(
"skill://incident-review/SKILL.md",
mime_type="text/markdown",
description="Run a blameless incident review.",
)
def incident_review() -> str:
return read("incident-review/SKILL.md")
@mcp.resource("skill://incident-review/checklist.md", mime_type="text/markdown")
def incident_review_checklist() -> str:
return read("incident-review/checklist.md")
@mcp.resource("skill://incident-review/_manifest", mime_type="application/json")
def incident_review_manifest() -> str:
return manifest("incident-review", ["SKILL.md", "checklist.md"])
def read(path: str) -> str:
return (SKILLS / path).read_text(encoding="utf-8")
def manifest(skill: str, files: list[str]) -> str:
entries = []
for file in files:
data = (SKILLS / skill / file).read_bytes()
digest = hashlib.sha256(data).hexdigest()
entries.append({"path": file, "size": len(data), "hash": f"sha256:{digest}"})
return json.dumps({"skill": skill, "files": entries})
if __name__ == "__main__":
mcp.run()from fastmcp import FastMCP, Skill
from fastmcp.skills.provider import SkillCatalogProvider
team_skills = [
Skill.from_directory("skills/release-notes"),
Skill.from_directory("skills/triage"),
Skill.from_directory("skills/incident-review"),
]
mcp = FastMCP("Team Skills", providers=[SkillCatalogProvider(team_skills)])
if __name__ == "__main__":
mcp.run()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.