Back to MCP Catalog

Fast MCP Server

Developer ToolsPython
A fast, Pythonic framework for building MCP servers and clients
Available Tools

add

Add two numbers

a: intb: int

FastMCP is a powerful Python framework for building Model Context Protocol (MCP) servers and clients. It provides an intuitive, Pythonic interface for creating tools, exposing resources, defining prompts, and connecting components with clean code. FastMCP 2.0 significantly expands on the original version with advanced client capabilities, server proxying, composition features, and OpenAPI/FastAPI integration. The framework makes it simple to build MCP servers that expose data and functionality to LLM applications in a standardized way. With FastMCP, developers can quickly create tools (similar to API endpoints), resources (for loading information into context), prompts (reusable templates), and more - all with minimal boilerplate code and maximum flexibility.

Getting Started with FastMCP

FastMCP is a Python framework for building Model Context Protocol (MCP) servers and clients. This guide will help you get up and running quickly.

Installation

Install FastMCP using pip:

pip install fastmcp

For development installations:

pip install -e ".[dev]"

Creating a Basic MCP Server

Here's a simple example of creating an MCP server with FastMCP:

# server.py
from fastmcp import FastMCP

mcp = FastMCP("Demo Server")

@mcp.tool()
def add(a: int, b: int) -> int:
    """Add two numbers"""
    return a + b

if __name__ == "__main__":
    mcp.run()

Running Your Server

You can run your server using the FastMCP CLI:

fastmcp run server.py

Or directly from Python:

python server.py

By default, the server runs on http://localhost:8000.

Core Concepts

Tools

Tools are functions that your LLM can call to perform actions:

@mcp.tool()
def search_database(query: str) -> list[dict]:
    """Search the database for information"""
    # Implementation here
    return results

Resources

Resources provide data to the LLM:

@mcp.resource()
def user_profile() -> dict:
    """Get the current user's profile information"""
    return {"name": "Alice", "role": "Admin"}

Prompts

Prompts are reusable templates:

mcp.prompt(
    name="greeting",
    content="Hello, {{name}}! Welcome to {{service_name}}.",
    parameters={"name": str, "service_name": str}
)

Context

Context provides background information:

mcp.context(
    name="company_info",
    content="Acme Corp was founded in 2020 and specializes in AI solutions."
)

Advanced Features

Proxy Servers

FastMCP can proxy requests to other MCP servers:

from fastmcp import FastMCP, MCPClient

mcp = FastMCP("Proxy Server")
other_server = MCPClient("http://localhost:8001")

mcp.proxy(other_server)

Composing MCP Servers

Combine multiple MCP servers:

from fastmcp import FastMCP

tools_mcp = FastMCP("Tools")
resources_mcp = FastMCP("Resources")

# Add tools and resources to respective servers

main_mcp = FastMCP("Main Server")
main_mcp.include(tools_mcp)
main_mcp.include(resources_mcp)

OpenAPI & FastAPI Integration

Generate FastAPI applications from your MCP server:

from fastmcp import FastMCP

mcp = FastMCP("API Server")
# Add tools, resources, etc.

# Generate a FastAPI app
app = mcp.fastapi_app()

Using the MCP Client

FastMCP includes a client for interacting with MCP servers:

from fastmcp import MCPClient

client = MCPClient("http://localhost:8000")

# Call a tool
result = await client.tools.add(a=5, b=3)
print(result)  # 8

# Get a resource
profile = await client.resources.user_profile()

Authentication

FastMCP supports authentication for secure MCP servers:

from fastmcp import FastMCP
from fastmcp.auth import APIKeyAuth

mcp = FastMCP(
    "Secure Server",
    auth=APIKeyAuth(api_key="your-secret-key")
)

For more detailed documentation, visit gofastmcp.com.

Related MCPs

Apple Shortcuts
Developer ToolsJavaScript

Control Apple Shortcuts automations from AI assistants

Clojars Dependency Lookup
Developer ToolsJavaScript

Fetch dependency information from Clojars, the Clojure community's artifact repository

Simple Timeserver
Developer ToolsPython

Provides Claude with current time and timezone information

About Model Context Protocol

Model Context Protocol (MCP) allows AI models to access external tools and services, extending their capabilities beyond their training data.

Generate Cursor Documentation

Save time on coding by generating custom documentation and prompts for Cursor IDE.