fix: add Accept-Encoding: identity to OAuth discovery fetch requests - #277
Closed
clouatre wants to merge 1 commit into
Closed
fix: add Accept-Encoding: identity to OAuth discovery fetch requests#277clouatre 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
|
Closing -- submitted prematurely without proper review. |
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
Node's built-in
fetch(undici) sendsAccept-Encoding: gzip, deflate, brby default on every request. Servers that honor this header -- includingmcp.atlassian.com-- return gzip-compressed response bodies.fetchAuthorizationServerMetadataandfetchProtectedResourceMetadataboth callresponse.json()on the raw compressed bytes, causing a fatal crash before any OAuth flow begins:The
--headerCLI arg does not help here because custom headers are only applied to MCP transport requests, not to the upstream OAuth discovery fetches.Changes
src/lib/authorization-server-metadata.ts: addAccept-Encoding: identityto the discovery fetchsrc/lib/protected-resource-metadata.ts: same fix for consistencyTest plan
mcp-remote https://mcp.atlassian.com/v1/mcp --resource https://<org>.atlassian.net/proceeds past OAuth discovery on Node 18+Fixes #276