项目简介

本项目实现了一个基于 Model Context Protocol (MCP) 的服务器,核心功能是提供 “思考 (think)” 工具。这个工具的设计灵感来源于 Anthropic 公司的研究,旨在提升类似 Claude 这样的大型语言模型在复杂任务中的推理能力。通过提供一个结构化的思考空间,该工具允许模型在解决问题、遵守策略以及进行多步骤推理时,记录、回顾和分析其思考过程,从而显著提高性能。

主要功能点

  • 提供“思考 (think)”工具:允许语言模型记录结构化思考内容,作为解决复杂问题的草稿空间。
  • 思考记录与回顾:支持模型检索 (get_thoughts) 当前会话中记录的所有思考内容,方便回顾推理过程。
  • 思考过程管理:提供清除 (clear_thoughts) 思考记录的功能,以便在需要时重置思考过程。
  • 思考分析:提供获取思考统计信息 (get_thought_stats) 的工具,帮助分析思考模式。
  • 优化复杂任务处理:特别适用于需要复杂工具链、策略遵循、序列决策和多步骤分析的场景。
  • 提升 Claude 性能:通过结构化思考,增强 Claude 等语言模型在复杂任务中的表现。

安装步骤

  1. 确保已安装 Node.js 和 npm。
  2. 打开终端,运行以下命令全局安装 'cgize_claude-mcp-think-tool' 包:
    npm install -g @cgize/mcp-think-tool

服务器配置

要将此 MCP 服务器与 MCP 客户端(如 Claude 桌面应用)连接,您需要编辑 MCP 客户端的配置文件。在配置文件中添加以下 'mcpServers' 配置,以注册 'think-tool' 服务器。

配置文件位置:

  • 'C:\Users[您的用户名]\AppData\Roaming\Claude\claude_desktop_config.json' (Windows)

配置信息 (JSON 格式):

将以下 JSON 代码添加到您的 MCP 客户端配置文件中。您可以选择使用全局安装的命令 'claude-mcp-think-tool' 或使用 'npx' 运行安装包。

选项 1:使用全局安装命令

{
  "mcpServers": {
    "think-tool": { // 服务器名称,可以自定义
      "command": "claude-mcp-think-tool", // 启动服务器的命令
      "args": [], // 启动参数,此处为空
      "type": "stdio", // 通信协议类型,使用 stdio
      "pollingInterval": 30000, // 轮询间隔 (毫秒)
      "startupTimeout": 30000, // 启动超时时间 (毫秒)
      "restartOnFailure": true // 失败时自动重启
    }
  }
}

选项 2:使用 'npx' 命令

{
  "mcpServers": {
    "think-tool": { // 服务器名称,可以自定义
      "command": "npx", // 使用 npx 命令执行 npm 包
      "args": [
        "-y",
        "@cgize/mcp-think-tool" // 要执行的 npm 包名称
      ],
      "type": "stdio", // 通信协议类型,使用 stdio
      "pollingInterval": 30000, // 轮询间隔 (毫秒)
      "startupTimeout": 30000, // 启动超时时间 (毫秒)
      "restartOnFailure": true // 失败时自动重启
    }
  }
}

配置说明:

  • '"think-tool"': 服务器名称,您可以在 MCP 客户端中使用此名称来引用该服务器。可以自定义。
  • '"command"': 启动 MCP 服务器的命令。根据您的安装方式选择 'claude-mcp-think-tool' 或 'npx'。
  • '"args"': 启动命令的参数。如果使用全局安装命令,则参数为空数组 '[]';如果使用 'npx',则参数为 '["-y", "@cgize/mcp-think-tool"]'。
  • '"type": "stdio"': 指定 MCP 服务器使用标准输入/输出 (stdio) 进行通信。
  • '"pollingInterval"', '"startupTimeout"', '"restartOnFailure"': 是 MCP 客户端用于管理服务器连接的参数,通常使用默认值即可。

基本使用方法

  1. 确保已按照安装步骤安装 'cgize_claude-mcp-think-tool'。
  2. 配置您的 MCP 客户端 (如 Claude 桌面应用),添加上述服务器配置信息。
  3. 启动 MCP 客户端。客户端会自动启动并连接到 'think-tool' 服务器。
  4. 在与 Claude 的对话中,您可以使用以下工具来利用 “思考” 功能:
    • 'think' 工具: 在提示词中指示 Claude 使用 'think' 工具记录思考过程。例如:'Use the "think" tool to plan the steps to solve this problem.'
    • 'get_thoughts' 工具: 指示 Claude 使用 'get_thoughts' 工具回顾已记录的思考内容。例如:'Use the "get_thoughts" tool to review your plan.'
    • 'clear_thoughts' 工具: 指示 Claude 使用 'clear_thoughts' 工具清除思考记录。例如:'Use the "clear_thoughts" tool to clear the previous thoughts and start a new thinking process.'
    • 'get_thought_stats' 工具: 指示 Claude 使用 'get_thought_stats' 工具获取思考统计信息。例如:'Use the "get_thought_stats" tool to analyze your thinking process so far.'

请参考仓库 README 文件中的 "Example Prompt""Custom Instructions" 部分,获取更详细的使用示例和优化 Claude 使用 'think' 工具的建议。

信息

分类

AI与计算