fix(qr-server): pass host/port to FastMCP for Docker compatibility (#372)

When FastMCP is created with the default host=127.0.0.1, MCP SDK 1.26+
automatically enables DNS rebinding protection that only allows requests
from localhost. This breaks Docker where requests come from
host.docker.internal, causing 421 Invalid Host header errors.

By passing host=HOST (0.0.0.0 for Docker), DNS rebinding protection
is not auto-enabled, allowing requests from any host.
This commit is contained in:
Maurizio Albari 2026-04-24 12:35:13 +02:00 • committed by GitHub
commit 0b83679909
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -26,7 +26,7 @@ VIEW_URI = "ui://qr-server/view.html"
HOST = os.environ.get("HOST", "0.0.0.0") # 0.0.0.0 for Docker compatibility
PORT = int(os.environ.get("PORT", "3001"))
mcp = FastMCP("QR Code Server", stateless_http=True)
mcp = FastMCP("QR Code Server", stateless_http=True, host=HOST, port=PORT)
# Embedded View HTML for self-contained usage (uv run <url> or unbundled)
EMBEDDED_VIEW_HTML = """<!DOCTYPE html>