From 6253a24cc71fdc264c77606d3eec4417ab936752 Mon Sep 17 00:00:00 2001 From: re2zero Date: Thu, 20 Aug 2026 02:13:45 +0800 Subject: [PATCH] fix(sequential-thinking): keep nextThoughtNeeded in inputSchema.required 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 #4651 --- src/sequentialthinking/index.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/sequentialthinking/index.ts b/src/sequentialthinking/index.ts index 217845bb3d..f26378f379 100644 --- a/src/sequentialthinking/index.ts +++ b/src/sequentialthinking/index.ts @@ -6,14 +6,14 @@ import { z } from "zod"; import { SequentialThinkingServer } from './lib.js'; /** Safe boolean coercion that correctly handles string "false" */ -const coercedBoolean = z.preprocess((val) => { - if (typeof val === "boolean") return val; - if (typeof val === "string") { - if (val.toLowerCase() === "true") return true; - if (val.toLowerCase() === "false") return false; - } - return val; -}, z.boolean()); +// Use a union (rather than z.preprocess) so that zod-to-JSON-Schema conversion +// keeps this field in the inputSchema `required` list. z.preprocess produces a +// schema whose input accepts `unknown`, which the conversion treats as optional +// and drops from `required`, causing a schema/runtime validation mismatch. +const coercedBoolean = z.union([ + z.boolean(), + z.enum(["true", "false"]).transform((val) => val === "true"), +]); const server = new McpServer({ name: "sequential-thinking-server",