Skip to content

feat(core): mirror SEP-2792 acceptLanguage on every Streamable HTTP send - #2990

Merged
cliffhall merged 1 commit into
v2/mainfrom
v2/feat/2987-direct-accept-language
Nov 18, 2026
Merged

cliffhall merged 1 commit into
v2/mainfrom
v2/feat/2987-direct-accept-language

Conversation

@cliffhall

Copy link
Copy Markdown
Member

Closes #2987

What changed

#2979 (#2988) mirrored the SEP-2792 language preference only in the web backend. The CLI and TUI connect without the backend, so they didn't mirror it, and Node's fetch sent its default Accept-Language: * beside the _meta value. A strict server rejects that pair as HeaderMismatch.

  • core/mcp/node/languageMirroringTransport.ts (new): a StreamableHTTPClientTransport subclass whose send derives Accept-Language from the message's own params._meta["io.modelcontextprotocol/acceptLanguage"], using acceptLanguageHeaderFor from Support SEP-2792 language preferences in Web Inspector #2979, and passes it through the SDK's per-send headers option. Overriding send covers every outbound message, SDK-internal ones included. The SDK applies per-send headers after requestInit.headers, so the mirror replaces a configured Accept-Language. Per-send headers the caller passed in, such as Mcp-Param-*, are kept.
  • core/mcp/node/transport.ts: createTransportNode builds that transport for Streamable HTTP. The CLI, the TUI and the web backend all use this factory, so one implementation serves all three clients.
  • core/mcp/remote/node/server.ts: removes Support SEP-2792 language preferences in Web Inspector #2979's backend-only upstreamSendHeaders now that the transport does the work. The backend's per-send header allowlist is back to Mcp-Param-* alone, and the language header is still never taken from the browser.
  • Docs: the "Language preferences" section in docs/test-servers.md drops the "CLI and TUI do not mirror yet" warning and adds a CLI example. I ran that example against the showcase server: it answered Hallo, world!, with _meta and the header both de-AT, de;q=0.9.

Tests

  • clients/web/src/test/core/mcp/node/languageMirroringTransport.test.ts, through createTransportNode:
    • an exact mirror;
    • no header when there's no preference;
    • replacement of a configured header;
    • Mcp-Param-* per-send headers kept, with and without a preference.
  • clients/cli/__tests__/metadata.test.ts: the real CLI with --metadata io.modelcontextprotocol/acceptLanguage=… against an HTTP test server, asserting that the server received the exact header. I checked that this case fails on the unpatched transport: the server receives *.
  • localized-greeting-fixture.test.ts: the old test that pinned the CLI/TUI gap ("flags Node fetch's default *") is now a positive mirroring test on a direct connection.
  • The remote end-to-end tests from Support SEP-2792 language preferences in Web Inspector #2979 pass unchanged; they now go through the shared transport instead of the removed backend code.

npm run local:gate passes. No screenshots: nothing in the UI changed.

🤖 Generated with Claude Code

createTransportNode now builds a StreamableHTTPClientTransport subclass that
derives Accept-Language from each message's own
params._meta["io.modelcontextprotocol/acceptLanguage"] and passes it through
the SDK's per-send headers option. That transport is shared by the CLI, the
TUI and the web backend, so all three mirror the preference exactly; before
this only the web backend did, and a direct connection sent Node fetch's
default "Accept-Language: *" beside the _meta value, which a strict server
rejects as HeaderMismatch.

The backend-only derivation added in #2979 (upstreamSendHeaders) is removed
in favor of the transport; the backend's per-send header allowlist is back
to Mcp-Param-* alone. Covered by transport unit tests, a CLI e2e case
(verified to fail on the unpatched transport), the updated fixture tests,
and the existing remote e2e tests, which still pass through the transport.

Closes #2987

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: cliffhall <[email protected]>
@cliffhall cliffhall added the v2 Issues and PRs for v2 label Nov 18, 2026
@cliffhall
cliffhall requested a balanced review from Copilot November 18, 2026 06:27

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.

🟢 Approval recommended

No active review issues remain for the shared language-header mirroring change.

No open issues 🎉

What changed in this PR

Moves SEP-2792 language-header mirroring from the web backend into the shared Node Streamable HTTP transport, extending support to direct CLI, TUI, and mcpdo connections.

Changes:

  • Derives Accept-Language from each message’s metadata while preserving other send options and headers.
  • Removes backend-only mirroring while retaining the browser header allowlist.
  • Adds transport and CLI regression coverage and updates the language-preference guide.
File Description
docs/​test-servers.md Documents shared mirroring and adds a CLI example.
core/​mcp/​remote/​node/​server.ts Removes backend-only mirroring; retains Mcp-Param-* filtering.
core/​mcp/​node/​transport.ts Instantiates the language-mirroring transport.
core/​mcp/​node/​languageMirroringTransport.ts Adds per-send metadata-derived language headers.
core/​mcp/​acceptLanguage.ts Updates comments to describe shared transport ownership.
clients/​web/​src/​test/​integration/​mcp/​remote/​server-extra-coverage.test.ts Removes tests for the deleted backend helper.
clients/​web/​src/​test/​integration/​mcp/​localized-greeting-fixture.test.ts Replaces the known-gap assertion with successful direct mirroring.
clients/​web/​src/​test/​core/​mcp/​node/​languageMirroringTransport.test.ts Tests exact mirroring, configured-header replacement, and header preservation.
clients/​cli/​__tests__/​metadata.test.ts Verifies the real CLI sends the exact language header.

Review effort: Balanced

@cliffhall

Copy link
Copy Markdown
Member Author

Copilot review loop closed: round 1 came back clean (approval recommended, no inline comments, nothing suppressed).

@cliffhall
cliffhall merged commit a7eaab0 into v2/main Nov 18, 2026
12 checks passed
@cliffhall
cliffhall deleted the v2/feat/2987-direct-accept-language branch November 18, 2026 06:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

v2 Issues and PRs for v2

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Mirror SEP-2792 _meta acceptLanguage to Accept-Language on CLI and TUI connections

2 participants