feat(client): add initial access token support for Dynamic Client Registration#1874
Open
JosephDoUrden wants to merge 1 commit intomodelcontextprotocol:mainfrom
Open
Conversation
…istration Add optional `dcrRegistrationAccessToken()` method to `OAuthClientProvider` interface, enabling OAuth 2.0 Dynamic Client Registration with initial access tokens per RFC 7591 Section 3. When the authorization server requires pre-authorisation for client registration, providers can implement this method to supply a Bearer token that is included in the DCR request. When not implemented, open registration continues as before (fully backward compatible). The token resolution is kept in the provider (not the SDK) as it is per-authorisation-server, following maintainer guidance from modelcontextprotocol#773. Closes modelcontextprotocol#772
|
@modelcontextprotocol/client
@modelcontextprotocol/server
@modelcontextprotocol/express
@modelcontextprotocol/fastify
@modelcontextprotocol/hono
@modelcontextprotocol/node
commit: |
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.
Summary
Add support for OAuth 2.0 Dynamic Client Registration initial access tokens (RFC 7591 Section 3), enabling enterprise deployments that require pre-authorisation for client registration.
dcrRegistrationAccessToken()method toOAuthClientProviderinterfaceregisterClient()includes anAuthorization: Bearer <token>header in the DCR requestundefined, open registration continues as before (fully backward compatible)Closes #772
Design decisions
Following maintainer feedback from the previous attempt (#773):
OAuthClientProvider.auth.tsonly.OAuthClientProvideris the right place to resolve per-server tokens, consistent with how other credentials are handled.Changes
packages/client/src/client/auth.ts:dcrRegistrationAccessToken?()toOAuthClientProviderinterfaceinitialAccessTokenparameter toregisterClient()auth()flow to call the provider method and pass the token toregisterClient()packages/client/test/client/auth.test.ts:Authorizationheader inclusion when token is providedAuthorizationheader when token is absentTest plan
pnpm --filter @modelcontextprotocol/client test)pnpm build:all)pnpm typecheck:all)pnpm lint:all)AI Disclosure
AI assistance (Claude) was used for issue research, reviewing the previous PR feedback, and code exploration. The implementation was written and reviewed by the author.