mcp-server-nuxt
v0.9.2MCP server for Nuxt projects — exposes routes, components, config, and more to AI agents
Give your AI agent Nuxt's resolved view of a project: routes, layouts, middleware, auto-imports, layers, and Nitro endpoints.No dev server. No nuxi prepare. An agent asking explain_route what happens when someone opens /users/42. Add this to .cursor/mcp.json (Cursor), .mcp.json (Claude Code), or your client's MCP config:
Summary extracted from the README.
Quick start
Add this to .cursor/mcp.json (Cursor), .mcp.json (Claude Code), or your client's MCP config:
{
"mcpServers": {
"nuxt": {
"command": "npx",
"args": ["-y", "mcp-server-nuxt@latest", "/absolute/path/to/your/nuxt/app"]
}
}
}
Restart your client and ask something like:
What happens when someone opens /users/42?
Requirements: Node.js 18+, macOS or Linux. Write tools stay in dry-run mode until you enable writes.
Why
A generic agent sees a Nuxt repo as a folder tree. It doesn't know that:
pages/users/[id].vueserves/users/:id, and which layout and middlewaredefinePageMetaaddscomponents/base/BaseButton.vueis usable as<BaseButton>with no importcomposables/useFoo.tsmakesuseFoo()available everywhereextends: ['../ui-kit']layers components, pages, and config over your appserver/api/hello.get.tsregistersGET /api/hello
So it guesses, and invents import paths, misnames components, and misreads layer precedence. mcp-server-nuxt reads Nuxt's own config loader and .nuxt/ output (with a source-level fallback) and hands the agent the real answers through 34 tools and 7 read-only resources.
It runs as a standalone CLI, so it works on a freshly cloned repo before anyone has installed dependencies or started npm run dev.
Highlight: explain_route
Most tools tell you which routes exist. explain_route tells you what actually happens for one real URL.
// input
{ "route": "/users/42" }
// output (abridged)
{
"matched": true,
"page": { "file": "pages/users/[id].vue", "pattern": "/users/:id", "params": { "id": "42" } },
"parents": [{ "file": "pages/users.vue", "pattern": "/users" }],
"layout": { "name": "default", "file": "layouts/default.vue" },
"middleware": [
{ "name": "logger", "type": "global", "file": "middleware/logger.global.ts" },
{ "name": "auth", "type": "named", "file": "middleware/auth.ts" }
],
"dataFetching": [
{ "composable": "useFetch", "keyOrUrl": "/api/hello", "line": 4, "file": "pages/users/[id].vue" }
],
"serverRoutes": [{ "url": "/api/hello", "file": "server/api/hello.get.ts", "method": "GET" }]
}
Middleware comes back in run order (global first, then named), catch-all params come back as arrays, and an unmatched URL returns suggestions.
Tools
| Tool | What it does |
|---|---|
explain_route |
Resolve one URL: page, parents, layout, middleware order, data fetching, /api files, render mode |
explain_middleware |
Middleware type (global/named/inline), alphabetical global run order, routes it applies to, navigateTo/abortNavigation, missing page references |
explain_render_mode |
Resolve a URL's Nitro render mode from routeRules (ssr/spa/prerender/isr/swr/static) |
list_routes |
All routes: dynamic, optional, catch-all, nested |
get_route |
One route by pattern, e.g. /users/:id |
inspect_route_meta |
definePageMeta, layout, middleware, props/emits/slots of a page |
add_route ✏️ |
Scaffold a page under pages/ |
| Tool | What it does |
|---|---|
list_server_routes |
Endpoints, server middleware, and plugins with method and middleware chain |
find_api_callers |
Find every caller of a server route (useFetch / $fetch / useAsyncData($fetch)) by file path or URL |
explain_data_fetching |
List useFetch / useLazyFetch / useAsyncData / $fetch calls with URL or key, method and options; flag duplicate keys, $fetch in onMounted, bare setup await $fetch, server: false without lazy, and missing pending checks |
scaffold_nitro_api ✏️ |
Generate an H3 handler with optional Zod body validation |
| Tool | What it does |
|---|---|
list_components |
Components from .nuxt/components.d.ts, or from components / components.dirs config |
find_usages |
Find every file using a component/composable (imports, auto-imports, Lazy, kebab-case), or list unused ones |
explain_injections |
Trace Nuxt plugin injections: where $name comes from, which files reference it, multiple providers, unresolved third-party names |
inspect_component |
Props, emits, and slots of one component |
generate_component ✏️ |
Generate a typed Vue SFC |
list_composables |
User-defined and auto-imported composables |
generate_composable ✏️ |
Scaffold a typed useXxx composable |
get_auto_imports |
Auto-import registry with source paths and signatures |
get_type_info |
Generated type info (.nuxt/types, schema) |
| Tool | What it does |
|---|---|
get_project_overview |
Nuxt version, layers, directories, and counts |
analyze_project |
Health check with dependency warnings and prepare hints |
check_nuxt4_migration |
Check a Nuxt project against the official Nuxt 4 upgrade guide: version, app/ structure, data-fetching defaults, removed APIs/options, readiness summary |
read_config |
Resolved nuxt.config from the project's own @nuxt/kit when Nuxt is installed, otherwise a source parse. Filterable by dot path |
update_config ✏️ |
Change a config value, keeping comments, and return a diff |
list_modules |
Installed modules with version, source, and options |
add_nuxt_module ✏️ |
Add a module to modules |
inspect_layers |
The full extends hierarchy in precedence order |
check_runtime_config |
Flatten runtimeConfig keys with NUXT_* env vars, scan useRuntimeConfig() use, flag undefined/unused keys and private keys read in client code |
| Tool | What it does |
|---|---|
check_type_errors |
Run tsc --noEmit against .nuxt/tsconfig.json |
analyze_bundle_deps |
Flag missing or misplaced dependencies |
search_code |
Search the codebase with line numbers and context |
check_ssr_safety |
Flag SSR hazards: browser globals at setup/module scope, non-deterministic values in templates and computed, shared composable state |
get_nuxt_docs |
Offline Nuxt guidance for routing, Nitro, modules, layers |
✏️ = write tool, dry-run by default. Full mapping: docs/SPEC_MATRIX.md.
Resources
Large, cacheable context is served as read-only resources so the agent doesn't re-scan files every turn.
| URI | Content |
|---|---|
nuxt://project/overview |
Nuxt version, layers, directories, counts |
nuxt://project/routes |
Route map with files, params, middleware, layouts, children |
nuxt://project/config |
Resolved nuxt.config via the project's @nuxt/kit, with a source-level fallback |
nuxt://project/modules |
Modules with status, source, and options |
nuxt://project/layers |
Layer hierarchy with override order (project > layers/* > earlier extends > later extends) |
nuxt://project/auto-imports |
Auto-imported symbols with source paths and signatures |
nuxt://project/types |
Raw generated types |
auto-imports and types need .nuxt/ to exist (nuxi prepare or a build). Everything else falls back to reading source.
Write protection
add_route, scaffold_nitro_api, generate_component, generate_composable, update_config, and add_nuxt_module all work the same way:
- They default to
dryRun: trueand return the planned file or diff without touching disk. - A real write needs
dryRun: falseand a server started with writes enabled. - Config edits only touch the affected lines and always return a diff.
{
"mcpServers": {
"nuxt": {
"command": "npx",
"args": ["-y", "mcp-server-nuxt@latest", "/absolute/path/to/your/nuxt/app"],
"env": { "MCP_NUXT_ALLOW_WRITES": "1" }
}
}
}
Or on the command line: mcp-server-nuxt /absolute/path/to/app --allow-writes.
Client setup
The JSON in Quick start works for Cursor, Claude Code, Claude Desktop, and Windsurf. Always pass an absolute project path, since MCP clients often start servers with an undefined working directory.
| Client | File |
|---|---|
| Cursor | .cursor/mcp.json in the project, or ~/.cursor/mcp.json |
| Claude Code | .mcp.json in the project, or Claude Code settings |
| Claude Desktop (macOS) | ~/Library/Application Support/Claude/claude_desktop_config.json (strict JSON, no comments) |
| Windsurf | Cascade → MCP settings |
VS Code uses servers instead of mcpServers. In .vscode/mcp.json:
{
"servers": {
"nuxt": {
"command": "npx",
"args": ["-y", "mcp-server-nuxt@latest", "--project", "/absolute/path/to/your/nuxt/app"]
}
}
}
npx -y mcp-server-nuxt@latest /absolute/path/to/app
pnpm dlx mcp-server-nuxt@latest /absolute/path/to/app
bunx mcp-server-nuxt@latest /absolute/path/to/app
npm install -g mcp-server-nuxt
mcp-server-nuxt --help
The project path can be passed positionally or with --project. Omit it to use the current directory. The server speaks MCP over stdio; it is not a web service.
FAQ
How is this different from DevTools-style Nuxt MCP servers?
Those attach to a running dev server, so the agent sees nothing until npm run dev is up. mcp-server-nuxt is a standalone CLI that reads the project directly, so it works on a fresh clone, in CI, or anywhere the app isn't running.
Does it support Windows? Not officially yet. It's tested on macOS and Linux.
Contributing
Pull requests are welcome.
git clone https://github.com/rynx-cc/mcp-server-nuxt.git
cd mcp-server-nuxt
npm install
npm run typecheck && npm test && npm run build
- Use Conventional Commits (
feat:,fix:,chore:). - Add tests under
tests/for new tools and resources. - Keep
@nuxt/kitoptional; every integration needs a fallback. Resolved config loads Kit from the target project'snode_modulesfirst (Kit 3 for Nuxt 3, Kit 4 for Nuxt 4), then this package's optional Kit 3, then the source parser. Kit errors are logged to stderr. - Write tools default to dry-run and go through
WriteGuard.