feat(auth): support OAuth 2.0 client_credentials grant type#1231
Open
MukundaKatta wants to merge 1 commit intomodelcontextprotocol:mainfrom
Open
feat(auth): support OAuth 2.0 client_credentials grant type#1231MukundaKatta wants to merge 1 commit intomodelcontextprotocol:mainfrom
MukundaKatta wants to merge 1 commit intomodelcontextprotocol:mainfrom
Conversation
Add a Client Credentials tab to the AuthDebugger so MCP servers secured behind an API gateway with M2M credentials can be inspected without manually pasting a Bearer token. Users provide a token endpoint, client ID, client secret, and optional scope; tokens are stored via the existing DebugInspectorOAuthClientProvider so the rest of the stack picks them up unchanged. The new helper exchangeClientCredentials is a small, fetchFn-pluggable RFC 6749 4.4 token request, so it works through the inspector proxy and is unit-testable. The existing authorization_code flow is unchanged. Closes modelcontextprotocol#1225
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1225
Why
MCP servers fronted by an API gateway with M2M credentials currently require users to manually obtain a Bearer token outside the inspector and paste it into a custom header. The issue asks for native
client_credentialssupport so the inspector can do this exchange itself.What
client/src/lib/clientCredentialsAuth.tsexporting:buildClientCredentialsRequest()- pure builder for the RFC 6749 section 4.4 token request (HTTP Basic by default, body fallback, optional scope, optional RFC 8707resource).exchangeClientCredentials()- performs the POST against the token endpoint, surfaces OAutherror/error_descriptionon failure, returns parsedOAuthTokens.AuthDebuggerto expose two tabs: Authorization Code (existing, unchanged behaviour) and Client Credentials (new). The new tab renders fields for token endpoint, client ID, client secret, optional scope, and a select forBasicvsbodyclient authentication.DebugInspectorOAuthClientProvider, so the rest of the connection / proxy stack picks them up unchanged. The proxyfetchFnis reused too, so the request goes through the inspector proxy when one is configured (avoids browser CORS on the auth server's token endpoint).Tested
client/src/lib/__tests__/clientCredentialsAuth.test.ts:fetchinvalid_client: secret rejected)AuthDebuggertests remain valid: the default tab isauthorization_code, so all previously-asserted buttons (Guided OAuth Flow,Quick OAuth Flow,Clear OAuth State,ContinuefromOAuthFlowProgress) are still rendered.Manual verification (suggested for reviewers): point the inspector at any MCP server behind an OAuth 2.0 client_credentials gateway (Auth0 M2M, Okta service apps, Keycloak service accounts, etc.), open Authentication Settings -> Client Credentials, fill in token endpoint / client id / secret / optional scope, click "Request Token", confirm the access token is fetched and used by subsequent requests without any header copy/paste.