debug launch config
This commit is contained in:
@@ -7,7 +7,7 @@ def main(cli: bool = True) -> None:
|
||||
"""Run the root MCP server."""
|
||||
settings = get_settings(cli=cli)
|
||||
uvicorn.run(
|
||||
"personal_mcp.web.app:create_app",
|
||||
"personal_mcp.app:create_app",
|
||||
factory=True,
|
||||
host=settings.host,
|
||||
port=settings.port,
|
||||
|
||||
+18
-1
@@ -8,6 +8,7 @@ from fastapi import Response
|
||||
from fastapi import status
|
||||
from fastapi.responses import RedirectResponse
|
||||
from fastapi.staticfiles import StaticFiles
|
||||
from fastmcp.utilities.lifespan import combine_lifespans
|
||||
|
||||
from .config import Settings
|
||||
from .config import get_settings
|
||||
@@ -16,7 +17,9 @@ from .mcp import create_mcp
|
||||
|
||||
def create_app(settings: Settings | None = None) -> FastAPI:
|
||||
runtime_settings = settings if settings is not None else get_settings()
|
||||
docs_route = runtime_settings.mounts.docs.rstrip("/") or "/docs"
|
||||
mcp_app = create_mcp().http_app(
|
||||
path="/",
|
||||
json_response=True,
|
||||
stateless_http=True,
|
||||
transport="http",
|
||||
@@ -26,9 +29,23 @@ def create_app(settings: Settings | None = None) -> FastAPI:
|
||||
docs_url=None,
|
||||
redoc_url=None,
|
||||
openapi_url=None,
|
||||
lifespan=app_lifespan,
|
||||
lifespan=combine_lifespans(app_lifespan, mcp_app.lifespan),
|
||||
)
|
||||
app.state.settings = runtime_settings
|
||||
|
||||
async def redirect_root_to_docs() -> RedirectResponse:
|
||||
return RedirectResponse(
|
||||
url=docs_route,
|
||||
status_code=status.HTTP_307_TEMPORARY_REDIRECT,
|
||||
)
|
||||
|
||||
app.add_api_route(
|
||||
"/",
|
||||
redirect_root_to_docs,
|
||||
methods=["GET", "HEAD"],
|
||||
include_in_schema=False,
|
||||
)
|
||||
|
||||
app.mount(runtime_settings.mounts.mcp, mcp_app, name="mcp")
|
||||
return app
|
||||
|
||||
|
||||
Reference in New Issue
Block a user