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

Abierto Apto para principiantes
#3,213 3 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

@marcus-beauregard ya está trabajando en esto.

Desde el 19/11/2026.

  • #3214 de @marcus-beauregard — abierto

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
78/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
typescript

Línea de trabajo

Empieza en src/shared/auth.ts, en OpenIdProviderDiscoveryMetadataSchema, y compáralo con OpenIdProviderMetadataSchema y OAuthMetadataSchema. Reproduce el análisis indicado con revocation_endpoint para confirmar qué campos se descartan. Se considerará terminado cuando el esquema de descubrimiento de OpenID conserve el endpoint de revocación anunciado y la regresión esté cubierta por una prueba.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

v1 v2

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).

Lenguaje dominante
TypeScript
Estrellas
13.8k
Forks
2.5k
Merge medio
6 d 23 h
PR fusionados (30 d)
2

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de modelcontextprotocol/typescript-sdk

Todos los issues de modelcontextprotocol/typescript-sdk

Issues similares

Más issues de TypeScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.