mirror of
https://github.com/Sun-ZhenXing/mcp-template-python.git
synced 2026-02-04 10:13:31 +00:00
feat: add /v1/** api
This commit is contained in:
@@ -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())
|
||||
|
||||
Reference in New Issue
Block a user