1.5 KiB
1.5 KiB
Why
The MCP server uses the Python MCP SDK's built-in DNS rebinding protection, which validates the Host header on every request. By default it only allows localhost, 127.0.0.1, and [::1]. When clients connect remotely — using an IP address or FQDN — the server returns 421 "Invalid Host header" and the connection fails. There is no way to configure allowed hosts without changing code.
What Changes
- Add a new environment variable
KB_MCP_ALLOWED_HOSTSthat accepts a comma-separated list of additional allowed hosts (IPs and/or FQDNs). - The MCP server passes these hosts (plus the existing localhost defaults) to the MCP SDK's
TransportSecuritySettingswhen constructing the ASGI app. - Both bare hosts and wildcard-port patterns are supported (e.g.
192.168.1.50andkb.example.comboth work, with any port). - When
KB_MCP_ALLOWED_HOSTSis empty or unset, behaviour is unchanged (localhost-only).
Capabilities
New Capabilities
None — this is configuration of an existing component, not a new capability.
Modified Capabilities
docker-deployment: AddKB_MCP_ALLOWED_HOSTSto the MCP container's environment variables in Compose files and document its usage.
Impact
- mcp/config.py — new
KB_MCP_ALLOWED_HOSTSenv var. - mcp/server.py — construct
TransportSecuritySettingswith merged allowed hosts/origins and pass to the FastMCP app. - engine/compose.*.yaml — add
KB_MCP_ALLOWED_HOSTSto the kb-mcp service environment block.