Skip to main content
Glama
Vault Cortex Obsidian MCP Server

Vault Cortex Obsidian MCP Server

Insert at Anchor

vault_insert_at_anchor

Insert whole lines before or after a body line matched by a short anchor substring in an Obsidian note. Use it to add table rows or list items at a precise location without knowing heading structure.

Instructions

Insert content as whole lines into a note's body, before or after a specific line identified by a short anchor substring. Properties are kept as written, and body line breaks are saved as LF. A repeated call inserts the content again, or fails as ambiguous when the content holds the anchor and first_match is false, so after a timeout or lost response, re-read the note before retrying.

Example: vault_insert_at_anchor({ path: "Tracker.md", anchor: "| 2024-03-02 | Acme", position: "after", content: "| 2024-03-03 | Beta Corp | New entry |" }) — inserts a new table row after the matched row. Example: vault_insert_at_anchor({ path: "Notes/Plan.md", anchor: "## Phase 2", position: "before", content: "> [!note] Phase 1 must close before this starts.\n" }) — inserts a callout and a blank line above the Phase 2 heading.

When to use: Adding content at a precise location identified by a nearby line's text, without needing to know the heading structure. Good for inserting rows into tables, adding items into lists at a specific position, or placing content relative to a known landmark line. Prefer vault_patch_note for heading-targeted inserts (append/prepend to a section). Prefer vault_replace_span when replacing a block rather than inserting next to it.

Parameters:

  • An anchor matches a body line (any line below the properties block).

  • content is inserted verbatim — blank lines inside it are kept, and a trailing newline adds a blank line after the inserted block.

Behavior: A failed save leaves the note unchanged.

Errors:

  • "note not found" — verify path with vault_list_notes

  • "path must end in …" — add the .md extension

  • "anchor not found" — no body line holds the fragment; verify with vault_read_note

  • "ambiguous anchor …" — the anchor matches multiple lines; use a longer fragment or set first_match: true

  • "absolute path blocked" / "path traversal blocked" / "hidden path blocked" — pass a vault-relative path with no dot-prefixed part

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

  • "content contains a control character" — remove the character the message names

  • "ENAMETOOLONG: …" or another filesystem error — the message says what to do

  • "the note would open with a properties block …" — a note without properties would start with --- lines around text that can't be properties; the error says how to avoid it

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

Returns: Confirmation message "Inserted line(s) <before|after> anchor in " — N counts the lines in content as sent (its line breaks plus one).

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "path": "<path>",
      "anchor": "<anchor>",
      "position": "<position>",
      "content": "<content>"
    },
    "name": "vault_insert_at_anchor"
  }
}

Input Schema

NameRequiredDescriptionDefault
pathYesVault-relative path to the note, including the ".md" extension (e.g. "Notes/Plan.md", "Tracker.md"). Use the exact letter case.
anchorYesShort, unique substring of the body line to insert next to (case-sensitive).
contentYesContent to insert (one or more lines).
positionYes"before" inserts above the anchor line, "after" below it.
first_matchNoIf the anchor matches more than one line, use the first match instead of erroring (default: false — ambiguity is an error).

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changedv0.56.3
    • changedInput schema / properties / position / description
      Previous value: -"\"before\" inserts above the anchor line, \"after\" below it; the anchor line itself is never changed."New value: +"\"before\" inserts above the anchor line, \"after\" below it."
  2. Changed2 schema fields changedv0.55.4
    • changedInput schema / properties / anchor / description
      Previous value: -"Short, unique substring on the line to insert next to (case-sensitive). Pick a brief fragment — do not paste the whole line."New value: +"Short, unique substring of the body line to insert next to (case-sensitive)."
    • changedInput schema / properties / position / description
      Previous value: -"\"before\" places the content on the lines above the anchor line; \"after\" places it on the lines below. The anchor line itself is never changed."New value: +"\"before\" inserts above the anchor line, \"after\" below it; the anchor line itself is never changed."
  3. Changed1 schema field changedv0.54.16
    • addedInput schema / additionalProperties
      Added value: +false
  4. Changed1 schema field changedv0.54.9
    • changedInput schema / properties / content / description
      Previous value: -"Content to insert (one or more lines), inserted verbatim as whole lines — blank lines are kept, and a trailing newline adds a blank line after the block."New value: +"Content to insert (one or more lines)."
  5. Changed1 schema field changedv0.54.7
    • changedInput schema / properties / path / description
      Previous value: -"Vault-relative path to the note, including the \".md\" extension (e.g. \"Notes/Plan.md\", \"Tracker.md\")"New value: +"Vault-relative path to the note, including the \".md\" extension (e.g. \"Notes/Plan.md\", \"Tracker.md\"). Use the exact letter case."
  6. Changed1 schema field changedv0.50.0
    • addedInput schema / properties / first_match / default
      Added value: +false
  7. Addedv0.41.2

TDQS

A4.6/5.0
Behavior4/5

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

Beyond the annotations (non-read-only, non-idempotent, non-destructive), the description discloses real behavior: repeated calls re-insert content, failed saves leave the note unchanged, body breaks are normalized to LF, properties are preserved, and it gives retry guidance after a timeout. The only shortfall is that the 'ambiguous when content holds the anchor' path is stated tersely enough to be slightly confusing on first read.

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?

Front-loaded with the core action, then examples, then usage routing, then errors — a sensible order for scanning. It is long, and the error catalog plus two examples carry some redundancy with the first_match schema description, but nearly every sentence earns its place for a mutation tool with many failure modes.

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 five-parameter mutating tool with no output schema, the description covers semantics, verbatim/escaping behavior, Obsidian syntax pitfalls, failure atomicity, every error string with a remedy, and the exact return message format. An agent has everything needed to call and recover from it.

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, but the description adds meaning the schema does not: that an anchor must match a body line below the properties block, that content is inserted verbatim with interior blank lines preserved, and that a trailing newline adds a blank line after the block. The interaction between first_match and the ambiguity error is also clarified.

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 opening sentence gives a specific verb and resource (insert content as whole lines into a note's body) plus the exact targeting mechanism (a short anchor substring, before or after). It also explicitly separates itself from vault_patch_note (heading-targeted) and vault_replace_span (replacement), so an agent can route 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?

There is a dedicated 'When to use' block with concrete scenarios (table rows, list items, landmark lines), plus two explicit 'Prefer X' exclusions naming the alternative tool and the condition that selects it. Nothing about tool selection is left to inference.

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