- Home
- MCP servers
- FastMCP
FastMCP
- python
20.9k
GitHub Stars
python
Language
4 months ago
First Indexed
3 weeks ago
Catalog Refreshed
Documentation & install
Readme and setup notes from the catalogue, plus a client-ready config you can copy for your MCP host.
FastMCP is a production-ready framework for building MCP servers and clients. It provides a Pythonic interface to expose data (Resources), actions (Tools), and templates (Prompts) to large language models, with enterprise authentication, deployment options, and testing utilities to take you from idea to production.
How to use
You build an MCP server by creating a FastMCP instance and decorating Python functions as Tools, Resources, or Prompts. Run the server locally to expose its endpoints to your MCP client. Use the client to discover available tools, call them, and read resources. Tools perform actions or computations, Resources provide read-only data, and Prompts guide LLM interactions. You can also compose multiple servers, proxy calls, or generate API bindings from OpenAPI or FastAPI apps.
How to install
Prerequisites: you should have Python 3.10 or newer installed on your system.
Install FastMCP using the production-ready method provided in the setup notes.
uv pip install fastmcp
Additional sections
This server framework centers on the FastMCP core concepts: the FastMCP server object, Tools, Resources, Prompts, and Context. You define tools with @mcp.tool, resources with @mcp.resource(...), and prompts with @mcp.prompt. The server can be run with different transports, including STDIO, HTTP, and SSE. OpenAPI and FastAPI generation enable a rapid connection between your existing web APIs and the MCP ecosystem. Enterprise authentication is supported out of the box, including Google, GitHub, Azure, Auth0, WorkOS, and more.
Running the server is done by calling the server’s run method or by using the provided CLI. For development, you typically run the server script directly; for production, you can deploy to a cloud host or self-host using HTTP or SSE transports.
Server example snippets
from fastmcp import FastMCP
mcp = FastMCP("Demo MCP Server")
@mcp.tool
def add(a: int, b: int) -> int:
"""Add two numbers"""
return a + b
if __name__ == "__main__":
mcp.run()
Transport and run patterns
FastMCP supports three transport protocols. STDIO is the default for local tools and scripts. Streamable HTTP is ideal for web deployments. SSE is compatible with existing SSE clients. To run with STDIO, you can rely on the default setup. For HTTP, you can specify host, port, and path. For SSE, you can enable server-sent events transport.
Example startup flow from development to production involves running the server locally first, then deploying to a cloud or self-hosted environment as needed.
Example client usage
Interact with an MCP server from a client by connecting through a suitable transport (stdio, SSE, or in-memory). List available tools, call specific tools with parameters, and access resources through the client.Create a client instance, connect to your server, and perform operations just like you would with any API—only adapted for MCP patterns.
Available tools
add
Adds two integers and returns the sum. Uses type hints to define input and output types.
multiply
Multiplies two numbers and returns the product. Demonstrates a simple arithmetic Tool.