Guides / FastAPI
⚡ FastAPI

Connect FastAPI to Claude Desktop

Paste your @app.get / @router.post decorators and get a hosted MCP server URL in under 2 minutes. Function names and path params detected automatically.

✓

Prerequisites

  • A FastAPI app with at least one route decorator (@app.get, @router.post, etc.)
  • Claude Desktop installed (claude.ai/download)
  • A free MCP Forge account — sign up here
1

Copy your route definitions

Open the file where you define your FastAPI routes. MCP Forge reads the decorator, the path, and the function name to build each tool:

from fastapi import FastAPI, Path, Query
app = FastAPI()

# Get a product by ID
@app.get("/products/{product_id}")
def get_product(product_id: str):
    ...

# List products with optional filter
@app.get("/products")
def list_products(category: str = None):
    ...

# Create a product
@app.post("/products")
def create_product(product: ProductCreate):
    ...

# Delete a product
@app.delete("/products/{product_id}")
def delete_product(product_id: str):
    ...
Tip: Path parameters wrapped in {curly_braces} are automatically extracted as required tool inputs. Query params (optional function args with defaults) are extracted too.
2

Paste into the dashboard

Sign in to your dashboard and go to the Deploy tab. Paste your route file into the editor. FastAPI is auto-detected from the from fastapi import import or from the decorator patterns — no manual selection needed.

Click Generate + Deploy MCP Server →.

3

Review the generated tools

The function names from your decorators become the MCP tool names:

Generated tools — products API
GET
get_product
/products/{product_id}
GET
list_products
/products?category=
POST
create_product
/products
DELETE
delete_product
/products/{product_id}

Your MCP endpoint URL is shown in the dashboard under Your MCP Endpoint.

4

Add to Claude Desktop

Open Claude Desktop → Settings → Developer → Edit Config and add your server to claude_desktop_config.json:

{
  "mcpServers": {
    "my-products-api": {
      "url": "https://api.main-duck.com/mcp/YOUR_TENANT_ID/sse"
    }
  }
}

Replace YOUR_TENANT_ID with the value shown in your dashboard. Save and restart Claude Desktop.

Done. Claude can now call your FastAPI endpoints. Try: "List all products in the electronics category" or "Create a product called Widget Pro."
⚡

Optional: Auto-sync on push

When you add or rename routes, connect GitHub auto-sync so tools re-deploy automatically:

  1. Go to Dashboard → GitHub Sync
  2. Paste your repo URL and a GitHub Personal Access Token (read scope)
  3. Set the branch to watch (default: main)
  4. Copy the webhook URL into GitHub → Settings → Webhooks

Every push to the configured branch triggers a re-deploy with no manual steps.