modelcontextprotocol / modelcontextprotocol/typescript-sdk

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

Open
#754 4 comments 1 reaction 1 assignee View on GitHub

@ochafik is already working on this.

Since Jul 16, 2025.

auth bug fix proposed P2 ready for work
Dominant language
TypeScript
Stars
13.4k
Forks
2.2k
Avg merge
3d 15h
Merged PRs (30d)
4

Description

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.