fix(sequential-thinking): keep nextThoughtNeeded in inputSchema.required - #4669
Open
re2zero wants to merge 1 commit into
Open
fix(sequential-thinking): keep nextThoughtNeeded in inputSchema.required#4669re2zero wants to merge 1 commit into
re2zero wants to merge 1 commit into
Conversation
The coercedBoolean helper used z.preprocess(), which produces a schema whose input type accepts 'unknown'. zod-to-JSON-Schema conversion treats 'unknown' inputs as optional and drops the field from the emitted 'required' list, creating a mismatch between the advertised schema and runtime validation. Replace z.preprocess with a z.union([z.boolean(), z.enum(...).transform(...)]) that preserves string coercion while keeping the field in the required list. Fixes modelcontextprotocol#4651
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.
Closes #4651
Problem
nextThoughtNeededis declared as a required field at runtime but is missing from theinputSchema.requiredlist. Client code that builds arguments from the advertised schema omits the field and gets-32602.Root cause:
z.preprocess()produces a schema whose input type acceptsunknown, so zod-to-JSON-Schema treats it as optional and drops it fromrequired.Fix
Replace
z.preprocesswithz.union([z.boolean(), z.enum(["true", "false"]).transform(...)]). This preserves boolean coercion while keeping the field correctly listed inrequired.Testing
server-sequential-thinkingtest suite: 14 passed (1 test file).