Skip to content

fix: omit oauth scopes when authorization server advertises scopes_supported: [] - #240

Open
wolever-gl wants to merge 1 commit into
geelen:mainfrom
wolever-gl:fix/oauth-empty-scopes-supported
Open

fix: omit oauth scopes when authorization server advertises scopes_supported: []#240
wolever-gl wants to merge 1 commit into
geelen:mainfrom
wolever-gl:fix/oauth-empty-scopes-supported

Conversation

@wolever-gl

@wolever-gl wolever-gl commented Mar 20, 2026

Copy link
Copy Markdown

Problem

OAuth authorize fails with invalid_scope for servers whose AS metadata includes "scopes_supported": []. The client was falling through to a hardcoded openid email profile default, which those servers do not support.

This bug was uncovered trying to connect to Datadog's MCP, which advertises "scopes_supported": [].

The fix has been tested against Datadog's MCP:

$ git checkout main
$ npm run build
$ node dist/client.js https://mcp.datadoghq.com/api/unstable/mcp-server/mcp
# ^-- does not work - datadog reports "<client> will have no permissions"

$ git checkout fix/oauth-empty-scopes-supported
$ npm run build
$ node dist/client.js https://mcp.datadoghq.com/api/unstable/mcp-server/mcp
# ^-- works correctly

Fix

  • If authorizationServerMetadata.scopes_supported is present and empty, treat that as no scopes and return an empty effective scope.
  • Only set the scope query param on the authorize URL and only include scope in dynamic client metadata when the effective scope is non-empty.
  • When metadata omits scopes_supported entirely, keep the existing OIDC fallback so behavior stays the same for unknown servers.

Tests

  • Assert client metadata omits scope when scopes_supported: []
  • Assert authorize URL has no scope param in that case

Refs: RFC 6749 §3.3 (omitted scope → server default or error); servers advertising an empty supported list should not receive unrelated OIDC scopes.

Made with Cursor

Authorization servers that advertise scopes_supported: [] (e.g. Datadog MCP)
reject authorize requests that include openid/email/profile defaults with
invalid_scope.

- Treat empty scopes_supported as explicit 'no scopes' and return ''
- Only add scope to authorize URL and client metadata when non-empty
- Keep OIDC fallback when metadata omits scopes_supported entirely

Made-with: Cursor
@wolever-gl wolever-gl changed the title fix(oauth): omit scope when authorization server advertises scopes_supported: [] fix: omit oauth scopes when authorization server advertises scopes_supported: [] Mar 20, 2026
@forty

forty commented Jun 15, 2026

Copy link
Copy Markdown

Hello @geelen , would it be possible to have this one merged? I think it's fairly straightfoward and it does fix some "big" MCP (like DataDog's)
Thanks!

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.

2 participants