Skip to content

Conversation

Palaxx
Copy link

@Palaxx Palaxx commented Sep 26, 2025

The PR adds authFlow a new optional method to the OAuthClientProvider interface.
The authFlow method will be used by the authInternal to select the appropriate flow to be executed. In case that the provider does not implement the new method the default value will be authorization_code.

When client/auth.ts::authInternal returns client_credentials a call to /token endpoint will be made with client_credentials grant type.

This should resolve #899

Motivation and Context

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.

How Has This Been Tested?

I wrote some unit tests, trying to follow the code style already present in the codebase.
I also manually update, but not commited, the simpleOAuthClient.ts to perform a client_crendential flow using WorkOs as AuthorizationServer

Breaking Changes

The PR should not bring breaking changes, authInternal method by default will use the old "authorization_flow" flow.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed

Additional context

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.

OAuthClientProvider should support the client_credentials authorization flow
1 participant