feat: expose ASGI app for direct uvicorn execution
This commit is contained in:
17
server.py
17
server.py
@@ -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
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user