revise_thought
Update and refine existing thoughts within structured thinking workflows to improve clarity, accuracy, and progression through problem-solving stages.
Instructions
Revises a thought in memory and in the thought history.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| thought | No | The content of the current thought | |
| thought_number | No | Current position in the sequence | |
| total_thoughts | No | Expected total number of thoughts | |
| next_thought_needed | No | Whether another thought should follow | |
| stage | No | Current thinking stage (e.g., 'Problem Definition', 'Analysis') | |
| is_revision | No | Whether this revises a previous thought | |
| revises_thought | No | Number of thought being revised | |
| branch_from_thought | No | Starting point for a new thought branch | |
| branch_id | No | Identifier for the current branch | |
| needs_more_thoughts | No | Whether additional thoughts are needed | |
| score | No | Quality score (0.0 to 1.0) | |
| tags | No | Categories or labels for the thought | |
| thought_id | Yes | The ID of the thought to revise |
Implementation Reference
- src/SequentialThinkingServer.ts:343-401 (handler)Core handler function implementing the revise_thought tool: locates thought by ID, applies updates to specified fields, flags as revision, persists changes to history, and returns formatted response.reviseThought(input: { thought_id: number; thought?: string; thought_number?: number; total_thoughts?: number; next_thought_needed?: boolean; stage?: string; is_revision?: boolean; revises_thought?: number; branch_from_thought?: number; branch_id?: string; needs_more_thoughts?: boolean; score?: number; tags?: string[]; }): any { try { // Find the thought to revise const thought = this.findThoughtById(input.thought_id); if (!thought) { throw new Error(`Thought with ID ${input.thought_id} not found`); } // Update thought properties with any provided values if (input.thought !== undefined) thought.thought = input.thought; if (input.next_thought_needed !== undefined) thought.nextThoughtNeeded = input.next_thought_needed; if (input.stage !== undefined) thought.stage = thoughtStageFromString(input.stage); if (input.is_revision !== undefined) thought.isRevision = input.is_revision; if (input.revises_thought !== undefined) thought.revisesThought = input.revises_thought; if (input.branch_from_thought !== undefined) thought.branchFromThought = input.branch_from_thought; if (input.branch_id !== undefined) thought.branchId = input.branch_id; if (input.needs_more_thoughts !== undefined) thought.needsMoreThoughts = input.needs_more_thoughts; if (input.score !== undefined) thought.score = input.score; if (input.tags !== undefined) thought.tags = input.tags; // Set revision flag thought.isRevision = true; // Update thought in history this.updateThought(thought); return { content: [{ type: "text", text: JSON.stringify({ status: "success", revision: { thoughtNumber: thought.thoughtNumber, stage: thought.stage, updated: true, timestamp: DateTime.now().toISO() } }, null, 2) }] }; } catch (e) { return this.handleError(e); } }
- src/tools.ts:41-43 (schema)Zod schema for revise_thought tool inputs, extending captureThoughtSchema with required thought_id and optional other fields.export const reviseThoughtSchema = captureThoughtSchema.extend({ thought_id: z.number().int().positive().describe("The ID of the thought to revise") }).partial().required({ thought_id: true });
- src/tools.ts:52-57 (registration)MCP Tool object registration defining name, description, parameters schema, and input schema for revise_thought.export const reviseThoughtTool: Tool = { name: "revise_thought", description: "Revises a thought in memory and in the thought history.", parameters: reviseThoughtSchema, inputSchema: zodToInputSchema(reviseThoughtSchema) };
- src/tools.ts:85-85 (registration)Inclusion of reviseThoughtTool in the exported toolDefinitions array used for listing available tools.reviseThoughtTool,
- index.ts:99-118 (handler)Dispatch handler in MCP server that routes revise_thought calls to the SequentialThinkingServer.reviseThought method.case "revise_thought": { if (!params.arguments) { console.error("ERROR: params.arguments object is undefined in revise_thought request"); return { content: [{ type: "text", text: JSON.stringify({ error: "Invalid request: params.arguments object is undefined", status: "failed" }) }], isError: true }; } // Cast the arguments to match reviseThoughtSchema const reviseParams = params.arguments as z.infer<typeof reviseThoughtSchema>; return thinkingServer.reviseThought(reviseParams); }