Skip to main content
Glama

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
NameRequiredDescriptionDefault
thoughtYesThe content of the current thought
thought_numberYesCurrent position in the sequence
total_thoughtsYesExpected total number of thoughts
next_thought_neededYesWhether another thought should follow
stageYesCurrent thinking stage (e.g., 'Problem Definition', 'Analysis')
is_revisionNoWhether this revises a previous thought
revises_thoughtNoNumber of thought being revised
branch_from_thoughtNoStarting point for a new thought branch
branch_idNoIdentifier for the current branch
needs_more_thoughtsNoWhether additional thoughts are needed
scoreNoQuality score (0.0 to 1.0)
tagsNoCategories or labels for the thought

Implementation Reference

  • 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); } }
  • 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 }; });

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Promptly-Technologies-LLC/mcp-structured-thinking'

If you have feedback or need assistance with the MCP directory API, please join our Discord server