Skip to main content
Glama

Patch

patch
Destructive

Apply a single-file unified diff to a file and write the result, with a dry-run option to preview changes first.

Instructions

Apply a single-file unified diff to one file and write the result. Pass { path, diff }. Use after inspecting a diff tool dry-run: pass the diff blob directly instead of re-expressing it as line edits. Rejects multi-file diffs and diffs whose hunk context does not match the file. Set dryRun=true to preview the result without writing.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
diffYesSingle-file unified diff to apply (as produced by the diff tool or edit dry-run)
pathYesFile to apply the diff to
dryRunNoPreview the result without writing (default: false)

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changedv2.4.1
    • addedInput schema / $schema
      Added value: +"https://json-schema.org/draft/2020-12/schema"
  2. Addedv2.0.0

TDQS

A4.9/5.0
Behavior5/5

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

Annotations declare destructiveHint=true, and the description reinforces that it writes the result. It discloses rejection behaviors (multi-file, context mismatch) and the dryRun preview option, which are not covered by annotations. No contradiction with annotations.

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?

Three sentences with no filler. The first sentence front-loads the core action and inputs, the second gives usage guidance, and the third lists constraints and the dryRun option. Every sentence earns its place.

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

Completeness5/5

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

For a destructive file-patch tool, the description covers what it does, when to use it, its limitations, and the dryRun option. With annotations providing the destructive hint and no output schema, nothing essential is missing for an agent to call it correctly.

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?

Schema coverage is 100% and describes each parameter. The description adds context to the diff parameter by clarifying it should come from a diff tool dry-run and that it rejects multi-file diffs and context mismatches, which goes beyond the schema's basic description. It also briefly mentions dryRun behavior.

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 states a specific verb (apply), a precise resource (a single-file unified diff to one file), and the result (write the result). It clearly differentiates from siblings like edit or replace_text by specifying the diff input and the rejection of multi-file diffs, making it distinct.

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

Usage Guidelines5/5

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

Explicitly instructs to use after a diff tool dry-run and to pass the diff blob directly rather than re-expressing it as line edits, which contrasts with edit/replace_text. It also states rejection conditions (multi-file diffs, mismatched context), effectively saying when not to use it.

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