capture_thought
Capture and process thoughts to classify them, provide metacognitive feedback, and retrieve relevant ideas for structured thinking.
Instructions
Stores a new thought in memory and in the thought history and runs a pipeline to classify the thought, return metacognitive feedback, and retrieve relevant thoughts.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| thought | Yes | The content of the current thought | |
| thought_number | Yes | Current position in the sequence | |
| total_thoughts | Yes | Expected total number of thoughts | |
| next_thought_needed | Yes | Whether another thought should follow | |
| stage | Yes | 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 |
Implementation Reference
- src/SequentialThinkingServer.ts:278-340 (handler)Core handler function that captures and processes a thought: validates input, applies reasoning, stores in memory and history, generates metacognitive feedback and retrieves related thoughts.captureThought(inputData: any): any { try { // Validate and create thought data const thoughtData = this.validateThoughtData(inputData); // Apply reasoning strategy const enhancedThought = this.reasoningEngine.applyReasoningStrategy(thoughtData); // Store in memory this.memoryManager.consolidateMemory(enhancedThought); // Get metacognitive insights const improvements = this.metacognitiveMonitor.suggestImprovements(enhancedThought); // Get related thoughts const relatedThoughts = this.memoryManager.retrieveRelevantThoughts(enhancedThought); // Store thought in history this.thoughtHistory.push(enhancedThought); // Handle branching if (enhancedThought.branchFromThought && enhancedThought.branchId) { if (!this.branches[enhancedThought.branchId]) { this.branches[enhancedThought.branchId] = []; } this.branches[enhancedThought.branchId].push(enhancedThought); } // Return in the format expected by tests return { content: [{ type: "text", text: JSON.stringify({ thoughtAnalysis: { currentThought: { thoughtNumber: enhancedThought.thoughtNumber, totalThoughts: enhancedThought.totalThoughts, nextThoughtNeeded: enhancedThought.nextThoughtNeeded, stage: enhancedThought.stage, score: enhancedThought.score, tags: enhancedThought.tags, timestamp: enhancedThought.createdAt.toISO(), branch: enhancedThought.branchId }, analysis: { relatedThoughtsCount: relatedThoughts.length, qualityMetrics: this.metacognitiveMonitor.evaluateThoughtQuality(enhancedThought), suggestedImprovements: improvements }, context: { activeBranches: Object.keys(this.branches), thoughtHistoryLength: this.thoughtHistory.length, currentStage: enhancedThought.stage } } }, null, 2) }] }; } catch (e) { return this.handleError(e); } }
- src/tools.ts:6-19 (schema)Zod schema defining the input parameters and validation for the capture_thought tool.export const captureThoughtSchema = z.object({ thought: z.string().describe("The content of the current thought"), thought_number: z.number().int().positive().describe("Current position in the sequence"), total_thoughts: z.number().int().positive().describe("Expected total number of thoughts"), next_thought_needed: z.boolean().describe("Whether another thought should follow"), stage: z.string().describe("Current thinking stage (e.g., 'Problem Definition', 'Analysis')"), is_revision: z.boolean().optional().describe("Whether this revises a previous thought"), revises_thought: z.number().int().optional().describe("Number of thought being revised"), branch_from_thought: z.number().int().optional().describe("Starting point for a new thought branch"), branch_id: z.string().optional().describe("Identifier for the current branch"), needs_more_thoughts: z.boolean().optional().describe("Whether additional thoughts are needed"), score: z.number().min(0).max(1).optional().describe("Quality score (0.0 to 1.0)"), tags: z.array(z.string()).optional().describe("Categories or labels for the thought") });
- src/tools.ts:45-49 (registration)Tool definition object for 'capture_thought' used in MCP tool listing.export const captureThoughtTool: Tool = { name: "capture_thought", description: "Stores a new thought in memory and in the thought history and runs a pipeline to classify the thought, return metacognitive feedback, and retrieve relevant thoughts.", parameters: captureThoughtSchema, inputSchema: zodToInputSchema(captureThoughtSchema)
- index.ts:57-97 (registration)MCP tool call dispatch handler that processes 'capture_thought' requests, validates arguments, maps to internal format, and invokes the core handler.switch (params.name) { case "capture_thought": { if (!params.arguments && params.arguments) { params.arguments = params.arguments; } if (!params.arguments) { console.error("ERROR: arguments are undefined in capture_thought request"); return { content: [{ type: "text", text: JSON.stringify({ error: "Invalid request: arguments object is defined", status: "failed", received: JSON.stringify(params) }) }], isError: true }; } // Type assertion for the params.arguments const captureParams = params.arguments as z.infer<typeof captureThoughtSchema>; const inputData = { thought: captureParams.thought, thoughtNumber: captureParams.thought_number, totalThoughts: captureParams.total_thoughts, nextThoughtNeeded: captureParams.next_thought_needed, stage: captureParams.stage, isRevision: captureParams.is_revision, revisesThought: captureParams.revises_thought, branchFromThought: captureParams.branch_from_thought, branchId: captureParams.branch_id, needsMoreThoughts: captureParams.needs_more_thoughts, score: captureParams.score, tags: captureParams.tags || [] }; return thinkingServer.captureThought(inputData); }
- index.ts:31-36 (registration)MCP list tools handler that returns the toolDefinitions array including capture_thought tool.// Handle the ListTools request server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools: toolDefinitions }; });