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
  4. A7mdMe commented on Nov 21, 2026

    @A7mdMe

    Client-Side RFC 7009 Revocation Handling & IdP Interop Considerations

    Great to see #3214 addressing the schema stripping for v1.x! For teams building production MCP clients and gateways that manage token lifecycles against OIDC-only servers (e.g. Amazon Cognito, Okta, Keycloak), preserving revocation_endpoint is the essential prerequisite.

    When executing the actual revocation request against the newly preserved endpoint, we encountered three IdP interoperability details worth keeping in mind:

    1. Form-Urlencoded Encoding & Parameter Passing

    RFC 7009 §2.1 mandates application/x-www-form-urlencoded:

    const body = new URLSearchParams();
    body.append('token', token);
    if (tokenTypeHint) {
      body.append('token_type_hint', tokenTypeHint); // 'access_token' | 'refresh_token'
    }

    2. Client Authentication Methods

    Different IdPs support different authentication schemes for the revocation endpoint (revocation_endpoint_auth_methods_supported):

    • Cognito & public clients: Often expect client_id in the form body (client_secret_post style without secret) or reject Basic auth headers if no secret exists.
    • Confidential clients / Okta / Keycloak: Expect HTTP Basic auth (Authorization: Basic base64(client_id:client_secret)).
      Checking metadata.revocation_endpoint_auth_methods_supported before selecting the header vs body strategy avoids unexpected 401 Unauthorized responses during logout.

    3. RFC 7009 §2.2 Status Code Handling

    Under RFC 7009 §2.2:

    The authorization server responds with HTTP status code 200 if the token has been revoked successfully or if the client submitted an invalid token.

    Some IdPs return HTTP 200 with an empty body, while others return HTTP 204 No Content. Clients should treat any 200 or 204 as successful termination, and avoid attempting to parse JSON bodies on empty success responses.


    Disclosure: I maintain MCP Production Kit, an open-source hardening suite for MCP servers. We implemented and verified this OIDC discovery preservation and RFC 7009 token revocation lifecycle in our test suite (Module 29).

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