Skip to main content

@ai-coach/vault-mcp-server

The vault MCP server. It is the standalone stdio process that opens your Obsidian vault, composes vault-application with its adapters, and exposes vault capabilities to ai-coach and AI agents over the Model Context Protocol.

What it does not do​

  • No vault business rules or query projections. Filtering, period math, planning projections, and write planning live in vault-domain and vault-application; handlers here stay thin transport wrappers.
  • No HTTP or browser UI hosting. The local web UI backend lives in vault-view-server, keeping Angular and HTTP adapters out of this app's dependency graph (DEC-AIC-0061).
  • No coaching, LLM, or terminal UI logic. Nothing in scope:coach may be imported here, and nothing in the workspace may import this app (enforced by Nx/ESLint boundary tags).
  • No unpreviewed writes. Every mutating MCP tool previews first and writes only when called again with execute: true and matching version hashes.

Architecture fit​

  • Scope: scope:vault
  • Style: architecture:hexagonal (type:app, app:vault-mcp-server)
  • Depends on: @ai-coach/vault-application, @ai-coach/vault-domain, @ai-coach/vault-adapter-fs, @ai-coach/vault-adapter-markdown, @ai-coach/vault-adapter-pdf, @ai-coach/vault-adapter-search, @modelcontextprotocol/sdk, zod (and @ai-coach/vault-adapter-view in its view integration tests)
  • Used by: coach CLI (via adapter-vault-mcp over stdio MCP) and external AI agents configured with life-vault
[coach CLI / AI agent] ──MCP stdio──▶ [@ai-coach/vault-mcp-server] ──▶ [vault-application] ──▶ [vault-domain]
│
└──▶ [vault-adapter-* (fs, markdown, pdf, search)]

Internal architecture & rules​

  • Composition root: src/compose.ts wires createVault to the filesystem, markdown, PDF, and search adapters.
  • CLI entrypoint (src/main.ts, src/cli/serve.ts): Resolves the vault root through resolveVaultForProcess from vault-adapter-fs and connects McpServer to StdioServerTransport.
  • MCP transport layer (src/mcp/): server.ts registers every tool from registry.ts onto an McpServer. Tool modules are organized by domain (notes/, reading/, climb/, planning/); shared Zod primitives, annotation presets, and refusal helpers live in src/mcp/shared/, and tool modules do not cross-import one another.
  • No comments in source code: Keep TypeScript source files comment-free (DEC-AIC-0011).

Public surface​

  • coach-vault-mcp serve — starts the MCP server on stdio for coach and AI agents (see Setup and Configuration).
  • MCP tool groups — reading and searching notes (list_notes, read_note, search, vault_graph), sparring and the climb (due_for_review, tier2_payload, record_session, climb, rebuild_climb, write_structure, list_topics, save_guideline), filing and raw books (init_vault, capture, file_note, archive_project, list_raw, convert_raw, reading_progress, mark_read, write_summary, add_reading_notes, find_passages, marked_passages, create_concept, extend_concept), and planning (planning_overview, plan_period, plan_days, add_tasks, add_habits, update_task, set_frontmatter, edit_note, create_workstream, roll_over, review_period, harvest_workstream).

How to extend it​

  1. Implement the domain rule or use case in vault-domain or vault-application with unit tests.
  2. Add a thin MCP tool under the matching domain folder in src/mcp/ (notes/, reading/, climb/, or planning/) reusing primitives from src/mcp/shared/schemas.ts, and register it in src/mcp/registry.ts.
  3. If coach or a planning skill calls the tool, wrap it in adapter-vault-mcp and update .agents/skills/vault-planning/tools.md.
  4. Add handler/MCP tests in src/mcp/mcp.test.ts and run npm exec nx run @ai-coach/vault-mcp-server:lint, typecheck, test, and build.

Running & testing​

The build outputs dist/main.js (the coach-vault-mcp binary). The vault path comes from --vault, DOCS_MCP_VAULT, or ~/.config/docs-mcp/config.json:

node apps/vault-mcp-server/dist/main.js serve --vault ~/Documents/my-vault

See Setup and the planning skills for full usage.

npm exec nx lint @ai-coach/vault-mcp-server
npm exec nx typecheck @ai-coach/vault-mcp-server
npm exec nx test @ai-coach/vault-mcp-server
npm exec nx build @ai-coach/vault-mcp-server

Tests​

Tests run with Vitest against isolated temporary directories and never touch your vault: src/mcp/mcp.test.ts tests MCP tool handlers and an in-memory MCP client/server connection, and src/integration/ exercises composeVault with real adapters across notes/, reading/, climb/, and planning/.

Key ADRs​

  • DEC-AIC-0061 — splits the pure MCP server from the local HTTP view server.
  • DEC-AIC-0048 — keeps the vault MCP server in this monorepo behind the MCP boundary.
  • DEC-AIC-0052 — defines the hexagonal split that src/compose.ts wires together.
  • DEC-AIC-0029 — requires agent planning skills to go exclusively through the vault MCP tools.
  • DEC-AIC-0060 — governs this README's eight-section structure.