Repository navigation
fix(tools): agent tool relay forwards every header except hop-by-hop and its own credentials - #49535
Conversation
…and its own credentials The relay kept a fixed list of request and response headers, so each new MCP header (Mcp-Method, Mcp-Name, Mcp-Param-*) was dropped until someone added it. Forward everything instead, except hop-by-hop headers, the ones fetch sets itself, and the agent's relay token and cookie. Saved headers still win, now regardless of case. Responses pass everything except hop-by-hop headers, content-length, content-encoding and www-authenticate.
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
…case-insensitive precedence
ELI5
When an agent calls an MCP tool through Orca's agent tool relay, the relay adds the tool's saved credentials and sends the call on. Until now it passed along only a short, fixed list of headers. Whenever MCP added a new header, the relay dropped it until someone updated the list, and strict servers rejected those calls. Now it passes every header except the few that must not cross: connection-level ones, ones fetch sets itself, and the agent's own relay token.
What Changed
Requests (
sendUpstream): every agent header is forwarded, except:connection,keep-alive,te,trailer,transfer-encoding,upgrade,proxy-*, and any header named inConnection);host,content-length,expect,accept-encoding, which fetch sets itself;authorizationandcookie, the agent's credentials for the relay.Saved headers are still applied last, and now win regardless of case. Before, an agent
X-Api-Keynext to a savedx-api-keywould have been joined by fetch.Responses (
streamUpstreamResponse): every upstream header is forwarded, except hop-by-hop headers,content-length,content-encoding(fetch already decoded the body) andwww-authenticate. That last one is still withheld on purpose, along with the existing 401 to 403 rewrite, so the agent's CLI never starts a sign-in against the relay.This replaces
FORWARDED_REQUEST_HEADERS,FORWARDED_RESPONSE_HEADERSand themcp-param-prefix special case.Why
#48477 already fixed the headers reported in #48475 (
Mcp-Method,Mcp-Name,Mcp-Param-*) by adding them to the list. This PR stops the next missing header: the spec keeps adding headers (for example MCP Events reuseMcp-Name), and so do servers. Webhook intake already moved from a header allowlist to a denylist for the same reason. Generic HTTP proxies work the same way: they forward everything except hop-by-hop headers (RFC 9110 §7.6.1).Linked Issue
Follow-up to #48475 (already closed by #48477).
Visual Proof
N/A: no UI change. This only changes which HTTP headers the local relay passes through.
Testing
The relay forwarding test now sends an arbitrary
x-customrequest header and gets an arbitraryx-upstream-customresponse header, and both pass through. The upstream'swww-authenticatestays withheld, and the agent's relay token and cookie never reach upstream. The agent also sendsX-Api-Key: agent-value, and upstream sees only the saved value. This is a security boundary: the relay token must never leak, and saved credentials must not be overridden. With the old allowlist restored, the test fails (expected undefined to be 'u1'). All 12 tests pass;pnpm tc:nodeis clean.Performance
None, because it is one pass over the request's and the response's headers per tool call, the same order of work as before.
Risk
Level: Low
Upstream servers now see agent headers they did not see before, such as
user-agent. This is a strict superset of what was sent before, the relay runs only on the host, and the agent's relay credentials are still dropped. A server that rejected unknown headers would now refuse calls, but that is not how MCP servers behave. Back out with a plain revert.AI Disclosure
Review