Skip to content

Architecture ​

A condensed tour of the design; the full rationale — including measurements and rejected alternatives — lives in the repository: ARCHITECTURE.md / ARCHITECTURE.ru.md.

Request path ​

client → MCP server (stdio / HTTP) → tool handler → ProjectIndex (in-memory) → answer as markdown/JSON
                                                          ↑
                          light build (at server start) or snapshot (after `index`)

The MCP process never compiles anything: it answers from the in-memory ProjectIndex — a flat JSON-serialised model. Entities and documents are addressed by stable ids (component:<project>:<normalized name>, doc:<level>:<scope>:<slug>).

Two indexing modes ​

Full type resolution requires a TypeScript program (seconds) — too slow at server start. Indexing is split:

ModeWhat it doesWhen
fullvue-component-meta for .vue + a TS program and type checker for .tsthe index command; result is a snapshot on disk
lightSyntactic parsing: @vue/compiler-sfc + the TypeScript AST, no resolutionserver start, when there is no snapshot

Every entity records its apiSource. Light-mode answers say explicitly that types are unresolved and suggest index. The snapshot is plain JSON in .vue-codebase-mcp.cache/index.json, versioned by SNAPSHOT_FORMAT_VERSION (currently 2; a v1 snapshot is ignored with a snapshotFormatMismatch warning and rebuilt). Files edited after the snapshot are marked stale by the watcher: it re-reads such a file with the syntactic parser, so its apiSource temporarily becomes sfc-lite, and a rebuild with index --mode full brings the exact types back. The why of the two-mode split is in About the Project.

Documentation: levels and linking ​

Documents live on four levels (component, workspace, collection, project) which determine the URI and the linking priority. docLinker connects documents to entities by seven rules, from an explicit docs.componentDocs map down to a JSDoc @docs ./file.md reference — the full list and the strong/weak link distinction are in About the Project.

Two independent mechanisms: a ranked lexical engine behind search and MiniSearch full-text behind search_docs. Name resolution accepts ids, exact names, prefix-stripped names and a single unambiguous prefix; failures return Levenshtein-ranked suggestions. The scoring table, the two closed traps (minimum token length, Cyrillic normalisation) and the word-form rules are in About the Project; what a result looks like is in Indexer tools.

i18n architecture ​

Diagnostics are { code, params }; strings are rendered only at the boundary. en.ts defines the dictionary shape (Messages = ReturnType<typeof createEn>), ru.ts must match it to compile, and a test asserts key parity. The view server reuses pluralFor, parseLanguage and createLogger from the indexer — one implementation of the shared logic, two servers. The user-visible consequences, the resolution order and what is deliberately left untranslated: Language.

How the view server reuses the indexer ​

vue-codebase-view-mcp does not duplicate indexing, configuration, language resolution or logging: its createViewContext wraps the indexer's createContext, and its public API imports (resolveEntity, text/failure/json helpers, entity types, EntityOfKind<K>) come from vue-codebase-mcp as a library. The browser-facing contract (contract.ts) imports types only — a runtime import would drag Node into the browser.

Vite findings worth knowing ​

Two behaviours of Vite the preview server had to learn the hard way:

  1. Vite does not register plugins returned from the config hook — the plugin container is already assembled. The working shape: read the target config via loadConfigFromFile, check for vite:vue, and pass vue() in the plugins array to createServer, forwarding the resolved config path as configFile so Vite does not execute the file twice.
  2. server.fs.allow replaces the Vite default instead of extending it — the project root, searchForWorkspaceRoot, the package directory and the UI directory must be listed explicitly, or even the project's own index.html gets a 403.

Also: ViteDevServer.close() can hang mid dep-optimisation, so stopping races a 3-second timeout (the port is released immediately); and module addresses are resolved from the running Vite root, so monorepo neighbours are addressed as /@fs/<abs>.

Security ​

  • Reads are confined to the project roots; .. and symlink escapes are rejected ([tools.pathOutsideRoots]).
  • Never served: .env*, .npmrc, .git/, node_modules/, .ssh/, .aws/, private keys, files with secret/credentials in the name ([tools.deniedPath]).
  • Absolute machine paths are stripped from entity payloads (they carry file, not absoluteFile) and from the preview HTTP API (project holds only its name). Two places still print them, deliberately: the get_project_overview answer and the index://overview resource report the host's configuration path, workspace roots and tsconfig.
  • In HTTP mode the Host and Origin headers are validated, and Authorization when a token is set. The full picture, including exactly what resources.exposeSourceCode closes: Deployment → Security.

Tests ​

Indexer: 141 tests in 14 suites — configuration loading, i18n key parity, the parsers (vueSfc, tsFile, markdown, indexer), the file watcher against a real filesystem (a file changed, added and removed, plus event selection by the configured patterns), the utility layer (match, name, security, synonyms), and end-to-end runs over stdio and HTTP plus the index CLI against fixture projects.

View server: 63 tests in 9 suites — i18n parity and templating, payload builders, the browser contract (contract.ts), the interface store, the preview CLI exit codes, UI rendering, the composition of the published tarball (every module the interface entry imports must be in files, and the license must be there), and E2E against a real Vite dev server (page, manifest, entities, graph, registry virtual module, and the single-Vue-instance invariant).

bash
cd packages/vue-codebase-mcp && npm test
cd packages/vue-codebase-view-mcp && npm test

MIT Licensed