think
Structure complex reasoning processes, log thoughts, and analyze problems step-by-step. Use for problem definition, analysis, and self-reflection without altering data.
Instructions
Use the tool to think about something. It will not obtain new information or change the database, but just append the thought to the log. Use it when complex reasoning or some cache memory is needed. Consider including: problem definition, relevant context, analysis steps, self-reflection on your reasoning, and conclusions. Adapt this structure as needed for your specific thought process.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| allowResearch | No | Whether to allow research via external tools during the reasoning process | |
| associateWithEntity | No | Optional entity name to associate this thought with | |
| category | No | Optional category for the thought (e.g., "problem-solving", "analysis", "planning") | |
| context | No | Optional context or situation relevant to this thought (e.g., project, meeting, or scenario) | |
| currentStep | No | The current step number in the thinking process | |
| formatOutput | No | Whether to apply markdown formatting to the output | |
| formatType | No | The type of formatting to apply | auto |
| plannedSteps | No | The total number of steps planned for this thinking process | |
| reflectPrompt | No | Custom prompt for the self-reflection stage | |
| researchQuery | No | Optional research query to execute during the reasoning process | |
| selfReflect | No | Whether to perform a self-reflection pass after generating the answer | |
| storeInMemory | No | Whether to store this thought in the knowledge graph memory | |
| structuredReasoning | Yes | A structured thought process to work through complex problems. Use this as a dedicated space for reasoning step-by-step. | |
| tags | No | Optional tags to help categorize and find this thought later |
Implementation Reference
- src/think/tools.ts:14-38 (handler)The execute handler for the 'think' tool. It implements step counting logic, estimates planned steps based on content length if not provided, increments the current step, and formats the output with step information.execute: async (params: any) => { const { structuredReasoning, selfReflect = false } = params; // Step counter logic // Initialize or estimate plannedSteps if not provided if (!params.plannedSteps) { // Roughly estimate based on content length const contentLength = structuredReasoning.length; params.plannedSteps = Math.max(1, Math.min(5, Math.ceil(contentLength / 300))); } // Initialize currentStep if not provided if (!params.currentStep) { params.currentStep = 1; } else { // Increment the current step params.currentStep += 1; } // Ensure current step doesn't exceed planned steps params.currentStep = Math.min(params.currentStep, params.plannedSteps); // Format output with step counter return `# Structured Reasoning (Step ${params.currentStep} of ${params.plannedSteps})\n\n${structuredReasoning}\n\n(Step ${params.currentStep} of ${params.plannedSteps})`; }
- src/think/tools.ts:10-39 (registration)The server.addTool call that registers the 'think' tool, specifying name, description, parameters schema, and execute handler.server.addTool({ name: "think", description: "Use the tool to think about something. It will not obtain new information or change the database, but just append the thought to the log. Use it when complex reasoning or some cache memory is needed. Consider including: problem definition, relevant context, analysis steps, self-reflection on your reasoning, and conclusions. Adapt this structure as needed for your specific thought process.", parameters: ExtendedThinkSchema, execute: async (params: any) => { const { structuredReasoning, selfReflect = false } = params; // Step counter logic // Initialize or estimate plannedSteps if not provided if (!params.plannedSteps) { // Roughly estimate based on content length const contentLength = structuredReasoning.length; params.plannedSteps = Math.max(1, Math.min(5, Math.ceil(contentLength / 300))); } // Initialize currentStep if not provided if (!params.currentStep) { params.currentStep = 1; } else { // Increment the current step params.currentStep += 1; } // Ensure current step doesn't exceed planned steps params.currentStep = Math.min(params.currentStep, params.plannedSteps); // Format output with step counter return `# Structured Reasoning (Step ${params.currentStep} of ${params.plannedSteps})\n\n${structuredReasoning}\n\n(Step ${params.currentStep} of ${params.plannedSteps})`; } });
- src/think/schemas.ts:6-27 (schema)The base ThinkSchema defining the input parameters for the 'think' tool using Zod validation.export const ThinkSchema = z.object({ structuredReasoning: z.string() .min(10, 'Reasoning must be at least 10 characters long') .describe('A structured thought process to work through complex problems. Use this as a dedicated space for reasoning step-by-step.'), // Optional memory parameters - can be added in future to associate thoughts with specific contexts associateWithEntity: z.string().optional() .describe('Optional entity name to associate this thought with'), category: z.string().optional() .describe('Optional category for the thought (e.g., "problem-solving", "analysis", "planning")'), tags: z.array(z.string()).optional() .describe('Optional tags to help categorize and find this thought later'), storeInMemory: z.boolean().optional() .default(false) .describe('Whether to store this thought in the knowledge graph memory'), context: z.string().optional() .describe('Optional context or situation relevant to this thought (e.g., project, meeting, or scenario)'), });
- src/agents/BasicAgent.ts:10-19 (schema)ExtendedThinkSchema extends the base schema with additional fields for step counting, self-reflection, research, and formatting options. This is the schema used in the 'think' tool parameters.export const ExtendedThinkSchema = BaseThinkSchema.extend({ plannedSteps: z.number().optional().describe('The total number of steps planned for this thinking process'), currentStep: z.number().optional().describe('The current step number in the thinking process'), selfReflect: z.boolean().optional().default(false).describe('Whether to perform a self-reflection pass after generating the answer'), allowResearch: z.boolean().optional().default(false).describe('Whether to allow research via external tools during the reasoning process'), reflectPrompt: z.string().optional().describe('Custom prompt for the self-reflection stage'), researchQuery: z.string().optional().describe('Optional research query to execute during the reasoning process'), formatOutput: z.boolean().optional().default(true).describe('Whether to apply markdown formatting to the output'), formatType: z.enum(['auto', 'general', 'problem', 'comparison']).optional().default('auto').describe('The type of formatting to apply') });
- src/core/tools.ts:18-20 (registration)Registration call to registerThinkTools(server), which adds the 'think' tool to the MCP server.// Register think tools console.error('[INFO] [tools] Registering think tools...'); registerThinkTools(server);