fix(runtime): run server.py and force FastMCP SSE bind on 0.0.0.0:8000
This commit is contained in:
20
server.py
20
server.py
@@ -209,10 +209,18 @@ def query_notebook(notebook: str, query: str, limit: int = 5) -> str:
|
||||
except Exception as e:
|
||||
return f"Query failed: {e}"
|
||||
|
||||
# NOTE:
|
||||
# We intentionally do NOT call mcp.run() here.
|
||||
# This module is meant to be run via the FastMCP CLI:
|
||||
# fastmcp run server.py:mcp --transport sse --host 0.0.0.0 --port 8000
|
||||
# The CLI handles proper server startup; calling mcp.run() directly has been
|
||||
# exiting cleanly (exit code 0) under this container setup.
|
||||
if __name__ == "__main__":
|
||||
import sys
|
||||
logging.info("Starting knowledge-mcp server via embedded FastMCP runner...")
|
||||
|
||||
# Force FastMCP.run() to start SSE listener on all interfaces.
|
||||
# We intentionally reset argv so container/entrypoint args cannot break startup.
|
||||
sys.argv = [sys.argv[0], "sse", "--host", "0.0.0.0", "--port", "8000"]
|
||||
logging.info(f"Forced argv: {sys.argv}")
|
||||
|
||||
try:
|
||||
mcp.run()
|
||||
except BaseException as e:
|
||||
logging.critical(f"Server crashed: {e}", exc_info=True)
|
||||
raise
|
||||
|
||||
|
||||
Reference in New Issue
Block a user