Skip to content

fix(core): allow additional JSON Schema properties in elicitInput requestedSchema#1768

Open
felixweinberger wants to merge 1 commit intomainfrom
fweinberger/elicit-schema-catchall
Open

fix(core): allow additional JSON Schema properties in elicitInput requestedSchema#1768
felixweinberger wants to merge 1 commit intomainfrom
fweinberger/elicit-schema-catchall

Conversation

@felixweinberger
Copy link
Contributor

Adds .catchall(z.unknown()) to requestedSchema, matching inputSchema/outputSchema (SEP-1613 / #1135).

Motivation and Context

z.toJSONSchema() emits $schema, additionalProperties, etc. The SDK's requestedSchema rejected these. The spec's own schema.ts allows $schema, so the SDK was stricter than spec.

Fixes #1362

How Has This Been Tested?

Regression test in types.test.ts — verified fails without fix, passes with.

Breaking Changes

None.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed

Additional context

Supersedes #1511, #1561, #1688, #1694 — thanks @Dave-London and @travisbreaks for the earlier work.

@KKonstantinov — is .catchall(z.unknown()) right here, or should we only add the spec-listed keys?

…uestedSchema

Adds .catchall(z.unknown()) to requestedSchema, matching the pattern used
by inputSchema/outputSchema (SEP-1613). Fixes type incompatibility when
using Zod v4's .toJSONSchema() output which includes extra properties
like $schema and additionalProperties.

Fixes #1362
@changeset-bot
Copy link

changeset-bot bot commented Mar 26, 2026

🦋 Changeset detected

Latest commit: 9f455cd

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@modelcontextprotocol/core Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@pkg-pr-new
Copy link

pkg-pr-new bot commented Mar 26, 2026

Open in StackBlitz

@modelcontextprotocol/client

npm i https://pkg.pr.new/modelcontextprotocol/typescript-sdk/@modelcontextprotocol/client@1768

@modelcontextprotocol/server

npm i https://pkg.pr.new/modelcontextprotocol/typescript-sdk/@modelcontextprotocol/server@1768

@modelcontextprotocol/express

npm i https://pkg.pr.new/modelcontextprotocol/typescript-sdk/@modelcontextprotocol/express@1768

@modelcontextprotocol/hono

npm i https://pkg.pr.new/modelcontextprotocol/typescript-sdk/@modelcontextprotocol/hono@1768

@modelcontextprotocol/node

npm i https://pkg.pr.new/modelcontextprotocol/typescript-sdk/@modelcontextprotocol/node@1768

commit: 9f455cd

Copy link

@claude claude bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM — consistent with the existing inputSchema/outputSchema pattern.

Extended reasoning...

Overview

This PR adds .catchall(z.unknown()) to the requestedSchema Zod object inside ElicitRequestFormParamsSchema in packages/core/src/types/schemas.ts. It also adds a regression test and a changeset file. Total change is ~30 lines across 3 files.

Security risks

None. The change only loosens Zod validation to accept additional unknown keys on the requestedSchema object (e.g. $schema, additionalProperties). These extra keys are already accepted on inputSchema and outputSchema via the same .catchall(z.unknown()) pattern. No auth, crypto, or permission logic is affected.

Level of scrutiny

Low scrutiny warranted. This is a one-line schema fix that aligns requestedSchema with the existing pattern used by inputSchema (line 1314) and outputSchema (line 1326) in the same file. The fix is mechanical and the test directly validates the scenario described in issue #1362.

Other factors

The PR author asks a maintainer whether .catchall(z.unknown()) is the right approach. However, since this exact pattern is already established for inputSchema and outputSchema, consistency strongly favors this approach. A regression test is included. The changeset is properly scoped as a patch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[TypeScript] Zod's .toJSONSchema() output type incompatible with elicitInput's requestedSchema parameter

1 participant