Skip to content

Conversation

@abdebek
Copy link
Owner

@abdebek abdebek commented Jan 17, 2026

feat: add auth scope requirement and validation

Introduces the basic features required for compliance with the https://modelcontextprotocol.io/specification/2025-11-25/basic/authorization, adding JWT token validation, scope enforcement, and RFC 8707 resource parameter support.

  • Add JWT token validation with expiration, audience, and scope checking (opt-in)
  • Add 403 Forbidden response with insufficient_scope error for valid tokens lacking required scopes
  • Add RFC 8707 resource parameter to all OAuth token requests
  • Add per-tool scope requirements with wildcard pattern matching
  • Integrate with existing OpenAPI OAuth configurations - scopes from OpenAPI specs are automatically
    enforced
  • Refactor OAuth form data building with FormUrlEncoded helper

- Introduced `ScopeRequirement` class to define scope requirements for tools or endpoints, including pattern matching and scope validation.
- Added `ScopeRequirementStore` to manage multiple `ScopeRequirement` instances and validate scopes against them.
- Created `TokenValidationOptions` to configure token validation behavior, including default required scopes and audience validation.
- Implemented `TokenValidationResult` to encapsulate the result of token validation, including validity status and error details.
- Developed unit tests for `JwtAccessTokenValidator`, `ScopeRequirement`, and `ScopeRequirementStore` to ensure correct functionality and validation logic.
- Enhanced OAuth authentication classes to support resource parameters in authorization requests.
@abdebek abdebek merged commit c67017f into main Jan 18, 2026
1 check passed
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