integration · FastAPI

FastAPI MCP integration.

FastAPI already auto-generates an OpenAPI 3 schema from your Python type hints — wmcp.sh consumes OpenAPI as input. There's literally no glue code. Of every framework on this site, FastAPI is the easiest.

wmcp.sh is not affiliated with the FastAPI project or Anthropic. FastAPI is open-source software maintained by Sebastián Ramírez and contributors.

There barely is one. FastAPI is already 95% MCP-ready.

What you have today

FastAPI routes with Pydantic v2 input/output models. /openapi.json already serves a fully-typed OpenAPI 3 schema. Auth via HTTPBearer, APIKeyHeader, or OAuth2PasswordBearer.

What agents need

A Model Context Protocol server with typed tool schemas. wmcp.sh consumes /openapi.json directly and emits MCP at https://wmcp.sh/mcp/<your-id>. One ingest call. Done.

A FastAPI route, exposed as a tool.

Standard FastAPI 0.110+ with Pydantic v2 — no extra libraries, no schema duplication.

# main.py — FastAPI on Python 3.12+
from fastapi import FastAPI, Depends, HTTPException
from fastapi.security import HTTPBearer, HTTPAuthorizationCredentials
from pydantic import BaseModel, Field

app = FastAPI(title='Acme Inventory', version='1.0.0')
bearer = HTTPBearer()

class QuoteIn(BaseModel):
    symbol: str = Field(min_length=1, max_length=12)
    size: float = Field(gt=0)

class QuoteOut(BaseModel):
    symbol: str
    bid: float
    ask: float
    size: float

@app.post('/quotes', response_model=QuoteOut, tags=['agent'])
async def get_quote(body: QuoteIn, creds: HTTPAuthorizationCredentials = Depends(bearer)) -> QuoteOut:
    if not creds.credentials:
        raise HTTPException(401)
    mid = await fetch_mid(body.symbol)
    return QuoteOut(symbol=body.symbol, bid=mid * 0.999, ask=mid * 1.001, size=body.size)

# OpenAPI is served at /openapi.json automatically. That's it.
# curl 'https://wmcp.sh/api/v1/tools?url=https://acme.example.com/openapi.json&tag=agent'

Hand-rolled MCP server vs wmcp.sh on FastAPI.

CapabilityHand-rolledwmcp.sh + FastAPI
Schema-from-type-hints ⚠️ Re-derive schemas in a tools.py ✅ FastAPI already emits it; one source of truth
Pydantic v2 JSON Schema ⚠️ Hand-translate to MCP shape ✅ Pydantic v2 → OpenAPI 3.1 JSON Schema → MCP tool input schema, 1:1
Security schemes ⚠️ Re-implement at MCP layer ✅ FastAPI's Depends(...) security flows through to wmcp.sh
MCP transport (Streamable HTTP, SSE) ⚠️ You build it ✅ Served at https://wmcp.sh/mcp/<your-id>
Per-route gating ⚠️ Manual ✅ FastAPI tags=[...] + &tag=agent ingest filter
Async + streaming ✅ Yes ✅ wmcp.sh handles both

Common questions from FastAPI teams.

Why is FastAPI the easiest MCP integration?
Because /openapi.json is already there. FastAPI generates it from your type hints with no extra library or config. wmcp.sh consumes OpenAPI as its primary input, so the integration is one curl call — no converter, no schema duplication.
Versions?
Python 3.12+ recommended. FastAPI 0.110+ is what most current docs target; anything from 0.95+ (Pydantic v2 integration) works identically.
How does auth flow through?
FastAPI's security dependencies emit corresponding securitySchemes in the OpenAPI output. wmcp.sh reads them and forwards credentials. For OAuth 2.1 DCR, the /mcp/<provider> proxy handles the full flow for clients that can't drive OAuth themselves.
Pydantic v1 vs v2?
v2 is the recommended path because its JSON Schema output maps 1:1 to MCP tool input schemas. v1 works but you'll see less expressive types in the MCP client.
Can I gate routes?
Yes. Tag operations with tags=['agent'] and pass &tag=agent at ingest, or set include_in_schema=False to keep routes out of the schema entirely.
Does Starlette / Litestar / Robyn work the same way?
Any Python framework that emits an OpenAPI spec works. Litestar generates one automatically (similar to FastAPI). Starlette doesn't by default — you'd add apispec or a similar generator. Point wmcp.sh at the spec URL; the rest is identical.
Need this done for you?

Skip the wiring — we ship the MCP server for your FastAPI app.

Audit your routes, tune tags + securitySchemes, deploy MCP at mcp.yourbrand.com. Starter $499 one-time setup; Managed Retainer $999/mo for ongoing maintenance; Enterprise $4,999+/mo for SLA + private deploy.

See /managed → Submit (free)