modelcontextprotocol / modelcontextprotocol/typescript-sdk
ProxyOAuthServerProvider fails with Zod validation error when using Ory Hydra as OAuth provider
@ochafik is already working on this.
Since Jul 16, 2025.
- 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:
- Configure ProxyOAuthServerProvider with Hydra endpoints (e.g., registrationUrl pointing to Hydra's
/oauth2/register) - Attempt client registration through the MCP server
- 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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.