AgentConn

FastMCP

MCP Intermediate Infrastructure Open Source

FastMCP is the developer-friendly framework for building MCP servers. Like FastAPI revolutionized web API development, FastMCP makes creating custom tool servers trivial — define a Python function with type hints, and FastMCP handles the MCP protocol, validation, and transport.

Input / Output

Accepts

python-function type-hints

Produces

mcp-server tool-endpoint

Overview

FastMCP is to MCP servers what FastAPI is to web APIs. Write a Python function with type hints, decorate it, and FastMCP handles everything — serialization, validation, transport, and the full MCP protocol handshake. With 24k+ stars and backing from Prefect, it’s the standard way to build custom MCP servers.

How It Works

  1. Define tools — Write Python functions with type annotations
  2. Decorate — Add @mcp.tool() to expose via MCP
  3. Run — FastMCP handles protocol and transport
  4. Connect — Any MCP client discovers your tools

Use Cases

  • Custom internal tools — Expose company APIs to AI agents
  • Database wrappers — Natural language database access
  • Business logic — Domain-specific agent operations
  • API bridges — Convert REST APIs into MCP tools

Getting Started

from fastmcp import FastMCP

mcp = FastMCP("My Tools")

@mcp.tool()
def get_weather(city: str) -> str:
    """Get current weather for a city."""
    return f"Weather in {city}: 72°F, sunny"

mcp.run()

Example

@mcp.tool()
def check_stock(product_id: str) -> dict:
    """Check inventory levels for a product."""
    stock = db.query(f"SELECT * FROM inventory WHERE id = %s", (product_id,))
    return {"product": product_id, "quantity": stock.quantity}

Alternatives

  • FastAPI MCP — Expose existing FastAPI endpoints as MCP tools
  • MCP SDK — Low-level official MCP SDK from Anthropic
  • MCP Use — Full-stack MCP application framework

Tags

#mcp #framework #python #tool-server #developer-tools

Compatible Agents

AI agents that work well with FastMCP.

Similar Skills