Claude Code MCP Enhanced

by grahama1970
MIT License
5
  • Apple
  • Linux
Integrations
  • Enables ESLint setup and configuration, including fixing configurations and creating new configuration files

  • Enables version control operations including staging files, committing changes, pushing commits, creating tags, and managing branches through Claude Code CLI

  • Facilitates GitHub interactions such as creating pull requests, checking CI status, and managing repositories through Claude Code CLI

🤖 Claude 代码 MCP 服务器

想要快速入门?查看我们的QUICKSTART.md指南!

该项目是steipete/claude-code-mcp的一个分支,具有增强的编排功能、可靠性改进和附加文档。

增强型模型上下文协议 (MCP) 服务器,允许在一次性模式下运行 Claude 代码,并自动绕过权限限制。该服务器包含高级任务编排功能、强大的错误处理功能以及可将复杂任务分解为可管理子任务的“回旋镖模式”。

您是否注意到,标准的 AI 助手有时会遇到复杂的多步骤编辑或操作?这款服务器凭借其强大的统一claude_code工具和增强的可靠性功能,旨在使 Claude 成为您编码任务的更直接、更强大的代理。

🔍 概述

此 MCP 服务器提供了强大的工具,可供 LLM 与 Claude Code 交互。与 Claude Desktop 或其他 MCP 客户端集成后,它允许 LLM 执行以下操作:

  • 运行 Claude Code 并绕过所有权限(使用--dangerously-skip-permissions
  • 执行克劳德代码,无需任何许可中断
  • 直接访问文件编辑功能
  • 通过强大的错误处理和重试执行复杂的多步骤操作
  • 使用回旋镖模式通过专门的代理角色来协调任务
  • 通过心跳机制维持可靠执行,防止超时

✨ 好处

  • **增强的可靠性:**强大的错误处理、自动重试、正常关机和请求跟踪
  • **任务编排:**复杂的工作流程可以分解为专门的子任务
  • **任务自动化:**自动将人类可读的 Markdown 任务列表转换为可执行的 MCP 命令
  • **性能优化:**通过配置缓存和资源效率改进执行
  • **更好的监控:**健康检查 API、详细的错误报告和全面的日志记录
  • **开发人员体验:**配置热加载、灵活的环境控制和简化的 API

加上所有标准克劳德法典的好处:

  • Claude/Windsurf 编辑文件经常出问题。Claude Code 在这方面做得更好,速度也更快。
  • 可以将多个命令排队执行,而不是直接执行。这节省了上下文空间,因此更重要的信息可以保留更长时间。
  • 文件操作、git 或其他操作不需要昂贵的模型。如果您注册了 Anthropic Max,Claude Code 会非常划算。
  • 克劳德拥有更广泛的系统访问权限,因此当标准助手遇到困难时,只需要求他们“使用克劳德代码”即可解除进度阻碍。

📝 先决条件

  • Node.js v20 或更高版本(使用 fnm 或 nvm 安装)
  • Claude CLI 在本地安装(运行它并调用 /doctor)并接受-dangerously-skip-permissions

💾 安装和使用

您可以通过三种不同的方式安装和使用此 MCP 服务器:

🚀 方法 1:通过 GitHub URL(推荐)

最灵活的方法是使用npx直接从 GitHub 安装。这样可以始终从存储库中获取最新版本。

将以下内容添加到您的.mcp.json文件:

{ "mcpServers": { "claude-code-mcp-enhanced": { "command": "npx", "args": [ "github:grahama1970/claude-code-mcp-enhanced" ], "env": { "MCP_CLAUDE_DEBUG": "false", "MCP_HEARTBEAT_INTERVAL_MS": "15000", "MCP_EXECUTION_TIMEOUT_MS": "1800000" } } } }

📦方法 2:通过 npm 包

如果该包已发布到 npm,则可以使用 npm 包名称进行安装:

{ "mcpServers": { "claude-code-mcp-enhanced": { "command": "npx", "args": [ "-y", "@grahama1970/claude-code-mcp-enhanced@latest" ], "env": { "MCP_CLAUDE_DEBUG": "false", "MCP_HEARTBEAT_INTERVAL_MS": "15000", "MCP_EXECUTION_TIMEOUT_MS": "1800000" } } } }

🔧 方法 3:本地安装

出于开发或测试目的,您可以从本地安装运行服务器:

  1. 克隆存储库:
    git clone https://github.com/grahama1970/claude-code-mcp-enhanced.git cd claude-code-mcp-enhanced
  2. 安装依赖项并构建:
    npm install npm run build
  3. 配置您的.mcp.json文件以使用本地服务器:
{ "mcpServers": { "claude-code-mcp-enhanced": { "command": "node", "args": [ "/path/to/claude-code-mcp-enhanced/dist/server.js" ], "env": { "MCP_CLAUDE_DEBUG": "false", "MCP_HEARTBEAT_INTERVAL_MS": "15000", "MCP_EXECUTION_TIMEOUT_MS": "1800000" } } } }

🔑 重要的首次设置:接受权限

在 MCP 服务器能够成功使用claude_code工具之前,您必须先使用--dangerously-skip-permissions标志手动运行一次 Claude CLI,登录并接受条款。

这是 Claude CLI 的一次性要求。

npm install -g @anthropic-ai/claude-code
claude --dangerously-skip-permissions

按照提示接受。完成后,MCP 服务器将能够以非交互方式使用该标志。

该工具首次运行时,macOS 可能会要求提供各种文件夹权限,因此首次运行可能会失败。后续运行将正常运行。

🔗 连接到您的 MCP 客户端

设置服务器后,您需要配置您的 MCP 客户端(如 Cursor、Claude Desktop 或其他使用mcp.jsonmcp_config.json客户端)。

MCP 配置文件示例

以下是如何将 Claude Code MCP 服务器添加到.mcp.json文件的示例:

{ "mcpServers": { "Local MCP Server": { "type": "stdio", "command": "node", "args": [ "dist/server.js" ], "env": { "MCP_USE_ROOMODES": "true", "MCP_WATCH_ROOMODES": "true", "MCP_CLAUDE_DEBUG": "false" } }, "other-services": { // Your other MCP services here } } }

MCP 配置位置

配置通常在 JSON 文件中完成。名称和位置可能因客户端而异。

光标

光标使用mcp.json

  • macOS: ~/.cursor/mcp.json
  • Windows: %APPDATA%\\Cursor\\mcp.json
  • Linux: ~/.config/cursor/mcp.json
风帆冲浪

Windsurf 用户使用mcp_config.json

  • macOS: ~/.codeium/windsurf/mcp_config.json
  • Windows: %APPDATA%\\Codeium\\windsurf\\mcp_config.json
  • Linux: ~/.config/.codeium/windsurf/mcp_config.json

(注意:在某些混合设置中,如果也安装了 Cursor,这些客户端可能会回退到使用 Cursor 的~/.cursor/mcp.json路径。如果使用 Codeium 扩展,请优先考虑 Codeium 特定的路径。)

如果不存在则创建此文件。

🛠️ 提供的工具

该服务器公开了三个主要工具:

claude_code

使用带有--dangerously-skip-permissions的 Claude Code CLI 直接执行提示。

参数:

  • prompt (字符串,必需):发送给 Claude Code 的提示。
  • workFolder (字符串,可选):Claude CLI 执行的工作目录,使用文件操作或引用任何文件时需要。
  • parentTaskId (字符串,可选):创建此任务的父任务的 ID(用于任务编排/回旋镖)。
  • returnMode (字符串,可选):返回结果的方式:“summary”(简洁)或“full”(详细)。默认为“full”。
  • taskDescription (字符串,可选):任务的简短描述,以便在协调的工作流中更好地组织和跟踪。
  • mode (字符串,可选):当 MCP_USE_ROOMODES=true 时,指定要使用的 Roo 模式(例如,“boomerang-mode”、“coder”、“designer”等)。

health 🩺

返回 Claude Code MCP 服务器的健康状态、版本信息和当前配置。

健康检查请求示例:

{ "toolName": "claude_code:health", "arguments": {} }

响应示例:

{ "status": "ok", "version": "1.12.0", "claudeCli": { "path": "claude", "status": "available" }, "config": { "debugMode": true, "heartbeatIntervalMs": 15000, "executionTimeoutMs": 1800000, "useRooModes": true, "maxRetries": 3, "retryDelayMs": 1000 }, "system": { "platform": "linux", "release": "6.8.0-57-generic", "arch": "x64", "cpus": 16, "memory": { "total": "32097MB", "free": "12501MB" }, "uptime": "240 minutes" }, "timestamp": "2025-05-15T18:30:00.000Z" }

convert_task_markdown 📋

将 markdown 任务文件转换为与 Claude Code MCP 兼容的 JSON 格式。

参数:

  • markdownPath (字符串,必需):要转换的 markdown 任务文件的路径。
  • outputPath (字符串,可选):保存 JSON 输出的路径。如果未提供,则直接返回 JSON。

示例请求:

{ "toolName": "claude_code:convert_task_markdown", "arguments": { "markdownPath": "/home/user/tasks/validation.md", "outputPath": "/home/user/tasks/validation.json" } }

示例使用场景

1. 基本代码操作

MCP 请求示例:

{ "toolName": "claude_code:claude_code", "arguments": { "prompt": "Your work folder is /path/to/project\n\nRefactor the function foo in main.py to be async.", "workFolder": "/path/to/project" } }

2. 任务编排(回旋镖模式)

家长任务要求:

{ "toolName": "claude_code:claude_code", "arguments": { "prompt": "Your work folder is /path/to/project\n\nOrchestrate the implementation of a new API endpoint with the following subtasks:\n1. Create database models\n2. Implement API route handlers\n3. Write unit tests\n4. Document the API", "workFolder": "/path/to/project" } }

子任务请求(由父级生成):

{ "toolName": "claude_code:claude_code", "arguments": { "prompt": "Your work folder is /path/to/project\n\nCreate database models for the new API endpoint as specified in the requirements.", "workFolder": "/path/to/project", "parentTaskId": "task-123", "returnMode": "summary", "taskDescription": "Database model creation for API endpoint" } }

3. 特殊模式请求

使用 Roo 模式的示例:

{ "toolName": "claude_code:claude_code", "arguments": { "prompt": "Your work folder is /path/to/project\n\nCreate unit tests for the user authentication module.", "workFolder": "/path/to/project", "mode": "coder" } }

🔄 任务转换器

MCP 服务器包含一个强大的任务转换工具,可以自动将人类可读的 Markdown 任务列表转换为完全可执行的 MCP 命令。这个智能转换器弥合了人类对任务的理解方式与机器执行方式之间的差距。

完整的工作流程

工作流程步骤

  1. 用户将 MCP 添加到其配置文件中
  2. 用户提示 Claude :“使用 convert_task_markdown 执行我的 tasks.md 文件”
  3. MCP 自动
    • 加载 markdown 文件
    • 验证格式(如果缺少部分则返回错误)
    • 将人类可读的任务转换为精确的可执行命令
    • 返回 Claude Code 可以顺序执行的 JSON
  4. Claude 接收 JSON并可以使用claude_code工具执行每个任务

主要特点

  • **自动路径解析:**将“将目录更改为项目”等通用指令转换为具有完整路径的精确可执行命令
  • **智能命令翻译:**将英文指令转换为精确的终端命令(例如,“激活虚拟环境”→ source .venv/bin/activate
  • **MCP 协议合规性:**确保所有输出与模型上下文协议 100% 兼容
  • **无歧义:**所有生成的命令都使用精确的路径和可执行语法 - 没有占位符或通用引用
  • **格式验证:**强制执行正确的 Markdown 结构,并为不正确的格式提供有用的错误消息
  • **实时进度更新:**在转换过程中提供实时进度更新,显示正在处理的任务

将 Markdown 任务转换为 MCP 命令

convert_task_markdown工具处理结构化 markdown 文件并生成与 MCP 兼容的 JSON:

请求格式:

{ "tool": "convert_task_markdown", "arguments": { "markdownPath": "/path/to/tasks.md", "outputPath": "/path/to/output.json" // optional } }

响应格式:

{ "tasksCount": 5, "outputPath": "/path/to/output.json", "tasks": [ { "tool": "claude_code", "arguments": { "command": "cd /project && source .venv/bin/activate\n\nTASK TYPE: Validation...", "dangerously_skip_permissions": true, "timeout_ms": 300000 } } // ... more tasks ] }

Markdown 任务文件格式

任务 markdown 文件应遵循以下结构:

# Task 001: Task Title ## Objective Clear description of what needs to be accomplished. ## Requirements 1. [ ] First requirement 2. [ ] Second requirement ## Tasks ### Module or Component Name - [ ] Validate `path/to/file.py` - [ ] Step 1 - [ ] Step 2 - [ ] Step 3

转换器将:

  1. 解析 markdown 结构
  2. 提取任务元数据和要求
  3. 为每个验证任务生成详细提示
  4. 包括正确的工作目录设置
  5. 添加验证和完成摘要

示例用法

  1. 创建任务文件tasks/api_validation.md ):
# Task 001: API Endpoint Validation ## Objective Validate all API endpoints work with real database connections. ## Requirements 1. [ ] All endpoints must use real database 2. [ ] No mock data in validation ## Core API Tasks - [ ] Validate `api/users.py` - [ ] Change directory to project and activate .venv - [ ] Test user creation endpoint - [ ] Test user retrieval endpoint - [ ] Verify JSON responses
  1. 转换为 MCP 任务
{ "tool": "convert_task_markdown", "arguments": { "markdownPath": "/project/tasks/api_validation.md" } }
  1. 转换器显示实时进度
    [Progress] Loading task file... [Progress] Validating markdown structure... [Progress] Converting 27 validation tasks... [Progress] Task 1/27: Converting core/constants.py [Progress] Task 2/27: Converting core/arango_setup.py ... [Progress] Conversion complete!
  2. 转换器将通用指令转换为精确命令
    • “将目录更改为项目并激活.venv”变为:
      cd /home/user/project && source .venv/bin/activate
    • 所有路径都解析为绝对路径
    • 所有命令均可完全执行,没有任何歧义
  3. 执行转换后的任务:返回的任务包含精确的、可执行的命令,并且可以使用claude_code工具按顺序执行。

完整示例:从 Markdown 到执行

步骤 1:用户创建 markdown 任务文件project_tasks.md ):

# Task 001: Setup Development Environment ## Objective Initialize the development environment with all dependencies. ## Requirements 1. [ ] Python 3.11+ installed 2. [ ] Virtual environment created ## Tasks - [ ] Validate `setup.py` - [ ] Change to project directory - [ ] Create virtual environment - [ ] Install dependencies

第 2 步:用户提示 Claude

Use convert_task_markdown to process /home/user/project_tasks.md

步骤3:MCP转换并验证

  • 如果格式正确:返回可执行 JSON
  • 如果格式错误:返回错误并附带指导

步骤 4:结果(如果成功)

[ { "tool": "claude_code", "arguments": { "prompt": "cd /home/user/project && python -m venv .venv && source .venv/bin/activate && pip install -r requirements.txt", "workFolder": "/home/user/project" } } ]

步骤 5:Claude 可以按顺序执行每个任务

格式验证和错误处理

任务转换器强制使用特定的 Markdown 结构,以确保任务转换的一致性和可靠性。如果您的 Markdown 文件格式不正确,转换器会提供有用的错误消息:

错误响应示例:

{ "status": "error", "error": "Markdown format validation failed", "details": "Markdown format validation failed:\n - Missing required title. Format: '# Task NNN: Title'\n - Missing or empty 'Requirements' section. Format: '## Requirements\\n1. [ ] Requirement'\n - No validation tasks found. Format: '- [ ] Validate `module.py`' with indented steps\n\nRequired markdown format:\n# Task NNN: Title\n## Objective\nClear description\n## Requirements\n1. [ ] First requirement\n## Task Section\n- [ ] Validate `file.py`\n - [ ] Step 1\n - [ ] Step 2", "helpUrl": "https://github.com/grahama1970/claude-code-mcp-enhanced/blob/main/README.md#markdown-task-file-format" }

验证确保:

  1. 存在必需部分(标题、目标、要求)
  2. 任务使用正确的复选框格式
  3. 每个任务都有缩进的步骤
  4. 要求使用复选框格式以保持一致性

🦚 任务编排模式

该MCP服务器支持强大的任务编排功能,可以高效地处理复杂的工作流程。

回旋镖图案(Claude 桌面⟷ Claude 代码)

Boomerang 模式允许 Claude Desktop 编排任务并将其委托给 Claude Code。这允许您:

  1. 将复杂的工作流程分解为更小、可管理的子任务
  2. 将上下文从父任务传递到子任务
  3. 将子任务的结果返回给父任务
  4. 选择详细结果或汇总结果
  5. 通过结构化任务列表跟踪和管理进度

回旋镖模式可视化

下面是一个简单的图表,展示了 Claude 如何将配方任务分解为几个步骤并将它们委托给 Claude Code:

在此示例中:

  1. 用户要求克劳德制作巧克力蛋糕食谱
  2. Claude(家长)将其分解为几个单独的任务
  3. Claude 将“查找食谱”任务委托给 Claude Code,并指定父任务 ID
  4. Claude Code 将菜谱信息返回给 Claude
  5. Claude 将“转换测量值”任务委托给 Claude Code
  6. Claude Code 返回转换后的测量值
  7. Claude 整合所有结果并向用户呈现完整的解决方案

简单任务示例:

任务 1 - 查找食谱:

{ "toolName": "claude_code:claude_code", "arguments": { "prompt": "Search for a classic chocolate cake recipe. Find one with good reviews.", "parentTaskId": "cake-recipe-123", "returnMode": "summary", "taskDescription": "Find Chocolate Cake Recipe" } }

任务 2 - 转换测量值:

{ "toolName": "claude_code:claude_code", "arguments": { "prompt": "Convert the measurements in this recipe from cups to grams:\n\n- 2 cups flour\n- 1.5 cups sugar\n- 3/4 cup cocoa powder", "parentTaskId": "cake-recipe-123", "returnMode": "summary", "taskDescription": "Convert Recipe Measurements" } }

工作原理

  1. 创建子任务:
    • 在父任务中生成唯一的任务ID
    • 使用以下命令向claude_code工具发送请求:
      • 您的具体提示
      • 父任务ID
      • 任务描述
      • 所需的返回模式(“摘要”或“完整”)
  2. 接收结果:
    • 子任务结果会包含一个特殊标记: <!-- BOOMERANG_RESULT {...} -->
    • 此标记包含带有任务元数据的 JSON
    • 父任务可以解析此信息以识别已完成的子任务
  3. Claude Desktop 的示例工作流程:
You: I need to refactor this codebase. It's quite complex. Claude Desktop: I'll help you with that. Let me break this down into smaller tasks for Claude Code to handle: 1. First, I'll have Claude Code analyze the codebase structure 2. Then, I'll have it identify problematic patterns 3. Finally, I'll ask it to generate a refactoring plan [Claude Desktop sends a request to the claude_code tool with parentTaskId="task1" and returnMode="summary"] [Claude Code analyzes the codebase and returns a summary with the BOOMERANG_RESULT marker] Claude Desktop: Based on Claude Code's analysis, here are the key issues found: - Duplicate code in modules X and Y - Poor separation of concerns in module Z - Inconsistent naming conventions Now I'll ask Claude Code to suggest specific refactorings...

这种方法对于需要深入分析或多个步骤的复杂任务特别有用。

综合任务列表管理示例

以下是使用 Claude 与 Claude Code MCP 管理和执行结构化任务列表的详细示例:

1. 设置任务列表结构

首先,创建一个具有以下结构的任务列表文件(例如, tasks.md ):

# Project Task List ## Parent Task: API Optimization Project - [ ] Optimize API performance for high-traffic endpoints - [ ] Analyze current API performance and identify bottlenecks - [ ] Implement database query optimization for user endpoints - [ ] Add Redis caching for frequently accessed data - [ ] Set up performance monitoring ## Assumptions and Decisions - [2025-05-15] Assumption: Redis is available in the infrastructure - [2025-05-15] Decision: Focus on user endpoints first (Rationale: Highest traffic area) ## Relevant Files - `src/controllers/userController.js`: User API endpoints - `src/services/userService.js`: Business logic for user operations ## Improvement Notes - Pattern identified: N+1 query issue in user listing endpoint - Automation opportunity: Add caching automatically for all get-by-id endpoints
2.执行任务列表

克劳德现在可以使用克劳德代码系统地完成任务:

You: Please help me execute the task list in tasks.md, starting with the first subtask. Claude: I'll help you work through your task list systematically. Let me first check the current task list to identify the next task to work on. [Claude uses claude_code to read the task list] I see the first subtask is "Analyze current API performance and identify bottlenecks". I'll execute this task now using Claude Code. [Claude sends the following request to claude_code]: { "toolName": "claude_code", "arguments": { "prompt": "Your work folder is /path/to/project\n\nTASK TYPE: Analysis\nTASK ID: api-perf-analysis\nCURRENT SUBTASK: Analyze current API performance and identify bottlenecks\n\nCONTEXT:\n- Parent task goal: Optimize API performance for high-traffic endpoints\n- This is the first step in our optimization process\n- Focus on user endpoints as noted in assumptions\n\nINSTRUCTIONS:\n1. Analyze the current API implementation in src/controllers/userController.js and src/services/userService.js\n2. Run performance tests on the user endpoints\n3. Identify specific bottlenecks and performance issues\n4. Document findings in a clear, structured format\n5. Update task list file after completion\n\nAfter completion, provide summary in this format:\n\nCOMPLETION SUMMARY:\n- What was done:\n- Results:\n- Files analyzed:\n- Issues identified:\n- Recommendations:\n- Next subtask in list:", "workFolder": "/path/to/project" } } [Claude Code executes the analysis task and returns results] Great! Claude Code has completed the analysis. Here's what was found: 1. Main performance bottlenecks identified: - N+1 query problem in the user listing endpoint - Missing indexes on frequently queried fields - No caching for repetitive data lookups 2. Recommendations: - Add eager loading for user relationships - Create database indexes for user_id and email fields - Implement Redis caching with a 5-minute TTL Let me update the task list to mark this task as complete and proceed to the next one. [Claude uses claude_code to update the task list]: { "toolName": "claude_code", "arguments": { "prompt": "Your work folder is /path/to/project\n\nTASK TYPE: Task List Update\n\n1. Read the current task list in tasks.md\n2. Mark the 'Analyze current API performance and identify bottlenecks' subtask as [x]\n3. Add new findings to the Improvement Notes section\n4. Add any new relevant files identified during analysis\n5. Write updated task list\n6. Return the updated task list", "workFolder": "/path/to/project" } } [Claude Code updates the task list and marks the first subtask complete] I've updated the task list. The first subtask is now complete, and I've added the detailed findings to the Improvement Notes section. The next subtask is "Implement database query optimization for user endpoints". Would you like me to proceed with this next subtask now?
3. 继续后续任务

得到确认后,克劳德便会继续进行下一个子任务:

You: Yes, please proceed with the next subtask. Claude: I'll now execute the next subtask: "Implement database query optimization for user endpoints". This will involve fixing the N+1 query problem identified in the analysis and adding appropriate database indexes. [Claude sends the following request to claude_code]: { "toolName": "claude_code", "arguments": { "prompt": "Your work folder is /path/to/project\n\nTASK TYPE: Code Implementation\nTASK ID: db-query-optimization\nCURRENT SUBTASK: Implement database query optimization for user endpoints\n\nCONTEXT:\n- Parent task goal: Optimize API performance for high-traffic endpoints\n- Previous subtask identified N+1 query issues and missing indexes\n- Need to implement eager loading and proper indexes\n\nINSTRUCTIONS:\n1. Modify src/controllers/userController.js to implement eager loading for related data\n2. Add appropriate database indexes to user-related tables\n3. Refactor any inefficient database queries in userService.js\n4. Ensure changes maintain existing functionality\n5. Run tests to verify performance improvements\n6. Update task list file after completion\n\nAfter completion, provide summary in this format:\n\nCOMPLETION SUMMARY:\n- What was done:\n- Results:\n- Files modified:\n- Performance improvements:\n- Next subtask in list:", "workFolder": "/path/to/project" } } [Claude Code implements the optimizations and returns results] Excellent! The database query optimizations have been successfully implemented. Here's a summary: 1. Changes made: - Added eager loading in userController.js for user relationships - Created new database indexes for user_id and email fields - Refactored list query to use a single efficient JOIN statement - Added pagination to prevent large result sets 2. Performance results: - User listing endpoint response time reduced by 68% - Database query count reduced from 25+ to 3 for typical requests Let me update the task list again to reflect this progress. [Claude uses claude_code to update the task list again]: { "toolName": "claude_code", "arguments": { "prompt": "Your work folder is /path/to/project\n\nTASK TYPE: Task List Update\n\n1. Read the current task list in tasks.md\n2. Mark the 'Implement database query optimization for user endpoints' subtask as [x]\n3. Add new files modified to the Relevant Files section\n4. Update Improvement Notes with performance metrics\n5. Write updated task list\n6. Return the updated task list", "workFolder": "/path/to/project" } } [Claude Code updates the task list and marks the second subtask complete] I've updated the task list again. Two subtasks are now complete, and the next one is "Add Redis caching for frequently accessed data". Would you like me to continue with this subtask?

这种结构化方法使 Claude 能够系统地处理复杂的任务列表,同时在整个过程中保持进度、假设和相关文件的清晰记录。

🎭 自我编排模式(Claude Code 作为编排者)

虽然 Claude Desktop 通常用作父代理,但您也可以使用 Claude Code 本身作为编排器和执行器。这种方法创建了一个独立的系统,其中 Claude Code 可以管理自己的任务编排,而无需 Claude Desktop。

实施步骤
  1. 创建一个入口脚本,用于初始化任务结构并启动 Claude Code 作为协调器
  2. 设计一个任务数据结构(通常为 JSON 格式)来跟踪任务状态和依赖关系
  3. 创建任务执行器脚本来处理单个任务并更新任务状态
自我编排的主要优势
  1. 自包含:无需外部协调器(如 Claude Desktop)
  2. 持久状态:所有任务信息都存储在 JSON 文件中
  3. 错误恢复:如果中断,可以从上一个成功的任务恢复
  4. 简化的依赖管理:单一系统管理所有 Claude Code 交互
  5. Shell 脚本自动化:轻松集成到 CI/CD 管道或自动化工作流程中

有关包含示例脚本和任务结构的详细实施指南,请参阅使用 Claude Code 进行自我编排

👓 Roo 模式集成

此 MCP 服务器支持通过.roomodes配置文件集成特殊模式。启用后,您可以指定每个任务使用的模式,从而实现特殊行为。

如何使用Roo模式

  1. 启用Roo模式支持:
    • 在 MCP 配置中设置环境变量MCP_USE_ROOMODES=true
    • 在 MCP 服务器的根目录中创建一个.roomodes文件
    • 可选地使用MCP_WATCH_ROOMODES=true启用热重载,以便在文件更改时自动重新加载配置
  2. 配置您的模式:
    • .roomodes文件应包含一个带有customModes数组的 JSON 对象
    • 每种模式都应该有一个slugnameroleDefinition ,以及可选的带有modelIdapiConfiguration
  3. 使用模式:
    • claude_code工具发出请求时,请包含一个mode参数,其中包含所需模式的 slug
    • MCP 服务器将自动应用角色定义和模型配置
  4. .roomodes 文件示例:
    { "customModes": [ { "slug": "coder", "name": "💻 Coder", "roleDefinition": "You are a coding specialist who writes clean, efficient code.", "apiConfiguration": { "modelId": "claude-3-sonnet-20240229" } }, { "slug": "designer", "name": "🎨 Designer", "roleDefinition": "You are a design specialist focused on UI/UX solutions." } ] }
  5. 环境配置示例:
    { "mcpServers": { "claude-code-mcp-enhanced": { "command": "npx", "args": ["github:grahama1970/claude-code-mcp-enhanced"], "env": { "MCP_USE_ROOMODES": "true", "MCP_WATCH_ROOMODES": "true", "MCP_CLAUDE_DEBUG": "false" } } } }
  6. 使用模式发出请求:
    { "toolName": "claude_code:claude_code", "arguments": { "prompt": "Your work folder is /path/to/project\n\nCreate unit tests for the user authentication module.", "workFolder": "/path/to/project", "mode": "coder" } }

Roo 模式的主要特点:

  • 特殊行为:不同模式可以有不同的系统提示和模型配置
  • 热重载:当MCP_WATCH_ROOMODES=true时, .roomodes文件发生更改时,服务器会自动重新加载配置
  • 性能:服务器缓存 roomodes 配置以获得更好的性能
  • 回退:如果未找到模式或房间模式被禁用,服务器将继续默认行为

🛠️增强的可靠性功能

该服务器包含多项改进,以提高可靠性和性能:

1. 心跳与超时预防

为了防止长时间运行的操作期间客户端超时:

  • 添加了可配置的心跳机制,每 15 秒发送一次进度更新
  • 实施执行时间跟踪和报告
  • 通过环境变量添加可配置的超时参数

2. 通过重试实现强大的错误处理

增加了针对瞬态错误的智能重试逻辑:

  • 实现可配置参数的自动重试
  • 添加了错误分类以识别可重试的问题
  • 创建详细的错误报告和跟踪

3. 请求跟踪系统

实施全面的请求生命周期管理:

  • 为每个请求添加唯一 ID
  • 为正在进行的请求创建跟踪
  • 确保完成或失败时进行适当的清理

4. 优雅关闭

添加了适当的进程终止处理:

  • 实现了 SIGINT 和 SIGTERM 的信号处理程序
  • 添加了对正在进行的请求的跟踪
  • 创建干净关机的等待逻辑
  • 确保退出时进行适当的清理

5. 配置缓存和热加载

增加了配置性能优化:

  • 实现 roomodes 文件的缓存
  • 添加了基于文件更改的自动失效功能
  • 创建可配置的文件监视机制

⚙️ 配置选项

可以使用以下环境变量定制服务器的行为:

多变的描述默认
CLAUDE_CLI_PATHClaude CLI 可执行文件的绝对路径自动检测
MCP_CLAUDE_DEBUG启用详细调试日志记录false
MCP_HEARTBEAT_INTERVAL_MS进度报告间隔15000(15秒)
MCP_EXECUTION_TIMEOUT_MSCLI 执行超时1800000(30米)
MCP_MAX_RETRIES暂时性错误的最大重试次数3
MCP_RETRY_DELAY_MS重试之间的延迟1000(1秒)
MCP_USE_ROOMODES启用 Roo 模式集成false
MCP_WATCH_ROOMODES更改后自动重新加载 .roomodesfalse

这些可以在您的 shell 环境中或mcp.json服务器配置的env块内设置。

📸 视觉示例

以下是服务器运行的一些视觉示例:

修复 ESLint 设置

下面是使用 Claude Code MCP 工具通过删除旧配置文件并创建新配置文件来以交互方式修复 ESLint 设置的示例:

列出文件示例

以下是 Claude Code 工具列出目录中文件的示例:

复杂的多步骤操作

此示例说明了claude_code如何处理更复杂、多步骤的任务,例如通过创建分支准备发布、更新多个文件( package.jsonCHANGELOG.md )、提交更改以及发起拉取请求,所有这些都在单个、连贯的操作中完成。

GitHub Actions 工作流程修正

🎯 关键用例

该服务器通过其统一的claude_code工具,让您的 AI 能够直接访问 Claude Code CLI,从而解锁各种强大的功能。以下是您可以实现的一些示例:

  1. 代码生成、分析和重构:
    • "Generate a Python script to parse CSV data and output JSON."
    • "Analyze my_script.py for potential bugs and suggest improvements."
  2. 文件系统操作(创建、读取、编辑、管理):
    • 创建文件: "Your work folder is /Users/steipete/my_project\n\nCreate a new file named 'config.yml' in the 'app/settings' directory with the following content:\nport: 8080\ndatabase: main_db"
    • 编辑文件: "Your work folder is /Users/steipete/my_project\n\nEdit file 'public/css/style.css': Add a new CSS rule at the end to make all 'h2' elements have a 'color: navy'."
    • 移动/复制/删除: "Your work folder is /Users/steipete/my_project\n\nMove the file 'report.docx' from the 'drafts' folder to the 'final_reports' folder and rename it to 'Q1_Report_Final.docx'."
  3. 版本控制(Git):
    • "Your work folder is /Users/steipete/my_project\n\n1. Stage the file 'src/main.java'.\n2. Commit the changes with the message 'feat: Implement user authentication'.\n3. Push the commit to the 'develop' branch on origin."
  4. 运行终端命令:
    • "Your work folder is /Users/steipete/my_project/frontend\n\nRun the command 'npm run build'."
    • "Open the URL https://developer.mozilla.org in my default web browser."
  5. 网页搜索和摘要:
    • "Search the web for 'benefits of server-side rendering' and provide a concise summary."
  6. 复杂的多步骤工作流程:
    • 自动更新版本、更新变更日志和标签发布: "Your work folder is /Users/steipete/my_project\n\nFollow these steps: 1. Update the version in package.json to 2.5.0. 2. Add a new section to CHANGELOG.md for version 2.5.0 with the heading '### Added' and list 'New feature X'. 3. Stage package.json and CHANGELOG.md. 4. Commit with message 'release: version 2.5.0'. 5. Push the commit. 6. Create and push a git tag v2.5.0."
  7. 修复有语法错误的文件:
    • "Your work folder is /path/to/project\n\nThe file 'src/utils/parser.js' has syntax errors after a recent complex edit that broke its structure. Please analyze it, identify the syntax errors, and correct the file to make it valid JavaScript again, ensuring the original logic is preserved as much as possible."
  8. 与 GitHub 交互(例如创建拉取请求):
    • "Your work folder is /Users/steipete/my_project\n\nCreate a GitHub Pull Request in the repository 'owner/repo' from the 'feature-branch' to the 'main' branch. Title: 'feat: Implement new login flow'. Body: 'This PR adds a new and improved login experience for users.'"
  9. 与 GitHub 交互(例如检查 PR CI 状态):
    • "Your work folder is /Users/steipete/my_project\n\nCheck the status of CI checks for Pull Request #42 in the GitHub repository 'owner/repo'. Report if they have passed, failed, or are still running."

关键:请记住在文件系统或 git 操作提示中提供当前工作目录(CWD)上下文(例如, "Your work folder is /path/to/project\n\n...your command..." )。

🔧 故障排除

  • **“命令未找到”(claude-code-mcp):**如果是全局安装,请确保 npm 全局 bin 目录位于系统 PATH 中。如果使用npx ,请确保npx本身正常运行。
  • **“未找到命令”(claude 或 ~/.claude/local/claude):**请确保 Claude CLI 已正确安装。运行claude/doctor或查看其文档。
  • **权限问题:**确保您已运行“重要的首次设置”步骤。
  • **来自服务器的 JSON 错误:**如果MCP_CLAUDE_DEBUGtrue ,错误消息或日志可能会干扰 MCP 的 JSON 解析。设置为false可正常运行。
  • **ESM/导入错误:**确保您使用的是 Node.js v20 或更高版本。
  • **客户端超时:**对于长时间运行的操作,服务器每 15 秒发送一次心跳消息,以防止客户端超时。如果仍然遇到超时问题,您可以使用MCP_HEARTBEAT_INTERVAL_MS环境变量调整心跳间隔。
  • **网络/服务器错误:**服务器现在包含针对瞬态错误的自动重试逻辑。如果您仍然遇到问题,请尝试增加MCP_MAX_RETRIESMCP_RETRY_DELAY_MS的值。
  • **Claude CLI 回退警告:**如果您看到关于在 ~/.claude/local/claude 中未找到 Claude CLI 的警告,这是正常现象。服务器正在回退到使用 PATH 中的claude命令。您可以根据需要设置CLAUDE_CLI_PATH环境变量来指定 Claude CLI 可执行文件的确切路径。

👨‍💻 对于开发人员:本地设置和贡献

如果您想开发或贡献此服务器,或从克隆的存储库运行它进行测试,请参阅我们的本地安装和开发设置指南

💪 贡献

欢迎贡献!请参阅本地安装和开发设置指南,了解如何设置环境。

GitHub 存储库提交问题和拉取请求。

⚖️ 许可证

麻省理工学院

💬 反馈和支持

如果您遇到任何问题或对使用 Claude Code MCP 服务器有疑问,请:

  1. 查看上面的故障排除部分
  2. GitHub 存储库上提交问题
  3. 加入存储库讨论部分的讨论

我们感谢您的反馈和贡献,使这个工具变得更好!

You must be authenticated.

A
security – no known vulnerabilities
A
license - permissive license
A
quality - confirmed to work

增强型模型上下文协议 (MCP) 服务器,允许在一次性模式下运行 Claude 代码,自动绕过权限,具有高级任务

  1. 🔍 概述
    1. ✨ 好处
      1. 📝 先决条件
        1. 💾 安装和使用
          1. 🚀 方法 1:通过 GitHub URL(推荐)
          2. 📦方法 2:通过 npm 包
          3. 🔧 方法 3:本地安装
        2. 🔑 重要的首次设置:接受权限
          1. 🔗 连接到您的 MCP 客户端
            1. MCP 配置文件示例
            2. MCP 配置位置
          2. 🛠️ 提供的工具
            1. claude_code
            2. health 🩺
            3. convert_task_markdown 📋
          3. 示例使用场景
            1. 基本代码操作
            2. 任务编排(回旋镖模式)
            3. 特殊模式请求
          4. 🔄 任务转换器
            1. 完整的工作流程
            2. 工作流程步骤
            3. 主要特点
            4. 将 Markdown 任务转换为 MCP 命令
            5. Markdown 任务文件格式
            6. 示例用法
            7. 完整示例:从 Markdown 到执行
            8. 格式验证和错误处理
          5. 🦚 任务编排模式
            1. 回旋镖图案(Claude 桌面⟷ Claude 代码)
            2. 回旋镖模式可视化
            3. 工作原理
            4. 综合任务列表管理示例
            5. 🎭 自我编排模式(Claude Code 作为编排者)
          6. 👓 Roo 模式集成
            1. 如何使用Roo模式
            2. Roo 模式的主要特点:
          7. 🛠️增强的可靠性功能
            1. 心跳与超时预防
            2. 通过重试实现强大的错误处理
            3. 请求跟踪系统
            4. 优雅关闭
            5. 配置缓存和热加载
          8. ⚙️ 配置选项
            1. 📸 视觉示例
              1. 修复 ESLint 设置
              2. 列出文件示例
              3. 复杂的多步骤操作
              4. GitHub Actions 工作流程修正
            2. 🎯 关键用例
              1. 🔧 故障排除
                1. 👨‍💻 对于开发人员:本地设置和贡献
                  1. 💪 贡献
                    1. ⚖️ 许可证
                      1. 💬 反馈和支持

                        Related MCP Servers

                        • A
                          security
                          A
                          license
                          A
                          quality
                          An implementation of Claude Code as a Model Context Protocol server that enables using Claude's software engineering capabilities (code generation, editing, reviewing, and file operations) through the standardized MCP interface.
                          Last updated -
                          8
                          86
                          JavaScript
                          MIT License
                        • A
                          security
                          A
                          license
                          A
                          quality
                          A Model Context Protocol (MCP) server that provides code analysis capabilities using tree-sitter, designed to give Claude intelligent access to codebases with appropriate context management.
                          Last updated -
                          26
                          33
                          Python
                          MIT License
                          • Apple
                          • Linux
                        • -
                          security
                          A
                          license
                          -
                          quality
                          A custom Model Context Protocol server that gives Claude Desktop and other LLMs access to file system operations and command execution capabilities through standardized tool interfaces.
                          Last updated -
                          22
                          Python
                          Apache 2.0
                          • Apple
                          • Linux
                        • A
                          security
                          F
                          license
                          A
                          quality
                          A server built on mcp-framework that enables integration with Claude Desktop through the Model Context Protocol.
                          Last updated -
                          1
                          1
                          • Apple

                        View all related MCP servers

                        MCP directory API

                        We provide all the information about MCP servers via our MCP API.

                        curl -X GET 'https://glama.ai/api/mcp/v1/servers/grahama1970/claude-code-mcp-enhanced'

                        If you have feedback or need assistance with the MCP directory API, please join our Discord server