Skip to main content
Glama
aliasunder

Vault Cortex Obsidian MCP Server

Replace in Note

vault_replace_in_note
Destructive

Find and replace exact, case-sensitive text within a markdown note's body, preserving frontmatter properties. Replace the first match or all occurrences, or delete text with an empty replacement.

Instructions

Find and replace text in a markdown note's body. Matches exact text (case-sensitive). Properties are preserved; YAML formatting may be normalized to block style on first edit. Operates on the body only — properties must be edited via vault_update_properties or vault_write_note's properties parameter.

Example: vault_replace_in_note({ path: "Projects/plan.md", old_text: "TODO: write summary", new_text: "Summary complete." })

When to use: Targeted text changes within a single location — fixing typos, updating values, renaming terms, or removing a short line (new_text=""). Replaces text in place; does not move content across sections. To delete a large multi-line block, prefer vault_delete_span (short anchors instead of full old_text). To replace a large block by anchors instead of reproducing the full old_text, use vault_replace_span. To relocate content between headings, vault_patch_note to add at the target first, then remove from source (new_text="") — add-before-delete, so a failure duplicates the block instead of losing it.

Parameters:

  • old_text is matched in the body only — frontmatter properties are never searched. Include enough surrounding context to ensure uniqueness when the target text appears in multiple places.

  • old_text + new_text together determine the operation: a non-empty new_text is an edit; an empty new_text ("") is a deletion. No regex — exact text only.

  • replace_all_occurrences (default false) replaces only the first match — a safety default when old_text appears in multiple places. Set true for deliberate bulk renames or term replacements.

Errors:

  • "note not found" — path does not exist; check vault_list_notes for valid paths

  • "text not found" — old_text does not appear in the note body; verify exact text with vault_read_note

  • "oldText cannot be empty" — old_text must be at least one character

  • "absolute path blocked" — the path starts at the filesystem root; use a vault-relative path

  • "hidden path blocked" — the path targets a hidden (dot-prefixed) file or folder like ".obsidian/"; hidden paths are not editable, matching Obsidian

  • "concurrent write in progress" — another write to this note is in flight; re-read the note and retry

  • "new_text contains a control character" — new_text includes a non-printable control byte; remove it before writing

Obsidian syntax: new_text is Obsidian Flavored Markdown (no escaping applied). Watch for: #word = tag, [[ = wikilink, %% = comment block in replacement text.

Returns: Confirmation message with replacement count (number of occurrences replaced).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathYesVault-relative path to the note, including the ".md" extension (e.g. "Projects/plan.md")
new_textYesReplacement text. Empty string ("") deletes the matched text.
old_textYesExact text to find (case-sensitive). Matches in the body only — text inside frontmatter properties is not searched.
replace_all_occurrencesNoReplace all occurrences (default: false — replaces first occurrence only)

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changedv0.50.0
    • addedInput schema / properties / replace_all_occurrences / default
      Added value: +false
  2. Addedv0.32.1
  3. Removedv0.32.0
  4. Changed1 schema field changedv0.23.10
    • changedInput schema / properties / path / description
      Previous value: -"Vault-relative path to the note (e.g. \"Projects/plan.md\")"New value: +"Vault-relative path to the note, including the \".md\" extension (e.g. \"Projects/plan.md\")"
  5. Changed3 schema fields changedv0.23.5
    • changedInput schema / properties / new_text / description
      Previous value: -"Replacement text"New value: +"Replacement text. Empty string (\"\") deletes the matched text."
    • changedInput schema / properties / old_text / description
      Previous value: -"Exact text to find (case-sensitive, non-empty)"New value: +"Exact text to find (case-sensitive). Matches in the body only — text inside frontmatter properties is not searched."
    • changedInput schema / properties / path / description
      Previous value: -"Vault-relative path to the note"New value: +"Vault-relative path to the note (e.g. \"Projects/plan.md\")"
  6. Added

TDQS

A4.8/5.0
Behavior5/5

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

Annotations already declare destructive=true and idempotent=false, but the description adds substantial context beyond them: YAML normalization to block style on first edit, properties are preserved, exact/case-sensitive matching with no regex, and a full error catalogue including concurrency ('concurrent write in progress'), path blocking, and control-character rejection. It also warns about Obsidian syntax pitfalls (#, [[, %%) in replacement text.

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?

It is long but well-organized and front-loaded: purpose, example, when-to-use, parameters, errors, returns. Every section earns its place, though the error enumeration and Obsidian-syntax note make it heavier than strictly necessary for a single-purpose replace tool.

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 destructive find-and-replace tool with no output schema, the description covers everything an agent needs: scope (body vs frontmatter), side effects (YAML normalization), operation semantics, failure modes, and return value (confirmation with replacement count). Nothing material is missing.

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 description coverage is 100%, so the baseline is 3, but the description adds real meaning on top: it explains the old_text+new_text pairing semantics (non-empty = edit, empty = deletion), the rationale for the replace_all_occurrences safety default, and guidance to include surrounding context for uniqueness when text repeats. The uniqueness guidance is not present in 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 states a specific verb and resource (find and replace text in a markdown note's body) and immediately scopes it against siblings (body-only, properties must go through vault_update_properties or vault_write_note). An agent can distinguish this from vault_replace_span and vault_patch_note without opening any schema.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

It gives an explicit 'When to use' clause with concrete examples (typos, value updates, term renames, short-line deletion via new_text="") and names three alternatives with the conditions that select them (vault_delete_span for large blocks, vault_replace_span for anchor-based block replacement, vault_patch_note add-before-delete for relocation). This is exactly the when/when-not/alternatives guidance the dimension asks for.

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