Skip to content

fix(auth): allow requested scopes without registered scope#3149

Draft
pradeep-ramola wants to merge 1 commit into
modelcontextprotocol:mainfrom
pradeep-ramola:pradeep-ramola/validate-scope-none
Draft

fix(auth): allow requested scopes without registered scope#3149
pradeep-ramola wants to merge 1 commit into
modelcontextprotocol:mainfrom
pradeep-ramola:pradeep-ramola/validate-scope-none

Conversation

@pradeep-ramola

Copy link
Copy Markdown

Fixes #2216

Summary

Updates OAuthClientMetadata.validate_scope() so a registered client with scope=None does not reject requested authorization scopes.

When the registration response omits scope, the SDK treats that as no client-specific scope restriction instead of converting it to an empty allowed-scope list. Explicit registered scopes are still enforced.

Tests

.\.venv\Scripts\python.exe -m pytest tests/shared/test_auth.py -q
.\.venv\Scripts\python.exe -m ruff check src/mcp/shared/auth.py tests/shared/test_auth.py
.\.venv\Scripts\python.exe -m ruff format --check src/mcp/shared/auth.py tests/shared/test_auth.py
git diff --check

Notes

Added regression coverage for:

  • no requested scope returns None
  • registered scopes are accepted
  • unregistered scopes are still rejected
  • omitted registered scope allows requested scopes

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.

Bug: validate_scope rejects client scopes when required scopes in None

1 participant