Skip to main content
Glama

Replace in Note

replace_in_note
Destructive

Search and replace text in a single Obsidian note using literal strings or regex patterns. Set an expected match count to block accidental over-replacement when a pattern is too broad.

Instructions

Search-and-replace within a single note. Supports literal strings or regex patterns. With expectedCount, the operation refuses to commit unless that many matches are present, guarding against accidental over-replacement when an LLM drafts a pattern that's too broad. Returns the count of replacements made.

Input Schema

NameRequiredDescriptionDefault
findYesLiteral string (default) or regex pattern to match.
pathYesVault-relative path to the note.
flagsNoRegex flags (e.g., 'gi'). Defaults to 'g' so all matches are replaced.
regexNoTreat `find` as a JavaScript regex (multi-line, case-sensitive by default).
replaceYesReplacement text. With `regex: true`, supports $1, $2 backreferences.
expectedCountNoIf set, abort unless exactly this many matches are found.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed4 schema fields changedv4.1.1
    • removedInput schema / additionalProperties
      Removed value: -false
    • addedInput schema / properties / expectedCount / maximum
      Added value: +9007199254740991
    • addedInput schema / properties / find / maxLength
      Added value: +4096
    • addedInput schema / properties / replace / maxLength
      Added value: +1000000
  2. Addedv2.0.0
  3. Removedv1.9.0
  4. Addedv1.8.0

TDQS

A4.2/5.0
Behavior4/5

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

Annotations already declare destructiveHint=true and idempotentHint=false, so safety profile is carried by structured data. The description adds real value beyond that: it discloses the fail-closed abort behavior with `expectedCount`, and states that the tool returns a replacement count — behavior an agent could not infer from annotations.

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?

Three sentences, each doing distinct work: core operation, mode support, safety guard plus return value. Front-loaded with the verb and resource, with no filler or restatement of the name.

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?

For a 6-parameter destructive mutation with full schema coverage and rich annotations, the description covers the operation, modes, guard, and return value. Minor gaps remain — e.g. behavior on zero matches, or what happens if `path` doesn't exist — but nothing critical to correct invocation 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 coverage is 100%, so baseline is 3. The description goes beyond the schema by explaining the *rationale* for `expectedCount` ('guarding against accidental over-replacement when an LLM drafts a pattern that's too broad') and by framing the literal-vs-regex tradeoff, which clarifies the interaction between `find` and `regex` better than the schema's per-field notes.

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?

States a specific verb+resource combination ('Search-and-replace within a single note') that immediately distinguishes it from sibling mutation tools like update_section, edit_block, or append_to_note. It also names the two modes of operation (literal strings vs regex) in the same breath.

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?

Explains the purpose of `expectedCount` as a guard against over-broad patterns, which is genuinely useful usage guidance. However, it never explicitly states when to prefer this over update_section or edit_block, nor any when-not conditions, so the agent must infer routing from sibling names alone.

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