Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Complete guide for building MCP servers with FastMCP 3.0 - tools, resources, authentication, providers, middleware, and deployment. Use when creating Python MCP servers or integrating AI models with external tools and data.
| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-02 | ✗→✓ | ▲ Improved | -16% | 0% |
| case-03 | ✗→✓ | ▲ Improved | 18% | 0% |
| case-04 | ✗→✓ | ▲ Improved | 75% | 0% |
| case-09 | ✗→✓ | ▲ Improved | 18% | 0% |
| case-11 | ✗→✓ | ▲ Improved | 58% | 0% |
Complete reference for building production-ready MCP (Model Context Protocol) servers with FastMCP 3.0 - the fast, Pythonic framework for connecting LLMs to tools and data.
Use FastMCP Server when:
Key areas covered:
Create a server with tools:
pythonfrom fastmcp import FastMCP mcp = FastMCP("MyServer") @mcp.tool def add(a: int, b: int) -> int: """Add two numbers""" return a + b
Create a resource:
python@mcp.resource("data://config") def get_config() -> dict: """Return server configuration""" return {"version": "1.0", "debug": False}
Create a resource template:
python@mcp.resource("users://{user_id}/profile") def get_user_profile(user_id: str) -> dict: """Get a user's profile by ID""" return fetch_user(user_id)
Create a prompt:
python@mcp.prompt def review_code(code: str, language: str = "python") -> str: """Review code for best practices""" return f"Review this {language} code:\n\n{code}"
Run the server:
pythonif __name__ == "__main__": mcp.run() # Or with transport options: # mcp.run(transport="sse", host="0.0.0.0", port=8000)
pythonfrom fastmcp import FastMCP, Context mcp = FastMCP("MyServer") @mcp.tool def process_data(uri: str, ctx: Context) -> str: """Process data with logging and progress""" ctx.info(f"Processing {uri}") ctx.report_progress(0, 100) data = ctx.read_resource(uri) ctx.report_progress(100, 100) return f"Processed: {data}"
pythonfrom fastmcp import FastMCP from fastmcp.server.auth import BearerAuthProvider auth = BearerAuthProvider( jwks_uri="https://your-provider/.well-known/jwks.json", audience="your-api", issuer="https://your-provider/" ) mcp = FastMCP("SecureServer", auth=auth)
Functions exposed as executable capabilities for LLMs. Decorated with @mcp.tool. Support Pydantic validation, async, custom return types, and annotations (readOnlyHint, destructiveHint).
Static or dynamic data sources identified by URIs. Resources use fixed URIs (data://config), templates use parameterized URIs (users://{id}/profile). Support MIME types, annotations, and wildcard parameters.
The Context object provides access to MCP features within tools/resources: logging, progress reporting, resource access, LLM sampling, user elicitation, and session state.
Inject values into tool/resource functions using Depends(). Supports HTTP requests, access tokens, custom dependencies, and generator-based cleanup patterns.
Control where components come from. LocalProvider (default, decorator-based), FileSystemProvider (load from Python files on disk), SkillsProvider (packaged bundles), or custom providers.
Multiple auth patterns: token verification (JWT, JWKS), OAuth proxy, OIDC proxy, remote OAuth, and full OAuth server. Authorization via scopes on components and middleware.
Intercept and modify requests/responses. Built-in middleware for rate limiting, error handling, logging, and response size limits. Custom middleware via @mcp.middleware.
Detailed documentation is organized in the references/ folder:
v1.0.0 (February 2026)
Other measured skills in the registry, with their headline benchmark lift.