Skip to content

fix(sequential-thinking): keep nextThoughtNeeded in inputSchema.required - #4669

Open
re2zero wants to merge 1 commit into
modelcontextprotocol:mainfrom
re2zero:fix/sequential-thinking-required-schema
Open

fix(sequential-thinking): keep nextThoughtNeeded in inputSchema.required#4669
re2zero wants to merge 1 commit into
modelcontextprotocol:mainfrom
re2zero:fix/sequential-thinking-required-schema

Conversation

@re2zero

@re2zero re2zero commented Aug 19, 2026

Copy link
Copy Markdown

Closes #4651

Problem

nextThoughtNeeded is declared as a required field at runtime but is missing from the inputSchema.required list. 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 accepts unknown, so zod-to-JSON-Schema treats it as optional and drops it from required.

Fix

Replace z.preprocess with z.union([z.boolean(), z.enum(["true", "false"]).transform(...)]). This preserves boolean coercion while keeping the field correctly listed in required.

Testing

  • server-sequential-thinking test suite: 14 passed (1 test file).

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
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.

sequential-thinking: nextThoughtNeeded missing from inputSchema.required but required at runtime (regression from #3533)

1 participant