Skip to content

Commit 0b83679

Browse files
authored
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.
1 parent 77b8daa commit 0b83679

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

examples/qr-server/server.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
HOST = os.environ.get("HOST", "0.0.0.0") # 0.0.0.0 for Docker compatibility
2727
PORT = int(os.environ.get("PORT", "3001"))
2828

29-
mcp = FastMCP("QR Code Server", stateless_http=True)
29+
mcp = FastMCP("QR Code Server", stateless_http=True, host=HOST, port=PORT)
3030

3131
# Embedded View HTML for self-contained usage (uv run <url> or unbundled)
3232
EMBEDDED_VIEW_HTML = """<!DOCTYPE html>

0 commit comments

Comments
 (0)