fastapi-local-mcp-server

farhanrhine/fastapi-local-mcp-server

3.2

If you are the rightful owner of fastapi-local-mcp-server and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to dayong@mcphub.com.

The Expense Tracker FastAPI Server is a versatile application that functions as both a REST API and an MCP server, designed to integrate seamlessly with Claude Desktop.

Expense Tracker FastAPI Server

A FastAPI application that can be used both as a REST API and as an MCP (Model Context Protocol) server for Claude Desktop.

📋 Prerequisites

  • Python 3.11+
  • uv package manager

🚀 Installation

# Navigate to the project folder
cd fastapi-local-server

# Install dependencies
uv add fastapi uvicorn

🏃 Running the Server

Option 1: Run as FastAPI (REST API with Docs)

uv run uvicorn main:app --reload --port 8000
URLDescription
http://localhost:8000Root endpoint
http://localhost:8000/docsSwagger UI (Interactive API docs)
http://localhost:8000/redocReDoc (Alternative docs)

Option 2: Run as MCP Server (stdio)

uv run python server.py

Option 3: Install to Claude Desktop

uv run fastmcp install claude-desktop server.py

Note: Restart Claude Desktop after installation.

📁 Project Structure

fastapi-local-server/
├── main.py          # FastAPI application with routes
├── server.py        # MCP server wrapper (converts FastAPI → MCP)
├── pyproject.toml   # Project dependencies
└── README.md        # This file

🛠️ API Endpoints

MethodEndpointDescription
GET/Root - Welcome message
POST/expensesAdd a new expense
GET/expensesList all expenses

🔄 How It Works

┌─────────────────┐
│   FastAPI App   │  ← REST API (main.py)
│   (main.py)     │
└────────┬────────┘
         │
         ▼
┌─────────────────┐
│   FastMCP       │  ← Converts FastAPI → MCP (server.py)
│   (server.py)   │
└────────┬────────┘
         │
         ▼
┌─────────────────┐
│ Claude Desktop  │  ← Uses MCP tools
└─────────────────┘

📝 Commands Cheat Sheet

TaskCommand
Run FastAPIuv run uvicorn main:app --reload
Run MCP serveruv run python server.py
Install to Claudeuv run fastmcp install claude-desktop server.py
Add dependencyuv add <package>
Sync dependenciesuv sync

🔧 Environment Variables (Optional)

To use the new OpenAPI parser and remove the legacy warning:

# PowerShell
$env:FASTMCP_EXPERIMENTAL_ENABLE_NEW_OPENAPI_PARSER = "true"

# Then run
uv run fastmcp install claude-desktop server.py

📚 Related Links