Skip to main content
Glama

Vault Patch

vault_patch

Perform precise find-and-replace edits in a vault file, with single or sequenced patches and optional git commit, ensuring all modifications are validated before writing.

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
findNoExact text to find (single mode). Empty = not set. (Use `find`/`replace`, NOT `old_string`/`new_string` — those are accepted as aliases.)
pathYesRelative path to the file within the project.
commitNoIf True, commit synchronously before returning. Defaults to False, which queues the path for the reconciler. See ``vault_write`` docstring for the durability contract.
patchesNoList of {"find", "replace"} dicts (multi mode).
projectYesProject slug or '_meta' for cross-project content.
replaceNoReplacement text (single mode). Empty = not set.
new_stringNoAlias of `replace` (#151). Prefer `replace`.
old_stringNoAlias of `find` (#151). Prefer `find`.
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

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed2 schema fields changedv3.0.0
    • changedInput schema / properties / commit / default
      Previous value: -trueNew value: +false
    • changedInput schema / properties / commit / description
      Previous value: -"If True (default), auto-commit. If False, write to disk\nwithout committing — useful for batching many patches into\none ``vault_commit`` flush. See ``vault_write`` docstring for\nthe durability contract."New value: +"If True, commit synchronously before returning.\nDefaults to False, which queues the path for the reconciler.\nSee ``vault_write`` docstring for the durability contract."
  2. Changed1 schema field changedv1.32.2
    • addedInput schema / properties / idempotency_key
      Added value: +{
      +  "default": "",
      +  "description": "Optional at-most-once token. If set, a retry with\nthe same key is a no-op after the first apply (ADR-013). Empty\n(default) disables idempotency.",
      +  "type": "string"
      +}
  3. Changed3 schema fields changedv1.23.0
    • changedInput schema / properties / find / description
      Previous value: -"Exact text to find (single mode). Empty = not set."New value: +"Exact text to find (single mode). Empty = not set.\n(Use `find`/`replace`, NOT `old_string`/`new_string` — those\nare accepted as aliases.)"
    • addedInput schema / properties / new_string
      Added value: +{
      +  "default": "",
      +  "description": "Alias of `replace` (#151). Prefer `replace`.",
      +  "type": "string"
      +}
    • addedInput schema / properties / old_string
      Added value: +{
      +  "default": "",
      +  "description": "Alias of `find` (#151). Prefer `find`.",
      +  "type": "string"
      +}
  4. Addedv1.21.0
  5. Removedv1.13.0
  6. Changed4 schema fields changedv1.4.2
    • addedInput schema / properties / find
      Added value: +{
      +  "default": "",
      +  "type": "string"
      +}
    • removedInput schema / properties / new_text
      Removed value: -{
      -  "default": "",
      -  "type": "string"
      -}
    • removedInput schema / properties / old_text
      Removed value: -{
      -  "default": "",
      -  "type": "string"
      -}
    • addedInput schema / properties / replace
      Added value: +{
      +  "default": "",
      +  "type": "string"
      +}
  7. First observedv1.11.0

TDQS

A4.8/5.0
Behavior5/5

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

With annotations only carrying false boolean hints, the description adds substantial behavioral detail: 3-pass cascading match, sequential patch application, all-or-nothing validation, and the auto-commit side effect. The commit parameter description further clarifies the default queue-for-reconciler path, so there is no misleading gap.

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 short paragraphs, each earning its place: summary, mode selection, validation constraint, and matching algorithm. It front-loads the core purpose and avoids restating schema definitions or adding filler.

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

Completeness5/5

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

For a 9-parameter tool with an output schema, the description covers all invocation-critical behavior: mode selection, uniqueness constraint, atomic failure, matching semantics, and commit behavior (with a pointer to the durability contract). An agent has enough to select and invoke the tool correctly.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, and the description goes beyond per-field docs by explaining how find/replace relate to patches, that patches apply in sequence, that each find must be unique, and that modes cannot be mixed. This adds real cross-parameter meaning rather than repeating the schema.

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 opens with 'Surgical find-and-replace in a vault file with auto git commit,' which names a specific operation, resource, and side effect. This clearly differentiates it from the sibling vault_write/vault_delete tools by emphasizing targeted in-place edits, and the mode details reinforce the purpose.

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?

It gives explicit usage rules: single mode via find/replace, multi mode via patches, 'Do not mix both modes,' and the validation requirement that each find must appear exactly once. It lacks explicit when-not guidance naming alternatives (e.g., vault_write for whole-file overwrites), so it doesn't earn a 5.

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