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
| URL | Description |
|---|---|
| http://localhost:8000 | Root endpoint |
| http://localhost:8000/docs | Swagger UI (Interactive API docs) |
| http://localhost:8000/redoc | ReDoc (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
| Method | Endpoint | Description |
|---|---|---|
| GET | / | Root - Welcome message |
| POST | /expenses | Add a new expense |
| GET | /expenses | List 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
| Task | Command |
|---|---|
| Run FastAPI | uv run uvicorn main:app --reload |
| Run MCP server | uv run python server.py |
| Install to Claude | uv run fastmcp install claude-desktop server.py |
| Add dependency | uv add <package> |
| Sync dependencies | uv 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