Git工作树MCP服务器

一个用于管理Git工作树并与MCP集成的工具,支持并行探索和多代理协作。

  • by kingkillery
  • TypeScript
  • 本地部署
  • 更新于
在 GitHub 查看 kingkillery/git-worktree-mcp

使用说明

具有增强并行探索功能的Git Worktree MCP服务器

🚀 先进的git工作树管理+集成MCP的AI并行探索

✨ 它做什么

核心MCP服务器功能:

  • 创建特征工作树 -使用特征分支创建独立的工作台
  • list_worktrees -显示所有活动工作树
  • cleanup_worktree -使用未提交的更改检查进行安全删除
  • get_worktree_status -检查分支状态和更改
  • setup_paralle_workflow -为代理协作生成多个工作树
  • get_paralle_workflow_status -聚合工作流状态

🆕 增强的并行探索插件:

  • MCP服务器发现 -自动检测可用的MCP服务器
  • 多代理编排 -协调多个AI代理(参见 特工.md)
  • 智能合成 -整合所有方法中的最佳元素
  • 工作流程自动化 -端到端并行探索(速度提高90%)

🎭 平行探索技能:

  • 超级大国一体化 -易于基于技能的使用
  • 真实世界的例子 -算法优化、API设计、安全
  • 完整的文件 -2500+字综合指南

🚀 Claude代码安装

选项1:直接集成(推荐)

  1. 克隆存储库 在您的项目目录中:
git clone https://github.com/kingkillery/git-worktree-mcp.git
cd git-worktree-mcp
npm install
npm run build
  1. 添加到克劳德代码MCP配置 (.claude/settings.json):
{
  "mcpServers": {
    "git-worktree-mcp": {
      "command": "node",
      "args": ["./git-worktree-mcp/dist/index.js"],
      "cwd": "${workspaceFolder}"
    }
  }
}
  1. 重新启动Claude代码 -MCP服务器将被自动发现

选项2:NPM全局安装(来自GitHub)

  1. 从GitHub全局安装:
npm install -g github:kingkillery/git-worktree-mcp
  1. 添加到Claude代码配置:
{
  "mcpServers": {
    "git-worktree-mcp": {
      "command": "git-worktree-mcp"
    }
  }
}

选项3:本地项目安装(来自GitHub)

  1. 从GitHub安装为开发依赖项:
npm install --save-dev github:kingkillery/git-worktree-mcp
  1. 添加到Claude代码配置:
{
  "mcpServers": {
    "git-worktree-mcp": {
      "command": "npx",
      "args": ["github:kingkillery/git-worktree-mcp"]
    }
  }
}

选项4:直接使用NPX(无需安装)

无需安装 -直接添加到Claude代码配置中:

{
  "mcpServers": {
    "git-worktree-mcp": {
      "command": "npx",
      "args": ["github:kingkillery/git-worktree-mcp"]
    }
  }
}

✅ 验证安装

安装后,验证它是否在Claude Code中工作:

User: List available MCP servers and git worktrees

Claude: I'll check the available MCP servers and list your git worktrees.

[Claude automatically discovers and uses the git-worktree-mcp server]

🎯 快速使用示例

Git工作树基本操作:

User: Create a worktree for the user-authentication feature
User: List all my active worktrees
User: Clean up the user-authentication worktree
User: Check the status of my current worktree

🆕 平行探索:

User: Use parallel exploration to optimize the sorting algorithm
User: Explore different approaches for implementing the user authentication API
User: Use parallel exploration to improve database query performance

高级多代理工作流:

User: Set up a parallel workflow for 3 agents to work on the next release
User: Get the status of the next-release parallel workflow

Claude代码工作流

非常适合在使用Claude Code CLI时在功能之间切换:

# Create worktree via MCP
# Navigate to new worktree directory
cd .worktree/user-auth

# Start Claude Code in the worktree directory
export $(cat .env | xargs) && claude

每个工作台都有自己的 .env, .claude/,并自动配置文件。从工作树目录中启动Claude Code,单独处理该特定功能。

它做什么

  • 创建 .worktree/feature-name 随着 feature/feature-name 分支
  • 副本 .env*, .mcp.json, .claude/, .vscode/ 文件自动
  • 使用未提交的更改检测进行安全清理
  • 并行工作流将元数据持久化 .worktree/workflows/<name>.json 供以后审计

需求

  • Node.js 18+
  • Git仓库

并行代理工作流

使用新的并行助手来编排群体式迭代:

  1. 代管人 电话 setup_parallel_workflow 与A iterationCount (默认为2)或显式 agentLabels示例:
    {
      "workflowName": "next-release",
      "iterationCount": 3
    }
    
    这创造了 feature/next-release-iteration-1..3,复制每个工作树的配置,并将元数据放置在 .worktree/workflows/next-release.json.
  2. 建筑商代理 跟随返回 instructions 字段(例如。, cd .worktree/next-release-iteration-1 && export $(cat .env | xargs) && claude)直接跳进他们的沙箱树里。
  3. 审核代理 跑 get_parallel_workflow_status 使用相同的工作流名称,在编译输出或投票选出获胜者之前,收集git状态、缺失迭代和推荐的后续行动。

混合 agentLabels (例如。, ["manager-a","builder-b","tester-c"])保持路径的描述性,同时仍然受益于用于清理和查看的共享元数据。