fix: widen requestedSchema type to accept Zod toJSONSchema output#1694
Closed
travisbreaks wants to merge 1 commit intomodelcontextprotocol:mainfrom
Closed
fix: widen requestedSchema type to accept Zod toJSONSchema output#1694travisbreaks wants to merge 1 commit intomodelcontextprotocol:mainfrom
travisbreaks wants to merge 1 commit intomodelcontextprotocol:mainfrom
Conversation
…tput Zod v4's `.toJSONSchema()` produces standard JSON Schema that includes `$schema` and `additionalProperties` fields. The `requestedSchema` type in `ElicitRequestFormParams` rejected these valid fields at the TypeScript level, even though they work correctly at runtime. Changes: - Add `additionalProperties?: boolean` to requestedSchema in spec.types.ts - Add index signature `[key: string]: unknown` for forward compatibility with other standard JSON Schema fields - Add `.passthrough()` to the Zod schema in types.ts so extra fields survive runtime validation - Add regression test verifying Zod toJSONSchema() output works with elicitInput() Closes modelcontextprotocol#1362
|
@modelcontextprotocol/client
@modelcontextprotocol/server
@modelcontextprotocol/express
@modelcontextprotocol/hono
@modelcontextprotocol/node
commit: |
3 tasks
9 tasks
Contributor
|
Thanks for the contribution! Closing in favor of #1768. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #1362.
Zod v4's
.toJSONSchema()returns standard JSON Schema fields ($schema,additionalProperties) that therequestedSchematype inElicitRequestFormParamsrejected at the TypeScript level, requiring users to cast withas unknown as ....Changes:
additionalProperties?: booleanand[key: string]: unknownindex signature to therequestedSchematype inspec.types.tsadditionalProperties: z.boolean().optional()and.passthrough()to the Zod schema intypes.tsso extra JSON Schema fields survive runtime validation.toJSONSchema()output works withelicitInput()All 388 existing tests pass. Typecheck and lint clean.
Test plan
z.object({...}).toJSONSchema()passes type check when assigned torequestedSchema