Skip to content

fix(sequentialthinking): restore nextThoughtNeeded in required schema and dynamic version - #4655

Open
AbhiPra24 wants to merge 1 commit into
modelcontextprotocol:mainfrom
AbhiPra24:fix/sequentialthinking-required-schema
Open

fix(sequentialthinking): restore nextThoughtNeeded in required schema and dynamic version#4655
AbhiPra24 wants to merge 1 commit into
modelcontextprotocol:mainfrom
AbhiPra24:fix/sequentialthinking-required-schema

Conversation

@AbhiPra24

@AbhiPra24 AbhiPra24 commented Aug 17, 2026

Copy link
Copy Markdown

Summary

Fixes #4651 and #4575.

1. Restore nextThoughtNeeded in inputSchema.required (Fixes #4651)

  • Problem: nextThoughtNeeded was previously wrapped in a z.preprocess()-based boolean coercion. Zod's toJSONSchema(..., { io: "input" }) treats z.preprocess() input as unknown, silently dropping the field from the emitted required array while runtime validation still requires it, causing -32602 Invalid params for clients constructing calls from the advertised schema.
  • Fix: Replaced z.preprocess() with a union transformation:
    const coercedBoolean = z.union([
      z.boolean(),
      z.enum(["true", "false"]).transform((v) => v === "true"),
      z.string().transform((v) => v.toLowerCase() === "true"),
    ]);
    This preserves the input types in the JSON Schema and retains nextThoughtNeeded in required: ["thought", "nextThoughtNeeded", "thoughtNumber", "totalThoughts"].

2. Dynamic Server Version (Fixes #4575)

  • Resolves server version dynamically from package.json rather than a hardcoded "0.2.0".

Verification

  • Added integration test suite in src/sequentialthinking/__tests__/index.test.ts.
  • npm run build and npm test passed (21/21 tests green).

cc @olaservo for review when available. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant