Skip to main content
Glama

Apply Patch

apply_patch

Apply a unified diff patch to workspace files using the system patch utility. Specify a target directory and optionally perform a dry run to validate changes before applying.

Instructions

Apply a unified diff patch to workspace files using the system patch utility.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "patch": "<patch>"
    },
    "name": "apply_patch"
  }
}

Input Schema

NameRequiredDescriptionDefault
cwdNo.
patchYes
dry_runNo

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.2.1

TDQS

C2.7/5.0
Behavior2/5

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

With no annotations, the description carries the full behavioral burden and mostly does not meet it. It reveals the implementation (system patch utility), which hints at path resolution semantics, but says nothing about whether files are created or deleted, what happens on a partially-applied or rejected hunk, whether the operation is atomic, or whether output reports failures.

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?

A single front-loaded sentence with no filler. It is efficient, though the terseness is part of why behavior and parameters go unexplained.

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

Completeness2/5

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

This is a mutation tool with no annotations, no output schema, and zero schema description coverage — the highest-burden combination — and the description is one sentence. For an agent to invoke it safely it needs failure-mode and dry_run guidance that is entirely absent.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0% and the description adds meaning for none of the three parameters. 'Unified diff' implies the patch format, but cwd (path base for the patch) and dry_run (the safety-critical preview flag) are completely undocumented in both schema and description.

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 unified diff patch to workspace files) and even names the underlying mechanism (the system patch utility), which tells an agent this is bulk multi-hunk editing rather than single-edit. It stops short of differentiating from edit_file or write_file, which occupy adjacent territory in the sibling list.

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

Usage Guidelines2/5

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

There is no guidance on when to prefer this over edit_file or write_file, no stated prerequisites (does the target file need to exist?), and no mention of the obvious recommended workflow of running with dry_run first. The agent must infer all of this.

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