Skip to main content
Glama

vaults-hub

M8ven Score npm

A Python MCP server that exposes your Obsidian-style Markdown vaults to MCP clients (e.g. OpenCode).

Keep each project's docs as plain Markdown on disk, and let an agent read and maintain them through a small, predictable tool API — no Obsidian plugins, windows, ports, or API keys. Every change is auto-versioned with local git, so nothing is ever truly lost.

Quickstart

The fastest way — no clone, no venv. Published on npm as vaults-hub:

npx -y vaults-hub

This needs Python 3.10+ on PATH (or VAULTS_HUB_PYTHON set to its path); CI tests 3.10, 3.12 and 3.14. On first run it bootstraps the pinned dependencies from requirements.txt into a cached venv (one-time, ~30s; later runs start instantly); see Configuration for the cache location.

From source (offline/dev alternative) — prereqs are Python 3.10+ (developed/tested on 3.14), a POSIX platform (Linux/macOS — locking uses fcntl), and optionally ripgrep (rg) for faster search (a pure-Python fallback is used when rg is absent):

git clone https://github.com/ishaan-jindal/vaults-hub.git vaults-hub
cd vaults-hub
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
python server.py                        # stdio MCP server (no HTTP port)

Vaults live in ~/.vaults by default (each subdir is one vault, e.g. ~/.vaults/MyProject/), auto-created on startup when missing. To use a different location:

export VAULTS_ROOT="$HOME/my-notes"
python server.py --vaults-root "$HOME/my-notes"   # flag wins over env var

Register with OpenCode

Add to your opencode.jsonc (adjust paths to your machine — do not copy any hardcoded home directory). The npx form is recommended:

{
  "mcp": {
    "servers": {
      "vaults": {
        "type": "local",
        "command": "npx",
        "args": ["-y", "vaults-hub"],
        // Pick ONE way to point at your vaults (flag wins over env var):
        "environment": {
          "VAULTS_ROOT": "<path-to-your-vaults>"
        }
      }
    }
  }
}

The local-venv form is the offline/dev alternative (replace with the actual paths on your machine):

{
  "mcp": {
    "vaults": {
      "type": "local",
      // Replace with the actual paths on your machine:
      "command": ["<path-to-vaults-hub>/.venv/bin/python", "<path-to-vaults-hub>/server.py"],
      // Pick ONE way to point at your vaults (flag wins over env var):
      "args": ["--vaults-root", "<path-to-your-vaults>"],
      "environment": {
        // ...or via env var instead of "args" above:
        "VAULTS_ROOT": "<path-to-your-vaults>"
      }
    }
  }
}

Related MCP server: obsidian-kb

Install via your AI agent

The fastest onboarding: tell your agent to set it up. Paste this into Claude Code, OpenCode, Cursor, or Codex:

Please go to https://github.com/ishaan-jindal/vaults-hub, run the install.sh script at the repo root with --apply, and confirm the vaults MCP server is reachable.

The script detects which MCP clients you have installed (OpenCode, Claude Code, Claude Desktop, Cursor, Codex), registers the vaults MCP server in each, symlinks the vaults-sync skill into the global skills directory, and drops a short AGENTS.md hint so every session auto-loads the skill when you ask to write or sync notes.

To run it yourself (clone first so you can inspect):

git clone https://github.com/ishaan-jindal/vaults-hub.git
cd vaults-hub
./install.sh --help        # see what it will do
./install.sh --apply       # actually write configs

The script is dry-run by default — no config is touched without --apply, and every JSON / TOML edit is merged, never overwritten.

Usage examples

Vault layout: each project is a directory directly under VAULTS_ROOT containing .md files, e.g. <VAULTS_ROOT>/MyProject/MyProject.md.

With the server registered as vaults:

  • List vaults: call list_vaults → [{"name": "MyProject", "path": "...", "notes": 12}]

  • Read a note: read_note(vault="MyProject", path="MyProject.md") → frontmatter, content, wiki-links, backlinks

  • Write safely: read_note → edit → write_note(..., expected_sha256="<sha from read>") to avoid clobbering concurrent edits

  • Search: search_notes(query="build command", vault="MyProject", before=1, after=1)

  • Recover a note: history(vault="MyProject", path="Notes.md") → pick a sha → restore(vault="MyProject", path="Notes.md", rev="<sha>")

Tools

14 tools (see vaults/server.py for exact descriptions). Read-only tools are marked R, mutating tools M (write_note/append_note/move_note/restore honor expected_sha256 for optimistic concurrency — read first, then pass the sha back; delete_note has no sha guard and delete_vault is gated on confirm instead):

Tool

R/M

What it does

list_vaults

R

List all project vaults with note counts

server_info

R

Server version, Python/platform, git + ripgrep availability, git_enabled, vaults root, vault count

create_vault

M

Create a new vault (created=False when it already exists; idempotent)

delete_vault

M

Delete a whole vault including git history (irreversible; confirm must equal the vault name)

list_notes

R

List dirs/notes under a vault path (recursive=True for flat listing); paginated with offset/limit (default 200, max 500) → total, truncated, next_offset

read_note

R

Read a note: frontmatter, content, wiki-links, backlinks, unresolved links

write_note

M

Create or atomically overwrite a note (expected_sha256 for optimistic concurrency)

append_note

M

Append text to a note (created if missing), atomic write, optional expected_sha256

delete_note

M

Delete a note (missing_ok=True to tolerate absence); lock files are left in place

move_note

M

Move/rename a note (copy+delete, not atomic); errors if src missing or dst exists; honors expected_sha256; refreshes updated:

list_tags

R

Tag counts per vault from cached frontmatter (one vault or all)

search_notes

R

Full-text search of .md notes via ripgrep (or Python fallback) across one vault or all, with before/after context lines; limit 1–200 with a truncated flag

history

R

Version history for a note ([{sha, date, message}]) or whole vault from the local git repo, with a truncated flag

restore

M

Restore a note from a past revision (snapshots dirty state first; recreates deleted notes); echoes the revision as restored_from

Also built in: YAML-frontmatter parsing with auto-refreshed updated: dates, file locking (fcntl), atomic writes via temp-file + rename, backlink/tag indexes with mtime invalidation, and optional debug logging to file.

Tool annotations

Every tool declares all four MCP ToolAnnotations hints explicitly, so hosts that gate on them (OpenAI's tool directory rejects a tool where any hint is missing or non-boolean) accept the whole set:

Hint

Meaning here

Value

readOnlyHint

does not modify the vault

true for the 7 read tools, false for the rest

destructiveHint

may destroy or overwrite existing data

true for write_note, append_note, move_note, delete_note, delete_vault, restore; false elsewhere

idempotentHint

repeat calls add no further effect

true for the 7 read tools and create_vault; false otherwise

openWorldHint

touches entities outside the vaults root

false for every tool — this server is closed-world by construction

The hints are hints, not guarantees: a client must not make trust decisions from them alone. They matter because the stdio writer serializes tool payloads with exclude_none=True, so an unset hint is dropped from tools/list entirely rather than sent as null. smoke_test.py asserts all four are present booleans on all 14 tools, so a new tool cannot silently reintroduce the gap.

Reliability

How the server avoids losing or corrupting notes:

  • Atomic writes. Every note write goes to a temp file in the same directory (fsynced, then os.replace), with the parent directory fsynced afterwards — readers never see a half-written note. Existing file permissions are preserved.

  • Locking. Mutations serialize per note (flock read-modify-write cycles across processes) and git operations serialize per vault, with a consistent lock order everywhere (note lock first, git lock inside it), so concurrent writes and restores cannot deadlock. Read-only history takes no locks and never blocks writers; truncation flags are computed by the core library, not the tool boundary.

  • Optimistic concurrency. write/append/move/restore accept expected_sha256; a stale sha is rejected instead of clobbering someone else's edit. delete_note has no sha guard; delete_vault is instead gated on confirm exactly equaling the vault name.

  • Fail-open versioning. The write itself is the source of truth — a missing git binary or failed commit warns (surfaced as commit_error) but never blocks the write.

  • Search parity. search_notes prefers rg --json and falls back to pure Python when ripgrep is absent; both sides search only .md notes, skip dotfiles, .obsidian/ and symlinks, and ignore .gitignore, so results match whichever backend runs. Regex syntax is the exception: ripgrep uses Rust regex, the fallback Python re, so lookarounds and backreferences are not portable.

  • No lossy rewrites. append_note, move_note and restore refuse content that is not valid UTF-8 instead of replacing bytes, and keep existing CRLF line endings.

  • No surprise frontmatter. Notes without a frontmatter block stay that way; updated: is only refreshed (or inserted) when a block exists.

  • Fresh indexes. Backlink/tag indexes are invalidated by mtime, so external edits are picked up on the next read. Like listings and search, they skip notes in hidden folders such as .obsidian/ and .trash/.

  • Symlink confinement. Symlink targets resolving outside the vault are rejected — a link can never pull reads or writes out of the vault. Escaping wiki-link path targets (e.g. [[../Outside.md]]) are treated as unresolved; list_notes skips escaping symlink entries instead of failing. A vault directory that is itself a symlink is not listed, searched, or counted in list_tags.

Configuration

Variable

Default

Purpose

VAULTS_ROOT

~/.vaults

Root dir; each immediate subdir is one vault

VAULTS_HUB_DEBUG

unset

Set to 1 to enable debug file logging; anything else disables it

VAULTS_HUB_GIT

unset (versioning on)

Set to 0 to disable git versioning; history/restore then return errors

Precedence for the vaults root: --vaults-root <dir> flag > VAULTS_ROOT env var > default ~/.vaults. Whatever wins is auto-created on startup when missing.

Notes:

  • ripgrep is optional. If rg is on PATH, search_notes uses rg --json; otherwise a pure-Python fallback with the same results is used. No configuration needed either way.

  • POSIX-only. File locking uses fcntl, so Windows is not supported.

  • npx launcher. VAULTS_HUB_PYTHON overrides which Python the vaults-hub bin uses (else python3, then python on PATH; must be 3.10+). When that interpreter lacks the pinned dependencies, the bin installs them once into a cached venv under $XDG_CACHE_HOME/vaults-hub (else ~/.cache/vaults-hub), keyed by Python minor version, and reuses it silently while the requirements.txt hash matches.

Versioning

Each vault is a local git repo (one per vault root), maintained automatically:

  • Default-on. The repo is lazily git init -b main on the first mutation; every write/append/delete/move commits path-scoped with a Sha256: trailer (e.g. vaults: write Notes.md). The write itself is the source of truth — a missing git binary or failed commit warns but never blocks the write.

  • Local-only, no push. Versioning never pushes, pulls, or fetches; identity is per-invocation (vaults-hub), never written to gitconfig. Lock/tmp files and .obsidian/ are excluded via $GIT_DIR/info/exclude (no visible .gitignore). A vault already nested inside an external repo is left alone.

  • Opt-out. Set VAULTS_HUB_GIT=0 to disable init/commits; history and restore then return clear errors.

  • history(vault, path?, limit?) lists [{sha, date, message}] (newest first, limit clamped 1–200) plus a truncated flag when more commits exist beyond the page; a deleted note keeps its history, and a path that was never committed returns [] with untracked:true. restore(vault, path, rev, expected_sha256?) writes git show rev:path back to disk atomically (snapshotting dirty state first), echoes the revision as restored_from, and can recreate deleted notes.

Testing

No test framework — one end-to-end smoke test over a temporary stdio server:

source .venv/bin/activate
python smoke_test.py

It creates fixture vaults in a temp dir, exercises all tools (including versioning and its opt-out), and exits non-zero with a traceback on failure.

Architecture (brief)

opencode (MCP client, stdio) <-> vaults/server.py (FastMCP "vaults", 14 tools) <-> ~/.vaults/<project>/*.md
  • vaults/ is the whole server: config.py (vaults root, logging, CLI), notes.py (path validation, UTF-8 checks, fcntl locks, atomic writes, SHA-256 optimistic concurrency, frontmatter/wiki-link helpers, note CRUD, vault creation), indexes.py (in-memory backlink/tag indexes with mtime-based invalidation), search.py (ripgrep + Python-fallback search), versioning.py (per-vault git layer), and server.py (FastMCP app, 14 tools). Root server.py is a thin shim so python server.py keeps working.

  • server.py keeps the event loop responsive: every tool runs its blocking library call in a worker thread via anyio.to_thread. Errors are sanitized at the tool boundary (client-safe ValueErrors pass through; anything else becomes a plain failure notice) while the server log keeps the full traceback; request logging records only vault/path.

  • smoke_test.py spawns server.py over stdio with VAULTS_ROOT pointed at a temp dir.

Limitations

  • Private SDK pin: dependencies are pinned in requirements.txt (anyio==4.15.1, mcp==1.30.0, PyYAML==6.0.3); bump deliberately and re-run python smoke_test.py.

  • Move is copy + delete, not one atomic rename: move_note writes the destination atomically, then unlinks the source — a crash between the two steps can leave both copies behind. A failed move cleans up the partial destination. It also refuses to overwrite an existing destination.

  • Wiki-link resolution is name-based: bare [[Name]] links resolve via a stem index (shortest path wins on collision); only [[path/with/slash]] links resolve as paths. Self-links are excluded from backlinks.

  • POSIX-only (fcntl locking); no Windows support.

  • No authentication: the stdio transport trusts the local client; do not expose vault contents beyond your machine without adding your own access controls.

License

MIT — see LICENSE.

Contributing

See CONTRIBUTING.md for setup, checks, and the PR flow.

Available Tools

14 tools
append_noteA
Destructive

Append text to a note (created if missing) via an atomic write. Optionally pass expected_sha256 to prevent appending to a changed note. Refreshes the frontmatter updated: date (inserted when a frontmatter block exists without one).

Inputs: path (required), text (required), vault (required), expected_sha256.

create_vaultA
Idempotent

Create a new vault (one subdirectory of the vaults root). Idempotent: returns created=False when the vault already exists.

Inputs: vault (required).

delete_noteA
Destructive

Delete a note file. Errors when missing unless missing_ok=True. Lock files are intentionally left in place.

Inputs: path (required), vault (required), missing_ok.

delete_vaultA
Destructive

Delete a whole vault: removes every note, lock file and the git history. Irreversible with no undo in this server; confirm must exactly equal the vault name.

Inputs: vault (required), confirm (required).

historyA
Read-onlyIdempotent

Show version history for a note (or the whole vault) from the local git repo: [{sha, date, message}] with a truncated flag when more commits exist beyond limit (clamped 1-200). An untracked path returns an empty list with untracked:true.

Inputs: vault (required), path, limit.

list_notesA
Read-onlyIdempotent

List directories and notes under a vault path (vault-root-relative, '' for root). Pass recursive=True to list all descendant notes flat (dirs=[]). Paginate with offset/limit (default limit 200, max 500); the response carries total (full match count), truncated, and next_offset (None when done).

Inputs: vault (required), path, limit, offset, +1 more.

list_tagsA
Read-onlyIdempotent

List tag counts per vault from cached frontmatter. Pass vault for one vault, or omit for all vaults.

Inputs: vault.

list_vaultsA
Read-onlyIdempotent

List all project vaults with their note counts.

Inputs: no named parameters. Returns: result

move_noteA
Destructive

Move/rename a note via copy+delete (not atomic): the destination is written atomically, then the source is unlinked, and a partial destination is cleaned up on failure. Errors if src is missing or dst exists. Honors expected_sha256 against src. Refreshes updated:.

Inputs: vault (required), dst_path (required), src_path (required), expected_sha256.

read_noteA
Read-onlyIdempotent

Read a note: frontmatter, content, wiki-links, backlinks, unresolved links.

Inputs: path (required), vault (required).

restoreA
Destructive

Restore a note's content from a past revision (git rev, e.g. a history sha); the response echoes the revision as restored_from. Snapshots dirty worktree state first; recreates deleted notes. Honors expected_sha256 against current content.

Inputs: rev (required), path (required), vault (required), expected_sha256.

search_notesA
Read-onlyIdempotent

Search .md note contents with ripgrep across one vault or all vaults. regex=True uses ripgrep's Rust syntax (Python re when ripgrep is absent), so lookarounds and backreferences are not portable. limit is clamped 1-200 and the response carries a truncated flag; before/after (0-10) add context lines. With context each hit keeps text (= match_line) plus before_lines/match_line/after_lines, otherwise only text.

Inputs: query (required), after, limit, regex, +3 more.

server_infoA
Read-onlyIdempotent

Report server version, Python/platform, git and ripgrep availability, whether git versioning is enabled, the local vaults root path, and the vault count. This is a local stdio server; the vaults root path is intentionally exposed.

Inputs: no named parameters.

write_noteA
Destructive

Create or atomically overwrite a note (vault-root-relative path). Pass sha256 from a prior read/write as expected_sha256 to prevent overwriting a changed note. Refreshes the frontmatter updated: date (inserted when a frontmatter block exists without one); notes without a frontmatter block stay that way.

Inputs: path (required), vault (required), content (required), expected_sha256.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A4.2/5.0

    Scored across 14 tools

    Disambiguation5/5

    Each tool maps to a distinct operation: read/list per entity, create/delete/move notes, git history/restore, and search/tags. Overlaps like write_note vs append_note are clearly distinguished by overwrite semantics, and list_vaults/list_notes/list_tags target different scopes.

    Naming Consistency5/5

    Consistent verb_noun snake_case throughout (read_note, list_vaults, create_vault, delete_note, move_note, list_tags, search_notes). Single-word tools like history, restore, and server_info are intuitive and fit the pattern.

    Tool Count5/5

    14 tools is well-scoped for a vault/notes server, covering CRUD, navigation, versioning, and search without redundancy. Every tool earns its place.

    Completeness5/5

    Full lifecycle coverage: vault create/delete/list, note read/write/append/delete/move/list, git history/restore, tags, search, and server_info. No obvious dead ends for the stated domain.

    Maintenance

    ActivityNo data
    ResponsivenessOutdated data

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      D
      maintenance
      MCP server that provides read and write access to an Obsidian vault by interacting directly with markdown files on disk. Supports searching, listing, reading, creating, editing, and appending notes without requiring any Obsidian plugins.
      ISC
    • F
      license
      C
      quality
      D
      maintenance
      Git-backed MCP server for creating and maintaining an Obsidian-style markdown knowledge base with full CRUD, search, and git sync.
      7
      -
    • F
      license
      C
      quality
      D
      maintenance
      MCP server to query and modify an Obsidian vault or any folder of markdown files. It provides search, tag filtering, backlinks, and CRUD operations on notes, with path traversal protection.
      11
      -
    • A
      license
      Not graded
      quality
      D
      maintenance
      MCP server for browsing Obsidian-compatible Markdown vaults, searching notes, viewing backlinks and knowledge graphs, and adding selected content to chat context.
      MIT