Skip to main content
Glama

apply_patch

Apply unified diff patches to repository files atomically, returning success status and changed file list.

Instructions

Atomically apply a unified diff patch to repository files.

Args: patch: The unified diff content (e.g., standard 'diff --git' or '--- / +++' format). file_path: Optional relative target path if targeting a single file.

Returns: JSON string with success status, list of changed files, and status message.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
patchYes
file_pathNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A4.2/5.0
Behavior4/5

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

With no annotations provided, the description carries the full disclosure burden. It discloses atomicity, accepted patch formats ('diff --git' or '--- / +++'), and the JSON return contract. It does not warn about destructive side effects or conflict behavior, but the core behavior is clearly and honestly stated.

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?

The description is compact and well-structured: a one-sentence summary followed by two argument explanations and a returns line. There is no redundant phrasing, and the most important facts are front-loaded.

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 two-parameter mutation tool with an output schema, the description covers the input format, optional path targeting, atomicity, and return structure. It is slightly thin on safety context such as whether changes are reversible or how conflicts are handled, but an agent has enough information to invoke 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?

The input schema provides only bare type names, so schema description coverage is 0%. The description compensates by explaining the patch parameter as unified diff content with format examples and clarifying file_path as optional, relative, and for targeting a single file. This adds real meaning beyond the schema.

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 leads with a specific verb and object: 'Atomically apply a unified diff patch to repository files.' This clearly differentiates it from sibling tools like get_git_diff, which generate diffs, and read_file/search_code, which are read-only. The purpose is unambiguous.

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: an agent should call this when it has a unified diff to apply to repository files. However, there is no explicit when-to-use versus alternatives guidance, such as 'use get_git_diff to inspect changes instead,' so the agent must infer the decision from sibling names.

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