from fastapi import FastAPI from ..config import Settings from ..config import get_settings from ..mcp import mcp from .docs_mount import mount_docs_static from .health import router as health_router def create_app(settings: Settings | None = None) -> FastAPI: runtime_settings = settings if settings is not None else get_settings() mcp_app = mcp.http_app( path=runtime_settings.mounts.mcp, json_response=True, stateless_http=True, transport="http", ) app = FastAPI( debug=runtime_settings.debug, docs_url=None, redoc_url=None, openapi_url=None, lifespan=mcp_app.lifespan, ) app.state.settings = runtime_settings app.include_router(health_router) mount_docs_static( app, docs_route=runtime_settings.mounts.docs, site_dir=runtime_settings.site_dir, ) app.mount("/", mcp_app, name="mcp") return app