Skip to main content
Glama
obsidian-mcp

obsidian-mcp

by Soleil1043

edit_note

Modify existing Obsidian notes with overwrite, append, or precise replace modes; replace needs a unique fragment and supports optional etag locking to prevent write conflicts.

Instructions

编辑 Obsidian vault 中已有笔记,三种模式:overwrite 整体覆盖、append 末尾追加、replace 把 old_string 精准替换为 content(字面替换,非正则)。replace 要求片段唯一,多处匹配时报错(可改传 replace_all=true);未找到时报错且文件不变。推荐先 read_note 拿到原文再 replace。

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>",
      "mode": "<mode>",
      "content": "<content>"
    },
    "name": "edit_note"
  }
}

Input Schema

NameRequiredDescriptionDefault
modeYesoverwrite=整体覆盖;append=在文末追加;replace=把 old_string 精准替换为 content
pathYes要编辑的笔记路径(vault 内 POSIX 风格相对路径,需以 .md 结尾)
contentYesoverwrite/append 模式:要写入的新内容;replace 模式:替换后的文本(可为空串实现删除片段)
if_matchNo乐观锁:传入上次 read_note 返回的 etag,与当前内容不符时拒绝写入(推荐多客户端场景使用)
old_stringNoreplace 模式必填:要被替换的原文片段;需在文中唯一,否则须传 replace_all=true
replace_allNoreplace 模式:替换全部匹配;默认 false(片段必须唯一才执行)

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A4.3/5.0
Behavior4/5

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

With no annotations supplied, the description carries the full burden, and it does disclose key behavior: replace is literal (not regex), requires a unique fragment, errors on multiple matches or a missing fragment, and leaves the file unchanged on error. It omits that overwrite irreversibly destroys prior content and says nothing about permissions or the etag/if_match concurrency guard, which the schema annotates.

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?

The content is dense and front-loaded, with the three modes listed before the replace caveats and the read_note recommendation last. It is slightly run-on with semicolon-chained clauses, but no sentence is wasted.

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 mutation tool with no annotations and no output schema, the description covers the modes, failure semantics, and recovery path well. The main gap is that it never mentions the optimistic-locking parameter, so an agent could edit a stale note without knowing the guard exists.

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 the baseline is 3; the description still earns more by explaining the interaction rules between old_string, replace_all, and error behavior, which the schema only states individually. It does not mention if_match at all, leaving that concurrency parameter to the schema alone.

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 names a specific verb (编辑) and resource (Obsidian vault 中已有笔记) and immediately enumerates the three modes, distinguishing itself from create_note/delete_note by restricting scope to existing notes.

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 states explicitly which mode to use for which outcome and recommends reading the note first with read_note before a replace, which is concrete routing guidance. It does not spell out when to prefer edit_note over create_note or when overwrite is unsafe, so the exclusion side is only implied.

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