fix: add Accept-Encoding: identity to OAuth discovery fetch requests - #279
Open
clouatre wants to merge 1 commit into
Open
fix: add Accept-Encoding: identity to OAuth discovery fetch requests#279clouatre wants to merge 1 commit into
clouatre wants to merge 1 commit into
Conversation
Node built-in fetch (undici) sends Accept-Encoding: gzip, deflate, br by default. Servers that honor this (e.g. mcp.atlassian.com) return gzip-compressed bodies. Both fetchAuthorizationServerMetadata and fetchProtectedResourceMetadata call response.json() on the raw bytes, causing a fatal SyntaxError before any OAuth flow begins. Add Accept-Encoding: identity to suppress compression on these two discovery requests. The --header CLI arg does not help here because custom headers are only applied to MCP transport requests, not to the upstream OAuth discovery fetch. Fixes geelen#276 Signed-off-by: Hugues Clouâtre <hugues@linux.com>
commit: |
Contributor
Author
|
The e2e failure is a pre-existing flakiness unrelated to this change: the test asserts |
This was referenced Jun 3, 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
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.
Summary
On Node 26,
fetch(undici) sendsAccept-Encoding: gzip, deflate, brby default.fetchAuthorizationServerMetadataandfetchProtectedResourceMetadatasetAccept: application/jsonbut notAccept-Encoding, so Cloudflare-fronted servers (e.g.mcp.atlassian.com) return gzip-compressed bodies thatresponse.json()cannot parse. This crashesmcp-remoteat OAuth discovery before the transport is initialized.Related Issues
Changes
'Accept-Encoding': 'identity'tofetch()headers infetchAuthorizationServerMetadata(src/lib/authorization-server-metadata.ts)'Accept-Encoding': 'identity'tofetch()headers infetchProtectedResourceMetadata(src/lib/protected-resource-metadata.ts)Test Plan
pnpm test:unit(103 tests, all pass)pnpm check(clean)pnpm build(clean)mcp.atlassian.comfor all three cases (noAccept-Encoding, gzip, identity)Verification Checklist
pnpm test:unitpnpm checkpnpm build