@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-domainandvault-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:coachmay 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: trueand 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-viewin its view integration tests) - Used by:
coachCLI (viaadapter-vault-mcpover stdio MCP) and external AI agents configured withlife-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.tswirescreateVaultto the filesystem, markdown, PDF, and search adapters. - CLI entrypoint (
src/main.ts,src/cli/serve.ts): Resolves the vault root throughresolveVaultForProcessfromvault-adapter-fsand connectsMcpServertoStdioServerTransport. - MCP transport layer (
src/mcp/):server.tsregisters every tool fromregistry.tsonto anMcpServer. Tool modules are organized by domain (notes/,reading/,climb/,planning/); shared Zod primitives, annotation presets, and refusal helpers live insrc/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 forcoachand 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
- Implement the domain rule or use case in
vault-domainorvault-applicationwith unit tests. - Add a thin MCP tool under the matching domain folder in
src/mcp/(notes/,reading/,climb/, orplanning/) reusing primitives fromsrc/mcp/shared/schemas.ts, and register it insrc/mcp/registry.ts. - If
coachor a planning skill calls the tool, wrap it inadapter-vault-mcpand update.agents/skills/vault-planning/tools.md. - Add handler/MCP tests in
src/mcp/mcp.test.tsand runnpm exec nx run @ai-coach/vault-mcp-server:lint,typecheck,test, andbuild.
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.tswires 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.