Skip to main content
Glama

github_mcp.apply_patch

Destructive

Replace an exact, uniquely occurring UTF-8 text fragment in a planned job file using a supplied checksum; rejects missing or ambiguous context instead of fuzzy matching.

Instructions

Replace an exact, uniquely occurring UTF-8 text fragment in a planned job file. Read the file first and supply its checksum. Rejects missing or ambiguous context instead of fuzzy matching. Returns path, new checksum and byte count; invalidates preview and checks without committing.

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": {
      "job_id": "<job_id>",
      "path": "<path>",
      "old_text": "<old_text>",
      "new_text": "<new_text>",
      "expected_checksum": "<expected_checksum>"
    },
    "name": "github_mcp.apply_patch"
  }
}

Input Schema

NameRequiredDescriptionDefault
pathYesPlanned repository-relative file path.
job_idYesExisting editable job identifier.
new_textYesReplacement text; may be empty to remove the fragment.
old_textYesNonempty exact text that occurs once in the current file.
expected_checksumYesCurrent SHA-256 checksum from read_file for this job workspace.

Output Schema

NameRequiredDescriptionDefault
okYes
dataNo
messageNo
error_codeNo

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed5 schema fields changedv1.0.2
    • addedInput schema / properties / expected_checksum / description
      Added value: +"Current SHA-256 checksum from read_file for this job workspace."
    • addedInput schema / properties / job_id / description
      Added value: +"Existing editable job identifier."
    • addedInput schema / properties / new_text / description
      Added value: +"Replacement text; may be empty to remove the fragment."
    • addedInput schema / properties / old_text / description
      Added value: +"Nonempty exact text that occurs once in the current file."
    • addedInput schema / properties / path / description
      Added value: +"Planned repository-relative file path."
  2. First observedv1.0.1

TDQS

A4.2/5.0
Behavior5/5

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

The annotations already declare destructiveHint=true and readOnlyHint=false, but the description goes well beyond them: it discloses the failure mode (rejection on missing or ambiguous context, no fuzzy matching), the return payload (path, new checksum, byte count), and the downstream side effect that previews and check results are invalidated without a commit. That invalidation detail is exactly the kind of consequence an agent could not infer from structured fields.

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?

Four short sentences, front-loaded with the core action, then precondition, then failure behavior, then effects. Nothing is repeated from the name or wasted.

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?

An output schema exists, so return values need not be explained, yet the description still summarizes them briefly while covering preconditions, failure semantics, and invalidation of preview/checks. For a destructive five-parameter mutation inside a job workspace, that is complete enough to call 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?

Schema coverage is 100%, so the baseline is 3, and the description earns above that by tying expected_checksum to a required prior read and by stressing 'exact, uniquely occurring' for old_text. It slightly sharpens the uniqueness precondition on the match, though it does not add format or syntax 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?

The first sentence names a precise verb and resource ('Replace an exact, uniquely occurring UTF-8 text fragment in a planned job file'), which makes the operation unmistakable. It implicitly separates itself from a whole-file write by scoping to a fragment inside a planned job, but it never names a sibling such as write_file to make the contrast explicit.

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?

'Read the file first and supply its checksum' gives a concrete procedural precondition, and 'Rejects missing or ambiguous context instead of fuzzy matching' tells the agent the operation will fail rather than guess. However, there is no guidance on when to choose this over write_file or create_file_commits, so selection between alternatives is left to inference.

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