Hive Vault MCP Server
io.github.mlorentedev/hive-vault
On-demand Obsidian vault access for AI assistants — persistent knowledge without loading everything upfront.
What is the Hive Vault MCP server?
The Hive Vault MCP server connects your AI coding assistant to an Obsidian vault, enabling persistent knowledge retrieval across sessions without loading entire vaults upfront. It provides on-demand querying of project context, tasks, lessons, and files with full-text search, git integration, and optional worker delegation to cheaper models.
Hive solves the problem of AI assistants forgetting context between sessions by giving them direct access to your Obsidian vault. Instead of loading static context upfront (consuming tokens and context), it queries only what's needed on demand. This reduces token cost by ~94% per query while retaining 100% of your knowledge in the vault. It includes tools for reading, writing, searching, and reinforcing lessons learned, plus optional integration with Ollama or OpenRouter for delegating tasks to cheaper models.
How to install Hive Vault
Copy-paste configuration for popular MCP clients.
VAULT_PATHAbsolute path to your Obsidian vault (or any Markdown directory)
HIVE_OLLAMA_ENDPOINTOllama API endpoint for local worker delegation
OPENROUTER_API_KEYsecretOpenRouter API key for cloud worker delegation
HIVE_VAULT_SCOPESJSON mapping of scope names to vault subdirectories
Tools & capabilities
Tools this server exposes to the agent.
vault_query— Load project context, tasks, roadmap, lessons, or any file by pathvault_search— Full-text search with metadata filters, regex, ranked results, recent changes, and lesson-usage rankingvault_list— Browse projects and files with glob filteringvault_health— Server identity, health metrics, drift detection, usage stats, and optional runtime blockvault_write— Create, append, or replace vault files with optional deferred git commitvault_patch— Surgical find-and-replace with optional deferred git commitvault_commit— Flush pending writes into one git commitcapture_lesson— Capture lessons inline, batch-extract from text, or look up existing lessons by keywordsession_briefing— Retrieve tasks, lessons, git log, and health in one calldelegate_task— Route tasks to cheaper models or summarize vault filesworker_status— Check budget, connectivity, and available models for delegation
Use cases
- Maintain persistent project context and lessons across multiple AI coding sessions without reloading entire vaults
- Search and retrieve specific knowledge from your vault on demand to reduce token usage and context window pressure
- Capture and reinforce lessons learned during coding sessions, with confidence scoring based on usage patterns
- Delegate expensive summarization or coding tasks to cheaper models (Ollama or OpenRouter) while keeping your main assistant focused
- Organize and query project-specific documentation, roadmaps, and task lists directly from your Obsidian vault
Hive Vault MCP server FAQ
Hive Vault is an MCP server that connects your AI assistant to an Obsidian vault, enabling on-demand knowledge retrieval across sessions. Instead of loading everything upfront, it queries only what's needed, reducing token cost by ~94% per query while retaining 100% of your knowledge.
Yes, Hive Vault is open-source (MIT license) and free to use. Optional features like Ollama (free local models) or OpenRouter (paid, with a $1/month cap) are available for task delegation but not required.
Install via: `claude mcp add -s user hive -- uvx --upgrade hive-vault` (Claude), or follow the Getting Started guide at mlorentedev.github.io/hive for Cursor, Codex CLI, GitHub Copilot, and other clients. Set `VAULT_PATH` to point to your Obsidian vault directory.
Python 3.12+ is required. A git-initialized vault directory is recommended for commit tracking. Obsidian desktop app and obsidian-git plugin are optional but recommended for authoring and auto-commit. Ollama or OpenRouter API key are optional for task delegation.
No authentication is required for basic vault operations. Optional OpenRouter API key (`OPENROUTER_API_KEY`) enables paid task delegation; Ollama is free and local. Daemon mode uses a bearer token for local security but no external auth.
Yes, Hive runs without a vault — vault tools return a friendly error until `VAULT_PATH` is set, so you can install first and configure later.
README (reference)
Source of truth, from the repository.
hive-vault
<a href="https://glama.ai/mcp/servers/mlorentedev/hive"> <img width="380" height="200" src="https://glama.ai/mcp/servers/mlorentedev/hive/badge" /> </a> <!-- mcp-name: io.github.mlorentedev/hive-vault -->Your AI coding assistant forgets everything between sessions. Hive fixes that.
Hive is an MCP server that connects your AI assistant to an Obsidian vault. Instead of loading everything upfront, it queries only what's needed — on demand.
| Metric | Without Hive | With Hive |
|---|---|---|
| Context loaded per session | ~800 lines (static) | ~50 lines (on demand) |
| Token cost for context | 100% every session | 6% average per query |
| Knowledge retained between sessions | 0% | 100% (in vault) |
Measured on a real vault with 19 projects, 200+ files. See benchmarks.
Quick Start
Hive runs without a vault — vault tools return a friendly error until VAULT_PATH is set, so you can install first and configure later.
# Minimal — uses default vault path ~/Projects/knowledge
claude mcp add -s user hive -- uvx --upgrade hive-vault
# With a custom vault path
claude mcp add -s user hive -e VAULT_PATH=$HOME/path/to/vault -- uvx --upgrade hive-vault
# Gemini CLI
gemini mcp add -s user -e VAULT_PATH=$HOME/path/to/vault hive-vault uvx -- --upgrade hive-vault
Default vault path:
~/Projects/knowledge. Override withVAULT_PATH(orHIVE_VAULT_PATH) as shown above.
For Codex CLI, GitHub Copilot, Cursor, Windsurf, and other clients, see Getting Started.
Then ask your assistant: "Use vault_list to see my vault"
Requirements
Hive degrades gracefully — every recommended or optional dependency reveals more capability without breaking the baseline.
-
Required
- Python 3.12+ (works on 3.13).
- A directory of markdown files. The vault structure used by
00_meta/10_projects/50_work/80_agentsis optional — without it, vault tools still operate but the scope routing is flat.
-
Recommended
gitinitialised inside the vault. Without it,vault_write/vault_patchstill write to disk; they just skip the per-write commit (andvault_commitreports the working tree as untracked).- The Obsidian desktop app to author the vault by hand.
- The obsidian-git plugin with auto-commit set to 5–10 minutes. Pair it with
vault_write(commit=False)/vault_patch(commit=False)to push the git workload off the synchronous tool path; see Recommended configuration below.
-
Optional
- Ollama running
qwen2.5-coder:7b(or compatible) for local, freedelegate_task/capture_lessonworker calls. - An OpenRouter API key (
OPENROUTER_API_KEY) as a free-tier and paid fallback worker. - A backup git remote (e.g. private GitHub repo) so vault history survives a disk loss.
- Ollama running
Recommended configuration
Per ADR-006 (commit policy), the recommended pairing for write-heavy flows is:
- Install and enable the obsidian-git plugin in your vault.
- Set its auto-commit interval to 5 or 10 minutes.
- Call
vault_write(..., commit=False)andvault_patch(..., commit=False)for all bulk operations. - Optionally call
vault_commit(message="...")at the end of a session to force a checkpoint sooner than the obsidian-git tick.
vault_health reports a ## external_committer block when it detects obsidian-git in the vault. The commit=False durability contract is explicit: files are persisted to disk regardless; only the commit is deferred. A crash before the next flush loses the commit, not the content.
When a tool call is cancelled mid-flight (slow worker, client timeout), the server may have already mutated the disk before the cancel ack reaches the wire. vault_health surfaces a ## ghost_responses counter and emits a mcp.ghost_response.suppressed_after_cancel_ack WARNING for each event — verify state via vault_query rather than retrying, since the ErrorData ack does not imply rollback (ADR-007).
Daemon mode (optional)
The default uvx hive-vault runs a fresh server per session. Daemon mode
instead runs one long-lived hive serve that owns the vault, with each
stdio-only session connecting through hive client. The adapter starts without
importing the Hive server or FastMCP, then relays JSON-RPC to the daemon's stable
loopback endpoint. If the daemon or credential is unavailable, it fails
explicitly rather than starting a competing in-process owner.
The default endpoint is a deterministic per-user port in 49152..65535, so an
ordinary daemon restart does not invalidate client configuration. Override it
with HIVE_DAEMON_PORT in both the daemon and every client environment when
the derived port conflicts with another local service. hive serve --port
changes only the daemon's bind port; it does not reconfigure hive client or
hive delegate. Hive fails closed rather than silently moving to a different
port. The owner-only bearer token persists across ordinary restarts in the daemon state
directory. daemon.port remains diagnostic migration metadata, not client
discovery state. See ADR-022.
uv tool install --upgrade hive-vault # >= 1.32.0
hive service install # supervise hive serve (systemd --user / Task Scheduler)
HTTP-capable clients should connect directly to
http://127.0.0.1:<derived-or-overridden-port>/mcp; stdio-only clients should
run hive client. Never print or copy the token into logs or shell history.
To install a newer release, use the platform-specific command:
# Linux / macOS
uv tool upgrade hive-vault
# Windows (the version is optional; omitted selects the latest PyPI release)
hive self-upgrade [version]
On Windows, self-upgrade builds the release beside the running files and atomically switches
the managed runtime, avoiding in-use-file conflicts. Open a new terminal after the first managed
upgrade so its PATH change is available. Once supervised, the daemon detects the new installed
version, exits 75, and the supervisor restarts it into the new code. See the
daemon mode guide and the
activation runbook.
Tools
| Tool | What it does |
|---|---|
vault_query | Load project context, tasks, roadmap, lessons — or any file by path |
vault_search | Full-text search with metadata filters, regex, ranked results, recent changes, lesson-usage ranking (rank_by) |
vault_list | Browse projects and files with glob filtering |
vault_health | Server identity (version, vault path, backends), health metrics, drift detection, usage stats, opt-in runtime block |
vault_write | Create, append, or replace vault files. commit=False defers the git commit for batching |
vault_patch | Surgical find-and-replace. commit=False defers the git commit for batching |
vault_commit | Flush pending commit=False writes into one git commit |
capture_lesson | Capture lessons inline / batch-extract from text / look up existing lessons by keyword (find=) |
session_briefing | Tasks + lessons + git log + health in one call |
delegate_task | Route tasks to cheaper models or summarize vault files |
worker_status | Budget, connectivity, available models |
Plus 5 resources and 4 prompts for guided workflows.
Lesson reinforcement
Every read of a lesson via vault_query, vault_search, or capture_lesson(find=…) increments a counter and grows that lesson's confidence asymptotically toward 1.0. Validated lessons rank higher than one-shot captures over time.
# Surface the top-ranked lessons matching a keyword
capture_lesson(project="hive", find="multi-process")
# Search lessons ranked by usage signal (not BM25)
vault_search(query="timeout", rank_by="reinforcements") # most-reinforced first
vault_search(query="timeout", rank_by="confidence") # highest decayed confidence
vault_search(query="timeout", rank_by="hybrid") # α=0.7 BM25 + 0.3 confidence
Storage: SQLite side-table at HIVE_LESSON_DB_PATH (default ~/.local/share/hive/lesson_reinforcement.db). WAL mode + busy_timeout make it cross-process safe.
Architecture
MCP Host (Claude Code, Gemini CLI, Codex CLI, Cursor, ...)
└── hive-vault (MCP server, stdio)
├── Vault Tools (7) ── Obsidian vault (Markdown + YAML frontmatter)
├── Session Tools (1) ── Adaptive context assembly
└── Worker Tools (2) ── Ollama (free) → OpenRouter free → paid ($1/mo cap) → reject
Documentation
Full documentation at mlorentedev.github.io/hive:
- Getting Started — install for all MCP clients
- Configuration — all 19 environment variables
- Vault Structure — how to organize your vault
- Use Cases — real-world workflows
- Architecture — module map and design decisions
- Troubleshooting — common issues and fixes
Project-bound knowledge (docs-as-code) lives in docs/:
docs/adr/— Architecture Decision Recordsdocs/runbooks/— operational proceduresdocs/troubleshooting/— known issues and root-cause write-upsdocs/lessons.md— accumulated gotchas and post-mortems
Contributing
See CONTRIBUTING.md for setup and PR workflow.
git clone https://github.com/mlorentedev/hive.git && cd hive
make install # create venv + install deps
make check # lint + typecheck + test (478 tests, 90% coverage)
License
Related MCP servers

PDF Modifier
Modify PDF text, replace with regex, and analyze layout while preserving fonts.
Detect any website's tech stack, security headers, SSL, DNS and CVEs via DetectZeStack.

Enterprise Architect
Read-only search and navigation of Sparx Enterprise Architect .qea model exports
Non-custodial, rug-gated crypto swaps + token safety + discovery for AI agents.
View repository →
华哥·全国招投标数据
查询 hndcw.com 全国政府招投标 / 建设项目库,可按关键词、省份、城市、行业、预算区间筛选,返回项目标题、地区、预算(万元)、业主单位、阶段、公告日期与原文链接。

华哥·社会调查服务
社会调查与现场执行服务咨询:满意度 / 民意 / 舆情 / 暗访 / 面访 / 座谈会等服务能力与报价查询,对接 hndcw.com 服务预约。

