feat: expose ASGI app for direct uvicorn execution

This commit is contained in:
Clawdbot
2026-02-12 12:28:04 +11:00
parent 36bc6238dd
commit b4391cb650

View File

@@ -234,3 +234,20 @@ if __name__ == "__main__":
except BaseException as e: except BaseException as e:
logging.critical(f"Server crashed: {e}", exc_info=True) logging.critical(f"Server crashed: {e}", exc_info=True)
raise raise
# Expose as ASGI app for uvicorn to pick up if run directly (uvicorn server:app)
# This bypasses the Typer CLI entirely.
app = mcp._sse_app if hasattr(mcp, "_sse_app") else None
if app is None:
# Fallback if _sse_app isn't pre-initialized or private
try:
from starlette.applications import Starlette
from mcp.server.sse import SseServerTransport
# We need to construct the app manually if FastMCP hides it
# But FastMCP typically creates it on demand.
# Let's try to find it or create a wrapper.
pass
except ImportError:
pass