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

Aberta Para iniciantes
#3,213 3 comentários 0 reações 0 responsáveis Ver no GitHub

Mantenedores costumam responder em até 1 dia

@marcus-beauregard já está trabalhando nisso.

Desde 19/11/2026.

  • #3214 de @marcus-beauregard — aberto

Avaliação

Dificuldade
2/5
Tempo estimado
1-3 horas
Facilidade para iniciantes
78/100
Tipo de issue
Bug
Clareza
Claramente especificada
Status de atividade
Ativa
Stack de tecnologia
typescript
Domínio
api, authentication

Direção de pesquisa

Comece em src/shared/auth.ts, em OpenIdProviderDiscoveryMetadataSchema, e compare com OpenIdProviderMetadataSchema e OAuthMetadataSchema. Reproduza o parse relatado com revocation_endpoint para confirmar quais campos são descartados. O trabalho estará concluído quando o esquema de descoberta OpenID preservar o endpoint de revogação anunciado e a regressão estiver coberta por um teste.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

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

Linguagem predominante
TypeScript
Estrelas
13.8k
Forks
2.5k
Merge médio
6d 23h
PRs com merge (30d)
2

Preparar o ambiente

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de modelcontextprotocol/typescript-sdk

Todas as issues de modelcontextprotocol/typescript-sdk

Issues semelhantes

Mais issues de TypeScript

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.