Skip to main content

Vault Retriever

PyPI Python License

Obsidian 知识库智能检索服务,为 AI 提供语义搜索和知识图谱分析能力。

特性

  • 混合检索:BM25 关键词 + 向量语义 + RRF 融合 + PageRank 加权
  • 轻量高效:mmap 索引加载,内存占用 ~300MB
  • 后台索引:启动不阻塞,增量更新
  • 零配置:开箱即用

安装

uv tool install vault-retriever --python 3.12

工具列表

工具 说明
vault_search 智能搜索笔记,融合关键词+语义+PageRank
vault_read 读取笔记完整内容
vault_list 列出笔记,支持目录过滤和最近修改筛选
vault_links 获取笔记的反向链接和出链关系
vault_tags 获取标签统计或按标签查找笔记
vault_related 查找语义相似的相关笔记

使用

Vault 路径配置

优先级:--vault 参数 > OBSIDIAN_VAULT_PATH 环境变量 > 当前目录

# 命令行参数
vault-retriever --vault /path/to/vault

# 环境变量
export OBSIDIAN_VAULT_PATH=/path/to/vault
vault-retriever

Claude Code 配置

命令行添加:

claude mcp add vault-retriever \
  -e OBSIDIAN_VAULT_PATH=/path/to/vault \
  -- vault-retriever

项目 .mcp.json(放在 vault 目录下):

{
  "mcpServers": {
    "vault-retriever": {
      "type": "stdio",
      "command": "vault-retriever",
      "env": {
        "OBSIDIAN_VAULT_PATH": "${PWD}"
      }
    }
  }
}

索引机制

  • 启动时后台初始化(不阻塞主线程)
  • BM25 索引使用 mmap 加载,内存高效
  • 向量索引使用 LanceDB 持久化
  • PageRank 图谱缓存到磁盘
  • 每 10 分钟检查文件变动,增量更新

配置

在 vault 目录下创建 .obsidian/vault-retriever.json:

{
  "embedding_model": "BAAI/bge-small-zh-v1.5",
  "index_interval": 600
}
  • embedding_model: 向量模型(默认 bge-small-zh-v1.5)
  • index_interval: 索引更新间隔秒数(默认 600)

开发

git clone https://github.com/chyax98/vault-retriever.git
cd vault-retriever
uv sync
uv run vault-retriever --vault /path/to/vault

License

MIT

Metadata

Release files for vault-retriever 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for vault-retriever 1.0.0
File Size Uploaded
vault_retriever-1.0.0.tar.gz 126.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for vault-retriever 1.0.0
File Interpreter ABI Platform
vault_retriever-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 144.1 kB

Release files / vault_retriever-1.0.0.tar.gz

Download URL vault_retriever-1.0.0.tar.gz
Size 126.6 kB
Tags Source
SHA-256 checksum
How to use checksums
abff3a108e1b0d3767353fe1f8509fbb5b7f26dfa481a6b31e9be9aa85c0fc27
BLAKE2b-256 checksum
How to use checksums
3eb1880af9868b892554860008a378cef22d001a7ebceb1a769d6d8bb39de886
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.9.13 {"installer":{"name":"uv","version":"0.9.13"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / vault_retriever-1.0.0-py3-none-any.whl

Download URL vault_retriever-1.0.0-py3-none-any.whl
Size 17.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
eb0647e983ff75b2537ffd4340b73a7f9083236836175c1c6dab9e07c9e9b9b5
BLAKE2b-256 checksum
How to use checksums
eea214719299d768ee50b0ad15de6113f3c77702c7678930dcc761258e35f1df
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.9.13 {"installer":{"name":"uv","version":"0.9.13"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page