fix(core): allow additional JSON Schema properties in elicitInput requestedSchema#1561
Open
corvid-agent wants to merge 1 commit intomodelcontextprotocol:mainfrom
Open
Conversation
…uestedSchema Add .catchall(z.unknown()) to the requestedSchema object type in ElicitRequestFormParamsSchema, matching the existing pattern used by inputSchema and outputSchema. This fixes a type incompatibility when passing Zod v4's .toJSONSchema() output (which includes $schema, additionalProperties, etc.) to elicitInput's requestedSchema parameter. Fixes modelcontextprotocol#1362 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
🦋 Changeset detectedLatest commit: 5725802 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
@modelcontextprotocol/client
@modelcontextprotocol/server
@modelcontextprotocol/express
@modelcontextprotocol/hono
@modelcontextprotocol/node
commit: |
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
.catchall(z.unknown())to therequestedSchemaobject type inElicitRequestFormParamsSchema, matching the existing pattern used byinputSchemaandoutputSchemafor tool definitions.toJSONSchema()output (which includes extra properties like$schemaandadditionalProperties) to be passed directly toelicitInput()without type errorsProblem
When using Zod v4's
.toJSONSchema()to generate a schema forelicitInput, the resulting object includes standard JSON Schema properties like$schemaandadditionalPropertiesthat are not present in therequestedSchemaTypeScript type. This works at runtime but fails type-checking, forcing users to use type casts.Fix
The fix follows the same pattern already established in this codebase for
inputSchemaandoutputSchema(lines 1391-1409 oftypes.ts), which use.catchall(z.unknown())to accept additional JSON Schema properties beyond the requiredtype,properties, andrequiredfields.The spec type in
spec.types.tsalready includes$schema?: stringin itsrequestedSchemadefinition (line 2155), confirming that additional properties are expected.Fixes #1362
Test plan
.catchall(z.unknown())only widens the accepted type)spec.types.test.ts) continues to pass (.catchall(z.unknown())adds an index signature which is structurally compatible)z.object({ name: z.string() }).toJSONSchema()is now accepted byelicitInputwithout type errors🤖 Generated with Claude Code