Skip to content

fix(deployment): disable fastmcp host-origin guard behind the runtime proxy#4205

Open
AnayGarodia wants to merge 1 commit into
dlt-hub:develfrom
AnayGarodia:fix/4199-mcp-launcher-host-origin-protection
Open

fix(deployment): disable fastmcp host-origin guard behind the runtime proxy#4205
AnayGarodia wants to merge 1 commit into
dlt-hub:develfrom
AnayGarodia:fix/4199-mcp-launcher-host-origin-protection

Conversation

@AnayGarodia

Copy link
Copy Markdown

Fixes #4199.

Summary

FastMCP >= 3.4.3 turns on DNS-rebinding (Host header) protection by default. The MCP launcher runs behind the runtime reverse proxy (modal / tower / local runner), which rewrites the Host header, so with the allowlist defaulting to localhost the guard rejects every request with 421 Misdirected Request. The server starts but never serves a usable request.

Fix

run_mcp_instance now passes host_origin_protection to instance.run(), driven by a new McpConfiguration.host_origin_protection field that defaults to False (these servers only receive traffic from the authenticated runtime proxy, so the guard is redundant). It stays overridable for anyone who wants it on.

Because dlt pins fastmcp>=3.0.0 but the option only exists in >=3.4.3, the argument is passed only when the installed FastMCP supports it (version-gated) — passing it to an older FastMCP would raise TypeError. Older versions never had the guard, so they need no change.

This replaces the interim fastmcp<3.4.3 pin in the test workspace: real deployments on the runtime were still broken until the launcher itself was fixed.

Tests

Two unit tests in tests/workspace/deployment/test_launchers.py: the arg is passed as False when supported, and omitted when not. black / ruff / mypy pass on the changed files.

Note

I went with option 1 from the issue (disable the guard for these proxied deployments) rather than a static allowlist, since the forwarded Host differs per backend (modal *.modal.host, tower, local *.dltrun.*) so no single allowlist works. Happy to switch to a config-driven per-backend allowlist if you prefer.

Copilot AI review requested due to automatic review settings July 11, 2026 00:04

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug(mcp): mcp launcher doesn't set http_allowed_hosts, so fastmcp ≥3.4.3 returns 421 behind a proxy

2 participants