You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

34 lines
784 B
Python

from __future__ import annotations
from contextlib import asynccontextmanager
import logging
from starlette.applications import Starlette
from starlette.routing import Mount
from app.config import get_settings
from app.mcp import mcp
settings = get_settings()
logger = logging.getLogger("personal-agent.mcp")
@asynccontextmanager
async def lifespan(_: Starlette):
effective_mode = settings.auth_mode if settings.mcp_auth_mode == "inherit" else settings.mcp_auth_mode
logger.info(
"MCP authentication mode=%s (base AUTH_MODE=%s)",
effective_mode,
settings.auth_mode,
)
async with mcp.session_manager.run():
yield
app = Starlette(
routes=[
Mount("/mcp", app=mcp.streamable_http_app()),
],
lifespan=lifespan,
)