Skip to main content
Glama

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-mcp

Option 2: Install from GitHub

npm install -g git+https://github.com/georgeasoto/worktree-tools-mcp.git

Option 3: npx (No Installation)

Use directly with npx:

npx -y git+https://github.com/georgeasoto/worktree-tools-mcp.git

Option 4: Local Development

git clone https://github.com/georgeasoto/worktree-tools-mcp.git
cd worktree-tools-mcp
npm install
npm run build
npm link

Configuration for Claude Code

Add to your Claude Code configuration file (typically ~/.config/Claude/claude_desktop_config.json or similar):

{
  "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:

  1. Auto-detects username from GitHub CLI or git config

  2. Creates worktree at ../<repo-name>-worktrees/username/TICKET/branch-name

  3. Creates branch: username/TICKET/branch-name

  4. Fetches latest changes from origin/master

  5. Auto-detects and installs dependencies (pnpm/npm/yarn)

  6. 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 remove

  • deleteBranch (optional): Also delete the local branch (default: false)

  • cwd (optional): Working directory

What it does:

  1. Removes the worktree directory

  2. Optionally deletes the local branch

  3. 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 worktree

  • title (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_TOKEN environment 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:

  1. Manual override - From .worktree-config file in repo root

  2. GitHub CLI - Uses gh api user --jq .login

  3. Git config - Converts user.name to 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.js

Companion 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 creation

  • Optional: pnpm, npm, or yarn for dependency installation

License

MIT

Available Tools

5 tools
cleanup_worktreeA

Remove a git worktree and optionally delete its branch. Automatically cleans up empty parent directories.

ParametersJSON Schema
NameRequiredDescriptionDefault
cwdNoOptional: Working directory (defaults to current directory)
deleteBranchNoOptional: Also delete the local branch (default: false)
worktreePathYesPath to the worktree to remove

TDQS

A4/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations provided, so description carries full burden. It discloses the removal action, optional branch deletion, and automatic cleanup of parent directories. Could mention error behavior or idempotency.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Two concise sentences, no wasted words. Front-loaded with the primary action, followed by a key behavioral detail.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Covers the main behavior and additional cleanup, but lacks details on error cases, return value, or preconditions. With no output schema, description could be slightly more complete.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

100% schema coverage provides basic parameter meanings. Description adds value by explaining the optional deleteBranch behavior and the automatic cleanup, going beyond the schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

Clearly states the verb (remove), resource (git worktree), and adds optional branch deletion and automatic cleanup of empty parent directories. Distinguishes from sibling tools like create_worktree and list_worktrees.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No explicit guidance on when to use this tool versus alternatives or any prerequisites. The description only states what it does, not when it should be used.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

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).

ParametersJSON Schema
NameRequiredDescriptionDefault
bodyNoOptional: PR body (auto-generated from commits if not provided)
draftNoOptional: Create as draft PR (default: false)
titleNoOptional: PR title (auto-generated from commits if not provided)
worktreePathYesPath to the worktree

TDQS

A4.1/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Since no annotations are provided, the description carries full burden. It discloses auto-generation of title/body from commits and auth requirements. However, it does not mention whether the branch is pushed automatically, what happens on success/failure, or if any user confirmation is needed. This leaves some behavioral gaps.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Two sentences with no unnecessary words. The first sentence states the core purpose, the second adds key behavioral and prerequisite details. Efficiently front-loaded.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

The description covers purpose and a key prerequisite, but lacks information on return value (e.g., does it return a PR URL?), error handling, and whether the branch is pushed. Given no output schema, the description should provide more context on what to expect after invocation.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents each parameter. The description repeats that title and body can be auto-generated, but adds no new meaning beyond the schema. The phrase 'from the current worktree' could be clearer in relation to the worktreePath parameter.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb ('Create') and resource ('GitHub pull request from the current worktree'). It differentiates from sibling worktree management tools by focusing on PR creation and mentions auto-generation of title and body, which specifies its unique behavior.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description explicitly states a prerequisite: 'Requires GitHub authentication (GITHUB_TOKEN env var or gh CLI)'. It provides clear context that this tool is for creating PRs from worktrees, but does not specify when not to use it or list alternative tools for similar tasks.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

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

ParametersJSON Schema
NameRequiredDescriptionDefault
cwdNoOptional: Working directory (defaults to current directory)
ticketYesTicket number (e.g., CO-4493, PROJ-123)
openIdeNoOptional: Open worktree in IDE after creation
branchNameYesBranch name (spaces will be converted to hyphens, e.g., "billing feature" -> "billing-feature")

TDQS

A3.8/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description must disclose behavioral traits. It mentions auto-detection, dependency installation, and .env copying, but does not cover prerequisites (e.g., existing git repo), error handling, or potential side effects.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is three sentences, front-loads the main action, and contains no redundant information. Every sentence adds value.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given 4 parameters, no output schema, and no nested objects, the description covers the tool's purpose, behavior, and output path. It lacks details on error conditions or prerequisites, but is otherwise complete for a creation tool.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so the baseline is 3. The description adds context about automated setup beyond parameter descriptions, but does not significantly enhance parameter-level understanding beyond what the schema already provides.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool creates a git worktree with automatic setup, including auto-detection of username, dependency installation, and .env copying. It distinguishes from siblings like list_worktrees or cleanup_worktree by focusing on creation.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage for creating worktrees but does not explicitly state when to use this tool versus alternatives like create_pr or list_worktrees. No when-not-to-use or exclusion criteria are provided.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

list_worktreesA

List all git worktrees with their status information. Shows branch name, path, uncommitted changes, and commits ahead/behind master.

ParametersJSON Schema
NameRequiredDescriptionDefault
cwdNoOptional: Working directory (defaults to current directory)

TDQS

A3.8/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations provided, so description carries full burden. It lists output fields but does not mention read-only nature, prerequisites (e.g., being in a git repo), or potential errors. Adequate but could be more explicit.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Two sentences front-loading purpose and then details. No extraneous words; every sentence provides value.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given one optional parameter and no output schema, the description is fairly complete. It explains the tool's output and behavior. Could mention requirement for git repository, but not essential.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema covers cwd parameter with description 'Optional: Working directory (defaults to current directory)'. Description adds no extra parameter meaning. Schema coverage is 100%, so baseline score is 3.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

Clearly states verb 'List' and resource 'git worktrees', specifies output fields (branch, path, uncommitted changes, commits ahead/behind master), and distinguishes from sibling tools like cleanup_worktree and create_worktree.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Describes what the tool does but lacks explicit guidance on when to use vs alternatives like worktree_status or when not to use it. Usage is implied but not explicit.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

worktree_statusA

Get the status of a worktree. Shows if working directory is clean, commits ahead/behind master, and if ready for PR.

ParametersJSON Schema
NameRequiredDescriptionDefault
worktreePathYesPath to the worktree to check

TDQS

A3.8/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden. It describes the output content but does not disclose potential side effects, authentication needs, error handling, or return format. Adequate but not detailed.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is two sentences, front-loaded with the main action, and every word adds value. No unnecessary information.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's simplicity (single parameter, no output schema), the description covers the essential purpose and output. Minor omission: no mention of error conditions or return format, but still largely complete.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100% with one parameter fully described. The description adds no extra meaning beyond the schema; baseline 3 is appropriate.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose with a specific verb ('Get') and resource ('status of a worktree'). It elaborates on what the status includes (clean, ahead/behind master, ready for PR), distinguishing it from siblings like list_worktrees or create_worktree.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies when to use (checking worktree status) but does not explicitly state when not to use it or provide alternatives. No guidance on prerequisites or exclusions.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections. Dates show when Glama detected each change.

  1. 5 tool updatesv1.0.0
    • First observedcleanup_worktree
    • First observedcreate_pr
    • First observedcreate_worktree
    • First observedlist_worktrees
    • First observedworktree_status

TDQS

A4.1/5.0
Disambiguation5/5

Each tool has a distinct purpose (create, list, status, cleanup, PR creation) with no overlap. Agents can clearly differentiate them.

Naming Consistency4/5

Most tools follow verb_noun pattern (create_worktree, list_worktrees, cleanup_worktree), but worktree_status deviates with noun_noun, causing minor inconsistency.

Tool Count5/5

5 tools is well-scoped for a worktree management server, covering creation, listing, status, cleanup, and PR creation without excess or deficiency.

Completeness4/5

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

ActivityInactive
ResponsivenessNo issues

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Connectors

Related MCP Servers

  • F
    license
    Not graded
    quality
    D
    maintenance
    Automates 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
    -
  • -
    license
    Not graded
    quality
    Not graded
    maintenance
    Enables 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.
    -
  • F
    license
    Not graded
    quality
    D
    maintenance
    Enables to interact with GitHub repositories directly from Claude, supporting actions like viewing repos, checking status, committing and pushing changes, and managing pull requests.
    -

Latest Blog Posts

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/georgeasoto/worktree-tools-mcp'

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