AI认知检查工具

MCP反射工具是一个为AI助手提供结构化思考和认知检查点的服务器,帮助LLM保持上下文、反思工作并系统化解决复杂问题。

  • by fourcolors
  • TypeScript
  • 本地部署
  • 6 星标
  • 更新于
在 GitHub 查看 fourcolors/think-tool

使用说明

MCP反射工具

一个模型上下文协议(MCP)服务器,为人工智能助手提供“反映”工具,以创建认知检查点和结构化推理。该工具帮助LLM维护上下文,反思他们的工作,并系统地思考复杂的问题。

为什么要使用这个工具?

关键见解: 如果不明确地输出思维过程,就不会发生深入思考。该工具创建了强制性的认知检查点,以防止捷径并提高准确性。

特性

  • 🧠 结构化推理:迫使人工智能助手逐步思考复杂问题
  • ✅ 任务验证:创建检查点以验证是否满足要求
  • 📝 学习文档:在解决问题的过程中捕捉发现和见解
  • 🔍 调试辅助设备:通过消除来帮助系统地解决问题
  • 🎯 决策审计追踪:为重要决策创建推理记录

安装

通过NPM快速安装

# Install globally
npm install -g mcp-reflection-tool

# Or run directly with npx (no installation needed)
npx mcp-reflection-tool

与AI工具集成

克劳德代码

使用单个命令添加服务器:

mcp add npx mcp-reflection-tool

这将在您的Claude Code设置中自动配置服务器。运行命令后,完全重新启动Claude Code。

光标

添加到游标配置中:

选项1:通过设置UI

  1. 打开光标设置(Cmd/Ctrl+,)
  2. 搜索“MCP”或导航到功能>MCP
  3. 添加反射工具配置

选项2:直接配置编辑

编辑 ~/.cursor/mcp_config.json:

{
  "mcpServers": {
    "reflection-tool": {
      "command": "npx",
      "args": ["mcp-reflection-tool"]
    }
  }
}

更改后重新启动Cursor。

帆板运动

添加到您的Windsurf MCP配置中:

位置: ~/.windsurf/mcp.json (macOS/Linux)或 %USERPROFILE%\.windsurf\mcp.json (Windows)

{
  "mcpServers": {
    "reflection-tool": {
      "command": "npx",
      "args": ["mcp-reflection-tool"]
    }
  }
}

重新启动Windsurf以应用更改。

Cline(VS代码扩展)

选项1:通过VS代码设置界面

  1. 打开VS代码设置(Cmd/Ctrl+,)
  2. 搜索“临床MCP”
  3. 添加服务器配置

选项2:编辑settings.json

添加到您的VS代码 settings.json:

{
  "cline.mcpServers": {
    "reflection-tool": {
      "command": "npx",
      "args": ["mcp-reflection-tool"]
    }
  }
}

配置后重新加载VS代码窗口。

替代方案:手动服务器模式

默认情况下,服务器通过stdio运行。如果需要HTTP模式,请使用环境变量:

# Start server in stdio mode (default)
npx mcp-reflection-tool

# Start in HTTP mode on port 8080
HTTP=true npx mcp-reflection-tool

# Start in HTTP mode on custom port
HTTP=true PORT=3000 npx mcp-reflection-tool

大多数现代AI工具自动支持stdio模式。

使用示例

安装后,AI助手将可以访问 reflect 工具。以下是如何使用它的示例:

复杂行动之前

Using reflection tool: "Breaking down authentication implementation:
1. Check existing auth patterns in codebase
2. Set up JWT token generation  
3. Add middleware for route protection
4. Test with valid and expired tokens"

完成任务后

Using reflection tool: "Task completion check:
- Completed: Implemented user authentication with JWT
- Learned: Existing middleware made integration smooth
- Technical debt: Need to add rate limiting
- Next: Update API documentation"

在问题解决过程中

Using reflection tool: "Debugging slow API responses:
- Symptom: 5+ second response times
- Hypothesis 1: Missing database indexes - CONFIRMED
- Hypothesis 2: N+1 query problem - Also found
- Solution: Added compound indexes and query batching
- Result: Response time now <200ms"

当工具被使用时

AI助手将自动使用此工具作为认知草稿,用于:

  • 🔍 思维链推理 通过复杂的问题
  • 📋 规划你的方法 在采取行动之前
  • ✅ 反思成果 完成任务后
  • ✔️ 验证该要求 满足
  • 📝 记录发现 和学习
  • 🎯 创建认知检查点 你不能跳过

这有助于人工智能逐步思考,提高准确性和合规性。

发展

先决条件

  • Node.js 18+或Bun运行时
  • npm或bun包管理器

设置

# Clone the repository
git clone https://github.com/sterling/think-tool.git
cd think-tool

# Install dependencies
bun install
# or
npm install

# Run in development mode (with hot-reload)
bun run dev
# or
npm run dev

从源头构建

# Build TypeScript to JavaScript
bun run build
# or
npm run build

# Run the built version
bun start
# or
npm start

项目结构

├── src/
│   └── server.ts      # TypeScript source code
├── dist/              # Built JavaScript (generated)
│   ├── server.js      # Main server file
│   └── cli.js         # CLI executable
├── package.json       # NPM package configuration
└── tsconfig.json      # TypeScript configuration

配置

环境变量

  • PORT:服务器端口(默认值:8080)
    PORT=3000 npx mcp-reflection-tool
    

运作原理

反射工具实现了模型上下文协议(MCP),为AI助手访问外部工具提供了一种标准化的方式。当AI助手需要反思问题时:

  1. AI称 reflect 工具及其推理
  2. 该工具将思维过程记录到服务器控制台
  3. 该工具将检查点确认回AI
  4. 这创建了一个认知检查点,提高了推理质量

这种“大声思考”的效果已被证明可以显著提高人工智能响应的准确性和完整性。

故障排除

常见问题

端口已在使用中

# Use a different port
PORT=8081 npx mcp-reflection-tool

权限不足

# Reinstall globally with proper permissions
sudo npm install -g mcp-reflection-tool

AI助手中没有工具

  1. 确保MCP服务器正在运行
  2. 添加配置后重新启动AI工具
  3. 检查配置文件中的有效JSON语法
  4. 验证操作系统的配置文件位置

检查日志

  • 服务器日志:在运行服务器的终端中可见
  • 克劳德代码日志: ~/Library/Logs/Claude/mcp*.log (macOS)
  • VS代码日志:查看>输出>从下拉列表中选择“Cline”
  • 游标日志:帮助>切换开发人员工具>控制台

验证安装

# Check if package is installed globally
npm list -g mcp-reflection-tool

# Test the server directly
npx mcp-reflection-tool

# Test stdio mode
echo '{"jsonrpc":"2.0","method":"initialize","id":1}' | npx mcp-reflection-tool

贡献

欢迎投稿!请随时提交拉取请求。

  1. 分叉存储库
  2. 创建功能分支(git checkout -b feature/amazing-feature)
  3. 提交您的更改(git commit -m 'Add amazing feature')
  4. 推到分支(git push origin feature/amazing-feature)
  5. 打开拉取请求

许可证

MIT许可证-有关详细信息,请参阅许可证文件。

作者

作为MCP实现创建,用于增强AI推理能力。

链接

致谢