feat: add /v1/** api

This commit is contained in:
Sun-ZhenXing
2025-07-19 22:50:04 +08:00
parent 43c7a970dd
commit bcb5994356
18 changed files with 177 additions and 44 deletions

View File

@@ -2,7 +2,8 @@ import contextlib
from fastapi import FastAPI
from .config import MCP_MAP
from .app import MCP_MAP
from .routers.helpers import router as helpers_router
@contextlib.asynccontextmanager
@@ -18,14 +19,21 @@ app = FastAPI(lifespan=lifespan)
@app.get("/")
async def root():
return {"message": "Welcome to the MCP Template Python Server!"}
"""Root endpoint."""
return {"message": "Welcome!"}
@app.get("/health")
async def health():
return {"status": "healthy"}
"""Check the health of the server and list available tools."""
return {
"status": "healthy",
"tools": list(MCP_MAP.keys()),
}
app.include_router(helpers_router)
for name, mcp in MCP_MAP.items():
app.mount(f"/{name}/compatible", mcp.sse_app())
app.mount(f"/{name}", mcp.streamable_http_app())