MM

markuspfundstein/mcp-obsidian

效率工作流

本页由 AI 翻译,技术细节请以原文为准。 查看原文

4513 stars 508 forks 质量 85 趋势 41MIT

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

概览

MCP 服务器通过本地 REST API 社区插件与 Obsidian 交互。 服务器实现了多种工具来与 Obsidian 交互: - list_files_in_vault:列出Obsidian vault根目录中的所有文件和目录- list_files_in_dir:列出特定Obsidian目录中的所有文件和目录- get_file_contents:返回vault中单个文件的内容。- 搜索:搜索vault中所有文件中匹配指定文本查询的文档- patch_content:将内容插入已有笔记中,相对于标题、块引用或前置字段。- append_content:将内容附加到vault中的新文件或现有文件。- delete_file:从vault中删除文件或目录。 最好先让Claude使用Obsidian。这样它就会一直调用工具。

概述(AI 翻译)

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

组成部分

工具

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

  • list_files_in_vault:列出你Obsidian vault根目录中的所有文件和目录
  • list_files_in_dir:列出特定 Obsidian 目录中的所有文件和目录
  • get_file_contents:返回保险库中单个文件的内容。
  • 搜索:在保险库中所有文件中搜索符合指定文本查询的文档
  • patch_content:将内容插入到已有笔记中,相对于标题、块引用或前置场。
  • append_content:将内容附加到保险库中的新文件或现有文件上。
  • delete_file:从你的保险库中删除一个文件或目录。

示例提示

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

使用提示如下:

  • 获取最后一个架构调用说明的内容并进行摘要
  • 搜索所有提到Azure CosmosDb的文件,并快速向我解释其被提及的上下文
  • 总结最近一次会议笔记,并将其放入新的笔记“摘要 meeting.md”中。

本页由 AI 翻译,技术细节请以原文为准。

README

以下为原文 README 节选,完整内容请查看原文。

MCP server for Obsidian

MCP server to interact with Obsidian via the Local REST API community plugin.

Components

Tools

The server implements multiple tools to interact with Obsidian:

  • list_files_in_vault: Lists all files and directories in the root directory of your Obsidian vault
  • list_files_in_dir: Lists all files and directories in a specific Obsidian directory
  • get_file_contents: Return the content of a single file in your vault.
  • search: Search for documents matching a specified text query across all files in the vault
  • patch_content: Insert content into an existing note relative to a heading, block reference, or frontmatter field.
  • append_content: Append content to a new or existing file in the vault.
  • delete_file: Delete a file or directory from your vault.

Example prompts

Its good to first instruct Claude to use Obsidian. Then it will always call the tool.

The use prompts like this:

  • Get the contents of the last architecture call note and summarize them
  • Search for all files where Azure CosmosDb is mentioned and quickly explain to me the context in which it is mentioned
  • Summarize the last meeting notes and put them into a new note ‘summary meeting.md’. Add an introduction so that I can send it via email.

Requirements

  • Python >= 3.11
  • mcp Python SDK >=1.1.0,=2.0 will crash at import with AttributeError: 'Server' object has no attribute 'list_tools'.

Configuration

Obsidian REST API Key

There are two ways to configure the environment with the Obsidian REST API Key.

  1. Add to server config (preferred)
{
  "mcp-obsidian": {
    "command": "uvx",
    "args": [
      "mcp-obsidian"
    ],
    "env": {
      "OBSIDIAN_API_KEY": "",
      "OBSIDIAN_HOST": "",
      "OBSIDIAN_PORT": ""
    }
  }
}

Sometimes Claude has issues detecting the location of uv / uvx. You can use which uvx to find and paste the full path in above config in such cases.

  1. Create a .env file in the working directory with the following required variables:
OBSIDIAN_API_KEY=your_api_key_here
OBSIDIAN_HOST=your_obsidian_host
OBSIDIAN_PORT=your_obsidian_port

Note:

  • You can find the API key in the Obsidian plugin config
  • Default port is 27124 if not specified
  • Default host is 127.0.0.1 if not specified

Quickstart

Install

Obsidian REST API

You need the Obsidian REST API community plugin running: https://github.com/coddingtonbear/obsidian-local-rest-api

在 GitHub 查看完整 README

安装

uvx mcp-obsidian
新手?先看 mcpskill.org 教程 →

配置

{ "mcpServers": { "mcp-obsidian": { "command": "uv", "args": [ "--directory", "<dir_to>/mcp-obsidian", "run", "mcp-obsidian" ], "env": { "OBSIDIAN_API_KEY": "<your_api_key_here>", "OBSIDIAN_HOST": "<your_obsidian_host>", "OBSIDIAN_PORT": "<your_obsidian_port>" } } } }