You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(bots): forward Mcp-Method, Mcp-Name and Mcp-Param-* headers through the bot-tool relay - #48477
When a bot uses a tool that has a saved key, Orca sends the bot's request to the tool's server through a small relay. The relay copies only a few request headers on purpose, so the bot's own token and cookies never reach the tool's server. Newer MCP servers expect extra headers on each request that say which action is being run, which tool it is for, and some of the tool's arguments. The relay was dropping those headers, so the servers rejected the requests and the tool never loaded. Now the relay passes them through.
mcp-method and mcp-name are added to FORWARDED_REQUEST_HEADERS.
Every incoming request header whose name starts with mcp-param- is also forwarded. These headers mirror annotated tool arguments, so their names vary per tool and a fixed list can't cover them. Node lowercases req.headers keys, so the prefix check covers any casing the client sends.
Nothing else changes. The tool's saved credential headers are still applied last, so they win over anything the agent sends. authorization, cookie and every other header are still dropped.
Before: a bot tool with a saved credential, pointed at a server that follows MCP 2026-07-28, failed with HTTP 400 / JSON-RPC -32020 (header mismatch). This happened in Oh My Pi chats, for example. After: the headers reach the server and the tool loads.
bot-tool-relay.test.ts: the existing saved-headers test now sends a tools/call with mcp-method, mcp-name and mcp-param-region (and the matching arguments.region in the body). It asserts that all three reach the upstream, and that the bot token and cookie still don't.
Why
The relay's allowlist is the right design, but it was written before these MCP headers existed. The MCP 2026-07-28 streamable HTTP spec requires Mcp-Method on every request. It requires Mcp-Name on tools/call, resources/read and prompts/get. It says intermediaries MUST forward Mcp-Param-{Name}. Servers must reject a request with 400 / -32020 when one of these headers is missing or doesn't match the body. The header values only repeat what the request body already sends to the same server, so forwarding them exposes nothing new. A prefix match is the narrowest rule that covers Mcp-Param-*, because those names come from each tool's schema.
N/A: there is no UI change. The fix changes which request headers the main-process relay forwards. The behavior is shown by the tests below.
Testing
I manually tested these changes locally (strict-server probe, see below)
Automated tests added/updated, or explained why not below
Every added test fails without this change and avoids the test anti-patterns
src/main/bots/tool-relay/bot-tool-relay.test.ts fails on main with expected undefined to be 'tools/call' and passes 11/11 with this change (macOS).
A separate probe used a fake upstream that behaves like a strict 2026-07-28 server and rejects with 400 / -32020 when a header is missing or doesn't match the body:
On main, both tools/call and tools/list were rejected.
With only mcp-method / mcp-name forwarded, tools/call with an annotated argument was still rejected because Mcp-Param-Region was dropped.
With this change, both are accepted.
The probe also confirmed that x-mcp-param-leak and mcp-parameter are not forwarded, that a saved credential header still overrides an agent header with the same name, and that authorization and cookie are still dropped.
The header names and requirements were checked against the MCP spec source (docs/specification/2026-07-28/basic/transports/streamable-http.mdx), the MCP TypeScript SDK client (which sets mcp-method / mcp-name) and Oh My Pi's HTTP upstream (which sets Mcp-Method, Mcp-Name and Mcp-Param-*).
oxlint, oxfmt, the anti-slop and native code-quality oxlint configs, ast-grep, and the changed-code quality gate are all clean on the touched files.
Performance
None that matters. This code runs in the main process once per relayed MCP HTTP request, which is already a network round trip. There is no polling, timer, I/O or subprocess. I measured the header copy with a Node microbenchmark (200k iterations, old vs new):
Adversarial request with 300 mcp-param-* headers, near Node's 16 KB header limit: 98 ns before, about 21 µs after.
The worst case is bounded by Node's header-size limit and stays far below a 16 ms frame.
Risk
Low. The only change is that more of the agent's own MCP request headers reach the tool's server. Servers that don't know these headers ignore them. Credential headers still take priority, and the bot token and cookies are still dropped. To back it out, do a plain revert.
Level: Low
Review
Cross-platform: no platform-specific code.
SSH/remote: the relay runs in the desktop main process, and nothing in this change depends on the host.
Agent compatibility: this is provider-neutral. Any MCP client that sends these headers benefits, and clients that don't send them see no change.
Agent skill upstream boundary
Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.
Notes
Ensure no issues in: Security, Cross-platform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance
Original fix by @pearson-tfl in #48477. Mcp-Param-* forwarding was added during review and squashed into one commit with their authorship kept.
Checklist
This PR is small and focused
I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
I stated the risk: what could break, for whom, and how to back it out
Before/after screenshots or videos attached for UI changes, or N/A with reason
Self-reviewed for correctness, security, and performance
Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred): ran the targeted tests and CI's static gates locally; CI covers the rest
No actionable comments were generated in the recent review.
Walkthrough
The bot-tool relay now forwards the mcp-method and mcp-name headers and incoming headers with the mcp-param- prefix. The test sends a tools/call request and checks that the headers and body reach the upstream. It also checks that the saved API key is added and authorization and cookie headers are omitted.
Severity of issue fixed: Medium
Merge Risk: Low · up to c6b8b
The relay now forwards MCP method, name and parameter headers, which fixes rejections from strict MCP servers. A narrow edge case remains: a tool with a saved header whose name matches a forwarded one but is cased differently could send a combined value. This is unlikely in practice and can be handled as a follow-up.
Pre-merge checks: 3 · 1
Failed checks: 1 inconclusive
Check name
Status
Explanation
Resolution
Out of Scope Changes check
The two allowlist entries mcp-method and mcp-name are within [#48475]. The diff also adds a second behavior change not described in the PR description or the linked issue. In sendUpstream, every incom…
Author to confirm whether mcp-param-* prefix forwarding is intended in this PR. If it is intended, update the PR description and linked scope to state it and cite the requirement that needs it. If it is not intended, remove the prefix loop …
Passed checks: 3 passed
Check name
Status
Explanation
Linked Issues check
[#48475] requires the bot-tool relay to forward Mcp-Method and Mcp-Name so strict MCP servers accept relayed requests. At the reviewed head, FORWARDED_REQUEST_HEADERS in src/main/bots/tool-relay/bot-t…
Title check
The title names the main change: forwarding the Mcp-Method, Mcp-Name and Mcp-Param-* headers through the bot-tool relay. It matches the raw summary, which adds mcp-method, mcp-name, and a prefix forwa…
Description check
The description follows the template. It has ELI5, What Changed, Why, a linked issue (Fixes #48475), Visual Proof marked N/A with a reason, Testing with results, Performance with a justified 'None' pl…
Full details: Linked Issues check
Explanation
[#48475] requires the bot-tool relay to forward Mcp-Method and Mcp-Name so strict MCP servers accept relayed requests. At the reviewed head, FORWARDED_REQUEST_HEADERS in src/main/bots/tool-relay/bot-tool-relay-upstream.ts includes 'mcp-method' and 'mcp-name' (diff against merge base, +2 lines). sendUpstream reads these through the existing header() helper, so the headers reach the upstream when present. The existing allowlist keeps the bot token, cookies, and other headers excluded. The updated test in bot-tool-relay.test.ts covers the new headers per the PR description and the previous review. Test results were reported by the author for macOS; CI was not inspected. Stack scope: no stack evidence was supplied, so only this PR is assessed.
Full details: Title check
Explanation
The title names the main change: forwarding the Mcp-Method, Mcp-Name and Mcp-Param-* headers through the bot-tool relay. It matches the raw summary, which adds mcp-method, mcp-name, and a prefix forward for mcp-param-*. The title uses a conventional fix(bots) scope and is specific. It is 90 characters, slightly long, but still clear.
Full details: Description check
Explanation
The description follows the template. It has ELI5, What Changed, Why, a linked issue (Fixes #48475), Visual Proof marked N/A with a reason, Testing with results, Performance with a justified 'None' plus measurements, Risk with level Low and a backout plan, and the AI Disclosure and upstream boundary sections. The Review, Notes and Checklist sections are also filled in. Two points are weak: the Testing checklist includes a manual local test claim that the PR objectives say was not run in a patched Orca build, and the full pnpm lint/typecheck/test/build checklist item is left unchecked. The AI Disclosure section was left with its template comment and no content, and the 'Review' section does not follow the template's heading structure exactly.
Resolution
Optionally: fill in the AI Disclosure section (or confirm it is not applicable for an internal contributor), and reconcile the 'I manually tested these changes locally' checkbox with the PR objectives, which say the author did not run a patched Orca build locally.
Full details: Out of Scope Changes check
Explanation
The two allowlist entries mcp-method and mcp-name are within [#48475]. The diff also adds a second behavior change not described in the PR description or the linked issue. In sendUpstream, every incoming header whose name starts with 'mcp-param-' is now forwarded (names = [...FORWARDED_REQUEST_HEADERS, ...keys filtered by prefix 'mcp-param-']). The PR description states that the change adds two names only and that the allowlist stays closed for other headers. The prefix rule widens the forwarded set to any header with that prefix. The issue does not request this. The code comment ties it to MCP Mcp-Param-* headers, so a relation to the same MCP feature is possible but is not established by the issue or PR text. The test summary also mentions parameter metadata headers, which suggests the prefix path is tested, but this was not verified in the test file.
Resolution
Author to confirm whether mcp-param-* prefix forwarding is intended in this PR. If it is intended, update the PR description and linked scope to state it and cite the requirement that needs it. If it is not intended, remove the prefix loop from sendUpstream so only the two named headers are added, and keep the test assertions for mcp-method and mcp-name.
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
The reason will be displayed to describe this comment to others. Learn more.
Minor · Data Integrity & Integration · Quick win
Saved headers can collide with forwarded mcp-method and mcp-name values.
sendUpstream now forwards mcp-method and mcp-name as lowercase keys. Saved tool headers keep their entered casing, so a saved Mcp-Method can coexist with the forwarded mcp-method in { ...headers, ...answer.headers } at line 56. Fetch joins the two entries into one value, such as tools/call, tools/call. A strict MCP server can reject that value, and a tool that worked before this change can then fail.
Keep one entry per header name. Forwarded values should not override or join a saved header with the same case-insensitive name:
Suggested fix
try {
// Bounds the wait for headers only; the timer is cleared before any of the body is read.
+ const saved = new Set(Object.keys(answer.headers).map((name) => name.toLowerCase()))+ const forwarded = Object.fromEntries(+ Object.entries(headers).filter(([name]) => !saved.has(name.toLowerCase()))+ )
return await fetchUpstream(answer.url, {
method: req.method,
- headers: { ...headers, ...answer.headers },+ headers: { ...forwarded, ...answer.headers },
The reason will be displayed to describe this comment to others. Learn more.
Not changing this here: the same merge already applies to every forwarded header (content-type, accept, mcp-session-id, mcp-protocol-version), and Mcp-Method/Mcp-Name are per-request values a user has no reason to save on a tool. Case-insensitive precedence for saved headers would be a separate change.
…gh the bot-tool relay
MCP 2026-07-28 clients send Mcp-Method on every request, Mcp-Name on
tools/call, resources/read and prompts/get, and Mcp-Param-* headers that
mirror annotated tool arguments. Strict servers reject a request missing
them with 400 / -32020. The relay's request-header allowlist dropped all
three, so tools behind a saved credential failed to load.
Add mcp-method and mcp-name to the allowlist and forward every
mcp-param-* request header by prefix. Saved credential headers are still
applied last, and the bot token and cookies are still dropped.
Fixesstablyai#48475
Co-authored-by: Neil <[email protected]>
nwparker
changed the title
fix(bots): forward Mcp-Method and Mcp-Name through the bot-tool relay
fix(bots): forward Mcp-Method, Mcp-Name and Mcp-Param-* headers through the bot-tool relay
Nov 24, 2026
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
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.
ELI5
When a bot uses a tool that has a saved key, Orca sends the bot's request to the tool's server through a small relay. The relay copies only a few request headers on purpose, so the bot's own token and cookies never reach the tool's server. Newer MCP servers expect extra headers on each request that say which action is being run, which tool it is for, and some of the tool's arguments. The relay was dropping those headers, so the servers rejected the requests and the tool never loaded. Now the relay passes them through.
What Changed
src/main/bots/tool-relay/bot-tool-relay-upstream.ts(sendUpstream):mcp-methodandmcp-nameare added toFORWARDED_REQUEST_HEADERS.mcp-param-is also forwarded. These headers mirror annotated tool arguments, so their names vary per tool and a fixed list can't cover them. Node lowercasesreq.headerskeys, so the prefix check covers any casing the client sends.authorization,cookieand every other header are still dropped.Before: a bot tool with a saved credential, pointed at a server that follows MCP 2026-07-28, failed with HTTP 400 / JSON-RPC
-32020(header mismatch). This happened in Oh My Pi chats, for example. After: the headers reach the server and the tool loads.bot-tool-relay.test.ts: the existing saved-headers test now sends atools/callwithmcp-method,mcp-nameandmcp-param-region(and the matchingarguments.regionin the body). It asserts that all three reach the upstream, and that the bot token and cookie still don't.Why
The relay's allowlist is the right design, but it was written before these MCP headers existed. The MCP 2026-07-28 streamable HTTP spec requires
Mcp-Methodon every request. It requiresMcp-Nameontools/call,resources/readandprompts/get. It says intermediaries MUST forwardMcp-Param-{Name}. Servers must reject a request with 400 /-32020when one of these headers is missing or doesn't match the body. The header values only repeat what the request body already sends to the same server, so forwarding them exposes nothing new. A prefix match is the narrowest rule that coversMcp-Param-*, because those names come from each tool's schema.Linked Issue
Fixes #48475
Visual Proof
N/A: there is no UI change. The fix changes which request headers the main-process relay forwards. The behavior is shown by the tests below.
Testing
I manually tested these changes locally (strict-server probe, see below)
Automated tests added/updated, or explained why not below
Every added test fails without this change and avoids the test anti-patterns
src/main/bots/tool-relay/bot-tool-relay.test.tsfails onmainwithexpected undefined to be 'tools/call'and passes 11/11 with this change (macOS).A separate probe used a fake upstream that behaves like a strict 2026-07-28 server and rejects with 400 /
-32020when a header is missing or doesn't match the body:main, bothtools/callandtools/listwere rejected.mcp-method/mcp-nameforwarded,tools/callwith an annotated argument was still rejected becauseMcp-Param-Regionwas dropped.x-mcp-param-leakandmcp-parameterare not forwarded, that a saved credential header still overrides an agent header with the same name, and thatauthorizationandcookieare still dropped.The header names and requirements were checked against the MCP spec source (
docs/specification/2026-07-28/basic/transports/streamable-http.mdx), the MCP TypeScript SDK client (which setsmcp-method/mcp-name) and Oh My Pi's HTTP upstream (which setsMcp-Method,Mcp-NameandMcp-Param-*).oxlint, oxfmt, the anti-slop and native code-quality oxlint configs, ast-grep, and the changed-code quality gate are all clean on the touched files.
Performance
None that matters. This code runs in the main process once per relayed MCP HTTP request, which is already a network round trip. There is no polling, timer, I/O or subprocess. I measured the header copy with a Node microbenchmark (200k iterations, old vs new):
mcp-param-*headers: 70 ns before, 275 ns after.mcp-param-*headers, near Node's 16 KB header limit: 98 ns before, about 21 µs after.The worst case is bounded by Node's header-size limit and stays far below a 16 ms frame.
Risk
Low. The only change is that more of the agent's own MCP request headers reach the tool's server. Servers that don't know these headers ignore them. Credential headers still take priority, and the bot token and cookies are still dropped. To back it out, do a plain revert.
Level: Low
Review
Agent skill upstream boundary
Notes
Ensure no issues in: Security, Cross-platform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance
Original fix by @pearson-tfl in #48477. Mcp-Param-* forwarding was added during review and squashed into one commit with their authorship kept.
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred): ran the targeted tests and CI's static gates locally; CI covers the rest