worktree-tools-mcp
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@worktree-tools-mcp Create a worktree for ticket CO-1234 called payment integration"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Worktree Tools MCP Server
MCP server for automated git worktree management with Claude. Enables Claude to create, manage, and clean up git worktrees automatically.
Features
Automatic username detection - From GitHub CLI or git config
Full worktree management - Create, list, cleanup worktrees
Dependency installation - Auto-detects and runs pnpm/npm/yarn
.env file copying - Automatically copies environment files
GitHub integration - Create PRs directly from worktrees
Status checking - Check if worktrees are clean and ready for PR
Related MCP server: MCP Git/PR Assist
Installation
Option 1: npm (Global)
npm install -g worktree-tools-mcpOption 2: Install from GitHub
npm install -g git+https://github.com/georgeasoto/worktree-tools-mcp.gitOption 3: npx (No Installation)
Use directly with npx:
npx -y git+https://github.com/georgeasoto/worktree-tools-mcp.gitOption 4: Local Development
git clone https://github.com/georgeasoto/worktree-tools-mcp.git
cd worktree-tools-mcp
npm install
npm run build
npm linkConfiguration for Claude Code
Add to your Claude Code configuration file (typically ~/.config/Claude/claude_desktop_config.json or similar):
Option 1: Using npx (Recommended - Always up to date)
{
"mcpServers": {
"worktree-tools": {
"command": "npx",
"args": ["-y", "git+https://github.com/georgeasoto/worktree-tools-mcp.git"]
}
}
}Option 2: If installed globally
{
"mcpServers": {
"worktree-tools": {
"command": "worktree-tools-mcp"
}
}
}Option 3: Local development
{
"mcpServers": {
"worktree-tools": {
"command": "node",
"args": ["/Users/YOUR_USERNAME/worktree-tools-mcp/dist/index.js"]
}
}
}After adding the configuration, restart Claude Code to enable the MCP server.
Available Tools
create_worktree
Create a new git worktree with automatic setup.
Parameters:
ticket(required): Ticket number (e.g., "CO-4493", "PROJ-123")branchName(required): Branch name (spaces converted to hyphens)cwd(optional): Working directory (defaults to current)openIde(optional): Open in IDE after creation ("cursor", "vscode", "auto")
Example:
{
"ticket": "CO-4493",
"branchName": "billing feature"
}What it does:
Auto-detects username from GitHub CLI or git config
Creates worktree at
../<repo-name>-worktrees/username/TICKET/branch-nameCreates branch:
username/TICKET/branch-nameFetches latest changes from origin/master
Auto-detects and installs dependencies (pnpm/npm/yarn)
Copies all .env files from main repo
list_worktrees
List all worktrees with status information.
Parameters:
cwd(optional): Working directory
Returns:
Array of worktrees with branch, path, and status
Status includes: clean/dirty, commits ahead/behind
cleanup_worktree
Remove a worktree and optionally delete its branch.
Parameters:
worktreePath(required): Path to worktree to removedeleteBranch(optional): Also delete the local branch (default: false)cwd(optional): Working directory
What it does:
Removes the worktree directory
Optionally deletes the local branch
Cleans up empty parent directories
worktree_status
Get the status of a worktree.
Parameters:
worktreePath(required): Path to worktree to check
Returns:
Clean/dirty status
Commits ahead/behind master
Ready for PR status
Human-readable message
create_pr
Create a GitHub pull request from a worktree.
Parameters:
worktreePath(required): Path to worktreetitle(optional): PR title (auto-generated from commits if not provided)body(optional): PR body (auto-generated if not provided)draft(optional): Create as draft PR (default: false)
Requirements:
GitHub CLI must be authenticated (
gh auth login)Or set
GITHUB_TOKENenvironment variable
Returns:
PR URL
PR number
PR title
Usage Examples with Claude
Once configured, Claude can automatically manage worktrees:
Example 1: Create a new worktree
User: "Create a worktree for ticket CO-1234 called payment integration"
Claude: [calls create_worktree tool]
Claude: "I've created a new worktree at ~/repos/myproject-worktrees/username/CO-1234/payment-integration
with dependencies installed and .env files copied. The worktree is ready to use."Example 2: List all worktrees
User: "Show me all my active worktrees"
Claude: [calls list_worktrees tool]
Claude: "You have 3 active worktrees:
1. CO-1234/payment-integration - 5 commits ahead, clean
2. CO-5678/user-dashboard - 2 commits ahead, uncommitted changes
3. CO-9012/api-refactor - up to date"Example 3: Create PR from worktree
User: "Create a PR for my payment integration work"
Claude: [calls create_pr tool]
Claude: "I've created PR #123: 'Add payment integration'
URL: https://github.com/org/repo/pull/123"Example 4: Clean up worktree
User: "Clean up the payment integration worktree"
Claude: [calls cleanup_worktree tool with deleteBranch: true]
Claude: "I've removed the worktree and deleted the local branch."Username Detection
Usernames are automatically detected with this priority:
Manual override - From
.worktree-configfile in repo rootGitHub CLI - Uses
gh api user --jq .loginGit config - Converts
user.nameto username format (lowercase, hyphens)
If detection fails, you'll get a clear error message with instructions.
Directory Structure
Worktrees are organized as:
~/repos/
├── myproject/ (main repository)
└── myproject-worktrees/ (all worktrees)
└── username/
├── CO-1234/
│ └── payment-integration/
└── CO-5678/
└── user-dashboard/Development
# Install dependencies
npm install
# Run in development mode
npm run dev
# Build
npm run build
# Test the MCP server
npm run build && node dist/index.jsCompanion Bash Scripts
This MCP server complements the worktree-tools bash scripts (located at ~/.checkout-scripts/ or ~/.worktree-tools/). You can use both:
Bash scripts - For manual CLI usage
MCP server - For Claude automation
Both implement the same logic and can be used interchangeably. The bash scripts provide a zero-dependency CLI interface, while the MCP server enables Claude to automate worktree operations.
Requirements
Node.js 18+
Git
Optional: GitHub CLI (
gh) for better username detection and PR creationOptional:
pnpm,npm, oryarnfor dependency installation
License
MIT
Available Tools
5 toolscleanup_worktreeA
Remove a git worktree and optionally delete its branch. Automatically cleans up empty parent directories.
Inputs: worktreePath (required), cwd, deleteBranch.
create_prA
Create a GitHub pull request from the current worktree. Auto-generates title and body from commits if not provided. Requires GitHub authentication (GITHUB_TOKEN env var or gh CLI).
Inputs: worktreePath (required), body, draft, title.
create_worktreeA
Create a new git worktree with automatic setup. Auto-detects username from GitHub/git, installs dependencies, and copies .env files. Worktrees are created at ../-worktrees/username/TICKET/branch-name
Inputs: ticket (required), branchName (required), cwd, openIde.
list_worktreesA
List all git worktrees with their status information. Shows branch name, path, uncommitted changes, and commits ahead/behind master.
Inputs: cwd.
worktree_statusA
Get the status of a worktree. Shows if working directory is clean, commits ahead/behind master, and if ready for PR.
Inputs: worktreePath (required).
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 5 tools
Each tool has a distinct purpose (create, list, status, cleanup, PR creation) with no overlap. Agents can clearly differentiate them.
Most tools follow verb_noun pattern (create_worktree, list_worktrees, cleanup_worktree), but worktree_status deviates with noun_noun, causing minor inconsistency.
5 tools is well-scoped for a worktree management server, covering creation, listing, status, cleanup, and PR creation without excess or deficiency.
Core worktree lifecycle is covered (create, list, status, delete via cleanup), but missing a tool to update/sync an existing worktree, leaving a minor gap.
Maintenance
Related MCP Connectors
Work on your own computers from Claude or ChatGPT: run commands, edit and search files.
Connect AI assistants to GitHub - manage repos, issues, PRs, and workflows through natural language.
Shared work memory for Claude Code, Codex, Cursor and chat, scoped to each repository.
Operate GitHub from your AI assistant: repos, PRs, issues, Actions. Previews and read-only mode.
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceAutomates git worktree management with iTerm2 integration for Claude Code, allowing users to create, manage, and close git worktrees in isolated environments with automatic tab handling.12-
- -licenseNot gradedqualityNot gradedmaintenanceEnables Git and GitHub pull request operations through Claude AI, including repository management, branch operations, commits, and PR creation/commenting. Streamlines development workflows by providing Git commands and GitHub API integration through natural language interactions.-
- AlicenseNot gradedqualityDmaintenanceEnables to interact with GitHub repositories directly from Claude, supporting actions like viewing repos, checking status, committing and pushing changes, and managing pull requests.544 npmMIT
- AlicenseNot gradedqualityCmaintenanceTurns Claude Code into an engineering project manager by orchestrating feature development with isolated Git worktrees, structured task validation, and approval-gated integration.1MIT