Skip to main content
Glama

patch-anchor

Apply a unified-diff hunk or search/replace edit to a file by content, refusing ambiguity — Applies unified-diff hunks (wrong line numbers are fine) or search/replace blocks to a supplied file text and returns the patched text, for an agent whose edit tool failed or whose diff has drifted line numbers. Each hunk is located by its content against the original file, trying exact, trailing-whitespace, outer-whitespace then collapsed-whitespace matching; the rung used is reported per hunk. I

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": {
      "file": "<file>"
    },
    "name": "patch-anchor"
  }
}

Input Schema

NameRequiredDescriptionDefault
diffNoSingle-file unified diff, at most 64 hunks and 400 anchor lines each. Header counts and line numbers are ignored except as a reported hint. Give either diff or edits.
fileYesCurrent file text, at most 524288 UTF-8 bytes and 100000 lines. A leading BOM is preserved.
editsNoSearch/replace blocks, matched as whole lines against the original file; all are located before any is applied.

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

A4/5.0
Behavior4/5

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

With no annotations, the description carries the full burden and does meaningful work: it discloses the four-rung content-matching ladder (exact, trailing-whitespace, outer-whitespace, collapsed-whitespace), that the rung used is reported per hunk, and that ambiguity is refused rather than guessed. Gaps remain around the failure mode when no rung matches (error object vs. partial output) and whether the operation is atomic for diff input, which the schema hints at for edits only.

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

Conciseness3/5

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

The core content is front-loaded and the matching ladder is well ordered, but the opening clause is immediately restated after an em-dash ('Apply ... — Applies ... to a supplied file text'), which is wasted text, and the description trails off mid-word ('I'), which reads as an editing artifact. Tightening to one purpose sentence plus the matching behavior would lose nothing.

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?

There is no output schema, yet the description states the return value (patched text) and the per-hunk rung report, which is the key output an agent needs to judge edits. For a three-parameter text transformer whose schema is fully documented, what remains missing is mainly error semantics on ambiguity, which 'refusing ambiguity' gestures at but does not specify.

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 `file` as current file text, `diff` as single-file unified diff with header counts ignored as a hint, and `edits[].line` as a non-tie-breaking hint. The description reinforces the 'wrong line numbers are fine' and content-anchoring ideas but adds little parameter-level meaning beyond that, so the baseline of 3 applies.

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 names a specific verb and resource (apply a unified-diff hunk or search/replace block to file text, returning patched text) and states the motivating situation (an edit tool failed or a diff drifted), which separates it from ordinary edit tools. Despite the redundant em-dash restatement, an agent can tell exactly what class of operation this is without opening the schema.

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?

It gives a clear triggering condition — use this when your own edit tool failed or line numbers in the diff have drifted — which is actionable selection guidance. It stops short of explicit exclusions (e.g., 'do not use when the diff applies cleanly with exact line numbers') and does not name a validation-only sibling such as edit-anchor-check, so routing between closely related tools is left partly implicit.

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

Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.

Resources