Skip to main content
Glama

FastAPI MCP Server

by bankszach
app.py830 B
import logging import os from fastapi import FastAPI from fastapi.middleware.cors import CORSMiddleware from mcp_facade import mcp_asgi_app, mcp_admin from mcp_ext.http_root import attach_healthz, mount_mcp_root logging.basicConfig(level=os.getenv("LOG_LEVEL", "INFO")) app = FastAPI(title="fastapi-mcp") # True MCP endpoint: app.mount("/mcp", mcp_asgi_app) # Optional manual reload endpoint for downstream catalog if mcp_admin: app.include_router(mcp_admin) # --- CORS (relax in dev; restrict in prod) --- app.add_middleware( CORSMiddleware, allow_origins=["*"], allow_methods=["*"], allow_headers=["*"], allow_credentials=False, ) COMMIT_SHA = os.getenv("COMMIT_SHA", "unknown") mount_mcp_root(app) attach_healthz(app) @app.get("/version") async def version(): return {"commit": COMMIT_SHA}

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/bankszach/fastapi-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server