branchFromThought silently creates phantom branches from nonexistent thoughts in sequential-thinking MCP
Reproduced behavior
When calling sequentialthinking with branchFromThought referencing a thought number that was never created, the server accepts the call, registers the branch in the branches array, and persists it across subsequent calls. No error, no warning.
Repro (5 calls in one session via stdio)
call 1: {thought:"Step 1", thoughtNumber:1, totalThoughts:3, nextThoughtNeeded:true}
→ OK: branches=[], thoughtHistoryLength=1
call 2: {thought:"Step 2", thoughtNumber:2, totalThoughts:3, nextThoughtNeeded:true}
→ OK: branches=[], thoughtHistoryLength=2
call 3: {thought:"Step 3", thoughtNumber:3, totalThoughts:3, nextThoughtNeeded:false}
→ OK: branches=[], thoughtHistoryLength=3
call 4: {thought:"Phantom branch", thoughtNumber:4, totalThoughts:4, nextThoughtNeeded:true, branchFromThought:999, branchId:"phantom-branch"}
→ OK: branches=["phantom-branch"], thoughtHistoryLength=4
⚠ branchFromThought=999 accepted — only thoughts 1-3 exist
call 5: {thought:"Continue", thoughtNumber:5, totalThoughts:5, nextThoughtNeeded:true}
→ OK: branches=["phantom-branch"], thoughtHistoryLength=5
⚠ phantom branch persists in subsequent callsRelated: phantom revisions also accepted
isRevision:true, revisesThought:999 succeeds silently in the same session (only 3 real thoughts). The "revision" increments thoughtHistoryLength but revises nothing.
Related: totalThoughts silently auto-expands
When thoughtNumber > totalThoughts (e.g., thoughtNumber=50, totalThoughts=2), the server rewrites totalThoughts to match thoughtNumber. This compounds: three calls can drift totalThoughts from 2→50→51 while thoughtHistoryLength stays at 3.
Environment
- Package:
@modelcontextprotocol/server-sequential-thinking(latest via npx, 2026-06-10) - Transport: stdio
- Protocol: MCP 2024-11-05
Question
How should callers handle this? Should branches and revisions targeting nonexistent thoughts be rejected by the server, or is the server intentionally permissive (accepting "future" thought references)? The current behavior means a hallucinating LLM client can create an internally contradictory thought graph with no feedback that anything is wrong.