# Directory Structure ``` ├── .gitignore ├── package.json ├── README.md ├── src │ └── index.ts └── tsconfig.json ``` # Files -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- ``` 1 | # Dependencies 2 | node_modules/ 3 | npm-debug.log 4 | yarn-debug.log 5 | yarn-error.log 6 | package-lock.json 7 | yarn.lock 8 | 9 | # Build outputs 10 | build/ 11 | dist/ 12 | *.tsbuildinfo 13 | 14 | # TypeScript incremental compilation cache 15 | *.tsbuildinfo 16 | 17 | # Environment variables 18 | .env 19 | .env.local 20 | .env.*.local 21 | 22 | # IDE/Editor folders 23 | .idea/ 24 | .vscode/ 25 | *.swp 26 | *.swo 27 | .DS_Store 28 | 29 | # Logs 30 | logs/ 31 | *.log 32 | 33 | # Operating System Files 34 | .DS_Store 35 | Thumbs.db 36 | ``` -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- ```markdown 1 | # MCP Think Tool 2 | 3 | This is an implementation of the "Think Tool" described in Anthropic's engineering blog post as an MCP server. The Think Tool is a simple but effective prompt engineering technique that helps Claude break down complex problems and enhance its reasoning capabilities. 4 | 5 | ## How it Works 6 | 7 | The Think Tool is incredibly simple - it provides a no-op tool that does nothing except echo back the input. The magic is in how it allows Claude to: 8 | 9 | 1. Take a step back and think through complex problems 10 | 2. Break down reasoning into discrete steps 11 | 3. Organize thoughts more systematically 12 | 4. Cache intermediate results during complex calculations 13 | 5. Show its work when solving problems 14 | 15 | As described by Anthropic, this is a "prompt engineering trick" where they use the standard tool calling mechanism to define a tool called "think" that "does nothing at all" - there is no implementation - it simply allows the model to use its existing training about when to use tools to stop and dump additional thoughts into the context. 16 | 17 | ## Implementation Details 18 | 19 | The MCP server exposes a single tool: 20 | 21 | 1. `think` - Takes a thought as input and returns it 22 | 23 | Tool definition: 24 | 25 | ```json 26 | { 27 | "name": "think", 28 | "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.", 29 | "input_schema": { 30 | "type": "object", 31 | "properties": { 32 | "thought": { 33 | "type": "string", 34 | "description": "A thought to think about." 35 | } 36 | }, 37 | "required": ["thought"] 38 | } 39 | } 40 | ``` 41 | 42 | ## Usage 43 | 44 | ### Setup 45 | 46 | 1. Clone this repository 47 | 2. Run `npm install` to install dependencies 48 | 3. Run `npm run build` to compile TypeScript 49 | 4. Run `npm start` to start the MCP server 50 | 51 | ### Connecting to Claude Desktop 52 | 53 | Add this server to your Claude Desktop configuration file: 54 | 55 | ```json 56 | { 57 | "mcpServers": { 58 | "think-tool": { 59 | "command": "node", 60 | "args": ["/path/to/mcp-think-tool/build/index.js"] 61 | } 62 | } 63 | } 64 | ``` 65 | 66 | Add this prompt to teach the LLM how to use the think tool: 67 | 68 | ``` 69 | ## Using the think tool 70 | 71 | Before taking any action or responding to the user after receiving tool results, use the think tool as a scratchpad to: 72 | - List the specific rules that apply to the current request 73 | - Check if all required information is collected 74 | - Verify that the planned action complies with all policies 75 | - Iterate over tool results for correctness 76 | 77 | Here are some examples of what to iterate over inside the think tool: 78 | <think_tool_example_1> 79 | User wants to cancel flight ABC123 80 | - Need to verify: user ID, reservation ID, reason 81 | - Check cancellation rules: 82 | * Is it within 24h of booking? 83 | * If not, check ticket class and insurance 84 | - Verify no segments flown or are in the past 85 | - Plan: collect missing info, verify rules, get confirmation 86 | </think_tool_example_1> 87 | 88 | <think_tool_example_2> 89 | User wants to book 3 tickets to NYC with 2 checked bags each 90 | - Need user ID to check: 91 | * Membership tier for baggage allowance 92 | * Which payments methods exist in profile 93 | - Baggage calculation: 94 | * Economy class × 3 passengers 95 | * If regular member: 1 free bag each → 3 extra bags = $150 96 | * If silver member: 2 free bags each → 0 extra bags = $0 97 | * If gold member: 3 free bags each → 0 extra bags = $0 98 | - Payment rules to verify: 99 | * Max 1 travel certificate, 1 credit card, 3 gift cards 100 | * All payment methods must be in profile 101 | * Travel certificate remainder goes to waste 102 | - Plan: 103 | 1. Get user ID 104 | 2. Verify membership level for bag fees 105 | 3. Check which payment methods in profile and if their combination is allowed 106 | 4. Calculate total: ticket price + any bag fees 107 | 5. Get explicit confirmation for booking 108 | </think_tool_example_2> 109 | ``` 110 | 111 | Replace `/path/to/mcp-think-tool` with the actual path to this repository. 112 | 113 | ## Examples 114 | 115 | Claude might use the Think Tool to work through a problem like: 116 | 117 | ``` 118 | Solving 235 × 47: 119 | 120 | Think: First I'll break this down. I need to multiply 235 by 47. 121 | Think: I'll start by calculating 235 × 40 = 9,400 122 | Think: Then I'll calculate 235 × 7 = 1,645 123 | Think: Now I add them together: 9,400 + 1,645 = 11,045 124 | 125 | Therefore, 235 × 47 = 11,045 126 | ``` 127 | 128 | Or for a more complex reasoning task: 129 | 130 | ``` 131 | Think: I need to analyze the given problem carefully. The question asks about the impact of reducing carbon emissions by 15% over 5 years. 132 | Think: First, I should establish the baseline emissions. The document mentions current annual emissions of 50 million metric tons. 133 | Think: 15% reduction over 5 years means approximately 3% reduction per year, assuming linear decrease. 134 | Think: After 5 years, annual emissions would be 50 × (1 - 0.15) = 50 × 0.85 = 42.5 million metric tons. 135 | Think: The total reduction over 5 years would be the sum of the reductions each year... 136 | ``` 137 | 138 | ## Development 139 | 140 | - `src/index.ts` - MCP server implementation 141 | 142 | ## License 143 | 144 | ISC 145 | ``` -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- ```json 1 | { 2 | "compilerOptions": { 3 | "target": "ES2022", 4 | "module": "Node16", 5 | "moduleResolution": "Node16", 6 | "outDir": "./build", 7 | "rootDir": "./src", 8 | "strict": true, 9 | "esModuleInterop": true, 10 | "skipLibCheck": true, 11 | "forceConsistentCasingInFileNames": true 12 | }, 13 | "include": [ 14 | "src/**/*" 15 | ], 16 | "exclude": [ 17 | "node_modules" 18 | ] 19 | } 20 | ``` -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- ```json 1 | { 2 | "name": "mcp-think-tool", 3 | "version": "1.0.0", 4 | "description": "A basic MCP server for memory management", 5 | "main": "build/index.js", 6 | "type": "module", 7 | "scripts": { 8 | "build": "tsc", 9 | "start": "node build/index.js", 10 | "dev": "tsc && node build/index.js", 11 | "test": "echo \"Error: no test specified\" && exit 1" 12 | }, 13 | "keywords": [ 14 | "mcp", 15 | "llm", 16 | "memory" 17 | ], 18 | "author": "", 19 | "license": "ISC", 20 | "dependencies": { 21 | "@modelcontextprotocol/sdk": "^1.7.0", 22 | "zod": "^3.22.4" 23 | }, 24 | "devDependencies": { 25 | "@types/node": "^20.11.0", 26 | "typescript": "^5.3.3" 27 | } 28 | } 29 | ``` -------------------------------------------------------------------------------- /src/index.ts: -------------------------------------------------------------------------------- ```typescript 1 | import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; 2 | import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js"; 3 | import { z } from "zod"; 4 | 5 | // Create server instance 6 | const server = new McpServer({ 7 | name: "mcp-think-tool", 8 | version: "1.0.0", 9 | }); 10 | 11 | // Register the "think" tool 12 | server.tool( 13 | "think", 14 | "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.", 15 | { 16 | thought: z.string().describe("A thought to think about."), 17 | }, 18 | async ({ thought }) => { 19 | // This tool does nothing at all - it's a no-op 20 | // It simply lets Claude externalize its thinking process 21 | return { 22 | content: [ 23 | { 24 | type: "text", 25 | text: thought, 26 | }, 27 | ], 28 | }; 29 | } 30 | ); 31 | 32 | async function main() { 33 | const transport = new StdioServerTransport(); 34 | await server.connect(transport); 35 | console.error("MCP Think Tool Server running on stdio"); 36 | } 37 | 38 | main().catch((error) => { 39 | console.error("Fatal error in main():", error); 40 | process.exit(1); 41 | }); 42 | ```