Skip to content

docs(client): clarify that custom JWT claims do not override standard claims#1915

Open
shaun0927 wants to merge 1 commit intomodelcontextprotocol:mainfrom
shaun0927:docs/custom-claims-standard-claims
Open

docs(client): clarify that custom JWT claims do not override standard claims#1915
shaun0927 wants to merge 1 commit intomodelcontextprotocol:mainfrom
shaun0927:docs/custom-claims-standard-claims

Conversation

@shaun0927
Copy link
Copy Markdown

Summary

  • clarify that PrivateKeyJwtProviderOptions.claims adds custom claims but does not override reserved standard JWT claims
  • add a regression test proving the current runtime behavior

Closes #1914

Motivation and Context

packages/client/src/client/authExtensions.ts currently says overlapping custom claims take precedence over the standard JWT claims.

The implementation does include additional custom claims, but it then re-applies the reserved claims via SignJWT setters (setIssuer, setSubject, setAudience, setIssuedAt, setExpirationTime, setJti). In practice, overlapping custom values are not preserved.

This PR keeps the runtime behavior unchanged and narrows the fix to docs + tests so the published contract matches the shipped behavior.

How Has This Been Tested?

  • corepack pnpm --filter @modelcontextprotocol/client test -- --run packages/client/test/client/authExtensions.test.ts
  • corepack pnpm --filter @modelcontextprotocol/client typecheck
  • corepack pnpm --filter @modelcontextprotocol/client lint

Breaking Changes

None.

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 or updated documentation as needed

The client auth helpers advertise overlapping custom claims as taking precedence over reserved JWT claims, but the implementation re-applies the reserved claims through SignJWT setters. This change narrows the scope to documentation and a focused regression test so the published contract matches shipped behavior without expanding API surface or changing runtime semantics.

Constraint: Upstream review guidance prefers small, spec-aware fixes backed by concrete evidence
Rejected: Change runtime behavior so custom claims override reserved claims | would alter shipped semantics and widen scope beyond a docs fix
Confidence: high
Scope-risk: narrow
Reversibility: clean
Directive: Keep reserved JWT claims authoritative unless maintainers explicitly decide to change runtime behavior in a separate design discussion
Tested: packages/client/authExtensions test suite; client package typecheck; client package lint/prettier
Not-tested: full monorepo test matrix
@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Apr 16, 2026

⚠️ No Changeset found

Latest commit: e99fb6c

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@shaun0927 shaun0927 requested a review from a team as a code owner April 16, 2026 15:30
@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Apr 16, 2026

Open in StackBlitz

@modelcontextprotocol/client

npm i https://pkg.pr.new/@modelcontextprotocol/client@1915

@modelcontextprotocol/server

npm i https://pkg.pr.new/@modelcontextprotocol/server@1915

@modelcontextprotocol/express

npm i https://pkg.pr.new/@modelcontextprotocol/express@1915

@modelcontextprotocol/fastify

npm i https://pkg.pr.new/@modelcontextprotocol/fastify@1915

@modelcontextprotocol/hono

npm i https://pkg.pr.new/@modelcontextprotocol/hono@1915

@modelcontextprotocol/node

npm i https://pkg.pr.new/@modelcontextprotocol/node@1915

commit: e99fb6c

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.

authExtensions docs say custom claims override reserved JWT claims, but implementation keeps reserved claims authoritative

1 participant