ClientOAuthProvider.Scopes have priority again (#1236)#1238
ClientOAuthProvider.Scopes have priority again (#1236)#1238halllo wants to merge 1 commit intomodelcontextprotocol:mainfrom
Conversation
|
I think we should update the doc comments to indicate that The November version of the MCP spec added a "Scope Selection Strategy" we now implement.
Do we know what the other SDK's do here? |
|
I asked Copilot what the TS and Python SDK do, and it appears the client-developer-provided scopes are only used as a fallback.
@halllo Can you explain the scenario where you need to override the scopes explicitly requested by the MCP server? Is this a scenario that works with any clients that do not use the MCP C# SDK? |
|
That is very interesting, because I find it counter-intuitive that the values I explicitly provide are not used. Alternatively additional integration points (e.g. custom scope selection) would also help me to have more control over what scopes are actually used. |
I adjusted the priority of scope determination. Scopes specified via
ClientOAuthOptions.Scopeshave priority over scopes from PRM.Motivation and Context
When the client specifies Scopes via the ClientOAuthOptions, these scopes are used before the scopes of the PRM, just as the xml comment states
For example this is needed if a client only supports a subset of PRM scopes or wants to add the
offline_accessscope.How Has This Been Tested?
I added test method.
Breaking Changes
No. Unless they unexpectedly rely on
ClientOAuthOptions.Scopesnot having an effect in the presence of PRM scopes.Types of changes
Checklist
Additional context
This addresses #1236