├── claude_desktop_config.json
├── Dockerfile
├── .gitignore
├── smithery.yaml
├── tsconfig.json
├── .npmignore
├── LICENSE
├── package.json
├── README.md
└── src
└── index.ts
/claude_desktop_config.json:
--------------------------------------------------------------------------------
1 | {
2 | "mcpServers": {
3 | "think-tool": {
4 | "command": "npx",
5 | "args": [
6 | "-y",
7 | "@cgize/mcp-think-tool"
8 | ],
9 | "type": "stdio",
10 | "pollingInterval": 30000,
11 | "startupTimeout": 30000,
12 | "restartOnFailure": true
13 | }
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/Dockerfile:
--------------------------------------------------------------------------------
1 | # Generated by https://smithery.ai. See: https://smithery.ai/docs/config#dockerfile
2 | FROM node:lts-alpine
3 |
4 | WORKDIR /app
5 |
6 | # Copy package files and install dependencies
7 | COPY package*.json ./
8 | RUN npm install --ignore-scripts
9 |
10 | # Copy the rest of the code
11 | COPY . .
12 |
13 | # Build the project
14 | RUN npm run build
15 |
16 | # Set the default command
17 | CMD [ "node", "dist/index.js" ]
18 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Dependencias
2 | node_modules/
3 |
4 | # Archivos compilados
5 | dist/
6 | build/
7 |
8 | # Archivos de sistema
9 | .DS_Store
10 | Thumbs.db
11 |
12 | # Archivos de registro
13 | *.log
14 | npm-debug.log*
15 | yarn-debug.log*
16 | yarn-error.log*
17 |
18 | # Archivos de entorno
19 | .env
20 | .env.local
21 | .env.development.local
22 | .env.test.local
23 | .env.production.local
24 |
25 | # Directorios y archivos de cachés
26 | .npm
27 | .cache
28 |
--------------------------------------------------------------------------------
/smithery.yaml:
--------------------------------------------------------------------------------
1 | # Smithery configuration file: https://smithery.ai/docs/config#smitheryyaml
2 |
3 | startCommand:
4 | type: stdio
5 | configSchema:
6 | # JSON Schema defining the configuration options for the MCP.
7 | {}
8 | commandFunction:
9 | # A JS function that produces the CLI command based on the given config to start the MCP on stdio.
10 | |-
11 | (config) => ({
12 | command: 'node',
13 | args: ['dist/index.js']
14 | })
15 | exampleConfig: {}
16 |
--------------------------------------------------------------------------------
/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "ES2020",
4 | "module": "NodeNext",
5 | "moduleResolution": "NodeNext",
6 | "esModuleInterop": true,
7 | "outDir": "./dist",
8 | "strict": true,
9 | "skipLibCheck": true,
10 | "forceConsistentCasingInFileNames": true,
11 | "declaration": true,
12 | "sourceMap": true,
13 | "rootDir": "./src"
14 | },
15 | "include": [
16 | "src/**/*"
17 | ],
18 | "exclude": [
19 | "node_modules",
20 | "dist"
21 | ]
22 | }
23 |
--------------------------------------------------------------------------------
/.npmignore:
--------------------------------------------------------------------------------
1 | # Source files (only dist is needed)
2 | src/
3 | tsconfig.json
4 |
5 | # Development files
6 | .github/
7 | .git/
8 | .gitignore
9 | .eslintrc.js
10 | .prettierrc
11 | .editorconfig
12 |
13 | # Testing
14 | test/
15 | coverage/
16 | *.test.ts
17 | *.spec.ts
18 |
19 | # IDE files
20 | .vscode/
21 | .idea/
22 | *.swp
23 | *.swo
24 |
25 | # Logs
26 | logs/
27 | *.log
28 | npm-debug.log*
29 | yarn-debug.log*
30 | yarn-error.log*
31 |
32 | # Dependency directories
33 | node_modules/
34 |
35 | # Environment variables
36 | .env
37 | .env.local
38 | .env.development.local
39 | .env.test.local
40 | .env.production.local
41 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2025 Cristobal
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@cgize/mcp-think-tool",
3 | "version": "1.0.0",
4 | "description": "MCP Think Tool server for Claude Desktop",
5 | "main": "dist/index.js",
6 | "type": "module",
7 | "bin": {
8 | "claude-mcp-think-tool": "./dist/index.js"
9 | },
10 | "scripts": {
11 | "build": "tsc",
12 | "start": "node dist/index.js",
13 | "dev": "ts-node --esm src/index.ts",
14 | "prepare": "npm run build",
15 | "prepublishOnly": "npm run build"
16 | },
17 | "keywords": [
18 | "claude",
19 | "mcp",
20 | "think-tool",
21 | "anthropic",
22 | "ai",
23 | "reasoning"
24 | ],
25 | "author": "cgize",
26 | "license": "MIT",
27 | "dependencies": {
28 | "@modelcontextprotocol/sdk": "^1.7.0",
29 | "zod": "^3.22.4"
30 | },
31 | "devDependencies": {
32 | "@types/node": "^20.11.19",
33 | "ts-node": "^10.9.2",
34 | "typescript": "^5.3.3"
35 | },
36 | "repository": {
37 | "type": "git",
38 | "url": "https://github.com/cgize/claude-mcp-think-tool.git"
39 | },
40 | "bugs": {
41 | "url": "https://github.com/cgize/claude-mcp-think-tool/issues"
42 | },
43 | "homepage": "https://github.com/cgize/claude-mcp-think-tool#readme",
44 | "publishConfig": {
45 | "access": "public"
46 | },
47 | "engines": {
48 | "node": ">=14.0.0"
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # MCP Think Tool Server
2 |
3 | [](https://smithery.ai/server/@cgize/claude-mcp-think-tool)
4 |
5 | A Model Context Protocol (MCP) server implementing the ["think" tool](https://www.anthropic.com/engineering/claude-think-tool) for improving Claude's complex reasoning capabilities.
6 |
7 |
8 |
9 |
10 |
11 | ## Overview
12 |
13 | This MCP server implements Anthropic's "think" tool, which provides Claude with a dedicated space for structured thinking during complex problem-solving tasks. As described in [Anthropic's blog post](https://www.anthropic.com/engineering/claude-think-tool), the think tool has been shown to significantly improve performance in complex tasks requiring policy adherence and reasoning in long chains of tool calls.
14 |
15 | ## Custom Instructions
16 |
17 | Add these custom instructions to Claude to optimize its use of the think tool:
18 |
19 | ```
20 | You have access to a "think" tool that provides a dedicated space for structured reasoning. Using this tool significantly improves your performance on complex tasks.
21 |
22 | ## When to use the think tool
23 | Before taking any action or responding to the user after receiving tool results, use the think tool as a scratchpad to:
24 | - List the specific rules that apply to the current request
25 | - Check if all required information is collected
26 | - Verify that the planned action complies with all policies
27 | - Iterate over tool results for correctness
28 | - Analyze complex information from web searches or other tools
29 | - Plan multi-step approaches before executing them
30 |
31 | ## How to use the think tool effectively
32 | When using the think tool:
33 | 1. Break down complex problems into clearly defined steps
34 | 2. Identify key facts, constraints, and requirements
35 | 3. Check for gaps in information and plan how to fill them
36 | 4. Evaluate multiple approaches before choosing one
37 | 5. Verify your reasoning for logical errors or biases
38 | ```
39 |
40 | ## Key Use Cases
41 |
42 | - **Complex Tool Chains**: When Claude needs to call complex tools and analyze outputs carefully
43 | - **Policy Adherence**: For navigating policy-heavy environments with detailed guidelines
44 | - **Sequential Decision Making**: When each step builds on previous ones and mistakes are costly
45 | - **Multi-step Analysis**: Breaking down complex problems into manageable steps
46 |
47 | ## Installation
48 |
49 | ### Installing via Smithery
50 |
51 | To install Think Tool Server for Claude Desktop automatically via [Smithery](https://smithery.ai/server/@cgize/claude-mcp-think-tool):
52 |
53 | ```bash
54 | npx -y @smithery/cli install @cgize/claude-mcp-think-tool --client claude
55 | ```
56 |
57 | ### Manual Installation
58 | ```bash
59 | npm install -g @cgize/mcp-think-tool
60 | ```
61 |
62 | ## Configuration
63 |
64 | Add this configuration to your MCP configuration file:
65 |
66 | ```json
67 | {
68 | "mcpServers": {
69 | "think-tool": {
70 | "command": "npx",
71 | "args": [
72 | "-y",
73 | "@cgize/mcp-think-tool"
74 | ],
75 | "type": "stdio",
76 | "pollingInterval": 30000,
77 | "startupTimeout": 30000,
78 | "restartOnFailure": true
79 | }
80 | }
81 | }
82 | ```
83 |
84 | Configuration file location:
85 | - `C:\Users\[username]\AppData\Roaming\Claude\claude_desktop_config.json`
86 |
87 | If installed globally, you can also use:
88 |
89 | ```json
90 | {
91 | "mcpServers": {
92 | "think-tool": {
93 | "command": "claude-mcp-think-tool",
94 | "args": [],
95 | "type": "stdio",
96 | "pollingInterval": 30000,
97 | "startupTimeout": 30000,
98 | "restartOnFailure": true
99 | }
100 | }
101 | }
102 | ```
103 |
104 | ## Available Tools
105 |
106 | - **think**: Record structured reasoning during problem-solving
107 | - **get_thoughts**: Retrieve all recorded thoughts
108 | - **clear_thoughts**: Reset the thinking process
109 | - **get_thought_stats**: Analyze thinking patterns
110 |
111 | ## Example Prompt
112 |
113 | ```
114 | Using the think tool, solve this multi-step problem:
115 |
116 | A train travels at a constant speed of 60 km/h. It departs from station A at 9:00 AM and arrives at station B at 11:30 AM. What is the distance between stations A and B?
117 | ```
118 |
119 | ## License
120 |
121 | MIT
--------------------------------------------------------------------------------
/src/index.ts:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env node
2 |
3 | import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
4 | import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
5 | import { z } from "zod";
6 |
7 | // Interface for storing thoughts
8 | interface ThoughtRecord {
9 | timestamp: string;
10 | thought: string;
11 | }
12 |
13 | class ThinkToolServer {
14 | private thoughtsLog: ThoughtRecord[] = [];
15 | private server: McpServer;
16 |
17 | constructor() {
18 | // Initialize MCP server
19 | this.server = new McpServer({
20 | name: "think-tool",
21 | version: "1.0.0"
22 | });
23 |
24 | // Register tools
25 | this.registerTools();
26 | }
27 |
28 | private registerTools(): void {
29 | // Register the "think" tool
30 | this.server.tool(
31 | "think",
32 | "Use this tool to think about something. It will not obtain new information or change anything, but just append the thought to the log. Use it when complex reasoning or cache memory is needed, especially during long chains of tool calls, policy adherence scenarios, or sequential decision making.",
33 | { thought: z.string().describe("A thought to think about. This can be structured reasoning, step-by-step analysis, policy verification, or any other mental process that helps with problem-solving.") },
34 | async ({ thought }) => {
35 | // Log the thought with a timestamp
36 | const timestamp = new Date().toISOString();
37 | this.thoughtsLog.push({
38 | timestamp,
39 | thought
40 | });
41 |
42 | console.error(`[${timestamp}] Thought recorded: ${thought.substring(0, 50)}${thought.length > 50 ? '...' : ''}`);
43 |
44 | // Return a confirmation
45 | return {
46 | content: [{
47 | type: "text",
48 | text: `Thought recorded: ${thought.length > 50 ? thought.substring(0, 50) + '...' : thought}`
49 | }]
50 | };
51 | }
52 | );
53 |
54 | // Register the get_thoughts tool
55 | this.server.tool(
56 | "get_thoughts",
57 | "Retrieve all thoughts recorded in the current session to review your reasoning process.",
58 | async () => {
59 | if (this.thoughtsLog.length === 0) {
60 | return {
61 | content: [{ type: "text", text: "No thoughts have been recorded yet." }]
62 | };
63 | }
64 |
65 | const formattedThoughts = this.thoughtsLog.map((entry, index) =>
66 | `Thought #${index + 1} (${entry.timestamp}):\n${entry.thought}\n`
67 | );
68 |
69 | return {
70 | content: [{ type: "text", text: formattedThoughts.join("\n") }]
71 | };
72 | }
73 | );
74 |
75 | // Register the clear_thoughts tool
76 | this.server.tool(
77 | "clear_thoughts",
78 | "Clear all thoughts recorded in the current session. Use this to start fresh if the thinking process needs to be reset.",
79 | async () => {
80 | const count = this.thoughtsLog.length;
81 | this.thoughtsLog = [];
82 |
83 | return {
84 | content: [{ type: "text", text: `Cleared ${count} recorded thoughts.` }]
85 | };
86 | }
87 | );
88 |
89 | // Register the get_thought_stats tool
90 | this.server.tool(
91 | "get_thought_stats",
92 | "Get statistics about the thoughts recorded in the current session to analyze your thinking process.",
93 | async () => {
94 | if (this.thoughtsLog.length === 0) {
95 | return {
96 | content: [{ type: "text", text: "No thoughts have been recorded yet." }]
97 | };
98 | }
99 |
100 | const totalThoughts = this.thoughtsLog.length;
101 | const avgLength = this.thoughtsLog.reduce((sum, entry) => sum + entry.thought.length, 0) / totalThoughts;
102 |
103 | let longestThoughtIndex = 0;
104 | let longestThoughtLength = 0;
105 |
106 | this.thoughtsLog.forEach((entry, index) => {
107 | if (entry.thought.length > longestThoughtLength) {
108 | longestThoughtLength = entry.thought.length;
109 | longestThoughtIndex = index;
110 | }
111 | });
112 |
113 | const stats = {
114 | total_thoughts: totalThoughts,
115 | average_length: Math.round(avgLength * 100) / 100,
116 | longest_thought_index: longestThoughtIndex + 1,
117 | longest_thought_length: longestThoughtLength
118 | };
119 |
120 | return {
121 | content: [{ type: "text", text: JSON.stringify(stats, null, 2) }]
122 | };
123 | }
124 | );
125 | }
126 |
127 | async run(transport = 'stdio'): Promise {
128 | console.error(`Starting Think Tool MCP Server with ${transport} transport...`);
129 |
130 | try {
131 | const transportHandler = new StdioServerTransport();
132 | await this.server.connect(transportHandler);
133 | console.error("Think Tool MCP Server running on stdio");
134 | } catch (error) {
135 | console.error("Error starting server:", error);
136 | process.exit(1);
137 | }
138 | }
139 | }
140 |
141 | // Signal handling for graceful shutdown
142 | process.on('SIGINT', () => {
143 | console.error("Shutting down Think Tool MCP Server...");
144 | process.exit(0);
145 | });
146 |
147 | process.on('SIGTERM', () => {
148 | console.error("Shutting down Think Tool MCP Server...");
149 | process.exit(0);
150 | });
151 |
152 | // Start server
153 | const server = new ThinkToolServer();
154 | server.run().catch(err => {
155 | console.error("Fatal error starting server:", err);
156 | process.exit(1);
157 | });
158 |
--------------------------------------------------------------------------------