Skip to main content
Glama
LIPiston

obsidian-rag-mcp

by LIPiston

obsidian-rag-mcp

一个基于 MCP (Model Context Protocol) 的 RAG 服务器:把 Obsidian 笔记库变成任何 AI 客户端(ZCode、Claude Desktop、Cursor、goose……)都可检索的知识库。

支持 MCP 的 AI 客户端会自动决定何时调用工具:先从你的 Obsidian 笔记中语义检索相关片段,再结合这些片段回答/分析——让你的笔记成为 AI 的「第二大脑」。

✨ 功能

  • 📁 读取 Obsidian vault:扫描 *.md 笔记,自动忽略 .obsidian.trash.git 等隐藏目录

  • 🧠 可配置 Embedding 模型:支持 OpenAI 兼容 API 与 Ollama 本地模型(也内置 fake 模式用于零依赖测试)

  • 🔍 语义检索:纯 Python 余弦相似度,无需重型向量数据库

  • 🧩 MCP 标准协议:stdio / SSE / streamable-http 三种传输,可接入任何 MCP 客户端

  • 🔧 7 个工具:索引、搜索、RAG 检索、列笔记、读笔记、查配置、查索引状态

Related MCP server: Obsidian MCP Server

🛠 工具一览

工具

说明

obsidian_index(force)

扫描 vault 并构建/重建 embedding 索引

obsidian_search(query, top_k)

语义搜索笔记片段

obsidian_rag(question, top_k)

检索与问题最相关的笔记上下文(供分析)

obsidian_list_notes(keyword)

列出 vault 中的笔记

obsidian_read_note(path)

读取单篇笔记全文(防路径穿越)

obsidian_get_config()

查看当前配置(不含 API Key)

obsidian_index_status()

检查索引是否存在且模型匹配

🚀 快速开始

1. 克隆并安装

git clone https://github.com/<your-org>/obsidian-rag-mcp.git
cd obsidian-rag-mcp
uv sync

2. 配置环境变量

在 MCP 客户端的服务器配置中设置(或在终端导出):

变量

必填

说明

默认值

OBSIDIAN_VAULT_PATH

Obsidian vault 的绝对路径

EMBEDDING_BASE_URL

Embedding API 地址(Ollama 用 http://localhost:11434

无地址且无 key 时为离线测试模式

EMBEDDING_MODEL

Embedding 模型名

text-embedding-3-small(OpenAI 兼容)

EMBEDDING_API_KEY

OpenAI 兼容时必填

API Key(Ollama 本地无需)

EMBEDDING_PROVIDER

手动覆盖后端识别

自动识别(openai / ollama / fake)

OBSIDIAN_INDEX_PATH

索引文件保存位置

~/.obsidian-rag/index.json

OBSIDIAN_CHUNK_SIZE

分块字符数

1500

OBSIDIAN_MAX_NOTES

最多索引的笔记数

1000

后端自动识别:只需配置地址 + 模型 + key,无需指定 provider。 地址含 Ollama 默认端口 11434 或以 /api 结尾 → 自动按 Ollama 调用; 其他地址 → 自动按 OpenAI 兼容 POST {base}/embeddings 调用。 自动识别不满足需求时,可用 EMBEDDING_PROVIDER=openai|ollama|fake 手动覆盖。

3. 在客户端中注册

启动命令统一为(任意客户端都一样):

uv run --directory D:/path/to/obsidian-rag-mcp obsidian-rag-mcp
{
  "mcp": {
    "servers": {
      "obsidian-rag": {
        "command": "uv",
        "args": ["run", "--directory", "D:/path/to/obsidian-rag-mcp", "obsidian-rag-mcp"],
        "env": {
          "OBSIDIAN_VAULT_PATH": "D:/path/to/your/vault",
          "EMBEDDING_BASE_URL": "https://api.openai.com/v1",
          "EMBEDDING_MODEL": "text-embedding-3-small",
          "EMBEDDING_API_KEY": "<你的 key>"
        }
      }
    }
  }
}

其他 MCP 客户端(VS Code、Claude Code、Windsurf……)的注册格式大同小异,都是 command + args + env 三段式,照抄上面的结构即可。

4. 使用

注册并重启会话后,AI 会自动决定何时调用工具。你可以直接说:

「用我的 Obsidian 笔记分析一下这个方案的可行性」「检索我笔记里关于网站改版的内容」

📂 项目结构

obsidian-rag-mcp/
├── obsidian_rag/
│   ├── server.py       # MCP 服务器与工具定义
│   ├── config.py       # 环境变量配置
│   ├── embeddings.py   # OpenAI/Ollama/fake embedding 客户端
│   ├── vault.py        # vault 扫描与 markdown 分块
│   └── store.py        # 向量存储与余弦相似度检索
├── recipes/
│   └── obsidian-rag.yaml   # goose 专用 slash command recipe(可选)
├── examples/sample-vault/  # 示例笔记库
└── tests/

📄 License

MIT

Available Tools

7 tools
obsidian_get_configA

Show the current configuration (vault path, embedding provider/model).

The API key is never returned.

ParametersJSON Schema
NameRequiredDescriptionDefault

No parameters

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

A4.5/5.0
Behavior4/5

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

With no annotations provided, the description carries the burden of behavioral disclosure. It adds a valuable privacy guarantee ('The API key is never returned') and implies read-only behavior through 'Show.' This goes beyond a bare getter description; only minor extras like side-effect confirmation are absent.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Two brief sentences, no filler. The primary purpose and contents are front-loaded, and the important security note about the API key is included as a separate concise sentence. Every word earns its place.

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?

This is a simple zero-parameter getter with an output schema present. The description names the key fields returned and adds the critical API-key caveat. Nothing needed to invoke it correctly is missing.

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?

The tool has zero parameters, so the baseline is 4. The description adds useful semantic clarity by naming the specific configuration fields returned (vault path, embedding provider/model), helping the agent interpret the output even without parameter details.

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 uses the specific verb 'Show' with a clear resource ('current configuration') and names concrete contents ('vault path, embedding provider/model'). This clearly distinguishes it from sibling tools focused on indexing, searching, and note operations.

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?

The purpose is so specific that when an agent needs configuration details, this is the obvious tool among the listed siblings. It doesn't explicitly name alternatives or exclusions, but no sibling overlaps with config retrieval, so no additional routing is needed.

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

obsidian_indexA

Scan the vault and build/refresh the embedding index.

Args: force: rebuild the index even if one already exists.

ParametersJSON Schema
NameRequiredDescriptionDefault
forceNo

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

A3.8/5.0
Behavior3/5

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

With no annotations, the description carries the full behavioral burden. It does disclose that it scans the whole vault, builds/refreshes the index, and that force rebuilds even if the index exists. However, it does not mention cost/latency of a full vault scan, whether an existing index is replaced or preserved, or side effects beyond indexing.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is compact and front-loaded with the main purpose. The Args section is clearly separated and every sentence/line contributes meaningful information without redundancy.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a simple one-parameter tool, the description covers the core action and parameter. Since an output schema is present, not describing return values is acceptable. However, it is not complete enough because it omits when to choose this over index_status and does not warn about the potentially expensive vault-wide scan. It is viable but has clear gaps.

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?

The schema provides only a boolean default false with no parameter description, so the description must compensate. It does so fully: the 'force' argument is explained as 'rebuild the index even if one already exists,' which adds real semantics beyond 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 description opens with a specific, actionable verb and object: 'Scan the vault and build/refresh the embedding index.' This clearly identifies what the tool does and distinguishes it from siblings like obsidian_index_status (checking status vs building) and obsidian_search/obsidian_rag (querying vs indexing).

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

There is no guidance on when to invoke this tool versus alternatives. It does not mention checking obsidian_index_status first, nor does it say when a refresh is needed or when a rebuild with force is appropriate. The only implied context is that the tool is for building an index, but no exclusions or alternative routing are provided.

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

obsidian_index_statusA

Report whether an index exists and matches the configured embedding model.

ParametersJSON Schema
NameRequiredDescriptionDefault

No parameters

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

A4/5.0
Behavior3/5

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

With no annotations, the description must carry the behavioral burden. It communicates a non-mutating status/report action and names the exact condition evaluated, but it does not disclose edge behavior (e.g., error vs false when index is missing) or explicitly confirm it will not create the index. That is adequate but not rich.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

A single sentence that front-loads the verb and delivers the key facts with no filler, redundancy, or irrelevant detail.

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 zero-parameter status tool with an output schema, the description states the core purpose sufficiently. It is slightly short of complete because it does not explicitly mention side-effects or preconditions, but complexity is low and the output schema can carry return-value details.

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?

The tool has zero parameters and 100% schema coverage, so there is nothing for the description to add. The zero-parameter baseline is 4; the description correctly avoids inventing parameter details.

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 uses a specific verb ('Report') and a clear resource ('index'), and specifies the exact condition being checked (exists and matches the configured embedding model). This clearly differentiates it from siblings like obsidian_index (creation) and obsidian_search (querying).

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

There is no explicit when-to-use or when-not-to-use statement, nor any named alternative. However, the status-report phrasing and sibling list (obsidian_index, obsidian_search, obsidian_rag) imply it is a readiness check before search/RAG operations, which gives the agent some guidance by inference.

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

obsidian_list_notesA

List the markdown notes in the vault.

Args: keyword: optional filter; only notes whose path contains this string are returned.

ParametersJSON Schema
NameRequiredDescriptionDefault
keywordNo

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

A3.5/5.0
Behavior3/5

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

With no annotations, the description carries the full burden of behavioral disclosure. It explains that the keyword filters by path substring, which adds useful behavioral detail. However, it does not mention what the output contains (beyond the existence of an output schema) or whether it includes notes in subfolders, though for a simple listing tool this is a minor gap.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is extremely concise, with a clear front-loaded purpose statement followed by a single parameter explanation. Every sentence earns its place and there is no redundant information.

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 simple, single-parameter listing tool with an output schema, the description covers the essential behavior and parameter semantics. It could be improved by explicitly saying 'use this to enumerate all vault notes' or distinguishing from content search, but nothing critical is missing for making a correct call.

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?

The schema only says keyword is a nullable string with default null; it provides no description. The description adds real semantic value: keyword is an optional filter and matches 'notes whose path contains this string.' This is exactly the meaning an agent needs to invoke the tool correctly.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description states a clear verb ('List') and resource ('markdown notes in the vault'), making the tool's primary function obvious. It does not explicitly distinguish itself from siblings like obsidian_search or obsidian_read_note, but the verb and resource are sufficiently specific to infer the difference.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

There is no guidance on when to use this tool versus alternatives such as obsidian_search (for content search) or obsidian_read_note (for reading a single note). The optional keyword filter is described, but no context is given about when listing notes is the right choice.

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

obsidian_ragA

Retrieve the most relevant Obsidian notes for question and return them as context.

Use this to analyze a user's message against what is stored in the vault: search first, then reason over the returned context.

Args: question: the user's question / content to analyze. top_k: number of context chunks to retrieve (1-20).

ParametersJSON Schema
NameRequiredDescriptionDefault
top_kNo
questionYes

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

A3.6/5.0
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It explains that the tool returns context chunks, but it does not state whether the tool is read-only, whether an index must already exist, what happens when no relevant notes are found, or whether external services are invoked. This is a significant gap for a tool with no annotation support.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is compact, well-organized, and front-loaded. The purpose sentence is immediately clear, the usage guidance is brief, and the Args section is direct. No sentence is wasted.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

An output schema exists, so return-value documentation is less critical. The two parameters are well covered. However, the description omits behavioral context such as indexing prerequisites and does not clarify how this tool relates to sibling tools like `obsidian_search` or `obsidian_index_status`, leaving some ambiguity.

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 description coverage is 0%, so the description must compensate. It does: `question` is explained as 'the user's question / content to analyze,' and `top_k` is clarified as 'number of context chunks to retrieve (1-20).' This adds real meaning beyond the schema's type and default fields.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description states a specific action and resource: 'Retrieve the most relevant Obsidian notes for `question` and return them as context.' This clearly identifies what the tool does. It does not explicitly distinguish itself from the sibling `obsidian_search` tool, so it falls just short of a 5.

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?

The description provides a concrete intended use: 'Use this to analyze a user's message against what is stored in the vault: search first, then reason over the returned context.' This tells an agent when to reach for this tool, though it does not mention when not to use it or name alternatives explicitly.

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

obsidian_read_noteA

Read the full text of a note from the vault.

Args: path: vault-relative markdown path, e.g. "Projects/MyProject.md".

ParametersJSON Schema
NameRequiredDescriptionDefault
pathYes

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

A3.9/5.0
Behavior3/5

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

With no annotations provided, the description must carry the behavioral burden. It does clearly convey that this is a read operation returning the full text of a note, implying no side effects. However, it does not disclose behavior for missing paths, non-markdown files, encoding, or other edge cases that could affect an agent's expectations.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is extremely concise and front-loaded. The first sentence states the action clearly, and the Args section adds the only necessary parameter detail without any filler or repetition of the schema.

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 single-parameter read tool with an output schema, the description is nearly complete: it explains what the tool does, what the path means, and provides an example. It is only missing brief mention of edge cases such as nonexistent paths or how it relates to sibling tools, but these are not critical for basic invocation.

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?

The input schema only defines 'path' as a string with no description (0% schema coverage). The description fully compensates by explaining that the path is vault-relative, should be a markdown path, and provides a concrete example: 'Projects/MyProject.md'. This gives the agent exactly what it needs to construct a correct argument.

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 clearly states the operation with a specific verb and resource: 'Read the full text of a note from the vault.' The phrase 'full text' helps distinguish this from sibling tools that index, search, or list notes, even though those siblings are not explicitly named.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description gives no guidance about when to use this tool versus alternatives such as obsidian_search, obsidian_list_notes, or obsidian_index. It does not mention exclusions, prerequisites, or a decision process, leaving the agent to infer the appropriate context from the tool name alone.

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

TDQS

A3.6/5.0
Disambiguation2/5

obsidian_search and obsidian_rag are heavily overlapping: both take a query/question and top_k to retrieve relevant vault content, with only a subtle framing difference. The other tools are distinct, but these two create real ambiguity for an agent.

Naming Consistency3/5

Most tools follow an obsidian_verb pattern (obsidian_search, obsidian_list_notes, obsidian_read_note, obsidian_get_config), but obsidian_rag and obsidian_index_status break the convention with an acronym and a noun phrase. The shared prefix helps, but the pattern is inconsistent.

Tool Count5/5

Seven tools is well-scoped for an Obsidian RAG server covering indexing, semantic retrieval, note listing/reading, status, and configuration. Each tool occupies a reasonable place in the workflow without obvious bloat.

Completeness4/5

The core RAG lifecycle is covered: build/refresh index, search and retrieve context, list/read notes, check index status, and view config. Minor omissions like an explicit index deletion or note write operations are outside the apparent read-only RAG scope.

Maintenance

ActivityMaintained
ResponsivenessSyncing

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Connectors

Related MCP Servers

  • F
    license
    Not graded
    quality
    D
    maintenance
    Provides semantic search capability over Obsidian vaults and exposes recent notes as resources to Claude through the MCP protocol.
    9
  • A
    license
    Not graded
    quality
    A
    maintenance
    Connects AI assistants to an Obsidian vault as a semantic knowledge graph, enabling graph navigation, semantic search, and content operations through MCP.
    18
    456
    MIT
  • A
    license
    Not graded
    quality
    C
    maintenance
    Exposes an Obsidian notes vault as MCP services, enabling AI assistants to search, read, create, update, and delete notes and folders.
    22
    1
    MIT

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/LIPiston/obsidian-rag-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server