Skip to main content
Glama

apply_patch

Apply a unified diff to a file in an Obsidian vault, validating context lines and optionally verifying content hash for safe, precise edits.

Instructions

Apply a unified diff to a file. Context lines (' ' prefix) are validated verbatim per hunk — the diff IS the content precondition. expected_content_hash is optional belt-and-suspenders. Use this for multi-hunk surgical edits.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
fileYes
patchYes
vaultNo
dry_runNo
expected_content_hashNo
Behavior4/5

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

The description explains the key behavioral trait that context lines are validated verbatim per hunk, and notes that the diff serves as a content precondition. It also clarifies that expected_content_hash is optional, adding transparency beyond what annotations (none) provide. However, it doesn't detail potential failure modes or side effects.

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 at three sentences, each serving a distinct purpose: stating the primary action, highlighting the critical validation behavior, and recommending usage. No redundant or excessive content.

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?

The description captures the core functionality and an important behavioral aspect, but lacks details about vault, dry_run, return values, and error conditions. Given no output schema, more information about what the tool returns would improve completeness.

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?

With 0% schema description coverage, the description must compensate for all 5 parameters. It only explains expected_content_hash ('belt-and-suspenders') and implies the role of file and patch. Vault and dry_run are not described, leaving significant gaps for the agent.

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 the tool applies a unified diff to a file, specifies the validation of context lines, and indicates it's for multi-hunk surgical edits, which distinguishes it from simpler tools like file.replace or str_replace.

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 explicitly recommends using this tool for multi-hunk surgical edits, providing guidance on when to use it. It does not explicitly mention when not to use or name alternative tools, but the context from sibling tools helps infer appropriate usage.

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/usrivastava92/obsidian-native-mcp'

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