Skip to content

fix: handle None required_scopes in validate_scope#2368

Open
IgnazioDS wants to merge 1 commit intomodelcontextprotocol:mainfrom
IgnazioDS:fix/validate-scope-none-handling
Open

fix: handle None required_scopes in validate_scope#2368
IgnazioDS wants to merge 1 commit intomodelcontextprotocol:mainfrom
IgnazioDS:fix/validate-scope-none-handling

Conversation

@IgnazioDS
Copy link
Copy Markdown

Summary

  • Add early return in validate_scope() when self.scope is None
  • None means "no scope restrictions" per the OAuth spec, so all client-requested scopes should be accepted
  • Previously, None was treated as an empty allowed set, rejecting all scopes with InvalidScopeError

Problem

When an MCP server does not specify required scopes (None), clients cannot authenticate because all requested scopes are rejected. See #2216.

Test plan

  • Verify validate_scope("read write admin") accepts all scopes when scope=None
  • Verify validate_scope("read write") still rejects unauthorized scopes when scope="read"
  • Verify validate_scope(None) returns None
  • Verify validate_scope("read write") accepts when scope="read write"

Fixes #2216

When required_scopes is None (meaning no restrictions), skip
validation entirely instead of treating it as an empty set of
allowed scopes which rejects all client-requested scopes.

Github-Issue: modelcontextprotocol#2216
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