Skip to content

Commit 6253a24

Browse files
committed
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
1 parent 599dafc commit 6253a24

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

src/sequentialthinking/index.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ import { z } from "zod";
66
import { SequentialThinkingServer } from './lib.js';
77

88
/** Safe boolean coercion that correctly handles string "false" */
9-
const coercedBoolean = z.preprocess((val) => {
10-
if (typeof val === "boolean") return val;
11-
if (typeof val === "string") {
12-
if (val.toLowerCase() === "true") return true;
13-
if (val.toLowerCase() === "false") return false;
14-
}
15-
return val;
16-
}, z.boolean());
9+
// Use a union (rather than z.preprocess) so that zod-to-JSON-Schema conversion
10+
// keeps this field in the inputSchema `required` list. z.preprocess produces a
11+
// schema whose input accepts `unknown`, which the conversion treats as optional
12+
// and drops from `required`, causing a schema/runtime validation mismatch.
13+
const coercedBoolean = z.union([
14+
z.boolean(),
15+
z.enum(["true", "false"]).transform((val) => val === "true"),
16+
]);
1717

1818
const server = new McpServer({
1919
name: "sequential-thinking-server",

0 commit comments

Comments
 (0)