Repository navigation
fix(mcp): accept the app host behind a same-host reverse proxy - #308
Open
ngunyimacharia wants to merge 1 commit into
Open
ngunyimacharia wants to merge 1 commit into
ngunyimacharia wants to merge 1 commit into
Conversation
Laravel Cloud's web proxy runs in the app container and forwards to the server over 127.0.0.1 while keeping the public Host header. mcp-go's DNS rebinding guard reads that as an attack and answers every /mcp request with 403 "invalid Host header", so OAuth succeeds but no client can connect. Upgrade mcp-go to v1.6.0 and allow the app origin's host with WithAllowedHosts. Loopback hosts stay allowed and every other Host header is still rejected, so the guard stays on.
ngunyimacharia
requested review from
anuragrao04 and
razvi-razorpay
as code owners
November 26, 2026 20:49
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What and why
Behind a reverse proxy on the same host (Laravel Cloud, or any sidecar nginx/Caddy forwarding to
127.0.0.1), every/mcprequest fails with 403invalid Host header. mcp-go's DNS rebinding guard sees a loopback connection carrying a publicHostand treats it as an attack. OAuth succeeds, so clients get a token they can never use.This upgrades mcp-go to v1.6.0 and passes the host of
SLASHDOCS_APP_ORIGINtoWithAllowedHosts. Loopback hosts stay allowed and any otherHostis still rejected, so the guard stays on.Closes #303
How it was tested
server_mcp_test.gosend MCP requests over a loopback connection, the way a same-host proxy does: the app's publicHostgets 200, and any otherHoststill gets 403.go test ./api/... ./cli/... ./internal/...andmake lintpass.Checklist
make lintandmake testpass locallyBreaking changes
With an allowlist set, mcp-go checks
Hoston every request, not only loopback ones. An agent that calls/mcpthrough a name other than the app origin (for example an in-cluster service name) now gets 403 and should use the public origin. Browser and OAuth clients are unaffected, since OAuth tokens are already bound to<app origin>/mcp.