fastapi-mcp-server

fastapi-mcp-server

Instantly converts any running FastAPI application into an MCP server by parsing its OpenAPI spec, enabling Claude to call all endpoints via natural language without manual tool writing.

Category
Visit Server

README

fastapi-mcp-server ⚡

Turn any FastAPI app into a Claude-compatible MCP server instantly by reading its OpenAPI spec

What it does

Point this tool at any running FastAPI app and it will:

  1. Fetch the OpenAPI spec automatically from /openapi.json
  2. Parse every endpoint — paths, methods, parameters, request bodies
  3. Dynamically register one MCP tool per endpoint
  4. Claude can now call any endpoint using natural language

Zero manual tool writing. Zero code changes to your existing FastAPI app.

Demo

User: "Create a task titled Push code to GitHub with high priority"
Claude: [calls post_tasks tool]
        → Task created successfully ✅

User: "Mark task 2 as completed"
Claude: [calls put_tasks_task_id tool]
        → Task updated ✅

User: "Show me all tasks"
Claude: [calls get_tasks tool]
        → Returns all tasks ✅

Architecture

Your FastAPI App (running)
        ↓
fastapi-mcp-server fetches /openapi.json
        ↓
OpenAPIParser extracts all endpoints
        ↓
One MCP tool registered per endpoint
        ↓
Claude calls tools using natural language
        ↓
MCP server makes real HTTP requests to your API
        ↓
Results returned to Claude

Tech Stack

  • Python 3.12
  • FastAPI + Pydantic
  • MCP (Model Context Protocol)
  • httpx
  • OpenAPI 3.x

Setup

1. Clone and install

git clone https://github.com/vkmech999/fastapi-mcp-server.git
cd fastapi-mcp-server
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt

2. Configure environment

cp .env.example .env
# Set TARGET_API_URL to your FastAPI app
# Set AUTH_TYPE if your API requires authentication

3. Connect to Claude Desktop

Add to ~/Library/Application Support/Claude/claude_desktop_config.json:

{
  "mcpServers": {
    "fastapi-mcp-server": {
      "command": "/path/to/venv/bin/python3",
      "args": ["-m", "mcp_server.server"],
      "env": {
        "TARGET_API_URL": "http://localhost:8000",
        "AUTH_TYPE": "none",
        "PYTHONPATH": "/path/to/fastapi-mcp-server"
      }
    }
  }
}

4. Use it in Claude Desktop

"List all available endpoints"
"Get all tasks"
"Create a new user named John with email john@example.com"
"Delete task with ID 3"

Authentication Support

Auth Type Use Case Config
none Public APIs AUTH_TYPE=none
bearer JWT / OAuth2 AUTH_TYPE=bearer + AUTH_TOKEN=eyJ...
api_key Third-party APIs AUTH_TYPE=api_key + AUTH_TOKEN=sk-... + AUTH_HEADER=X-API-Key
basic Legacy systems AUTH_TYPE=basic + AUTH_USERNAME + AUTH_PASSWORD

MCP Tools

Tool Description
list_api_endpoints Discover all registered endpoint tools
get_* Auto-generated GET endpoint tools
post_* Auto-generated POST endpoint tools
put_* Auto-generated PUT endpoint tools
delete_* Auto-generated DELETE endpoint tools

Running Tests

pytest tests/test_server.py -v

Author

Vivek Kumar — Senior Python Full Stack Developer
LinkedIn · GitHub

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured