Skip to main content
Glama

patch

Apply unified diff patches to files while preserving original encoding and verifying context lines. Use dry_run to preview changes before applying them.

Instructions

Applies a unified diff patch to a file. Parses @@ hunk headers, verifies context lines, and applies changes. Encoding-aware: preserves original file encoding. Use dry_run=true to preview without modifying the file.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
file_pathYesAbsolute path to the file to patch
patchYesUnified diff text (output of the diff tool)
dry_runNoPreview patch result without modifying the file (default false)
Behavior4/5

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

No annotations provided, so description carries full burden. It discloses key behavioral traits: parses hunk headers, verifies context lines, preserves encoding, and supports dry-run preview. Deducted one point because it doesn't mention failure modes (what happens if context doesn't match?) or whether the operation is atomic.

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 sentences, each earning its place: (1) core purpose, (2) parsing mechanics, (3) encoding behavior, (4) usage guidance. Front-loaded with the essential action and no redundant text.

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

Completeness3/5

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

Adequate for a 3-parameter tool with complete schema coverage, but given this is a file mutation tool without safety annotations (destructiveHint), the description could benefit from explicit warnings about file modification or failure handling. No output schema exists, but the description appropriately doesn't attempt to describe return values.

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?

With 100% schema coverage, baseline is 3. Description adds value by explaining the dry_run use case ('preview without modifying') and encoding behavior ('preserves original file encoding') that applies to the file_path parameter. The explanation of hunk parsing also adds semantic context to the patch parameter.

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?

Description clearly states the core action ('Applies a unified diff patch') and resource ('file'), with specific technical details ('@@ hunk headers') that distinguish it from generic siblings like 'edit' or 'write'. The mention of 'unified diff' specifically links it to the 'diff' tool output, creating clear sibling differentiation.

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?

Provides explicit guidance for the dry_run parameter ('Use dry_run=true to preview without modifying the file'), which helps with safe usage. However, lacks explicit when-to-use guidance versus alternatives like 'edit' or 'write', though the unified diff format implies specific use cases.

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

Install Server

Other Tools

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