Skip to main content
Glama

apply_edits

Apply multi-file, multi-hunk code edits with optional inline verification, returning the edit result and test verdict in one call.

Instructions

Multi-hunk editor (up to 50 files) with optional inline verify: the edit and its verdict come back in one call. Shape: edits=[{path, hunks:[{target, replacement}]}]; a top-level path fills edits that omit one (single-file shorthand). target/replacement take a string or an array of lines; in a single string escape every newline as \n and every double quote as " so the arguments stay valid JSON.

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": {
      "edits": "<edits>"
    },
    "name": "apply_edits"
  }
}

Input Schema

NameRequiredDescriptionDefault
cwdNoRepo root for relative edit paths; absolute paths inside a known root are rebased automatically
pathNoSingle-file shorthand: fills the path of every edit that omits one
rootNoAlias of cwd
editsYes
verifyNoCommand run after the edit; 'auto' = the project's declared test command
dry_runNo
best_effortNo

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed8 schema fields changedv4.16.0
    • addedInput schema / properties / cwd
      Added value: +{
      +  "description": "Repo root for relative edit paths; absolute paths inside a known root are rebased automatically",
      +  "type": "string"
      +}
    • addedInput schema / properties / edits / items / properties / hunks / items / properties / replacement / items
      Added value: +{
      +  "type": "string"
      +}
    • changedInput schema / properties / edits / items / properties / hunks / items / properties / replacement / type
      Previous value: -"string"New value: +[
      +  "string",
      +  "array"
      +]
    • addedInput schema / properties / edits / items / properties / hunks / items / properties / target / items
      Added value: +{
      +  "type": "string"
      +}
    • changedInput schema / properties / edits / items / properties / hunks / items / properties / target / type
      Previous value: -"string"New value: +[
      +  "string",
      +  "array"
      +]
    • removedInput schema / properties / edits / items / required
      Removed value: -[
      -  "path"
      -]
    • addedInput schema / properties / path
      Added value: +{
      +  "description": "Single-file shorthand: fills the path of every edit that omits one",
      +  "type": "string"
      +}
    • addedInput schema / properties / root
      Added value: +{
      +  "description": "Alias of cwd",
      +  "type": "string"
      +}
  2. Changed6 schema fields changedv4.7.15
    • removedInput schema / properties / cwd
      Removed value: -{
      -  "type": "string"
      -}
    • addedInput schema / properties / edits / items / properties / hunks / description
      Added value: +"Replacement hunks. Copy start_line/end_line from the read slice header (`// --- Lx-Ly`): a target that occurs more than once is rejected with the occurrence lines and a scoped retry, and a ranged hunk is never ambiguous. The tool auto-scopes when the last read window contains exactly one occurrence."
    • addedInput schema / properties / edits / items / properties / hunks / items / properties / end_line / description
      Added value: +"1-based last line to search"
    • addedInput schema / properties / edits / items / properties / hunks / items / properties / start_line / description
      Added value: +"1-based first line to search; take it from the slice header (// --- Lx-Ly)"
    • changedInput schema / properties / verify / description
      Previous value: -"Shell command to run after edits (e.g. pytest, npm test)"New value: +"Command run after the edit; 'auto' = the project's declared test command"
    • removedInput schema / properties / verify_timeout_sec
      Removed value: -{
      -  "type": "integer"
      -}
  3. Addedv4.6.2

TDQS

A3.6/5.0
Behavior3/5

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

Annotations declare readOnlyHint=false and destructiveHint=false, so the description needn't re-state safety, and it correctly does not contradict them. It adds real context — the 50-file cap, that verify runs a command after the edit, and the JSON escaping requirement — but says nothing about atomicity, partial-failure behavior, or what best_effort/'auto' actually do, which matters for a mutation tool.

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?

Front-loaded with the tool's identity and limits, then moving to shape and escaping rules. Dense but each sentence contributes; the closing escaping clause is a run-on but is high-value operational detail rather than filler.

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?

For a 7-parameter mutation tool with no output schema, the description covers the arguments' shape, the return contract ('the edit and its verdict come back in one call'), limits, and encoding gotchas. Remaining gaps are failure semantics and the meaning of dry_run/best_effort, which are moderate rather than critical omissions.

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?

With schema coverage at 57%, the description carries weight by fully unpacking the complex nested edits structure (path/hunks/target/replacement), the top-level path shorthand, and the string-vs-array plus escaping rules that the schema does not state. It leaves cwd/root aliasing, dry_run, and best_effort to the schema, so it is strong on the hardest parameter but not exhaustive.

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?

States a specific verb and resource ('Multi-hunk editor') plus hard scope ('up to 50 files') and an optional capability ('inline verify'). An agent can tell this is the edit tool, though nothing in the description explicitly distinguishes it from siblings like smart_read_file or scoped_search.

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 only implied: the 'edit and its verdict come back in one call' line suggests combining edits with verify, and the single-file shorthand hints at simpler cases. There is no explicit when-not-to-use, no guidance on dry_run vs. real edits, and no routing to alternatives.

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