Skip to main content
Glama

patch

Apply a unified diff to a file after verifying context lines, preserving original encoding and line endings. Use dry-run to preview changes.

Instructions

Applies a unified diff patch to a file. Parses @@ hunk headers, verifies context lines, and applies changes. Encoding-aware: preserves original file encoding. Line-ending aware: each line keeps its own ending (a mixed CRLF/LF file is not rewritten) and a file without a trailing newline does not gain one. Use dry_run=true to preview without modifying the file.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathNoAlias for file_path
patchYesUnified diff text (output of the diff tool)
dry_runNoPreview patch result without modifying the file: true or false. Default: false
file_pathNoFile to patch. Relative paths use the configured workspace or MCP client root

Schema Changelog

Changes observed during successful MCP inspections. Dates show when Glama detected each change.

  1. Changed2 schema fields changedv0.9.5
    • addedInput schema / properties / dry_run / type
      Added value: +"boolean"
    • changedInput schema / properties / file_path / description
      Previous value: -"Absolute path to the file to patch"New value: +"File to patch. Relative paths use the configured workspace or MCP client root"
  2. Addedv0.8.7
  3. Removed
  4. Changed1 schema field changedv0.7.12
    • changedOutput schema / (root)
      Previous value: -{
      -  "additionalProperties": false,
      -  "properties": {
      -    "result": {
      -      "type": "string"
      -    }
      -  },
      -  "required": [
      -    "result"
      -  ],
      -  "type": "object"
      -}New value: +null
  5. First observedv0.4.2

TDQS

A3.6/5.0
Behavior1/5

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

The description directly contradicts the provided annotations: it says the tool 'applies changes' and can modify a file, while annotations mark readOnlyHint=true and destructiveHint=false. This is an annotation contradiction, which forces the lowest score regardless of the strong encoding and line-ending details.

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 concise and well-structured: it front-loads the primary action, then adds useful encoding/line-ending behavior, and ends with an actionable dry-run usage. Every sentence contributes unique information.

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?

The tool description covers the behavioral full picture: diff format, context verification, encoding preservation, line-ending behavior, and dry-run safety. The confusing annotation contradiction prevents a 5, but as a standalone spec it is nearly complete.

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 input schema already describes all four parameters clearly, including patch, dry_run, and the path aliases. The description adds little beyond restating that dry_run previews without modifying, so baseline 3 applies.

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 starts with a precise verb-resource pair: 'Applies a unified diff patch to a file.' It further clarifies behavior with hunk parsing and context verification, making it clearly distinct from nearby siblings like edit, write, or multiedit.

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

Usage Guidelines4/5

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

The description conveys a clear use-case: applying unified diff output to a file, with dry_run for preview. It does not explicitly contrast with edit or write, but the diff-specific framing makes the correct context fairly obvious.

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

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/knewstimek/agent-tool'

If you have feedback or need assistance with the MCP directory API, please join our Discord server