Skip to content

Allow extra JSON Schema keys in elicit primitive schemas#1856

Open
Christian-Sidak wants to merge 1 commit intomodelcontextprotocol:mainfrom
Christian-Sidak:fix/elicit-primitive-schema-passthrough
Open

Allow extra JSON Schema keys in elicit primitive schemas#1856
Christian-Sidak wants to merge 1 commit intomodelcontextprotocol:mainfrom
Christian-Sidak:fix/elicit-primitive-schema-passthrough

Conversation

@Christian-Sidak
Copy link
Copy Markdown

Summary

Fixes #1844

The property-level primitive schemas (StringSchemaSchema, NumberSchemaSchema, BooleanSchemaSchema, and all enum schema variants) in the elicitation form params were strict Zod objects that rejected any keys not explicitly defined. This meant standard JSON Schema keywords like pattern, format (beyond the 4 allowed values), exclusiveMinimum, exclusiveMaximum, const, etc. were silently stripped or caused validation failures.

This PR adds .passthrough() to each primitive schema variant so that extra JSON Schema keys are preserved through validation, matching the behavior already applied to the top-level requestedSchema via .catchall(z.unknown()) in #1768.

Changes

  • Add .passthrough() to BooleanSchemaSchema, StringSchemaSchema, NumberSchemaSchema
  • Add .passthrough() to all enum schema variants: UntitledSingleSelectEnumSchemaSchema, TitledSingleSelectEnumSchemaSchema, LegacyTitledEnumSchemaSchema, UntitledMultiSelectEnumSchemaSchema, TitledMultiSelectEnumSchemaSchema
  • Add .passthrough() to the nested items objects in multi-select enum schemas
  • Add [key: string]: unknown index signatures to all corresponding TypeScript interfaces in spec.types.ts
  • Remove now-unnecessary @ts-expect-error comments in elicitation tests

Test plan

  • All 54 elicitation integration tests pass
  • All 489 core package tests pass
  • TypeScript typecheck passes across all packages
  • Prettier formatting verified

Add .passthrough() to all primitive schema Zod definitions
(BooleanSchemaSchema, StringSchemaSchema, NumberSchemaSchema, and all
enum schema variants) so that standard JSON Schema keywords like
pattern, format, exclusiveMinimum, const, default, etc. are not
rejected during validation.

Also add index signatures to the corresponding TypeScript interfaces
in spec.types.ts, and remove now-unnecessary @ts-expect-error comments
in elicitation tests.

Fixes modelcontextprotocol#1844
@Christian-Sidak Christian-Sidak requested a review from a team as a code owner April 6, 2026 04:21
@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Apr 6, 2026

⚠️ No Changeset found

Latest commit: 961b39c

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Apr 6, 2026

Open in StackBlitz

@modelcontextprotocol/client

npm i https://pkg.pr.new/@modelcontextprotocol/client@1856

@modelcontextprotocol/server

npm i https://pkg.pr.new/@modelcontextprotocol/server@1856

@modelcontextprotocol/express

npm i https://pkg.pr.new/@modelcontextprotocol/express@1856

@modelcontextprotocol/fastify

npm i https://pkg.pr.new/@modelcontextprotocol/fastify@1856

@modelcontextprotocol/hono

npm i https://pkg.pr.new/@modelcontextprotocol/hono@1856

@modelcontextprotocol/node

npm i https://pkg.pr.new/@modelcontextprotocol/node@1856

commit: 961b39c

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.

Elicit primitive schemas reject extra JSON Schema keys (pattern, format, etc.)

1 participant