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.
This commit is contained in:
Atlas 2026-07-01 22:43:02 +02:00
parent 43a8dbb36f
commit c248365c7d

View file

@ -30,11 +30,18 @@ import brain
try: try:
from mcp.server.fastmcp import FastMCP from mcp.server.fastmcp import FastMCP
from mcp.server.transport_security import TransportSecuritySettings
except Exception: except Exception:
sys.stderr.write("SecondBrain MCP needs the MCP SDK: pip install \"mcp[cli]\"\n") sys.stderr.write("SecondBrain MCP needs the MCP SDK: pip install \"mcp[cli]\"\n")
raise 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. # 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.host = os.environ.get("MCP_HOST", "127.0.0.1")
mcp.settings.port = int(os.environ.get("MCP_PORT", "8790")) mcp.settings.port = int(os.environ.get("MCP_PORT", "8790"))