Skip to main content

DEC-AIC-0061: Split vault-server into pure vault-mcp-server and dedicated vault-view-server

Draft

Status: draft · 2026-11-30

Context​

DEC-AIC-0048 kept the vault server in this repository behind the MCP boundary, and DEC-AIC-0052 split the vault logic into hexagonal domain, application, and adapter libraries composed by apps/vault-server. At that time apps/vault-server hosted two local transports under one binary (coach-vault): stdio MCP (serve) and the loopback HTTP UI server (view) backed by @ai-coach/vault-adapter-view (observed: apps/vault-server/src/main.ts @ 2026-11-30).

Because @ai-coach/vault-adapter-view depends on the Angular frontend @ai-coach/vault-view (apps/vault-view, introduced in DEC-AIC-0059), every build, typecheck, and test run of apps/vault-server triggered an Angular ng build even when only MCP tools changed (observed: Nx task graph @ 2026-11-30). At the same time, apps/vault-view is a browser-only scope:vault-view layered app that cannot import Node scope:vault libraries directly.

Decision​

  1. Rename apps/vault-server to apps/vault-mcp-server (@ai-coach/vault-mcp-server, binary coach-vault-mcp):
    • Hosts only the stdio MCP server (serve) and removes @ai-coach/vault-adapter-view from its dependencies and TypeScript project references.
    • Tagged scope:vault, architecture:hexagonal, type:app, app:vault-mcp-server.
  2. Create apps/vault-view-server (@ai-coach/vault-view-server, binary coach-vault-view):
    • Dedicated Node loopback HTTP server (BFF) that composes the vault with its adapters, serves @ai-coach/vault-adapter-view APIs and the built Angular @ai-coach/vault-view bundle on 127.0.0.1, and owns the loopback HTTP integration tests (src/view.test.ts).
    • Tagged scope:vault, architecture:hexagonal, type:app, app:vault-view-server.
  3. Move shared process-level CLI flag parsing and vault-root resolution into @ai-coach/vault-adapter-fs:
    • parseVaultFlags, parseViewFlags, workspaceRootsAbove, and resolveVaultForProcess live in libs/vault/adapter-fs/src/lib/process-root.ts alongside resolveVaultRoot, keeping both Node apps thin without introducing a new composition library or relaxing type:adapter ESLint boundaries.
  4. Update apps/cli configuration and coach view:
    • defaultVaultMcpServerBin() resolves apps/vault-mcp-server/dist/main.js (still overridable via DOCS_MCP_BIN / docsMcpBin).
    • defaultVaultViewServerBin() resolves apps/vault-view-server/dist/main.js (overridable via VAULT_VIEW_BIN / vaultViewBin), and coach view spawns config.vaultViewBin directly.

Consequences​

  • @ai-coach/vault-mcp-server is a pure MCP server with zero dependency on @ai-coach/vault-adapter-view or Angular (@ai-coach/vault-view), making MCP server builds and tests faster and more isolated.
  • @ai-coach/vault-view remains a pure browser-only Angular application while @ai-coach/vault-view-server serves as its dedicated Node backend.
  • External MCP configurations (.mcp.json) point to apps/vault-mcp-server/dist/main.js instead of apps/vault-server/dist/main.js.

Alternatives Considered​