modelcontextprotocol / modelcontextprotocol/kotlin-sdk
Implement SEP-985: Align OAuth 2.0 Protected Resource Metadata with RFC 9728
Nobody has claimed this yet.
- Dominant language
- Kotlin
- Stars
- 1.5k
- Forks
- 248
- Avg merge
- 1d 20h
- Merged PRs (30d)
- 23
Description
Blocked by: #88
This is a tracking issue for implementing the updated Authorization spec behavior SEP-958
Summary
Update MCP authorization behavior so that clients first honor WWW-Authenticate when present, and fall back to well-known Protected Resource Metadata discovery when it is not.
Needs to implement:
-
Client behavior
- On
401 Unauthorizedresponses, parseWWW-Authenticateand, if present withresource_metadata, use that URL for protected resource metadata. - If the header is absent or missing
resource_metadata, fall back to probing/.well-known/oauth-protected-resource. - Implement the overall flow:
- Attempt the MCP request without a token.
- If a
401 Unauthorizedis received:- If
WWW-Authenticatewithresource_metadatais present, use it. - Otherwise, request
/.well-known/oauth-protected-resource.
- If
- On
-
Server behavior
- Servers SHOULD return
WWW-Authenticatewithresource_metadatawhen responding with401 Unauthorized, where feasible. - Maintain support for metadata discovery via
/.well-known/oauth-protected-resourcefor environments where header injection is not practical.
- Servers SHOULD return
-
Tests and validation
- Cover both paths: header-present and header-absent fallback.
- Validate interoperability with existing deployments that already use
WWW-Authenticate. - Add regression tests for incremental authorization flows that rely on
WWW-Authenticatechallenges (e.g. requests that require additional scopes).
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by resolving the dependency on issue #88, then locate the Kotlin client and server authorization handling for 401 responses and metadata discovery. Add coverage for WWW-Authenticate resource_metadata handling, the well-known fallback, and incremental authorization challenges; done means both discovery paths and existing deployments remain supported.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- kotlin
- Domain
- api, authentication
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100