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"))