Allow issuer-only OAuth metadata for PRM helper - #2652
Conversation
🦋 Changeset detectedLatest commit: 2bebaca The changes in this PR will be included in the next version bump. Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
@modelcontextprotocol/client
@modelcontextprotocol/codemod
@modelcontextprotocol/core
@modelcontextprotocol/server
@modelcontextprotocol/server-legacy
@modelcontextprotocol/express
@modelcontextprotocol/fastify
@modelcontextprotocol/hono
@modelcontextprotocol/node
commit: |
There was a problem hiding this comment.
Pull request overview
This PR relaxes the input contract for server-side OAuth discovery helpers so callers that only need RFC 9728 Protected Resource Metadata (PRM) can provide just an Authorization Server issuer (instead of a full RFC 8414 AS metadata document), while keeping the full AS metadata requirement for the AS passthrough response helper.
Changes:
- Introduces
OAuthProtectedResourceMetadataOptionsand updatesbuildOAuthProtectedResourceMetadatato accept issuer-onlyoauthMetadata(viaPick<OAuthMetadata, 'issuer'>). - Keeps
AuthMetadataOptionsforoauthMetadataResponse, requiring full RFC 8414OAuthMetadata. - Adds regression coverage for issuer-only PRM construction and exports the new options type; includes a patch changeset.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| packages/server/src/server/middleware/oauthMetadata.ts | Splits options types so PRM building can be configured with issuer-only metadata while preserving full metadata for AS passthrough responses. |
| packages/server/src/index.ts | Exports the new OAuthProtectedResourceMetadataOptions type from the server package entrypoint. |
| packages/server/test/server/oauthMetadata.test.ts | Adds a test asserting buildOAuthProtectedResourceMetadata works with issuer-only options. |
| .changeset/pretty-plums-grab.md | Patch changeset documenting the issuer-only PRM options support. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| * issuer before any request arrives. | ||
| */ | ||
| export function buildOAuthProtectedResourceMetadata(options: AuthMetadataOptions): OAuthProtectedResourceMetadata { | ||
| export function buildOAuthProtectedResourceMetadata(options: OAuthProtectedResourceMetadataOptions): OAuthProtectedResourceMetadata { |
Closes #2623
Summary
OAuthProtectedResourceMetadataOptionsforbuildOAuthProtectedResourceMetadataissueroauthMetadataResponseon the fullAuthMetadataOptionscontract because it serves AS metadata verbatimValidation
pnpm --filter @modelcontextprotocol/server exec vitest run test/server/oauthMetadata.test.tspnpm --filter @modelcontextprotocol/server typecheckpnpm --filter @modelcontextprotocol/server lintpnpm --filter @modelcontextprotocol/server buildpnpm --filter @modelcontextprotocol/express typecheckpnpm --filter @modelcontextprotocol/express exec vitest run test/auth/resourceServer.test.tsNotes
A full lifecycle-script install on this dev box falls back to compiling
better-sqlite3because the prebuilt binary requires a newer glibc; the local compiler then rejects-std=c++20. I installed dependencies withpnpm install --ignore-scriptsand ran the package-level checks above, which cover the changed server and Express metadata surfaces.