Skip to content

OpenIdProviderDiscoveryMetadataSchema strips revocation_endpoint, so clients can't revoke against OIDC-only authorization servers #3213

Open

Description

@gerardcastell

Summary

When authorization server metadata comes from OpenID Connect discovery, parsing it with OpenIdProviderDiscoveryMetadataSchema silently drops revocation_endpoint, along with any other RFC 8414 field that isn't declared. A client that later looks for revocation_endpoint concludes the server doesn't support revocation, even though the discovery document lists it.

Where

src/shared/auth.ts in @modelcontextprotocol/sdk 1.32.2 (with zod 4.6.7):

export const OpenIdProviderDiscoveryMetadataSchema = z.object({
    ...OpenIdProviderMetadataSchema.shape,
    ...OAuthMetadataSchema.pick({
        code_challenge_methods_supported: true
    }).shape
});
  • OpenIdProviderMetadataSchema is a z.looseObject, but spreading .shape into a plain z.object drops the loose behaviour. In zod v4, unknown keys are stripped.
  • OpenIdProviderMetadataSchema doesn't declare revocation_endpoint.
  • The only OAuth metadata field picked in is code_challenge_methods_supported.
  • So the parsed result never contains revocation_endpoint.

Impact

Some authorization servers publish metadata only through OpenID discovery and return an error for the RFC 8414 paths. Amazon Cognito is one. Against those servers, clients built on the SDK never revoke on logout.

We see this in Claude Code 2.1.328: claude mcp logout <server> deletes the local credentials but logs Server does not support token revocation, and no revoke request reaches the server. The discovery document does list revocation_endpoint.

By contrast, anthropics/claude-code#105134 reports that logout does send revoke requests for servers that serve RFC 8414 metadata. That fits this being specific to the OpenID discovery path.

Repro

import { OpenIdProviderDiscoveryMetadataSchema, OAuthMetadataSchema } from "@modelcontextprotocol/sdk/shared/auth.js";

const doc = {
  issuer: "https://issuer.example.com",
  authorization_endpoint: "https://issuer.example.com/oauth2/authorize",
  token_endpoint: "https://issuer.example.com/oauth2/token",
  jwks_uri: "https://issuer.example.com/.well-known/jwks.json",
  response_types_supported: ["code"],
  subject_types_supported: ["public"],
  id_token_signing_alg_values_supported: ["RS256"],
  code_challenge_methods_supported: ["S256"],
  revocation_endpoint: "https://issuer.example.com/oauth2/revoke",
};

console.log(OpenIdProviderDiscoveryMetadataSchema.parse(doc).revocation_endpoint); // undefined
console.log(OAuthMetadataSchema.parse(doc).revocation_endpoint);                   // "https://issuer.example.com/oauth2/revoke"

(Run against 1.32.2: the first line prints undefined, the second prints the URL.)

Suggested fix

Either:

  • keep unknown keys, by building the schema with z.looseObject({...}) or .loose(); or
  • spread the optional RFC 8414 fields that OpenID discovery documents commonly carry, such as revocation_endpoint, introspection_endpoint and revocation_endpoint_auth_methods_supported.

Related: #2733 and #2734 (the same schema, about over-strict validation rather than dropped fields), and the closed #739 (a client revocation helper).

Activity

  1. added 2 commits that reference this issue on Nov 19, 2026
    005e950
    9f7dba5
  2. marcus-beauregard commented on Nov 19, 2026

    @marcus-beauregard

    Thanks for the write-up — the repro and the "loose behaviour disappears when you spread .shape into z.object" diagnosis were both right and made this quick to fix.

    I've opened #3214 against v1.x: the schema is a z.looseObject again, and the three RFC 7009 revocation fields are picked from OAuthMetadataSchema so they arrive typed (and keep the javascript:/data:/vbscript: URL guard). Undeclared fields now pass through instead of being stripped, so the parsed metadata no longer contradicts the discovery document.

    One note for your client: discoverAuthorizationServerMetadata() returns the parsed metadata as AuthorizationServerMetadata, so after this lands revocation_endpoint will be there for OIDC-only servers — worth re-checking your revocation path against it once a release ships.

  3. added
    v1Issues / PRs related to v1.x
    v2Ideas, requests and plans for v2 of the SDK which will incorporate major changes and fixes
    on Nov 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    v1Issues / PRs related to v1.xv2Ideas, requests and plans for v2 of the SDK which will incorporate major changes and fixes

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions