Skip to main content
Glama

Patch files

patch
Destructive

Apply multiple exact-string edits across one or more files in a single validated operation; if any edit fails, no file is changed. Use it to commit related changes together.

Instructions

Apply several exact-string edits across one or more files in a single all-or-nothing operation. Every edit is validated against the current file contents first; if any edit fails, NO file is modified and the failing edit index is reported. Use this instead of several edit_file calls when changes belong together. Read the affected files first with read_file. Changes are written to disk immediately when all edits are valid.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
editsYesEdits to apply. All must be valid against the current file contents, otherwise nothing is written.
workspaceNoWorkspace name (see workspace_list). Defaults to the primary workspace.

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv1.5.0

TDQS

A4.7/5.0
Behavior5/5

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

Goes well beyond the destructiveHint and readOnlyHint annotations: describes validation against current file contents, atomic all-or-nothing failure behavior with failing edit index reporting, and immediate disk writes when all edits are valid. This is exactly the kind of behavioral detail an agent needs.

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?

Five sentences, each carrying distinct information: function, atomicity/failure behavior, usage guidance, prerequisite, and write timing. Front-loaded with the core capability and no filler.

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?

The description covers what the tool does, when to use it, prerequisites, failure semantics, and persistence behavior. Given the moderate complexity, the complete schema coverage, and the existing annotations, nothing material is missing for an agent to invoke this correctly.

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?

The schema already documents all parameters with 100% coverage, including exact-match semantics for oldString and replaceAll behavior. The description adds context about 'exact-string' edits and atomic validation, but does not add significant per-parameter meaning beyond the schema, so baseline 3 is appropriate.

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?

States a specific action: apply several exact-string edits across files as one all-or-nothing operation. Clearly differentiates from sibling edit_file by naming it and explaining when patch should be preferred.

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 says 'Use this instead of several edit_file calls when changes belong together' and instructs to read files first with read_file. This gives an agent clear selection criteria and prerequisites.

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