Skip to content

fix(mcp): propagate scopes through dynamic client registration - #3881

Draft
aheritier wants to merge 1 commit into
mainfrom
fix/3879-dcr-scope-propagation
Draft

fix(mcp): propagate scopes through dynamic client registration#3881
aheritier wants to merge 1 commit into
mainfrom
fix/3879-dcr-scope-propagation

Conversation

@aheritier

Copy link
Copy Markdown
Collaborator

Summary

Fixes #3879

Successful dynamic client registration (DCR) dropped configured or discovered scopes, causing scope mismatches for Atlassian integrations.

Implementation

  • Applies selector precedence: configured > challenge > PRM > omitted.
  • Propagates the selected scopes exactly through DCR, authorization, and RequestedScopes.
  • Adds a quote-aware parser for multi-challenge WWW-Authenticate headers.
  • Normalizes configuration and validates it during preflight.
  • Keeps explicit and prompt-based paths unchanged; they are not widened.

Testing

Focused and full test suites, lint, build, and race coverage were run.

Follow-up and merge gates

  • Catalog owner decision is required.
  • Add/update documentation for re-consent behavior and include a release note.
  • Standalone debug-login scope support is separate planned work and is not included here.

@aheritier aheritier added area/mcp MCP protocol, MCP tool servers, integration kind/fix PR fixes a bug (maps to fix:). Use on PRs only. status/do-not-merge labels Aug 1, 2026
@aheritier
aheritier force-pushed the fix/3879-dcr-scope-propagation branch from 110a591 to 3560481 Compare August 8, 2026 21:37
@aheritier
aheritier force-pushed the fix/3879-dcr-scope-propagation branch from 83030ee to 0d3fe04 Compare August 10, 2026 20:28
Carry explicitly configured or provider-advertised scopes through
DCR-based remote MCP OAuth so registration, authorization, and stored
token bookkeeping stay consistent. Adds quote-aware, multi-challenge-
continuing WWW-Authenticate parsing, normalizes configured scopes the
same way on both the DCR-selection and preflight-coverage sides to
avoid a reauth loop, and exercises every resolveClientCredentials
branch (explicit client, prompt fallback, successful DCR) with
end-to-end scope equality across the registration body, authorize URL,
and RequestedScopes.

Also covers the Docker MCP Catalog's on-demand toolset
(pkg/tools/builtin/mcpcatalog), which always constructs its inner
mcp.Toolset with a nil *latest.RemoteOAuthConfig: a new httptest
fixture drives enable_remote_mcp_server through a real, unstubbed
Start() and proves that same nil-config product path reaches a
successful dynamic client registration carrying the challenge/PRM
scope fallback, and then the authorize URL and stored token's
RequestedScopes bookkeeping, without panicking.

Windows test fixture coverage: setupFakeBrowserOpener and
setupFakeCatalogBrowserOpener shim only the open/xdg-open binaries via
a #!/bin/sh script on PATH, but pkg/browser launches rundll32 on
Windows instead, so the shim never intercepts it -- the real launcher
runs, no URL is captured, and the polling read times out while holding
interactiveOAuthMu, wedging later interactive-OAuth tests in the same
run. Skip both helpers on Windows before any mutex-touching setup, and
fix their comments, which falsely claimed the shim was host-independent.
@aheritier
aheritier force-pushed the fix/3879-dcr-scope-propagation branch from 0d3fe04 to 942074e Compare August 10, 2026 21:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/mcp MCP protocol, MCP tool servers, integration kind/fix PR fixes a bug (maps to fix:). Use on PRs only.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: propagate OAuth scopes in successful DCR MCP flows

1 participant