Skip to content

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

@boogie-amplitude

Description

@boogie-amplitude

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.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions