Skip to main content
Glama

Inspect or clean up Codex worktrees

codex_worktree

List managed Codex worktrees, inspect git status and diffs inside them, or remove finished worktrees.

Instructions

List managed Codex worktrees (~/.codex-mcp/worktrees), inspect git status & diff inside a worktree, or remove a finished worktree.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "action": "<action>"
    },
    "name": "codex_worktree"
  }
}

Input Schema

NameRequiredDescriptionDefault
cwdNoOptional repo path to filter worktrees when action="list".
pathNoWorktree path (required for diff and remove).
forceNoAllow removing a dirty worktree (action="remove").
actionYes
max_bytesNoMax diff size in bytes for action="diff".
delete_branchNoAlso delete the codex/* branch after removing the worktree (action="remove").

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.2.0

TDQS

B3.4/5.0
Behavior3/5

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

With no annotations, the description carries the burden, and it does disclose the managed directory scope and the three behavioral modes. It stops short of the important traits for a destructive operation: that removal discards the worktree, that dirty worktrees are refused unless forced, and that delete_branch removes a codex/* branch — those survive only in the schema property text.

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

Conciseness4/5

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

A single front-loaded sentence that enumerates the modes in the same order as the enum, with no filler. It is efficient, though it could have spent one more clause on the destructive caveat rather than being strictly minimal.

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?

For a six-parameter tool with no annotations and no output schema, the description covers what each action means but not the consequences of remove or what diff returns. The schema fills most parameter gaps, so the definition is usable but not fully self-sufficient.

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 83%, so the schema already explains cwd, path, force, delete_branch and max_bytes. The description adds no parameter-level meaning beyond restating the action set, which matches the baseline of 3 when the schema does the documentation work.

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

Purpose4/5

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

The description names three concrete operations (list, diff, remove) against a specific resource (managed Codex worktrees under ~/.codex-mcp/worktrees), which clearly separates it from siblings like codex_status or codex_threads. One wrinkle: it advertises 'git status & diff' while the action enum only offers 'diff', leaving a small gap about whether status is a separate mode or bundled into diff output.

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?

Usage is implied by the three listed operations, and 'finished worktree' hints that removal is the terminal step. However, there is no explicit when-to-use guidance relative to alternatives, no explanation of when force or delete_branch should be set, and no preconditions for the remove flow.

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