Claude Code Sonnet 4.5 crashes on sequentialthinking MCP: "Invalid thoughtNumber: must be a number"
Using Claude Code with the Sonnet 4.5 model and the sequential-thinking MCP server from modelcontextprotocol/servers, the agent crashes when it calls sequentialthinking. The server returns
Error: Invalid thoughtNumber: must be a numberwith status failed. Sonnet 4 worked in the same setup; what causes this and how do I fix it?Originally asked on GitHub: https://github.com/modelcontextprotocol/servers/issues/2792
3 answers
Fixed in the v2 release of the reference MCP servers. The maintainers closed this as superseded: after the servers were rebuilt for the 2026-07-28 MCP specification and published as v2 (2.0.0 on npm for the TypeScript servers), the sequential-thinking tool coerces string numbers and booleans, so clients that send
thoughtNumberas a string are accepted.Root cause (from the workaround author's analysis in the thread): Claude Sonnet 4.5 sometimes sends integer parameters as strings ("1") instead of numbers (1). The older server's strict validation rejected that and the MCP call failed, crashing the agent. The reporter expected behavior identical to Sonnet 4.
What to do:
- Upgrade to v2. If the error still occurs on v2, open a fresh issue with the server version and reproduction steps. A maintainer note in the thread mentions that a solution was being discussed in PR modelcontextprotocol/servers#2812.
- For older versions, a commenter posted a wrapper: a Node.js script that spawns the real server with
npx -y @modelcontextprotocol/server-sequential-thinking@latest, intercepts each JSON line from stdin, and coerces the numeric fields (thoughtNumber,totalThoughts,revisesThought,branchFromThought) withparseIntplus boolean fields before forwarding. The thread does not confirm whether this wrapper was validated, so treat it as a proposed workaround rather than a verified fix.
Did this work for you?What a GitHub user tried on GitHub (Didn't work)
Triggered sequentialthinking from Claude Code Sonnet 4.5 following the reproduction steps; the server returned
Invalid thoughtNumber: must be a numberwith status failed and Claude Code crashed.Source: https://github.com/modelcontextprotocol/servers/issues/2792 (opens external site)
Did this work for you?What @JCJinvesting tried on GitHub (Outcome unclear)
Created a Node.js wrapper that spawns the real server via
npx -y @modelcontextprotocol/server-sequential-thinking@latestand coerces string values in numeric fields likethoughtNumberwithparseInt, plus boolean fields, before forwarding to the server. The commenter presented it as a working solution, but the thread contains no confirmation.Did this work for you?
Related questions
- mcp-server-fetch: 'AnyUrl' object has no attribute 'decode' error
- Does the official MCP Postgres example validate SQL before executing it?
- How to fix UTF-8 Japanese text corruption/crash in mcp-server-sqlite with Claude Desktop on Windows?
- MCP Knowledge Graph Memory Server fails with ${workspaceFolder} in MEMORY_FILE_PATH
- npx @modelcontextprotocol/server-filesystem: ERR_MODULE_NOT_FOUND for zod-to-json-schema