Skip to main content
Glama
Vault Cortex Obsidian MCP Server

Vault Cortex Obsidian MCP Server

Delete Span

vault_delete_span
Destructive

Delete a contiguous block of whole lines from a note by short anchor substrings, so table rows, callouts, or list runs can be removed without reproducing exact text.

Instructions

Delete a contiguous block of whole lines from a note's body by referencing short anchor substrings instead of reproducing the full block text. Properties are kept as written, and body line breaks are saved as LF. With first_match: true, a repeated call deletes the next match, so after a timeout or lost response, re-read the note before retrying.

Example: vault_delete_span({ path: "Tracker.md", start_anchor: "| 2024-03-02 | Acme" }) — deletes the one table row whose line contains that fragment. Example: vault_delete_span({ path: "Notes/Plan.md", start_anchor: "> [!warning] Stale", end_anchor: "remove after launch" }) — deletes from the start anchor line through the end anchor line.

When to use: Removing a block you have already read — a table row, callout, or run of list items — where reproducing it exactly as old_text would be error-prone. Prefer vault_replace_in_note for small in-place edits. To replace a block, use vault_replace_span (one atomic step).

Parameters:

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

  • end_anchor is searched at or after the start line and must be unique among those lines. If start_anchor and end_anchor match the same line, only that one line is deleted.

  • A span that includes a code block's opening fence can't end at a plain closing fence (```): the end anchor is ambiguous, and first_match: true would end the span at the opening fence; to remove such a block, use vault_replace_in_note with new_text: "".

Behavior:

  • Where the removed lines stood, blank lines never double: the text above and below ends up separated by the wider of the two runs of empty lines that stood there. So removing a table row leaves the table whole.

  • At the note's end, where no text follows, the run of empty lines above is kept one line shorter ("A\n\nB\n" without "B" → "A\n").

  • A line holding only spaces or tabs counts as text, not as an empty line.

Errors:

  • "note not found" — verify path with vault_list_notes

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

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

  • "ambiguous start anchor …" / "ambiguous end 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

  • "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

Returns: 'Deleted line(s) from : ""' — the removed lines joined by line breaks, cut at 80 characters with "…".

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>",
      "start_anchor": "<start_anchor>"
    },
    "name": "vault_delete_span"
  }
}

Input Schema

NameRequiredDescriptionDefault
pathYesVault-relative path to the note, including the ".md" extension (e.g. "Tracker.md", "Notes/Plan.md"). Use the exact letter case.
end_anchorNoShort substring of the block's LAST line, a body line (case-sensitive). Omit to delete just the single line containing start_anchor.
first_matchNoIf an anchor matches more than one line, delete using the first match instead of erroring (default: false — ambiguity is an error).
start_anchorYesShort, unique substring of the block's first line, a body line (case-sensitive).

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed2 schema fields changedv0.55.4
    • changedInput schema / properties / end_anchor / description
      Previous value: -"Short substring that identifies the LAST line of the block (case-sensitive). Omit to delete just the single line containing start_anchor."New value: +"Short substring of the block's LAST line, a body line (case-sensitive). Omit to delete just the single line containing start_anchor."
    • changedInput schema / properties / start_anchor / description
      Previous value: -"Short, unique substring that identifies the first line of the block (case-sensitive). Pick a brief fragment — do not paste the whole block."New value: +"Short, unique substring of the block's first line, a body line (case-sensitive)."
  2. Changed3 schema fields changedv0.54.16
    • addedInput schema / additionalProperties
      Added value: +false
    • changedInput schema / properties / end_anchor / description
      Previous value: -"Short substring that identifies the LAST line of the block. The entire line is selected. Omit to delete just the single line containing start_anchor."New value: +"Short substring that identifies the LAST line of the block (case-sensitive). Omit to delete just the single line containing start_anchor."
    • changedInput schema / properties / start_anchor / description
      Previous value: -"Short, unique substring that identifies the first line of the block (case-sensitive). The entire line is selected, not just the substring. Pick a brief fragment — do not paste the whole block."New value: +"Short, unique substring that identifies the first line of the block (case-sensitive). Pick a brief fragment — do not paste the whole block."
  3. Changed1 schema field changedv0.54.9
    • changedInput schema / properties / end_anchor / description
      Previous value: -"Short, unique substring that identifies the LAST line of the block, searched at or after the start_anchor line. The entire line is selected. Omit to delete just the single line containing start_anchor."New value: +"Short substring that identifies the LAST line of the block. The entire line is selected. Omit to delete just the single line containing start_anchor."
  4. 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. \"Tracker.md\", \"Notes/Plan.md\")"New value: +"Vault-relative path to the note, including the \".md\" extension (e.g. \"Tracker.md\", \"Notes/Plan.md\"). Use the exact letter case."
  5. Changed1 schema field changedv0.50.0
    • addedInput schema / properties / first_match / default
      Added value: +false
  6. Changed2 schema fields changedv0.41.2
    • changedInput schema / properties / end_anchor / description
      Previous value: -"Short, unique substring on the LAST line of the block, searched at or after the start_anchor line. Omit to delete just the single line containing start_anchor."New value: +"Short, unique substring that identifies the LAST line of the block, searched at or after the start_anchor line. The entire line is selected. Omit to delete just the single line containing start_anchor."
    • changedInput schema / properties / start_anchor / description
      Previous value: -"Short, unique substring on the first line of the block to delete (case-sensitive). Pick a brief fragment — do not paste the whole block."New value: +"Short, unique substring that identifies the first line of the block (case-sensitive). The entire line is selected, not just the substring. Pick a brief fragment — do not paste the whole block."
  7. Addedv0.32.1
  8. Removedv0.32.0
  9. Changed1 schema field changedv0.23.10
    • changedInput schema / properties / path / description
      Previous value: -"Vault-relative path to the note (e.g. \"Tracker.md\", \"Notes/Plan.md\")"New value: +"Vault-relative path to the note, including the \".md\" extension (e.g. \"Tracker.md\", \"Notes/Plan.md\")"
  10. Changed1 schema field changedv0.23.5
    • changedInput schema / properties / path / description
      Previous value: -"Vault-relative path to the note"New value: +"Vault-relative path to the note (e.g. \"Tracker.md\", \"Notes/Plan.md\")"
  11. Addedv0.21.0

TDQS

A4.9/5.0
Behavior5/5

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

Annotations already declare destructive=true, idempotent=false, readOnly=false, but the description goes well beyond them: blank-line normalization at the splice point, the special case at the note's end where the trailing blank run shrinks by one, whitespace-only lines counting as text, LF preservation, properties left untouched, and a full error catalog with recovery steps. The non-idempotency warning under first_match is exactly the kind of context annotations cannot convey.

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?

Purpose and the risky retry caveat are front-loaded, and the sectioned layout (examples, when-to-use, parameters, behavior, errors, returns) makes it skimmable. It is nonetheless long: ten error entries plus two worked examples include some material an agent will rarely need, so it is thorough rather than tight.

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, non-idempotent mutation with no output schema, the definition still documents the return string format, truncation at 80 characters, and every foreseeable failure mode with a next action. Nothing an agent needs to call it safely or recover from failure is missing.

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 already 100%, yet the description still adds real meaning: anchors match body lines only (below the properties block), end_anchor is searched at or after the start line and must be unique among those lines, same-line anchors delete one line, and a span including a code fence's opening cannot close on a plain fence. The first_match retry hazard (a repeated call deletes the next match) is a semantic detail absent from 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 first sentence states a specific verb (Delete), a specific resource (a contiguous block of whole lines from a note's body), and the distinguishing mechanism (anchor substrings instead of full old_text). Sibling tool names (vault_replace_span, vault_replace_in_note) appear immediately after, so an agent can route without opening schemas.

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 an explicit 'When to use' section naming the scenario (removing a block you already read where reproducing old_text is error-prone) plus two named alternatives with their selecting conditions: vault_replace_in_note for small in-place edits and vault_replace_span for atomic block replacement. Nothing 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.