Skip to content

Respect configured OAuth scopes#1581

Closed
pragnyanramtha wants to merge 1 commit into
modelcontextprotocol:mainfrom
pragnyanramtha:codex/restore-configured-oauth-scopes
Closed

Respect configured OAuth scopes#1581
pragnyanramtha wants to merge 1 commit into
modelcontextprotocol:mainfrom
pragnyanramtha:codex/restore-configured-oauth-scopes

Conversation

@pragnyanramtha
Copy link
Copy Markdown

Summary

Fixes #1236.

ClientOAuthOptions.Scopes is documented as overriding scopes advertised by protected resource metadata, but ClientOAuthProvider only used configured scopes after scopes_supported was absent. This updates scope selection to keep challenge-provided WWW-Authenticate scopes authoritative, then prefer configured scopes, then fall back to protected resource metadata.

Validation

  • dotnet test tests/ModelContextProtocol.AspNetCore.Tests/ModelContextProtocol.AspNetCore.Tests.csproj -f net10.0 --filter "FullyQualifiedName~AuthorizationFlow_Uses" --logger "console;verbosity=normal"
  • dotnet test tests/ModelContextProtocol.AspNetCore.Tests/ModelContextProtocol.AspNetCore.Tests.csproj -f net10.0 --no-build --filter "FullyQualifiedName~AuthorizationFlow_Uses" --logger "console;verbosity=minimal"
  • dotnet format whitespace ModelContextProtocol.slnx --verify-no-changes --include src/ModelContextProtocol.Core/Authentication/ClientOAuthProvider.cs tests/ModelContextProtocol.AspNetCore.Tests/OAuth/AuthTests.cs
  • git diff --check

Notes

Validation was focused on the OAuth scope-selection regression and adjacent scope-priority tests. Full multi-target test coverage was not run locally.

@pragnyanramtha pragnyanramtha marked this pull request as ready for review May 16, 2026 22:25
Copilot AI review requested due to automatic review settings May 16, 2026 22:25
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@mikekistler mikekistler requested a review from halter73 May 17, 2026 13:27
@halter73
Copy link
Copy Markdown
Contributor

Thanks for picking this up, but I'm going to close this in favor of consolidating discussion on #1238. As written, it has the same issue: it makes ClientOAuthOptions.Scopes override PRM scopes_supported, which diverges from the MCP spec's Scope Selection Strategy and from the TS/Python SDKs, both of which treat client-configured scopes as a fallback only. The primary motivating scenario (adding offline_access) is also now handled automatically by #1479.

@halter73 halter73 closed this May 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Specified ClientOAuthOptions.Scopes are ignored

4 participants