Repository navigation
feat(core): mirror SEP-2792 acceptLanguage on every Streamable HTTP send - #2990
Merged
Merged
Conversation
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]>
There was a problem hiding this comment.
🟢 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-Languagefrom 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
Member
Author
|
Copilot review loop closed: round 1 came back clean (approval recommended, no inline comments, nothing suppressed). |
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.
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
fetchsent its defaultAccept-Language: *beside the_metavalue. A strict server rejects that pair asHeaderMismatch.core/mcp/node/languageMirroringTransport.ts(new): aStreamableHTTPClientTransportsubclass whosesendderivesAccept-Languagefrom the message's ownparams._meta["io.modelcontextprotocol/acceptLanguage"], usingacceptLanguageHeaderForfrom Support SEP-2792 language preferences in Web Inspector #2979, and passes it through the SDK's per-sendheadersoption. Overridingsendcovers every outbound message, SDK-internal ones included. The SDK applies per-send headers afterrequestInit.headers, so the mirror replaces a configuredAccept-Language. Per-send headers the caller passed in, such asMcp-Param-*, are kept.core/mcp/node/transport.ts:createTransportNodebuilds 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-onlyupstreamSendHeadersnow that the transport does the work. The backend's per-send header allowlist is back toMcp-Param-*alone, and the language header is still never taken from the browser.docs/test-servers.mddrops the "CLI and TUI do not mirror yet" warning and adds a CLI example. I ran that example against the showcase server: it answeredHallo, world!, with_metaand the header bothde-AT, de;q=0.9.Tests
clients/web/src/test/core/mcp/node/languageMirroringTransport.test.ts, throughcreateTransportNode: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.npm run local:gatepasses. No screenshots: nothing in the UI changed.🤖 Generated with Claude Code