modelcontextprotocol / modelcontextprotocol/typescript-sdk

ProxyOAuthServerProvider fails with Zod validation error when using Ory Hydra as OAuth provider

Aperta
#754 4 commenti 1 reazione 1 assegnatario Vedi su GitHub

@ochafik ci sta già lavorando.

Dal 16/7/2025.

auth bug fix proposed P2 ready for work
Lingua principale
TypeScript
Stelle
13.4k
Fork
2.2k
Merge medio
3g 15h
PR unite (30g)
4

Descrizione

Describe the bug
The ProxyOAuthServerProvider's client registration fails with a Zod schema validation error when using Hydra as the upstream OAuth provider. The error occurs because Hydra returns "contacts": null in the client registration response, but the MCP SDK's OAuthClientInformationFullSchema expects contacts to be an array.

To Reproduce
Steps to reproduce the behavior:

  1. Configure ProxyOAuthServerProvider with Hydra endpoints (e.g., registrationUrl pointing to Hydra's /oauth2/register)
  2. Attempt client registration through the MCP server
  3. Registration request succeeds at Hydra but fails during MCP SDK's response parsing

Expected behavior
Client registration should succeed when using standards-compliant OAuth2 providers like Hydra that return valid OAuth client information responses.

Logs

Unexpected error registering client: ZodError: [
    {
      "code": "invalid_type",
      "expected": "array",
      "received": "null",
      "path": [
        "contacts"
      ],
      "message": "Expected array, received null"
    }
  ]
  at Object.registerClient 
  (/node_modules/@modelcontextprotocol/sdk/src/server/auth/providers/proxyProvider.ts:113:51)

Additional context
Hydra returns valid RFC 7591 compliant client registration responses where optional fields like contacts can be null. The MCP SDK's Zod schema appears to be stricter than the OAuth2 specification requires for these optional fields.

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.