type
Post
status
Published
date
Nov 21, 2025
slug
summary
tags
Claude
MCP
category
icon
password
Property
Nov 21, 2025 08:33 AM
Language
在使用Claude Code Sonnet 4.5使用sequential-thinking会报错:
 
sequential-thinking - sequentialthinking (MCP)(thought: XXX)
Error: { "error": "Invalid thoughtNumber: must be a number", "status": "failed" }
 
修复方案:
创建sequential-thinking-wrapper.js
#!/usr/bin/env node /** * Sequential Thinking Wrapper - Handles type coercion for Claude Sonnet 4.5 * * Problem: Claude sometimes sends string numbers ("1") instead of integers (1) * Solution: Intercept and coerce types before passing to the MCP server */ const { spawn } = require('child_process'); const readline = require('readline'); console.error('[Sequential-Thinking Wrapper] Starting with type coercion...'); // Start the actual sequential-thinking server const serverProcess = spawn('npx', ['-y', '@modelcontextprotocol/server-sequential-thinking@latest'], { stdio: ['pipe', 'pipe', 'inherit'], shell: true }); // Create readline interfaces for line-by-line processing const inputReader = readline.createInterface({ input: process.stdin, crlfDelay: Infinity }); const outputReader = readline.createInterface({ input: serverProcess.stdout, crlfDelay: Infinity }); /** * Coerce string numbers to actual numbers in the data */ function coerceTypes(data) { try { const parsed = JSON.parse(data); // Check if this is a tool call with parameters if (parsed.params && parsed.params.arguments) { const args = parsed.params.arguments; // Coerce numeric parameters const numericFields = [ 'thoughtNumber', 'totalThoughts', 'revisesThought', 'branchFromThought' ]; numericFields.forEach(field => { if (args[field] !== undefined) { // Convert string numbers to actual numbers if (typeof args[field] === 'string' && !isNaN(args[field])) { args[field] = parseInt(args[field], 10); console.error(`[Wrapper] Coerced ${field}: "${args[field]}" -> ${args[field]}`); } } }); // Coerce boolean parameters const booleanFields = [ 'nextThoughtNeeded', 'isRevision', 'needsMoreThoughts' ]; booleanFields.forEach(field => { if (args[field] !== undefined) { if (typeof args[field] === 'string') { args[field] = args[field].toLowerCase() === 'true'; console.error(`[Wrapper] Coerced ${field}: "${args[field]}" -> ${args[field]}`); } } }); } return JSON.stringify(parsed); } catch (e) { // If not JSON or parsing fails, return as-is return data; } } // Forward stdin to server with type coercion inputReader.on('line', (line) => { const coerced = coerceTypes(line); serverProcess.stdin.write(coerced + '\n'); }); // Forward server output to stdout outputReader.on('line', (line) => { process.stdout.write(line + '\n'); }); // Handle process termination process.stdin.on('end', () => { serverProcess.stdin.end(); }); serverProcess.on('exit', (code, signal) => { console.error(`[Wrapper] Server exited with code ${code}, signal ${signal}`); process.exit(code || 0); }); serverProcess.on('error', (error) => { console.error(`[Wrapper] Server error:`, error); process.exit(1); }); // Forward signals process.on('SIGTERM', () => serverProcess.kill('SIGTERM')); process.on('SIGINT', () => serverProcess.kill('SIGINT'));
然后MCP配置修改为:
"sequential-thinking": { "type": "stdio", "command": "node", "args": [ ".claude/sequential-thinking-wrapper.js" ], "env": { "DISABLE_THOUGHT_LOGGING": "false" } }
东方财富分析解决Docker用户权限报错” the attribute version is obsolete, it will be ignored, please remove it to avoid potential confusion unable to get image 'redis:alpine': permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get "http://%2Fvar%2Frun%2Fdocker.sock/v1.51/images/redis:alpine/json": dial unix /var/run/docker.sock: connect: permission denied ”