Skip to main content
Glama
obsidian-mcp

obsidian-mcp

by yanxue06

obsidian-mcp

为 Claude(及任何 MCP 客户端)提供对您的 Obsidian 库的真正代理访问权限——包括图谱遍历、Dataview 查询、每日笔记感知等功能。

npm version License: MIT MCP GitHub stars

安装 · 工具 · 尝试提示词 · 对比分析 · 常见问题


大多数 Obsidian MCP 服务器仅暴露 read_file 和 write_file 就草草了事。而本项目将您的库视为一个知识图谱——您的 LLM 可以通过单次调用获取反向链接、正向链接、Dataview 查询、每日笔记以及多跳图谱遍历。

为什么选择本项目

当您打开 Claude Desktop,要求它查找笔记中的关联时,它通常会通过 read_file 一次读取一个笔记。但这并不是 Obsidian 用户思考笔记的方式。图谱本身才是价值所在——反向链接、传递性连接、标签、Dataview 类型元数据。本服务器将所有这些都作为一等工具暴露出来。

Related MCP server: obsidian-mcp-server

安装

您需要在 Obsidian 中安装 Local REST API 插件。从社区插件中安装并启用它,然后从其设置中复制 API 密钥。

Claude Desktop

将其添加到 ~/Library/Application Support/Claude/claude_desktop_config.json (macOS) 或 %APPDATA%\Claude\claude_desktop_config.json (Windows):

{
  "mcpServers": {
    "obsidian": {
      "command": "npx",
      "args": ["-y", "obsidian-mcp"],
      "env": {
        "OBSIDIAN_API_KEY": "paste-your-key-here"
      }
    }
  }
}

重启 Claude Desktop。安装完成。

Claude Code

claude mcp add obsidian -e OBSIDIAN_API_KEY=paste-your-key-here -- npx -y obsidian-mcp

Cursor / Cline / Continue / Zed

任何兼容 MCP 的客户端均可使用。将其指向 npx -y obsidian-mcp 并在环境变量中设置 OBSIDIAN_API_KEY。

从源码安装

git clone https://github.com/yanxue06/obsidian-mcp.git
cd obsidian-mcp
npm install
npm run build
OBSIDIAN_API_KEY=... node dist/index.js

尝试提示词

在连接了服务器的 Claude Desktop 中尝试以下提示词:

为我所有关于分布式系统的笔记构建一个内容地图(MOC)。使用 traverse_graph 从 "Distributed systems.md" 开始,深度设为 2,然后按主题对邻居节点进行分组,并将 MOC 写入 MOCs/Distributed systems MOC.md。

查找所有标记为 #project 且 status != "done" 且截止日期在本周的笔记。使用 query_dataview。

我今天的每日笔记里写了什么?有没有什么我从昨天的笔记中忘记跟进的事项?

查找 Inbox/ 中所有孤立笔记。针对每一篇,根据其内容和现有标签建议它应该归类到哪里。

我要将 "Atomic notes.md" 重命名为 "Evergreen notes.md"。请找出所有链接到它的笔记,并告诉我哪些需要更新。

从 "Working memory.md" 开始遍历 2 跳,告诉我哪些笔记是我关于注意力思考的核心。

工具

共 15 个工具。差异化工具已加粗。

读取

工具

功能

get_note

笔记内容加上图谱上下文——反向链接、正向链接、标签、元数据——一次调用即可获取。

get_active_note

当前在 Obsidian 中聚焦的笔记。

get_daily_note

今天的每日/每周/每月/每季度/每年笔记。

list_vault

所有文件(或文件夹中的文件),默认仅限 Markdown 文件。

搜索与图谱

工具

功能

search_vault

全文或 #tag 搜索,带有片段预览。

query_dataview

运行 Dataview DQL 查询。需要安装 Dataview 插件。

traverse_graph

从笔记开始遍历 N 跳(向前、向后或双向)。返回节点 + 边。

find_orphans

没有入站链接的笔记——被遗忘的想法,清理的候选对象。

find_broken_links

无法解析的 Wiki 链接。在批量重命名之前运行此工具。

写入

工具

功能

create_note

新建笔记,支持可选的元数据和自动生成的 ## Related 部分(包含 [[wiki-links]])。

update_note

替换笔记的全部内容。

append_to_note

在笔记末尾追加 Markdown 内容。

append_to_daily_note

常见模式:代理记录其对今日每日笔记的操作。

patch_note

在特定标题、块或元数据字段下插入内容——无需重写其余部分。

delete_note

破坏性操作——仅在明确要求时使用。

对比分析

obsidian-mcp

其他 Obsidian MCP 服务器

Obsidian Copilot (插件)

一次调用获取反向链接

是

否

是

多跳图谱遍历

是

否

否

Dataview DQL 透传

是

否

部分

每日/周期性笔记

是

否

否

在标题/块下修补内容

是

否

否

查找孤立/损坏链接

是

否

否

适用于任何 MCP 客户端

是

是

否 (仅限 Obsidian)

需要安装 Obsidian 插件

仅 Local REST API

仅 Local REST API

是

配置

所有配置均通过环境变量完成——在您的 MCP 客户端配置中设置它们。

变量

必需

默认值

说明

OBSIDIAN_API_KEY

是

—

来自 Local REST API 插件设置。

OBSIDIAN_HOST

否

127.0.0.1

OBSIDIAN_PORT

否

27124 (https) / 27123 (http)

OBSIDIAN_PROTOCOL

否

https

插件默认使用带有自签名证书的 HTTPS。

OBSIDIAN_VERIFY_TLS

否

false

如果您已替换自签名证书,请设为 true。

OBSIDIAN_TIMEOUT_MS

否

15000

单次请求超时时间。

工作原理

┌──────────────┐     stdio (MCP)      ┌──────────────┐    HTTPS     ┌──────────────────┐
│ Claude / IDE │ ───────────────────► │ obsidian-mcp │ ───────────► │  Local REST API  │ ──► Vault
└──────────────┘                      └──────────────┘              │ (Obsidian plugin)│
                                                                    └──────────────────┘

obsidian-mcp 是 Local REST API 插件 的轻量级封装。该插件在 Obsidian 内部运行一个 HTTPS 服务器,提供对库的完全访问权限;本服务器将该接口适配为 MCP 协议,并添加了 Obsidian REST API 未直接暴露的图谱感知工具(反向链接、多跳遍历、孤立节点检测)。

一切都在本地运行。除了您的 MCP 客户端向其模型提供商发出的请求外,没有任何数据离开您的机器——且您可以控制这些请求。

常见问题

我需要安装 Obsidian 插件吗? 是的——需要 Local REST API 插件。这是从外部与运行中的库进行通信的唯一合理方式。安装后,obsidian-mcp 本身作为由您的 MCP 客户端启动的独立 Node 进程运行;您无需为此在 Obsidian 中安装其他插件。

如果 Obsidian 关闭了,它还能工作吗? 不能。Local REST API 在 Obsidian 内部运行,因此应用程序必须保持打开状态。

它支持多个库吗? 一个服务器实例指向一个正在运行的 Obsidian 实例。如果您经常切换库,请运行多个 MCP 服务器条目(不同的名称 + 不同的端口)。

为什么默认使用 OBSIDIAN_VERIFY_TLS=false 的 HTTPS? 该插件附带一个自签名证书。流量仅限于本地回环 (127.0.0.1),因此验证只会增加麻烦而没有实际的安全收益。如果您已替换证书,请设置该标志。

这安全吗? MCP 服务器赋予模型 API 密钥所授予的任何权限。模型愿意删除的任何内容,它都可以删除。请像对待任何具有文件写入权限的代理一样对待它——在执行批量操作之前,请务必审查它即将执行的操作。

路线图

  • [ ] 基于嵌入的语义搜索(目前通过插件仅支持关键词搜索)

  • [ ] 工作区切换 / 多库路由

  • [ ] 只读安全模式(不注册写入工具)

  • [ ] 资源订阅(笔记更改时推送更新)

  • [ ] Smithery / mcp-get 注册表提交

欢迎提交 PR。请参阅 CONTRIBUTING.md。

致谢

许可证

MIT — 详见 LICENSE。

Available Tools

25 tools
append_to_daily_noteAppend to daily noteB

Append markdown to the current daily (or weekly/etc.) note. Common pattern: agent logs what it just did at the end of the day.

Inputs: content (required), period.

append_to_noteAppend to a noteA

Append markdown to the end of an existing note. Creates the note if it doesn't exist.

Inputs: path (required), content (required).

create_noteCreate a noteA

Create a new note (fails if it already exists unless overwrite is true). Frontmatter is rendered as YAML. Use links to append a wiki-link section at the end. For creating many notes in one call, use create_notes. For idempotent create-or-update writes, use upsert_note.

Inputs: path (required), content, frontmatter, links, +1 more.

create_notesCreate multiple notes in one callA

Create many notes in a single tool call. Designed for bootstrapping a knowledge graph (MOC + topical notes) without paying N round-trips. Each entry follows the same schema as create_note. Per-note errors are reported individually; pass stop_on_error: true to abort on the first failure. Within a batch, later entries also fail if they target a path already created earlier in the same call.

Inputs: notes (required), stop_on_error.

delete_noteDelete a noteA

Delete a note from the vault. Destructive — only call when the user has explicitly asked to remove a file.

Inputs: path (required).

find_orphansFind orphan notesB

Find notes with no incoming links anywhere in the vault. Use to surface forgotten ideas or candidates for cleanup.

Inputs: folder, limit, sample_size.

get_active_noteGet currently open noteA

Return the note the user currently has focused in Obsidian. Useful for 'what am I looking at' style prompts.

Inputs: no named parameters.

get_daily_noteGet daily / periodic noteA

Fetch the user's current daily (or weekly/monthly/etc.) note. Returns content + frontmatter + tags. Requires the Periodic Notes or Daily Notes plugin in the vault.

Inputs: period.

get_noteGet note with graph contextA

Get a note's content plus its graph context: backlinks (who links to it), forward links (who it links to), tags, and frontmatter. Use the include array to control which context is fetched — backlinks are O(vault size) so omit them when unneeded.

Inputs: path (required), include, backlinks_limit.

get_outlineGet a note's heading outlineA

Return the heading structure of a note (level + text + line number). Use this instead of get_note when you only need to navigate to a section of a long note — it's much smaller in tokens.

Inputs: path (required).

get_vault_statsGet vault statisticsA

Get high-level stats about the vault: total notes, total words (sampled), top folders, file extensions. Useful for 'how big is my vault?' / 'where do I write the most?' prompts.

Inputs: sample_size, top_folders.

list_commandsList Obsidian commandsA

List every registered Obsidian command (built-in + plugin) with its id and human name. Use this before run_command to discover what's available — vaults differ based on installed plugins.

Inputs: filter, limit.

list_tagsList all tags in the vaultA

Return every tag used in the vault, with usage counts and a sample of notes per tag. Useful for 'what topics do I write about most?' or as a starting point for organizing.

Inputs: sample_size, min_count, sample_notes_per_tag.

list_vaultList vault filesB

List all files in the Obsidian vault. Use folder to scope to a subdirectory and markdown_only to filter to notes. Prefer this over guessing paths.

Inputs: folder, markdown_only, limit.

move_noteMove or rename a note (with backlink updates)A

Move a note from one path to another, optionally rewriting wiki-links so backlinks keep working. This is the safe way to rename notes — agents should not naively delete + create because that breaks the graph.

Inputs: from (required), to (required), update_backlinks, overwrite.

open_noteOpen a note in Obsidian's UIA

Surface a note in Obsidian's workspace (focuses an existing tab or opens a new one). Great for ending an agent task with 'and here's the result for you to review'.

Inputs: path (required), new_leaf.

patch_noteInsert content at a heading or blockA

Insert content relative to a heading, block reference, or frontmatter field — without rewriting the whole note. Example: append a bullet under '## Tasks' without touching the rest of the page.

Inputs: path (required), content (required), operation (required), target_type (required), +1 more.

query_dataviewRun a Dataview DQL queryA

Run a Dataview DQL query (LIST / TABLE / TASK) against the vault. Requires the Dataview plugin installed in the vault. Powerful for structured questions like 'all notes tagged #project where status != done sorted by due date'.

Inputs: dql (required).

run_commandRun an Obsidian commandA

Execute an Obsidian command by id (e.g. 'editor:toggle-bold', 'app:reload', 'graph:open'). Discover ids with list_commands. This is powerful — it lets the agent trigger any plugin action — so use only commands the user has approved.

Inputs: id (required).

search_vaultSearch the vaultA

Full-text search across all notes. Supports two modes: keyword (fast plain-text) and tag (find notes tagged with #X). For structured queries, use query_dataview.

Inputs: query (required), mode, context_length, limit.

traverse_graphTraverse the vault graphA

Walk the link graph starting from a note. Returns nodes (notes) and edges (links) up to depth hops away. Use direction=both for a neighborhood, forward for what a note depends on, backward for what depends on it. Cap with max_nodes on large vaults.

Inputs: start (required), depth, direction, max_nodes, +1 more.

update_noteReplace a note's contentA

Overwrite a note's full content. Prefer append_to_note or patch_note when only adding to a note — replacing wholesale is destructive.

Inputs: path (required), content (required).

upsert_noteCreate or update a noteA

Create a note if missing, replace it if it exists. Body is always fully replaced. Frontmatter is replaced by default; pass merge_frontmatter: true to keep existing frontmatter keys not specified in this call. Use this when you want an idempotent write — neither create_note (errors on existence) nor update_note (errors when missing) handle that on their own.

Inputs: path (required), content, frontmatter, links, +1 more.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.9/5.0

    Scored across 25 tools

    Disambiguation4/5

    Most tools target distinct actions, but there is slight overlap between get_note and get_backlinks (backlinks are also in get_note context) and between create_note, update_note, and upsert_note. However, clear descriptions mitigate confusion.

    Naming Consistency5/5

    All tool names follow a consistent snake_case pattern with verb_noun structure (e.g., append_to_note, find_broken_links, list_tags). No mixed conventions or vague verbs.

    Tool Count4/5

    25 tools is at the upper bound but justified for a comprehensive Obsidian MCP server covering notes, vault management, graph navigation, and plugin integration. Each tool earns its place.

    Completeness4/5

    Covers CRUD for notes, batch operations, vault statistics, search, graph analysis, and plugin commands. Minor gap: no dedicated tool to create a daily note (append assumes existing) or manage folders.

    Maintenance

    ActivityStale
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      A
      maintenance
      Standalone MCP server for Obsidian vaults - hybrid search (FTS5 + vector + reranking), files in agent-readable form (images, PDFs, canvases, HTML, scripts, data files), Kanban-aware tasks (Tasks-plugin + Dataview formats), structured memory with topic recall, fine-grained read/write tools, and link graph support. Run locally, self-host, or one-click deploy for remote access. OAuth 2.1.
      16
      35
      39
      MIT
    • A
      license
      Not graded
      quality
      D
      maintenance
      Connects Claude.ai to your local Obsidian vault for full CRUD access, search, and daily note creation via the Model Context Protocol.
      14
      MIT
    • F
      license
      D
      quality
      D
      maintenance
      Enables Claude Desktop to securely search and retrieve knowledge from an Obsidian vault through a stateless MCP interface, with progressive disclosure and gated write capabilities.
      13
      -