think
Log structured thought processes for complex reasoning tasks like bug fixing, test troubleshooting, refactoring planning, feature design, and debugging analysis without making repository changes.
Instructions
Use the tool to think about something. It will not obtain new information or make any changes to the repository, but just log the thought. Use it when complex reasoning or brainstorming is needed. Ensure thinking content is concise and accurate, without needing to include code details
Common use cases:
When exploring a repository and discovering the source of a bug, call this tool to brainstorm several unique ways of fixing the bug, and assess which change(s) are likely to be simplest and most effective
After receiving test results, use this tool to brainstorm ways to fix failing tests
When planning a complex refactoring, use this tool to outline different approaches and their tradeoffs
When designing a new feature, use this tool to think through architecture decisions and implementation details
When debugging a complex issue, use this tool to organize your thoughts and hypotheses
When considering changes to the plan or shifts in thinking that the user has not previously mentioned, consider whether it is necessary to confirm with the user.
<think_example> Feature Implementation Planning
New code search feature requirements:
Search for code patterns across multiple files
Identify function usages and references
Analyze import relationships
Generate summary of matching patterns
Implementation considerations:
Need to leverage existing search mechanisms
Should use regex for pattern matching
Results need consistent format with other search methods
Must handle large codebases efficiently
Design approach:
Create new CodeSearcher class that follows existing search patterns
Implement core pattern matching algorithm
Add result formatting methods
Integrate with file traversal system
Add caching for performance optimization
Testing strategy:
Unit tests for search accuracy
Integration tests with existing components
Performance tests with large codebases </think_example>
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| thought | Yes | The detailed thought process to record |
Implementation Reference
- The core execution logic for the 'think' tool handler. Validates the 'thought' parameter, logs it using the tool context, and returns a confirmation message without making external changes.async def call( self, ctx: MCPContext, **params: Unpack[ThinkingToolParams], ) -> str: """Execute the tool with the given parameters. Args: ctx: MCP context **params: Tool parameters Returns: Tool result """ tool_ctx = create_tool_context(ctx) tool_ctx.set_tool_info(self.name) # Extract parameters thought = params.get("thought") # Validate required thought parameter if not thought: await tool_ctx.error( "Parameter 'thought' is required but was None or empty" ) return "Error: Parameter 'thought' is required but was None or empty" if thought.strip() == "": await tool_ctx.error("Parameter 'thought' cannot be empty") return "Error: Parameter 'thought' cannot be empty" # Log the thought but don't take action await tool_ctx.info("Thinking process recorded") # Return confirmation return "I've recorded your thinking process. You can continue with your next action based on this analysis."
- Pydantic-based input schema defining the required 'thought' parameter with validation (non-empty string).Thought = Annotated[ str, Field( description="The detailed thought process to record", min_length=1, ), ] class ThinkingToolParams(TypedDict): """Parameters for the ThinkingTool. Attributes: thought: The detailed thought process to record """ thought: Thought
- mcp_claude_code/tools/common/__init__.py:10-21 (registration)Instantiates and registers the ThinkingTool instance using ToolRegistry, returning it for further use.def register_thinking_tool( mcp_server: FastMCP, ) -> list[BaseTool]: """Register thinking tools with the MCP server. Args: mcp_server: The FastMCP server instance """ thinking_tool = ThinkingTool() ToolRegistry.register_tool(mcp_server, thinking_tool) return [thinking_tool]
- mcp_claude_code/tools/__init__.py:87-90 (registration)Top-level registration call during all_tools setup, integrating the 'think' tool into the comprehensive tool registry.# Initialize and register thinking tool thinking_tool = register_thinking_tool(mcp_server) for tool in thinking_tool: all_tools[tool.name] = tool
- mcp_claude_code/tools/common/thinking_tool.py:136-154 (registration)The tool's register method defines and decorates the actual 'think' handler function with @mcp_server.tool, delegating to self.call().def register(self, mcp_server: FastMCP) -> None: """Register this thinking tool with the MCP server. Creates a wrapper function with explicitly defined parameters that match the tool's parameter schema and registers it with the MCP server. Args: mcp_server: The FastMCP server instance """ tool_self = self # Create a reference to self for use in the closure @mcp_server.tool(name=self.name, description=self.description) async def think( ctx: MCPContext, thought: Thought, ) -> str: ctx = get_context() return await tool_self.call(ctx, thought=thought)