Skip to main content
Glama
sangingeum
by sangingeum

file_apply_patch

Destructive

Apply unified diffs safely: validate every hunk and file before writing, preview changes with dry_run, and return an undoable operation ID.

Instructions

Apply a unified diff and return operation_id and undo_available. Destructive.

    The whole patch is parsed and every hunk is checked against its file
    before a byte is written; a failed or ambiguous hunk rejects the patch
    with PATCH_FAILED and leaves the pre-patch state intact. A patch is
    limited to 1048576 bytes here. A multi-file patch is recorded as one
    logical operation and is undoable, but its application is recoverable,
    not atomic across files. dry_run validates and reports every file and
    hunk without touching the tree. Renaming patches are refused.
    

Input Schema

NameRequiredDescriptionDefault
patchYes
dry_runNo
i_accept_secret_write_riskNo

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.8

TDQS

A4.1/5.0
Behavior5/5

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

Goes well beyond the annotations (which already give destructiveHint=true) by disclosing parse-before-write validation, PATCH_FAILED behavior with pre-patch state preserved, a 1048576-byte limit, and the crucial caveat that multi-file application is 'recoverable, not atomic across files'.

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 essential verb and the destructive warning, and nearly every sentence carries distinct information (validation, size cap, atomicity, dry_run, rename refusal).

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?

No output schema exists, but the description still tells the agent what is returned, and it covers failure modes, limits, and undo semantics for a destructive tool.

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 0%, so the description does the heavy lifting: it explains the patch semantics (unified diff, size cap, rename refusal) and fully explains dry_run's effect. But 'i_accept_secret_write_risk' is never mentioned at all, despite being an unusual, surprising required-of-attention flag.

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 opening line names a specific verb and resource ('Apply a unified diff') and states the return values ('operation_id and undo_available'), which functionally distinguishes this from plain-write siblings like file_write or file_replace_text that take content rather than a diff.

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 rather than spelled out: 'dry_run validates and reports every file and hunk without touching the tree' tells the agent when to use the dry_run mode, and 'Renaming patches are refused' documents a hard boundary.

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