Skip to main content
Glama

vault_patch

Perform precise find-and-replace operations in Obsidian vault files with automatic git commit. Supports single or batch patches with validation.

Instructions

Surgical find-and-replace in a vault file with auto git commit.

Supports single or multi-replacement. For a single replacement, provide find and replace. For multiple replacements, provide patches — a list of {"find": "...", "replace": "..."} dicts applied in sequence. Do not mix both modes.

Each find value must appear exactly once in the file (after prior patches in the list have been applied). If any patch fails validation, no changes are written.

Uses 3-pass cascading match: exact → body-only → whitespace-normalized.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
projectYesProject slug or '_meta' for cross-project content.
pathYesRelative path to the file within the project.
findNoExact text to find (single mode). Empty = not set. (Use `find`/`replace`, NOT `old_string`/`new_string` — those are accepted as aliases.)
replaceNoReplacement text (single mode). Empty = not set.
patchesNoList of {"find", "replace"} dicts (multi mode).
commitNoIf True (default), auto-commit. If False, write to disk without committing — useful for batching many patches into one ``vault_commit`` flush. See ``vault_write`` docstring for the durability contract.
old_stringNoAlias of `find` (#151). Prefer `find`.
new_stringNoAlias of `replace` (#151). Prefer `replace`.
idempotency_keyNoOptional at-most-once token. If set, a retry with the same key is a no-op after the first apply (ADR-013). Empty (default) disables idempotency.

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes
Behavior4/5

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

The description discloses the 3-pass cascading match, validation failure behavior (no changes written), and the optional idempotency key. It mentions auto git commit, which implies mutation despite annotations showing destructiveHint=false. There is no contradiction with annotations, but the description could be more explicit about what happens when find patterns are not found or when multiple matches exist (it says must appear exactly once but not the error behavior).

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 brief and well-structured: a one-line purpose statement followed by separate paragraphs for single/multi mode, validation rules, and matching strategy. Every sentence adds necessary context without fluff. It is front-loaded with the core verb and resource.

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 tool has an output schema (not shown), the description does not need to detail return values. It covers the main behavioral aspects, but could be more complete by specifying error conditions (e.g., duplicate find occurrences, file not found) and the exact effect of the commit flag. However, for a patch tool with moderate complexity, the description is largely adequate.

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 schema already documents all parameters. The description adds value by explaining the semantic difference between single mode (find/replace) and multi mode (patches), and notes aliases. It does not repeat schema details but clarifies usage patterns. This compensates well for the high schema coverage.

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 identifies the tool as a surgical find-and-replace in vault files with auto git commit. It names the specific verb ('patch') and resource ('vault file'), and distinguishes between single and multi-replacement modes. Sibling tools like vault_write and vault_commit have different purposes, so this is well-differentiated.

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 provides explicit guidance on when to use single vs. multi mode, warns against mixing them, and explains validation and auto-commit behavior. It references vault_commit for batching, which aids decision-making. However, it does not explicitly state when not to use this tool (e.g., for large-scale edits better suited to vault_write).

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/mlorentedev/hive'

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