Introduction
Vue Codebase MCP is a pair of MCP (Model Context Protocol) servers for Vue 3 codebases:
| Package | Answers the question | Consumer |
|---|---|---|
vue-codebase-mcp | What is in the codebase? — components with props/emits/slots, composables, stores, routes, docs | an AI assistant, over MCP |
vue-codebase-view-mcp | What does it look like when it runs? — a live Vite dev server that really renders your components | a human, in a browser |
The view server is built on top of the indexer: it reads the same index snapshot and the same .vue-codebase-mcp.json, and reuses the indexer as a library instead of duplicating it.
Why
An AI assistant working in a Vue repository guesses: it invents prop names, misses the design-system prefix, does not know that a ready-made UiSelect exists, and rewrites what is already written. These servers give it the same picture a developer sees in an IDE — without pasting the whole codebase into the context.
Documentation rots and screenshots lie, so the second server shows the truth instead: your real components, compiled by your own Vite pipeline, rendered live in a gallery with interactive controls.
Neither server hands the model a dump of the project. The index snapshot on disk is an internal cache that makes startup instant; what the assistant receives is one slice per question — search returns up to 50 matches, get_entity_details the API of a single component, get_source one file or a window of lines — and every answer is capped at 24 000 characters with an explicit truncation notice. A library of 1 000 components therefore costs the context about what a library of 20 costs: what matters is the size of the answer, not the size of the index.
Requirements
- Node ≥ 20
- A Vue 3 project (TypeScript or JavaScript). Vue 2 is not supported.
Install
# the indexer
npm install --save-dev vue-codebase-mcp
# the live preview server (depends on the indexer)
npm install --save-dev vue-codebase-view-mcpQuick start
Three commands. They are shown together first and taken apart one by one below — what each does, which flags it takes, and what it prints.
# 1. Build an index snapshot with resolved types (once; ~3 s for 125 components)
npx vue-codebase-mcp index --root /path/to/your/project
# 2. Start the indexer as an MCP server (normally the client does this, not you)
npx vue-codebase-mcp serve --root /path/to/your/project
# 3. (Optional) open the live preview in a browser
npx vue-codebase-view-mcp preview --root /path/to/your/project --openTwo words that appear in every command:
npxruns a command from an npm package. If the packages are installed into the project (npm install --save-dev vue-codebase-mcp),npxuses the local version; otherwise it downloads the latest one from npm into a temporary directory. Both work, but the local install is better: the version matches what is pinned inpackage.jsonand the command does not depend on the network.--root <path>is the root of the Vue project to index; an absolute path is more reliable than a relative one. All three commands take this flag, and all three try to detect the root on their own without it — from the location of.vue-codebase-mcp.jsonor of the current directory.
Command 1 — index: build the snapshot
npx vue-codebase-mcp index --root /path/to/your/projectThe only command you have to run in advance, before connecting a client. It reads the project's files, resolves the types of props and events, and writes the result to .vue-codebase-mcp.cache/index.json — the snapshot every tool answers from.
You do not have to type --mode full: it is the default for index. The alternative --mode light is faster but does not resolve types, and the API table of a component stays nearly empty.
The command ends with a report you can check:
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.jsonZero components means the index is empty and the tools will answer [tools.indexEmpty] — check components.locations with npx vue-codebase-mcp config --root /path/to/your/project.
Add .vue-codebase-mcp.cache/ to .gitignore: it is a local artifact that one command recreates.
Command 2 — serve: start the MCP server
npx vue-codebase-mcp serve --root /path/to/your/projectThis is the MCP server itself: the process that answers the assistant's questions. It loads the snapshot from command 1 (or builds a light index itself when there is none) and waits for protocol requests.
Normally you do not run this command — the client does. In the client's configuration you write "command": "npx", "args": ["-y", "vue-codebase-mcp", "serve"], and the client executes it when it needs the server and stops the process at the end of the session. You run serve by hand for two reasons: to check that the server starts at all and sees your project, and to talk to it directly from a terminal (how — in What is MCP → How stdio works).
Run in a terminal it prints no URL and does not exit — that is not a hang, the server is waiting for JSON messages on standard input. In stderr you see the real startup log:
[vue-codebase-mcp] info: Loaded index snapshot from 2026-11-20T19:14:44.227Z: 12 entities, 10 documents
[vue-codebase-mcp] info: Index: full, 12 entities, 10 documents
[vue-codebase-mcp] info: Watching 7 patterns
[vue-codebase-mcp] info: vue-codebase-mcp: stdio transport startedStop it with Ctrl+C. stdout stays empty because the protocol occupies it — more about that here. The line about watching is the file watcher: it re-reads edited files on the fly, but only a rebuild with index --mode full brings exact types back after an edit (see Quick Start → step 6).
Useful flags: --lang ru|en (answer language), --no-watch (do not start the watcher), --config <path>, and for a remote host --transport http --host 127.0.0.1 --port 3333.
Command 3 — preview: the live browser preview
npx vue-codebase-view-mcp preview --root /path/to/your/project --openThis command is for a human, not for the assistant: it starts a real Vite dev server on top of your project and shows an interface with a component gallery, a stand for driving props, an API table and a dependency graph. Components are compiled by your own pipeline — with your aliases, plugins and styles — so the browser shows exactly what a user sees.
--open opens the tab right away; --port 5299 pins the port (without it Vite picks a free one); --no-open cancels opening the tab — needed on a server or in CI. The target project must have vue installed, otherwise the server reports [preview.vueMissing] and the components will not compile.
The command prints the URL to open:
Preview for ui-library is running at http://localhost:5299/__vue-view__/
Press Ctrl+C to stop the server.The full walkthrough — every step with its real output, the client configuration, the first tool call and a troubleshooting table — is on the Quick Start page. If MCP itself is new to you, start with What is MCP.
Both servers also work without a snapshot: a light index is built in a fraction of a second by syntactic parsing, but types stay unresolved and the tools say so explicitly — see Architecture.
Connecting a client
There are two ways to connect a server to an AI client; only the shape of the configuration entry differs.
| Local, stdio | Remote, HTTP | |
|---|---|---|
| Where the process runs | on your machine, started by the client | on a host, running permanently (systemd, Docker) |
| What you put in the config | command + args + env | an address (httpUrl / url) + a token header |
| The project | must be on your machine | lives on the host, no local copy needed |
| When to choose it | you work alone | a team, CI or several machines need the same index |
A local server: command and args
Qwen Code, Cursor, VS Code, Claude Desktop, Windsurf — register both servers:
{
"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"
}
}
}
}How to read it:
"vue-codebase"and"vue-codebase-view"are the names under which the servers appear in the client. They are arbitrary; what matters is that you can tell them apart in the tool list."command"+"args"is the command the client runs to start the process.-yanswers "yes" to npm's question about downloading the package; without itnpxmay stop and wait for input nobody will give."env"holds the environment variables of that process. Here they replace command-line flags:VUE_CODEBASE_MCP_ROOTsets the root of the target project (like--root),VUE_CODEBASE_MCP_LANGthe answer language (like--lang). The full list and the precedence: Configuration.
The client's working directory does not matter: the project root comes from VUE_CODEBASE_MCP_ROOT, the --root flag, or the location of the configuration file — and the configuration search, the snapshot directory and the top-level documentation globs are all resolved from that root. The path must be absolute — ~/projects/app is not expanded. Since 0.1.2 the variable and the flag are fully equivalent; on the published 0.1.1 the variable moves only the indexing root, so pass --root in args until you upgrade.
To verify: restart the client and look at its tool list. You should see the indexer's 10 tools (search, get_entity_details, get_documentation, …) and the view server's 4 tools (preview_project, preview_component, preview_status, preview_stop). If the list is empty, read the server's stderr — see Troubleshooting.
A remote server: address and token
When the server runs on a host, you name its URL instead of a command. Qwen Code — .qwen/settings.json:
{
"mcpServers": {
"vue-codebase": {
"httpUrl": "https://mcp.internal.example/mcp",
"headers": { "Authorization": "Bearer <your token>" },
"timeout": 15000
}
}
}or with one command:
qwen mcp add --transport http vue-codebase https://mcp.internal.example/mcp \
--header "Authorization: Bearer <your token>"Cursor uses the key url instead of httpUrl. Claude Desktop and other stdio-first clients need a local bridge — for example npx mcp-remote <url> --header "Authorization: Bearer …". Keys differ between clients, so check their documentation.
Only the indexer can be remote: the view server has no HTTP transport, so the preview runs locally (through an SSH tunnel when necessary). How to start the server on a host and bring it to a working URL: Deployment.
A monorepo: why project has to be passed
A project (also called a workspace) is one root in the configuration: packages/ui-kit, apps/widget and so on. An ordinary repository has one project and the server picks it itself. A monorepo has several, and each one has its own vite.config, its own aliases and its own dependencies: you cannot start one preview "for the whole monorepo", only for a specific project. That is why the view server asks you to name it.
{ "name": "preview_project", "arguments": { "project": "ui-kit" } }This is not something you type by hand: it is a tool call that the assistant sends to the server over MCP. Saying it in plain language — "start the preview of the ui-kit project" — is enough, and the assistant fills in project itself. The project parameter exists on three of the four view-server tools (preview_project, preview_component, preview_stop; preview_status takes no parameters at all) and on most indexer tools: it narrows the answer down to one workspace.
Without a name the server refuses to guess. Real output on the playground/monorepo demo project:
[preview.ambiguousProject] The configuration describes several projects — pass "project" explicitly. Available: ui-kit, widgetThe message lists the real names — take one of them. A typo produces the neighbouring code [preview.projectNotFound]; in both cases the CLI exits with code 2 — "the project is not determined":
[preview.projectNotFound] Project "ui-kit2" is not in the configuration. Available: ui-kit, widgetThe indexer's tools answer [tools.unknownProject] in the same situation. How to describe several projects in .vue-codebase-mcp.json: Configuration.
Demo projects in this repository
The repository ships three playground projects that every example in this documentation is measured against. They are the fastest way to see both servers working without touching your own code:
cd playground/ui-library && npm install && cd ../.. # once per playground project
npx vue-codebase-mcp index --root playground/ui-library --mode full
npx vue-codebase-view-mcp preview --root playground/ui-library --open| Project | What it demonstrates | Index size |
|---|---|---|
playground/mini-widget | A small app with a router and Pinia stores. No configuration file — everything is auto-detected | 17 components, 2 composables, 2 stores, 6 routes, 5 utils, 4 documents |
playground/ui-library | A design system with a modular layout (ui/ + docs/ per component), namePrefixes, docMapping, and an _internal component that stays out of the index | 7 components, 2 composables, 3 utils, 10 documents |
playground/monorepo | npm workspaces: two projects (ui-kit, widget) in one index, and what "project" changes | 6 components, 1 composable, 1 store, 2 routes, 1 util, 4 documents |
Errors, exit codes and logs
Everything that can fail is reported the same way: a code plus a localized message. In tool answers and CLI output the format is [code] message, optionally followed by a hint in a separate paragraph:
[tools.indexEmpty] Nothing found for "button" (the index holds 0 entities).
Inspect the project composition with `list_entities` or rephrase the query.
The index is empty — there is nothing to search in. Check `components.locations` in the configuration and rebuild the index: `npx vue-codebase-mcp index --mode full`.In JSON (index --json) a diagnostic is an object, so scripts can switch on the code while humans read the message:
{ "code": "config.projectRootMissing", "params": { "root": "…" }, "message": "…" }Code families: config.* and index.* (building the index), tools.* (indexer tools), preview.* (view server tools and CLI), api.* (the preview HTTP API). Full lists: Indexer tools · View server tools.
Exit codes let CI distinguish outcomes:
| Command | 0 | 1 | 2 | 3 | 4 |
|---|---|---|---|---|---|
index | built, not empty | bad arguments / fatal error | project root not found, snapshot not written | index empty | — |
preview | running (Ctrl+C) | bad arguments / fatal error | project unknown, its root missing, or none selected in a monorepo | index empty — the server stops instead of serving an empty gallery | port unavailable (in use or privileged) |
Logs always go to stderr — stdout is occupied by the MCP protocol in serve mode. The level is set by MCP_LOG_LEVEL (error, warn, info by default, debug).
The browser interface has its own three failure states, and their texts also arrive pre-rendered in the manifest: a fatal error panel (Could not load the index from the preview server, The preview server sent a malformed manifest) with a Retry button, a render failure panel with a Stack trace disclosure and a Reload page button, and a hint after a few seconds of waiting — Loading is taking longer than usual. The manifest itself is validated twice: on the server before it is sent (500 [api.manifestInvalid]) and again in the browser. See View server.
Troubleshooting
Start with the log: add "MCP_LOG_LEVEL": "debug" to the server's env in the client configuration, restart the client, and read stderr. Most "the server does nothing" cases are visible there.
| Symptom | Cause | Fix |
|---|---|---|
| The client does not see the server | the command failed to start, or the path is not absolute | run npx vue-codebase-mcp version in a terminal; check that --root / VUE_CODEBASE_MCP_ROOT holds an absolute path |
| The server is connected but the session lists no tools | in Qwen Code, servers from a project .qwen/settings.json are approval-gated and silently never start; a new chat does not re-read the configuration either | qwen mcp approve --all from the project root, then restart the process — Developer: Reload Window, /exit + qwen, or qwen daemon restart. Full walkthrough: mcp-approval-troubleshooting.md |
| "Server is not responding", "invalid JSON" | something writes to stdout, or the process died at startup | MCP_LOG_LEVEL=debug and read stderr |
[tools.indexEmpty] | no snapshot and nothing matched the locations | npx vue-codebase-mcp index --root <path> --mode full; print the resolved config with config --root <path> |
[tools.unknownProject] | a workspace is named differently | the answer lists the real names; pass one as "project" |
[tools.entityNotFound] with suggestions | a typo or a missing design-system prefix | take a suggested name; prefixes are configured via components.namePrefixes |
[tools.pathOutsideRoots] / [tools.deniedPath] / [tools.extensionNotAllowed] | the path escapes the project, is forbidden, or has a disallowed extension | use a path inside the project; widen resources.allowedFileExtensions only deliberately |
[tools.sourceDisabled] | resources.exposeSourceCode: false | enable it, or ask for get_entity_details instead of sources |
Answers warn that types are unresolved (api: sfc-lite) | the index is light | npx vue-codebase-mcp index --mode full |
index exits with 2 | a typo in --root; the snapshot was not written | fix the path |
index exits with 3 | nothing matched | check components.locations |
preview exits with 4 | the port is taken or below 1024 | pass another --port, or omit it and let Vite choose |
[preview.portInUse] / [preview.portDenied] | the same, reported by the tool | stop the other server or choose a port above 1024 |
[preview.vueMissing] | the target project has no vue installed | npm install vue in that project |
| The preview page is blank | the manifest did not arrive, or rendering failed | read the panel text and the server log; check index.mode in /__vue-view__/api/manifest |
An answer says api: sfc-lite and snapshot stale | the file changed after the snapshot was built: the watcher re-read it with the syntactic parser, so type resolution is out of date | re-run index --mode full or restart the server |
| An answer is in the wrong language | the resolution order picked another source | --lang wins over VUE_CODEBASE_VIEW_MCP_LANG, VUE_CODEBASE_MCP_LANG and language in the config — see Language |
Component catalog skill
The repository ships an agent skill that does the whole routine at once: it checks the environment, connects the servers, asks which components to read, collects their API, usages, dependencies and documentation through the MCP tools, and writes one catalog file — COMPONENTS.md or a JSON summary — usable both as assistant context and as a team reference.
# inspect the environment: snapshot, mode, counters, freshness
node skills/vue-codebase-collector/scripts/collect.mjs check --root /path/to/project
# collect every component (25 per run by default) into a catalog file
node skills/vue-codebase-collector/scripts/collect.mjs collect --root /path/to/project --select all --out COMPONENTS.mdIt lives in skills/vue-codebase-collector/ (SKILL.md plus a dependency-free Node script) and can be copied into .qwen/skills/, ~/.qwen/skills/ or .claude/skills/. Selection accepts names, globs and all; a monorepo workspace is passed with --project. Typos are resolved with the server's own suggestions, and the report states what did not fit — the limit, truncated answers, light mode without exact types. The full key list and the step-by-step procedure the agent follows: skills/vue-codebase-collector/SKILL.md.
Glossary
The same words are used with the same meaning across both packages, the tools' answers and this site:
| Term | Meaning |
|---|---|
| Entity | A component, composable, Pinia store, route or utility in the index |
| Index | The in-memory model of the project that every tool answers from |
| Snapshot | The index serialised to .vue-codebase-mcp.cache/index.json by the index command |
full / light | Indexing mode: with type resolution (vue-component-meta + a TS program) or syntactic parsing only |
apiSource | Where an entity's API came from: vue-component-meta, typescript, sfc-lite, syntax |
stale | The file was edited after the snapshot was built |
| Project (workspace) | One root in the configuration; a monorepo has several, and tools accept "project" to narrow the scope |
| Document level | component, workspace, collection or project — determines the doc:// URI and the linking priority |
| Preview | The view server's Vite dev server, served under /__vue-view__ |
Where to go next
- What is MCP — client, server, tool and resource, explained without jargon
- Quick Start — install, index, connect, first request, browser preview, with real outputs
- Tools — the overview; Indexer tools and View server tools in detail
- Recipes — eight real tasks and the calls that answer them
- Configuration —
.vue-codebase-mcp.jsonfor an app, a UI library or a monorepo - View Server — the four interface modes, the HTTP API and the manifest
- Deployment — running the indexer on a host over HTTP
- About the Project — the detailed story: indexing modes, doc linking, ranked search, i18n