Repository navigation
A routing header the caller sent stopped at the gateway - #93
Merged
Merged
Conversation
MCP lets a client mirror selected tool arguments into Mcp-Param-{Name}
headers so an intermediary can dispatch without parsing the JSON-RPC
body, and the transport addresses intermediaries by name: one that does
not recognize such a header "MUST forward it and otherwise ignore it".
fold is that intermediary and dropped them. Its upstream leg is a fresh
SDK client session whose headers the SDK generates, so nothing the
caller set survived the hop — measured against a real upstream, which
saw none of them.
Both halves of that sentence are implemented. fold forwards them and
ignores them: it does not read the values, does not route on them, and
lets nothing they contain influence a decision, so the body stays the
only thing fold parses and the headers cannot become a second,
forgeable control surface.
The relay is the narrowest thing that satisfies the rule. fold forwards
no other client header — a standing decision, and the reason a caller
cannot smuggle a credential or an identity assertion to an upstream
through one — and this is the single namespace a specification requires
be passed through. It never overwrites a value the SDK generated, which
is not about freshness: the specification requires the header to agree
with the body, and only a value derived from the body fold is about to
send is guaranteed to, so caller-wins would let a caller manufacture a
mismatch a conforming upstream then rejects. And it sits inside the same
host bound as credential attachment, so nothing caller-supplied rides a
request to a host the upstream did not configure.
Two consequences are documented rather than smoothed over, because
neither is visible from the code and one of them makes a claim in the
first draft of this change wrong.
"fold ignores them" is true of fold and not of the deployment. An
upstream's own transport validates a param header against the body only
once it has negotiated 2026-07-28, and fold's default upstream protocol
sits below that so the sessionful handshake can carry server-initiated
traffic. So on a default deployment nothing validates these at all, and
a balancer in front of an upstream would dispatch on a caller-supplied
value fold's policy engine never saw and that need not agree with the
body fold authorized. README says so beside the feature: route on these
and you must check them yourself.
And they ride the request context, so every upstream request made under
one carries them — including the bridged session's own initialize, which
is issued lazily inside the first named invocation. A value scoped to
one call can therefore reach a router deciding where a whole session
lives.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
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.
The last open code finding from the
/spec-driftsweep. With this, every finding from it is landed, documented, or in flight.The gap
Mcp-Param-{Name}is how a client mirrors selected tool arguments into HTTP headers so an intermediary can dispatch without parsing the body. fold is that intermediary and dropped them — its upstream leg is a fresh SDK client session whose headers the SDK generates. Measured against a real upstream before touching anything: it saw none of the caller's headers.Both halves of the sentence
fold forwards them and ignores them: it does not read the values, does not route on them, and lets nothing they contain influence a decision. The body stays the only thing fold parses, which is what keeps these a hint rather than a second, forgeable control surface.
The relay is the narrowest thing that satisfies the rule. fold forwards no other client header — a standing design decision, and the reason a caller cannot smuggle a credential to an upstream — so I did not want a spec-mandated relay to quietly become a general one. Verified in the same test:
The narrowness is asserted in six places. Widening the relay fails all of them.
Precedence: a value the SDK generated always wins over the caller's. Not because it is fresher — because the spec requires the header to agree with the body, and only a value derived from the body fold is about to send is guaranteed to. Caller-wins would let a caller manufacture a mismatch that a conforming upstream then rejects as its own error.
Two consequences documented rather than smoothed over
Both came out of testing, and the first makes a claim in my first draft wrong:
"fold ignores them" is true of fold, not of the deployment. An upstream's transport validates a param header against the body only once it has negotiated
2026-07-28— and fold's default upstream protocol deliberately sits below that, so the sessionful handshake can carry server-initiated traffic. So on a default deployment nothing validates these: a balancer in front of an upstream dispatches on a caller-supplied value fold's policy engine never saw and that need not agree with the body fold authorized. README now says it plainly: route on these and you must check them yourself.They ride the request context, so every upstream request under one carries them — including the bridged session's own
initialize, issued lazily inside the first named invocation. Measured:Harmless as the spec is written, but a value scoped to one call can reach a router deciding where a whole session lives.
Verification
go test -race ./...green; lint 0 issues; gofmt / vet clean; conformance 40/40withParamHeadersasserted allocation-free on the no-header path viatesting.AllocsPerRun, which is the common caseheader mismatch: missing Mcp-Param-Tenant header for parameter "tenant"protocol: "auto"so the SDK server actually enforces header/body agreement🤖 Generated with Claude Code