ruby-sdk/lib/mcp/client/oauth
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Koichi ITO 29e8d3f2b9 Let the client_credentials and jwt-bearer grants run without Protected Resource Metadata
## Motivation and Context

When a server publishes no Protected Resource Metadata, discovery takes the legacy 2025-03-26 path and `prm` is `nil`.
The authorization-code branch of `run!` allowed for that by passing `prm || {}` to `resolve_scope`,
but `run_client_credentials!` and `run_jwt_bearer!` passed `prm` as is, and `resolve_scope` then
called `prm["scopes_supported"]` on `nil`. Without a non-empty challenge scope, a `ClientCredentialsProvider` or
`CrossAppAccessProvider` pointed at such a server therefore failed with `NoMethodError` after discovery and before
the token request or the ID-JAG callback, instead of running its grant against the legacy authorization base
the way `Provider` does.

`resolve_scope` now treats a missing PRM as advertising no scopes, so the challenge scope or the provider's own scope applies,
and the authorization-code branch passes `prm` unchanged like the other two.

## How Has This Been Tested?

New tests in `test/mcp/client/oauth/flow_test.rb` run the `client_credentials` grant against a PRM-less server with metadata
at the origin, checking the provider's scope, the `resource`, and the recorded issuer, and run the `jwt-bearer` grant against
a server without any metadata, checking the default token endpoint, the assertion audience, the `resource`, and the recorded
issuer. Both raise `NoMethodError` against the previous library.

## Breaking Changes

None.
2026-09-17 19:05:51 +09:00
..
authorization_request.rb Let the embedding application refuse an authorization request 2026-08-31 02:33:10 +09:00
bounded_body.rb Bound OAuth response bodies in the client 2026-08-16 03:29:15 +09:00
client_credentials_provider.rb Let the embedding application refuse an authorization request 2026-08-31 02:33:10 +09:00
cross_app_access_provider.rb Let the embedding application refuse an authorization request 2026-08-31 02:33:10 +09:00
discovery.rb Restrict OAuth Discovery URL Destinations 2026-08-13 14:54:27 +09:00
flow.rb Let the client_credentials and jwt-bearer grants run without Protected Resource Metadata 2026-09-17 19:05:51 +09:00
id_jag_token_exchange.rb Bound OAuth response bodies in the client 2026-08-16 03:29:15 +09:00
in_memory_storage.rb Bind Stored Client Credentials to the Authorization Server Issuer per SEP-2352 2026-07-05 01:12:08 +09:00
jwt_client_assertion.rb Support private_key_jwt Client Authentication for the client_credentials Grant 2026-06-28 20:59:37 +09:00
pkce.rb Add OAuth 2.1 client support for MCP authorization flow 2026-05-17 00:48:41 +09:00
provider.rb Let the embedding application refuse an authorization request 2026-08-31 02:33:10 +09:00
storage_backed_provider.rb Let the embedding application refuse an authorization request 2026-08-31 02:33:10 +09:00