Skip to main content
Glama
MCP server for Obsidian

MCP server for Obsidian

Obsidian 的 MCP 服务器

MCP 服务器通过本地 REST API 社区插件与 Obsidian 交互。

成分

工具

服务器实现了多个工具来与 Obsidian 交互:

  • list_files_in_vault:列出 Obsidian 保险库根目录中的所有文件和目录

  • list_files_in_dir:列出特定 Obsidian 目录中的所有文件和目录

  • get_file_contents:返回保险库中单个文件的内容。

  • 搜索:在库中的所有文件中搜索与指定文本查询匹配的文档

  • patch_content:将内容插入到相对于标题、块引用或前置字段的现有注释中。

  • append_content:将内容附加到保险库中的新文件或现有文件。

  • delete_file:从您的保管库中删除文件或目录。

示例提示

最好先指示 Claude 使用 Obsidian。这样它就会一直调用该工具。

使用提示如下:

  • 获取上次架构通话记录的内容并进行总结

  • 搜索所有提及 Azure CosmosDb 的文件,并快速向我解释其提及的上下文

  • 总结上次会议的笔记,并将其添加到新笔记“summary meeting.md”中。添加简介,以便我可以通过电子邮件发送。

Related MCP server: mcp-obsidian-ek

配置

Obsidian REST API 密钥

有两种方法可以使用 Obsidian REST API Key 配置环境。

  1. 添加到服务器配置(首选)

{
  "mcp-obsidian": {
    "command": "uvx",
    "args": [
      "mcp-obsidian"
    ],
    "env": {
      "OBSIDIAN_API_KEY": "<your_api_key_here>",
      "OBSIDIAN_HOST": "<your_obsidian_host>"
    }
  }
}
  1. 在工作目录中创建一个.env文件,其中包含以下必需变量:

OBSIDIAN_API_KEY=your_api_key_here
OBSIDIAN_HOST=your_obsidian_host

注意:您可以在 Obsidian 插件配置中找到密钥。

快速入门

安装

Obsidian REST API

您需要运行 Obsidian REST API 社区插件: https://github.com/coddingtonbear/obsidian-local-rest-api

在设置中安装并启用它并复制 api 密钥。

克劳德桌面

在 MacOS 上: ~/Library/Application\ Support/Claude/claude_desktop_config.json

在 Windows 上: %APPDATA%/Claude/claude_desktop_config.json

{
  "mcpServers": {
    "mcp-obsidian": {
      "command": "uv",
      "args": [
        "--directory",
        "<dir_to>/mcp-obsidian",
        "run",
        "mcp-obsidian"
      ]
    }
  }
}
{
  "mcpServers": {
    "mcp-obsidian": {
      "command": "uvx",
      "args": [
        "mcp-obsidian"
      ],
      "env": {
        "OBSIDIAN_API_KEY" : "<YOUR_OBSIDIAN_API_KEY>"
      }
    }
  }
}

发展

建筑

准备分发包:

  1. 同步依赖项并更新锁文件:

uv sync

调试

由于 MCP 服务器通过 stdio 运行,调试起来可能比较困难。为了获得最佳调试体验,我们强烈建议使用MCP Inspector 。

您可以使用以下命令通过npm启动 MCP Inspector:

npx @modelcontextprotocol/inspector uv --directory /path/to/mcp-obsidian run mcp-obsidian

启动后,检查器将显示一个 URL,您可以在浏览器中访问该 URL 以开始调试。

您还可以使用以下命令查看服务器日志:

tail -n 20 -f ~/Library/Logs/Claude/mcp-server-mcp-obsidian.log

Available Tools

13 tools
obsidian_append_contentC

Append content to a new or existing file in the vault.

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

obsidian_batch_get_file_contentsA

Return the contents of multiple files in your vault, concatenated with headers.

Inputs: filepaths (required).

obsidian_delete_fileC

Delete a file or directory from the vault.

Inputs: filepath (required), confirm (required).

obsidian_get_file_contentsC

Return the content of a single file in your vault.

Inputs: filepath (required).

obsidian_get_periodic_noteB

Get current periodic note for the specified period.

Inputs: period (required), type.

obsidian_get_recent_changesB

Get recently modified files in the vault.

Inputs: limit, days.

obsidian_get_recent_periodic_notesC

Get most recent periodic notes for the specified period type.

Inputs: period (required), limit, include_content.

obsidian_list_files_in_dirA

Lists all files and directories that exist in a specific Obsidian directory.

Inputs: dirpath (required).

obsidian_list_files_in_vaultA

Lists all files and directories in the root directory of your Obsidian vault.

Inputs: no named parameters.

obsidian_patch_contentA

Insert content into an existing note relative to a heading, block reference, or frontmatter field.

Inputs: filepath (required), operation (required), target_type (required), target (required), +1 more.

obsidian_put_contentC

Create a new file in your vault or update the content of an existing one in your vault.

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

Tool Schema Changelog

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

Loading tool schema changelog…

    TDQS

    A3.6/5.0

    Scored across 13 tools

    Disambiguation4/5

    Most tools have distinct purposes targeting specific operations like reading, writing, searching, or listing files. However, obsidian_simple_search and obsidian_complex_search could cause confusion as both handle search functionality, though their descriptions clarify different use cases (simple text vs. complex JsonLogic queries).

    Naming Consistency5/5

    All tool names follow a consistent snake_case pattern with the 'obsidian_' prefix and descriptive verb_noun combinations (e.g., obsidian_get_file_contents, obsidian_list_files_in_dir). This uniformity makes the tool set predictable and easy to navigate.

    Tool Count5/5

    With 13 tools, the count is well-suited for an Obsidian vault management server. It covers a comprehensive range of operations without being overwhelming, including file CRUD, content manipulation, searching, and listing, which aligns with the domain's scope.

    Completeness5/5

    The tool set provides complete coverage for Obsidian vault operations, including CRUD (create/read/update/delete via tools like obsidian_put_content, obsidian_get_file_contents, obsidian_patch_content, obsidian_delete_file), searching (simple and complex), listing files, and handling periodic notes. No obvious gaps are present for typical agent workflows.

    Maintenance

    ActivityInactive
    ResponsivenessMostly unanswered

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      D
      maintenance
      MCP server providing tools to interact with Obsidian via the Local REST API community plugin.
      5
      MIT
    • A
      license
      Not graded
      quality
      D
      maintenance
      MCP server for interacting with Obsidian via the Local REST API, enabling file operations, search, and content editing in your vault.
      MIT