fix: preserve configured Authorization in external MCP passthrough#3177
Merged
walker-tx merged 3 commits intoJun 3, 2026
Conversation
External MCP tools with requires_oauth=true forwarded the gating OAuth token (presented to the local Gram MCP server) upstream as "Authorization: Bearer <token>", overwriting any Authorization header the user configured via env/user config in BuildHeaders. This broke setups where the local server is OAuth-guarded but the upstream MCP expects a static credential (e.g. "Basic ..."): the upstream rejected the forwarded gating token with 401. Forward the gating OAuth token only when no explicit Authorization was already set from config. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
🦋 Changeset detectedLatest commit: 87df9ec The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Collaborator
🚀 Preview Environment (PR #3177)Preview URL: https://pr-3177.dev.getgram.ai
Gram Preview Bot |
subomi
reviewed
Jun 3, 2026
subomi
approved these changes
Jun 3, 2026
Contributor
subomi
left a comment
There was a problem hiding this comment.
approved. with a non-blocking comment.
Address review nit: rename the case to "system config Authorization wins over oauth token" so it is explicit and parallel to the user config case. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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
External MCP tools with
requires_oauth=trueforwarded the gating OAuth token (the token presented to the local Gram MCP server) upstream asAuthorization: Bearer <token>, overwriting anyAuthorizationheader the user configured via env/user config inBuildHeaders(server/internal/externalmcp/config.go).This broke setups where the local server is OAuth-guarded but the upstream MCP expects a static credential (e.g.
Basic ...): the upstream rejected the forwarded gating token with401.Fix
Forward the gating OAuth token only when no explicit
Authorizationwas already set from config. Config-providedAuthorizationnow wins; the gating token remains the fallback when none is configured.Tests
Added two
TestBuildHeadersWithOAuthTokencases: config-provided and user-config-providedAuthorizationeach take precedence over the OAuth token.Resolves AIS-83.
🤖 Generated with Claude Code
Summary by cubic
Preserves the configured Authorization header in external MCP passthrough; only forwards the gating OAuth token if no Authorization is set. Prevents upstream 401s for MCPs that require static credentials (addresses AIS-83).
BuildHeadersinserver/internal/externalmcp/config.goto applyBearer <oauthToken>only when Authorization isn’t set by system or user config.server.Written for commit 87df9ec. Summary will update on new commits.