Skip to main content
Glama

apply_patch

Validate and apply a strict unified diff relative to cwd. Rejects entire patch on context mismatch, with no fuzzy or partial fallback.

Instructions

Apply a strict standard unified diff relative to cwd. All hunks are validated before mutation; context mismatch rejects the entire patch without fuzzy or partial fallback.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
cwdNoPatch root directory. Defaults to the agent user home directory.
patchYesStandard unified diff to validate and apply.

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.5.0

TDQS

A3.8/5.0
Behavior4/5

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

With no annotations present, the description carries the full burden and does well: it discloses that all hunks are validated before any mutation, that context mismatch rejects the entire patch, and that there is no fuzzy or partial fallback — a clear atomicity and failure-mode guarantee. It omits permissions requirements or what the result reports, but the core mutation semantics are unusually well specified.

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?

Two tight sentences, zero filler, with the format requirement and the atomicity guarantee front-loaded. Every clause earns its place.

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 mutation tool with no annotations and no output schema, the description covers the critical ground: required input format, validation-before-mutation ordering, and all-or-nothing failure behavior. It does not describe the return value or error reporting, which is the only meaningful gap.

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% with both parameters documented, so the schema already does the heavy lifting (baseline 3). The description adds only marginal meaning, clarifying that the patch is interpreted relative to cwd, but no syntax or format detail beyond the schema.

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: 'Apply a strict standard unified diff relative to cwd.' An agent immediately knows this mutates files via a patch. It does not explicitly name an alternative sibling, but no sibling overlaps this function, so disambiguation is unnecessary.

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?

The requirement for a 'strict standard unified diff' implies when the tool is appropriate, and the strictness constraint signals when it is a safe choice. However, it never states when to prefer this over writing files directly or what kinds of edits it should not be used for, leaving usage largely inferred.

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