-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Description
Is your feature request related to a problem? Please describe.
Enhancing the OAuthClientProvider
class to support the client_credentials
OAuth flow will allow the MCP machine client to retrieve tokens from the authorization server. This is necessary for machine-to-machine authentication scenarios where no user context is available.
Describe the solution you'd like
It would be helpful if OAuthClientProvider
provided a new method to specify the authorization flow. The client/auth.ts::authInternal
method could then use this to select the appropriate flow. I believe that most of OAuthClientProvider's existing methods would still be necessary even when using the client_credentials
flow.
Describe alternatives you've considered
Currently, there is no way to use OAuthClientProvider
to retrieve a token using the client_credentials
flow. As a result, we have to manually retrieve the token before instantiating the StreamableHTTPClientTransport
class. Unfortunately, this also requires implementing all the authentication-related steps ourselves (metadata discovery, client registration, etc.).
Additional context
There is a similar issue for the python sdk: modelcontextprotocol/python-sdk#709