Skip to content

Quick Start ​

From an empty terminal to a live preview in about ten minutes. Every command below was really run against playground/ui-library from this repository and every output is copied verbatim; the only edit is that the absolute path of this checkout is shortened to <repo>.

New to MCP itself? Read What is MCP first — it explains client, server, tool and resource without jargon.

What you need ​

  • Node ≥ 20
  • a Vue 3 project (TypeScript or JavaScript)

To follow along without touching your own code, use the demo project from this repository:

bash
git clone https://gitlab.com/pnym/mcp.git && cd mcp
cd playground/ui-library && npm install && cd ../..

Step 1 — Install ​

bash
npm install --save-dev vue-codebase-mcp vue-codebase-view-mcp

Both are development dependencies: they serve developers and AI assistants, never the production bundle. vue-codebase-view-mcp depends on vue-codebase-mcp and reuses it as a library, so installing the view server alone is enough if you want both.

Step 2 — Build the index ​

bash
npx vue-codebase-mcp index --root playground/ui-library --mode full

Real output:

text
[vue-codebase-mcp] info: Index built (full) in 498 ms: 7 components, 2 composables, 0 stores, 0 routes, 3 utils, 10 documents
Index built (full) in 500 ms
  components:  7
  composables: 2
  stores:      0
  routes:      0
  utils:       3
  documents:   10
  snapshot:    <repo>/playground/ui-library/.vue-codebase-mcp.cache/index.json

What it means:

  • the first line is a log and goes to stderr; the report goes to stdout — so index … > report.txt captures only the report;
  • full means types were resolved by vue-component-meta (the engine behind Volar): props keep their real types, generics and imported types included;
  • apiSources in the JSON report below shows where each API came from — vue-component-meta for .vue files, typescript for .ts files;
  • the result is written to .vue-codebase-mcp.cache/index.json. Add .vue-codebase-mcp.cache/ to .gitignore: it is a machine-local artifact.

index is the only command that must be run ahead of time. Without a snapshot both servers still start — they build a light index by syntactic parsing in a fraction of a second — but types stay unresolved and every answer says so.

Exit codes ​

index distinguishes outcomes so that CI and scripts do not treat an empty build as success (the same list is printed by npx vue-codebase-mcp help):

CodeMeaning
0index built and not empty
1bad arguments or a fatal error
2project root not found — the snapshot is not written
3index is empty — nothing to index

Code 2 protects against a typo in --root: without it the command would create a cache directory at a path that does not exist and look successful. Code 3 usually means components.locations does not match anything — check the configuration and rebuild.

Machine-readable report ​

bash
npx vue-codebase-mcp index --root playground/ui-library --mode full --json
json
{
  "mode": "full",
  "durationMs": 470,
  "stats": {
    "components": 7,
    "composables": 2,
    "stores": 0,
    "routes": 0,
    "utils": 3,
    "docs": 10,
    "projects": ["ui-library"],
    "apiSources": {
      "vue-component-meta": 7,
      "typescript": 5
    },
    "generatedAt": "2026-11-20T17:12:45.270Z",
    "durationMs": 468
  },
  "snapshotFile": "<repo>/playground/ui-library/.vue-codebase-mcp.cache/index.json",
  "warnings": [],
  "errors": []
}

warnings and errors are arrays of { code, params, message }: code is stable for scripts, message is already localized for humans. Diagnostics elsewhere (build report, tool answers, preview) follow the same shape and are printed as [code] message.

Step 3 — Connect your AI client ​

Register both servers in the client's MCP configuration — ~/.claude/claude_desktop_config.json for Claude Desktop, .cursor/mcp.json for Cursor, .mcp.json or settings.json for Qwen Code. The shape is the same:

json
{
  "mcpServers": {
    "vue-codebase": {
      "command": "npx",
      "args": ["-y", "vue-codebase-mcp", "serve"],
      "env": {
        "VUE_CODEBASE_MCP_ROOT": "/absolute/path/to/your/project",
        "VUE_CODEBASE_MCP_LANG": "en"
      }
    },
    "vue-codebase-view": {
      "command": "npx",
      "args": ["-y", "vue-codebase-view-mcp", "serve"],
      "env": {
        "VUE_CODEBASE_MCP_ROOT": "/absolute/path/to/your/project",
        "VUE_CODEBASE_VIEW_MCP_LANG": "en"
      }
    }
  }
}

VUE_CODEBASE_MCP_ROOT and the --root flag in args are equivalent since 0.1.2. On the published 0.1.1 the variable moves only the indexing root — the configuration file and the snapshot are still resolved from the client's working directory — so prefer --root in args until you upgrade.

What happens on the first start:

  1. the client spawns the process itself and talks to it over stdin/stdout — there is nothing to open in a browser and no port to remember; how that is wired is explained in What is MCP → How stdio works;
  2. the handshake (initialize) reports the server name, version and capabilities;
  3. the client calls tools/list and sees 10 tools from the indexer and 4 tools from the view server;
  4. from then on the assistant calls tools on its own, when it decides it needs to.

Because stdout carries the protocol, all logs go to stderr. If a client says the server "does not respond", the reason is in stderr — restart it with MCP_LOG_LEVEL=debug in env and read the log. See Troubleshooting.

Check the connection in one question

Ask the assistant: "Call get_project_overview and tell me how many components are indexed." A working server answers with the numbers from step 2.

Step 4 — First request ​

This is what the assistant sends over MCP (shown as JSON-RPC tools/call parameters):

json
{ "name": "search", "arguments": { "query": "button" } }

Real answer of the indexer started with --lang en:

text
## Index matches (1)
- **UiButton** · component · `src/components/ui-button/ui/UiButton.vue` (stable)
  Базовая кнопка дизайн-системы: варианты, размеры, состояние загрузки.
  match: exact name, category

Two things to notice:

  • the last line is the reason for the match — here an exact name plus a category hit. Selection is automatic, so the model always sees what a result hung on;
  • the description stays Russian because it comes from the JSDoc comment in the demo project's source: --lang translates the server's own text (headings, labels, errors) and never translates your code's text. Line by line this is taken apart in What is MCP → A live example.

Now the exact API of that component:

json
{ "name": "get_entity_details", "arguments": { "name": "UiButton" } }
text
## UiButton · component · ui-library
file: `src/components/ui-button/ui/UiButton.vue` · uri: `component://UiButton` · api: vue-component-meta · status: stable

Базовая кнопка дизайн-системы: варианты, размеры, состояние загрузки.

Category: components / ui-button / ui

### Props
- `variant` — `Variant` [default: `"primary"`] — Визуальный вариант оформления
- `size` — `Size` [default: `"m"`] — Размер кнопки
- `loading` — `boolean` [default: `false`] — Переводит кнопку в состояние «загрузка» и блокирует клики
- `disabled` — `boolean` [default: `false`] — Кнопка недоступна для взаимодействия
- `type` — `"button" | "submit" | "reset"` [default: `"button"`] — Тип нативной кнопки в форме
### Events
- `click` — `(event: MouseEvent): void`
### Slots
- `default` — Основное содержимое кнопки (текст)
- `icon` — Иконка перед текстом

### Documentation
- UiButton · `doc://component/UiButton` · file: `src/components/ui-button/docs/ui-button.md`

Request the full text or a single section via `get_documentation`.

### Mentioned in documentation
- Начало работы · `doc://workspace/ui-library/docs/getting-started`
- Темы и оформление · `doc://workspace/ui-library/docs/theming`
- ui-library — демо-проект `vue-codebase-mcp` · `doc://project/README`

Dependencies: uses 1, used in 0 — details via `get_dependencies`.

api: vue-component-meta is the promise that these types were resolved, not guessed. Names are accepted in any shape — UiButton, ui-button, button all resolve — and a typo returns ranked suggestions instead of an empty answer:

text
[tools.entityNotFound] "UiButon" was not found in the index (12 entities).

Did you mean:
- UiButton · component · ui-library
- UiBadge · component · ui-library

Refine the request with the `search` tool.

Which tool to use for which question: Indexer tools.

Step 5 — See it in a browser ​

bash
npx vue-codebase-view-mcp preview --root playground/ui-library --port 5299 --open

Real output:

text
[vue-codebase-mcp] info: Loaded index snapshot from 2026-11-21T17:47:58.839Z: 12 entities, 10 documents
[vue-codebase-view-mcp] info: Starting preview for ui-library (<repo>/playground/ui-library)
[vue-codebase-view-mcp] info: Preview for ui-library is ready at http://localhost:5299/__vue-view__/ in 32 ms
Preview for ui-library is running at http://localhost:5299/__vue-view__/
Press Ctrl+C to stop the server.

This is a real Vite dev server started against your project: components are compiled by your own pipeline and rendered by the browser, with your aliases, plugins and styles. The interface lives under /__vue-view__/; your own app (if the project has one) keeps working at /.

Probe a running preview from another terminal — this is also how you check whether a port is already serving something:

bash
npx vue-codebase-view-mcp status --port 5299
text
url:      http://localhost:5299/__vue-view__/
project:  ui-library
index:    2026-11-20T17:12:45.270Z (full)
version:  0.1.0
language: en

Four views are available, addressable by hash — #/gallery, #/component/UiButton, #/api/UiButton, #/graph/UiButton. What each one shows and how to reach it from a tool call: View server.

preview exit codes are just as explicit as index's: 0 running (stopped by Ctrl+C), 1 bad arguments or a fatal error, 2 unknown project, missing root or no project selected in a monorepo, 3 empty index — the server stops instead of showing an empty gallery, 4 port unavailable (taken, or below 1024 without privileges).

Step 6 — Keep the index fresh ​

serve starts a file watcher (cache.watch: true is the default) and logs Watching N patterns. An edited file is re-read on the fly — no server restart and no full rebuild of the index.

This is the header of get_entity_details on the demo project before an edit of UiButton.vue and a few seconds after it; the server was not restarted:

text
file: `src/components/ui-button/ui/UiButton.vue` · uri: `component://UiButton` · api: vue-component-meta · status: stable
file: `src/components/ui-button/ui/UiButton.vue` · uri: `component://UiButton` · api: sfc-lite · snapshot stale

The important part: a pinpoint refresh re-reads the file with the syntactic parser, not with the heavy vue-component-meta pass that builds full mode. So for a component that was just edited api temporarily becomes sfc-lite and the entity is marked stale — "this file changed after the snapshot was built, type resolution may be out of date". That is the server honestly saying: the data for this file is fresh but less precise than the snapshot's.

Exact types come back with a rebuild: run index --mode full again, or restart the server so that it re-reads the snapshot. Only the index command rewrites the snapshot on disk, which is why teams put the rebuild on a schedule or into CI — see Deployment → Preparing the index.

--no-watch disables the watcher: the session then answers from the index it built at startup, and edits are picked up by a rebuild only.

If something goes wrong ​

SymptomReason and fix
The client lists no tools from the serverIn Qwen Code, servers declared in a project .qwen/settings.json are approval-gated, and no dialog appears outside the interactive terminal: run qwen mcp approve --all from the project root, then reload the window (Developer: Reload Window) — a new chat is not enough. Full walkthrough: mcp-approval-troubleshooting.md
index exits with 3Nothing matched components.locations (or the project really has no components). Print the resolved configuration: npx vue-codebase-mcp config --root <path>
index exits with 2Typo in --root. The snapshot was not written
Client says the server does not respondLook at stderr: add "MCP_LOG_LEVEL": "debug" to the server's env and restart the client
[tools.indexEmpty] in an answerThe server started without a snapshot and found nothing. Run index --mode full
[tools.unknownProject]A monorepo workspace is named differently; the answer lists the available names
preview exits with 4The port is taken or requires privileges — pass --port 5299 (or omit it and let Vite choose)
Answers say types are unresolvedThe index is light. Run npx vue-codebase-mcp index --mode full

A full walkthrough of failures with their codes: Troubleshooting.

Next ​

  • What is MCP — the same steps, but explaining what actually happens between the client and the server
  • Indexer tools · View server tools — every tool with a real request and answer
  • Recipes — “is there a ready-made component?”, “what breaks if I change this?”
  • Configuration — .vue-codebase-mcp.json for an app, a UI library, a monorepo
  • Deployment — the indexer on a server over HTTP: from scratch, systemd, Docker, TLS

MIT Licensed