Skip to main content
Glama

apply_patch_workspace_file

Destructive

Apply search/replace edits to a workspace file using hunks or unified diff, with whitespace-tolerant matching and optional dry-run.

Instructions

Apply one or more search/replace hunks to an existing file. Preferred arg: hunks=[{old_string,new_string,replace_all?,exact?}]. Aliases accepted: edits/changes/replacements, or patch as the same array, or a small unified-diff string with context/-/+ lines. Each old_string must match the current file exactly once unless replace_all is true. If an exact match fails purely on whitespace/indentation (tabs vs spaces, trailing space) AND the snippet anchors to exactly one place, the patch is still applied — new_string is reindented to the file's real style and the response notes whitespace_adjusted. Exact matches also restyle new_string indent chars to the file's tab/space convention. Pass exact=true on a hunk to disable tolerant re-anchoring. Preserves untouched content verbatim. Returns a unified diff and revert_token.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathYesPath relative to repo root
repoNoRepository name (optional; defaults to current MCP workspace)
hunksNoArray of {old_string, new_string, replace_all?:bool, exact?:bool}. Applied in order. Aliases: edits, changes, replacements.
patchNoOptional alias: same as hunks (JSON array) OR a small unified-diff string with context/-/+ lines
dry_runNoIf true, do not write; just return the diff that would be produced
Behavior4/5

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

The description goes beyond annotations by explaining whitespace-tolerant matching, exact match behavior, replace_all semantics, and the returned diff and revert_token. It also notes that the tool returns a unified diff and revert_token. No contradiction with annotations (destructiveHint=true is consistent).

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?

The description is a single paragraph of moderate length. It starts with the core purpose, then details matching behavior and return values. Every sentence contributes useful information, but it could be slightly more concise without losing essential details.

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?

Given the absence of output schema, the description adequately explains return value (unified diff and revert_token) and error conditions. It covers parameter semantics and behavioral aspects. However, it does not address prerequisites or when to prefer this tool over sibling file modification tools, and for a destructive tool, additional cautionary context could be beneficial.

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 baseline is 3. The description adds significant value by explaining the structure of hunks, aliases (edits, changes, replacements), the behavior of exact and replace_all, and the dry_run option. It clarifies how parameters interact and what happens on match failure, raising the score to 4.

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 clearly states 'Apply one or more search/replace hunks to an existing file.' It specifies the primary function, preferred argument format, and aliases. The verb 'apply' combined with resource 'patch' and 'file' is specific, and the details distinguish it from siblings like 'edit_cycle' or 'verify'.

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?

The description does not explicitly state when to use this tool over alternatives. While it describes what the tool does, it lacks guidance on context or exclusions. Usage is implied through the description of patch application, but no direct comparison to siblings is provided.

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/VeyrForge/codehelper'

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