app factory

This commit is contained in:
John Lancaster
2026-07-21 08:49:36 -05:00
parent 7970e76d4f
commit 27f783fc90
3 changed files with 48 additions and 33 deletions
+10 -3
View File
@@ -1,7 +1,14 @@
from personal_mcp.mcp import mcp
from personal_mcp.web.app import app
from fastapi import FastAPI
__all__ = ["app", "main", "mcp"]
from personal_mcp.mcp import mcp
from personal_mcp.web.app import create_app as create_fastapi
__all__ = ["create_app", "main", "mcp"]
def create_app() -> FastAPI:
"""Create the HTTP application for ASGI servers using factory mode."""
return create_fastapi()
def main() -> None:
+6 -9
View File
@@ -1,14 +1,14 @@
from fastapi import FastAPI
from personal_mcp.config import Settings
from personal_mcp.config import get_settings
from personal_mcp.mcp import mcp
from personal_mcp.web.docs_mount import mount_docs_static
from personal_mcp.web.health import router as health_router
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 or get_settings()
runtime_settings = settings if settings is not None else get_settings()
mcp_app = mcp.http_app(
path=runtime_settings.mounts.mcp,
json_response=True,
@@ -32,6 +32,3 @@ def create_app(settings: Settings | None = None) -> FastAPI:
)
app.mount("/", mcp_app, name="mcp")
return app
app = create_app()