From c248365c7d2ec47ee03b5a44b26a530cf76e834a Mon Sep 17 00:00:00 2001 From: Atlas Date: Wed, 1 Jul 2026 22:43:02 +0200 Subject: [PATCH] MCP server: stateless HTTP + relaxed host check for web-UI hosts Enables Open WebUI / LibreChat native Streamable-HTTP MCP (host.docker.internal, stateless_http + json_response). Deployed as atlas-brain-mcp on atlas-01. Atlas Corporation proprietary. --- mcp_server.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/mcp_server.py b/mcp_server.py index 70d6868..a4b8a4a 100755 --- a/mcp_server.py +++ b/mcp_server.py @@ -30,11 +30,18 @@ import brain try: from mcp.server.fastmcp import FastMCP + from mcp.server.transport_security import TransportSecuritySettings except Exception: sys.stderr.write("SecondBrain MCP needs the MCP SDK: pip install \"mcp[cli]\"\n") raise -mcp = FastMCP("secondbrain") +# Allow reverse-proxied / container access (host.docker.internal, LAN) over Streamable HTTP. +# The brain endpoint itself should be bound to a private interface / put behind auth. +_SECURITY = TransportSecuritySettings(enable_dns_rebinding_protection=False) +# stateless_http + json_response = broadest compatibility with web-UI MCP clients +# (e.g. Open WebUI) that don't hold an SSE session. +mcp = FastMCP("secondbrain", transport_security=_SECURITY, + stateless_http=True, json_response=True) # Streamable-HTTP bind (used with `--http`); the transport all web UIs consume natively. mcp.settings.host = os.environ.get("MCP_HOST", "127.0.0.1") mcp.settings.port = int(os.environ.get("MCP_PORT", "8790"))