wtx
Provides tools for managing Git worktrees, including creating, listing, removing, and cleaning worktrees while checking branch merge status and dirty state.
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
wtx
Git worktree manager with a built-in MCP server. Create, inspect, and clean isolated workspaces from your terminal — or let your AI coding agents do it themselves.
Parallel AI coding agents made git stash-juggling obsolete — but raw git worktree add ../foo -b foo && cd ../foo && cp ../.env . is a chore nobody wants to repeat five times a day. wtx turns worktrees into a one-word workflow for humans and for agents:
$ wtx new fix-login
✔ created worktree fix-login
path: ~/code/myapp/.worktrees/fix-login
branch: wt/fix-login (new)
copied: .env, .env.localYour agent gets the same power through MCP:
{ "name": "create_worktree", "arguments": { "name": "fix-login", "setup": "npm install" } }Why wtx
One tool, two interfaces. A fast CLI for you, an MCP server (
wtx mcp) for Claude Code, Cursor, Codex, or any MCP-capable agent.Zero dependencies. Single Node.js binary that only shells out to
git. Nothing to audit, nothing to break.Hygiene-aware. Every worktree shows its disk footprint and last activity. Reclaim gigabytes of stale
node_modulesclones withwtx clean --dry-run.Safe by default. Refuses to delete dirty worktrees, never touches the main checkout, deletes branches only when fully merged, and hides
.worktrees/via.git/info/exclude(no.gitignorepollution).Batteries included. Copies env files into new worktrees and runs your project's setup hook automatically.
Related MCP server: worktree-tools-mcp
Install
npm install -g wtx # or: brew install wtx (planned)Requires Node.js ≥ 18 and any modern git.
Quickstart
$ cd myapp
$ wtx new feat-search # isolated workspace at .worktrees/feat-search on branch wt/feat-search
$ cd $(wtx path feat-search) # jump in
$ wtx ls # see every workspace, its state and size
NAME BRANCH STATUS AGE SIZE PATH
myapp* main ✓ clean 2d ago 412 MB ~/code/myapp
feat-api wt/feat-api ● dirty (1) 3h ago 38 MB ~/code/myapp/.worktrees/feat-api
$ wtx clean --dry-run # preview reclaimable space
· feat-api (branch merged, 38 MB)
would free: 38 MB · kept 0 worktree(s)Commands
Command | Description |
| Create |
| Table of worktrees: branch, ahead/behind, dirty state, last-commit age, disk usage |
| Remove a worktree; refuses if dirty; deletes merged branches |
| Remove worktrees whose branches are fully merged and/or inactive |
| Spawn |
| Print a worktree's absolute path (shell-script friendly) |
| Run as an MCP server over stdio |
Global flags: --json (machine-readable output), --base <ref>, --setup <cmd>, --no-copy, --no-setup.
Use it from AI agents (MCP)
Add to your MCP client config:
// e.g. claude_desktop_config.json / opencode.json / .mcp.json
{
"mcpServers": {
"wtx": { "command": "npx", "args": ["-y", "wtx", "mcp"] }
}
}The server exposes four tools: list_worktrees, create_worktree, remove_worktree, clean_worktrees. All accept an optional repo_path; otherwise the server's working directory is used. Responses are JSON, so agents can chain them: create → work → remove without ever switching branches in your main checkout.
Example agent prompt: "Set up a workspace called oauth-fix based on develop, run pnpm install in it, then tell me the path."
Configuration
Drop a wtx.config.json (or .wtxrc) in your repo root:
{
"dir": ".worktrees",
"copyFiles": [".env", ".env.local"],
"setup": "pnpm install",
"branchPrefix": "wt/"
}Key | Default | Meaning |
|
| Where worktrees live, relative to repo root (auto-added to |
|
| Files copied from the main checkout into each new worktree |
| (none) | Shell command run inside a new worktree after creation |
|
| Prefix for branches created by |
Safety model
The main worktree is never removed by
rmorclean.Dirty worktrees are always preserved by
clean, andrmrequires--force.Branches are deleted only when fully merged into the default branch (
origin/HEAD→main→masterfallback).Worktree directories live under
.worktrees/, excluded via.git/info/excludeso your.gitignorestays untouched.Names are sanitized; traversal like
../evilis rejected.
How it compares
raw | TUI managers | wtx | |
One-command create + env copy + setup hook | ✗ | partial | ✓ |
Disk usage & staleness per worktree | ✗ | rare | ✓ |
Machine-readable | ✗ | ✗ | ✓ |
MCP server for coding agents | ✗ | ✗ | ✓ |
Zero runtime dependencies | n/a | ✗ (usually heavy) | ✓ |
Development
git clone https://github.com/willkhinz/wtx && cd wtx
npm install
npm test # build + 32 integration/unit tests
node dist/src/cli.js helpArchitecture: src/core.ts (engine), src/cli.ts (human UI), src/mcp.ts (agent UI). The MCP implementation is dependency-free newline-delimited JSON-RPC 2.0.
Roadmap
wtx exec <name> -- <cmd>run commands across all worktreestmux/iTerm session spawning per worktree
Homebrew formula
GitHub Action: comment PRs with per-worktree previews
License
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
GitHub Copilot MCP: code, repo, PR, workflow tools for AI assistants.
AI-native git hosting — repos, PRs, issues, CI gates, and AI code review over MCP (60 tools).
Persistent cloud workspaces for AI agents: run commands, edit files, use git and a browser.
Your org's AI agents, tasks, runs, search, and brain files as MCP tools and resources.
Related MCP Servers
- AlicenseNot gradedqualityCmaintenanceAn MCP server that wraps git-worktree-runner to enable AI agents to manage git worktrees safely.Apache 2.0
- AlicenseAqualityDmaintenanceEnables Claude to create, manage, and clean up git worktrees automatically, including dependency installation and GitHub PR creation.5MIT
- AlicenseAqualityDmaintenanceDelegate coding tasks to external AI coding agents in isolated git worktrees with independent verification, enabling any MCP client to orchestrate multi-agent workflows.5MIT
- FlicenseNot gradedqualityDmaintenanceEnables AI agents to manage local project files and Git operations through MCP tools, including file CRUD, search, Git status, recent commits, and project summaries.-