Skip to content

fix(auth): align OAuth metadata discovery ordering#887

Open
jstar0 wants to merge 1 commit into
modelcontextprotocol:mainfrom
jstar0:fix/oauth-metadata-path-append
Open

fix(auth): align OAuth metadata discovery ordering#887
jstar0 wants to merge 1 commit into
modelcontextprotocol:mainfrom
jstar0:fix/oauth-metadata-path-append

Conversation

@jstar0

@jstar0 jstar0 commented Jun 4, 2026

Copy link
Copy Markdown

Fixes #878.

Summary

  • align path-bearing authorization-server discovery with the MCP authorization spec / RFC 8414 ordering
  • keep OAuth authorization-server metadata discovery ahead of OpenID Connect fallback candidates
  • add regression coverage for both candidate ordering and a real client credentials discovery flow

Changes

For a resource URL such as https://example.com/mcp, the direct authorization-server discovery list is:

  • https://example.com/.well-known/oauth-authorization-server/mcp
  • https://example.com/.well-known/openid-configuration/mcp
  • https://example.com/mcp/.well-known/openid-configuration
  • https://example.com/.well-known/oauth-authorization-server

The first three entries match the path-bearing issuer ordering from the MCP authorization spec. The existing canonical OAuth fallback remains last.

The client credentials regression now serves metadata at the RFC 8414 path-inserted OAuth endpoint, so the test exercises the same URL form as the candidate builder.

Verification

cargo test -p rmcp --features auth generate_discovery_urls
cargo test -p rmcp --features auth --test test_client_credentials test_client_credentials_discovers_path_inserted_oauth_metadata
cargo test -p rmcp --features auth
cargo test --all-features
cargo fmt --all -- --check
cargo clippy -p rmcp --features auth --lib -- -D warnings
cargo clippy -p rmcp --features auth --test test_client_credentials -- -D warnings

@jstar0 jstar0 requested a review from a team as a code owner June 4, 2026 16:30
@github-actions github-actions Bot added T-test Testing related changes T-core Core library changes T-transport Transport layer changes labels Jun 4, 2026

@michaelneale michaelneale left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks @jstar0 from a brief reading of the spec: https://www.rfc-editor.org/info/rfc8414/#section-3.1 - then the tenant should be at the end, not before .well-known:

ie:

https://auth.example.com/.well-known/oauth-authorization-server/tenant1

not so much:

https://auth.example.com/tenant1/.well-known/oauth-authorization-server

I think, but otherwise looking good.

@jstar0 jstar0 force-pushed the fix/oauth-metadata-path-append branch from b387a7a to 2472e16 Compare June 9, 2026 14:13
@jstar0 jstar0 changed the title fix(auth): discover path-appended OAuth metadata fix(auth): align OAuth metadata discovery ordering Jun 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

T-core Core library changes T-test Testing related changes T-transport Transport layer changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement SEP-2351: RFC 8414 well-known URI suffix handling

2 participants