vault-semantic-mcp

vault-semantic-mcp

A local semantic search MCP server for Markdown vaults that indexes and retrieves notes using hybrid keyword and embedding search.

Category
访问服务器

README

vault-semantic-mcp

A local semantic search MCP server for a Markdown vault. Intended as a sidecar for OpenClaw or other MCP-enabled agents.

What it does

  • Indexes markdown files under a vault root (inbox, projects, decisions, entities, memory, sessions, templates)
  • Chunks content by headings, with paragraph subdivision for large sections
  • Embeds chunks using OpenAI text-embedding-3-small (stored as JSON in SQLite for v1)
  • Search combines FTS5 keyword search with cosine-similarity semantic search and folder-based ranking
  • Related notes finds notes similar to a given path
  • File watcher keeps the index in sync as files change
  • MCP tools expose everything to agents over stdio

Important: The vault markdown files are the source of truth. The SQLite database is a derived search index only. If the DB is lost, it can be rebuilt with a full reindex.

Architecture

  • Vault root → scan .md files → parse frontmatter, chunk by headings
  • Chunks → OpenAI embeddings → stored in SQLite with FTS5 for full-text
  • Search → hybrid FTS + semantic → folder boost (memory/entities/decisions > projects/sessions > inbox)
  • MCP → stdio transport → tools call search/get/recent/related/reindex/status

Setup

  1. Requirements: Node.js 20+

  2. Install:

    npm install
    
  3. Configure: Copy .env.example to .env:

    cp .env.example .env
    

    Set OPENAI_API_KEY and adjust paths:

    • VAULT_ROOT – vault directory (default ./data/vault)
    • SQLITE_PATH – index DB (default ./data/index/vault.db)
  4. Run:

    npm run dev   # development with watch
    npm run build && npm start   # production
    

Environment variables

Variable Default Description
OPENAI_API_KEY (required) OpenAI API key for embeddings
VAULT_ROOT ./data/vault Root directory of the markdown vault
SQLITE_PATH ./data/index/vault.db Path to SQLite index database
EMBEDDING_MODEL text-embedding-3-small OpenAI embedding model
TOP_K_DEFAULT 8 Default number of search results

MCP usage

Configure your MCP client (e.g. OpenClaw) to run this server via stdio:

{
  "mcpServers": {
    "vault": {
      "command": "node",
      "args": ["/path/to/vault-semantic-mcp/dist/index.js"],
      "env": {
        "OPENAI_API_KEY": "...",
        "VAULT_ROOT": "/path/to/vault",
        "SQLITE_PATH": "/path/to/index/vault.db"
      }
    }
  }
}

Or with tsx for development:

{
  "mcpServers": {
    "vault": {
      "command": "npx",
      "args": ["tsx", "/path/to/vault-semantic-mcp/src/index.ts"],
      "env": { ... }
    }
  }
}

Tools

Tool Args Description
vault_search query, folders?, topK? Hybrid search over the vault
vault_get path Get full markdown for a file
vault_recent folder?, topK? Recently indexed documents
vault_related path, topK? Notes related to a given path
vault_reindex path? Reindex one path or whole vault
vault_status Vault root, counts, watcher state

Local validation (test harness)

Before wiring into OpenClaw, validate indexing and retrieval locally:

Seed vault

The repo includes sample notes in data/vault/ across projects, decisions, entities, memory, sessions, and inbox. Add or edit markdown files as needed.

Run test harness

# Reindex and run all evaluation queries (uses OPENAI_API_KEY)
npm run test:search

# Skip reindex, reuse existing index (faster for iterating on queries)
SKIP_REINDEX=1 npm run test:search

The harness runs the same hybridSearch used by vault_search, so results reflect real MCP behavior.

Evaluation queries

Query ID Purpose
exact_keyword_sqlite FTS exact term match
exact_keyword_chunking FTS on common term
semantic_memory_routing Semantic: "how should the agent store durable knowledge"
embedding_cost_strategy Semantic: "why OpenAI instead of local embeddings"
file_watcher_reindex Semantic: "what happens when vault files are edited"
related_notes_openclaw Semantic: "notes related to semantic search sidecar"
decision_log_architecture Semantic: "where did we decide vault files as source of truth"
fts_keyword_mcp FTS exact term

What to inspect

  • Exact matches (SQLite, MCP, chunking): FTS should surface those notes
  • Semantic matches: Different phrasing should find the right notes (e.g. "durable knowledge" → memory/durable-knowledge-storage)
  • Deduplication: At most one chunk per document in results
  • Folder ranking: memory/entities/decisions should rank higher than inbox for similar content
  • Snippets: Chunk text should be readable and relevant

Reindex only

npm run reindex
VERBOSE=1 npm run reindex   # log each file

Embeddings

  • v1 uses OpenAI text-embedding-3-small and stores vectors as JSON in SQLite.
  • No sqlite-vec or vector extensions. Future versions may add Ollama support.

License

MIT

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选