Skip to content

Document ClientOAuthOptions.ScopeSelector usage #1867

Description

@z0rimo

ClientOAuthOptions.ScopeSelector is a public API for customizing the OAuth scopes selected after the server-provided scope information has been resolved. It was added in #1596, but I couldn't find any conceptual documentation showing when or how to use it.

The XML documentation describes the API behavior, but users browsing the SDK documentation may not discover that ScopeSelector can be used to:

  • filter scopes advertised by the server;
  • append client-specific scopes when needed;
  • return null or an empty sequence to omit the scope parameter entirely.

A small conceptual example would make this behavior easier to discover, for example:

var oauthOptions = new ClientOAuthOptions
{
    ScopeSelector = scopes =>
        scopes?.Where(scope => scope is "mcp:tools" or "mcp:resources")
};

This would be especially useful alongside the existing OAuth guidance, where users may otherwise assume that Scopes is the only way to influence the requested scope set.

I also checked the currently open OAuth documentation work in #1801, which does not appear to cover ScopeSelector.

I'd be happy to submit a focused documentation PR for this and keep the change narrowly scoped to client-side scope selection, placing it wherever best fits the documentation structure.

Note

This issue was prepared with AI assistance.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions