fix(runtime): run server.py and force FastMCP SSE bind on 0.0.0.0:8000
This commit is contained in:
@@ -22,5 +22,5 @@ USER appuser
|
|||||||
# Expose the SSE port
|
# Expose the SSE port
|
||||||
EXPOSE 8000
|
EXPOSE 8000
|
||||||
|
|
||||||
# Run via MCP CLI in SSE mode
|
# Run via python entrypoint (server.py forces FastMCP SSE on 0.0.0.0:8000)
|
||||||
CMD ["mcp", "run", "server.py:mcp", "--transport", "sse"]
|
CMD ["python", "server.py"]
|
||||||
|
|||||||
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:
|
except Exception as e:
|
||||||
return f"Query failed: {e}"
|
return f"Query failed: {e}"
|
||||||
|
|
||||||
# NOTE:
|
if __name__ == "__main__":
|
||||||
# We intentionally do NOT call mcp.run() here.
|
import sys
|
||||||
# This module is meant to be run via the FastMCP CLI:
|
logging.info("Starting knowledge-mcp server via embedded FastMCP runner...")
|
||||||
# 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
|
# Force FastMCP.run() to start SSE listener on all interfaces.
|
||||||
# exiting cleanly (exit code 0) under this container setup.
|
# 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