From 0bb0da3d7c921b38a6dd3b661b77d2817d7de144 Mon Sep 17 00:00:00 2001 From: Maurizio Albari Date: Tue, 27 Jan 2026 11:39:57 +0100 Subject: [PATCH] fix(qr-server): pass host/port to FastMCP for Docker compatibility 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. --- examples/qr-server/server.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/qr-server/server.py b/examples/qr-server/server.py index d282d1ad..c1c302ed 100755 --- a/examples/qr-server/server.py +++ b/examples/qr-server/server.py @@ -26,7 +26,7 @@ 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 or unbundled) EMBEDDED_VIEW_HTML = """