Skip to content

Use project directory name as MCP server name in monorepos#43

Open
20syldev wants to merge 1 commit into
antfu:mainfrom
20syldev:fix/monorepo-server-name-collision
Open

Use project directory name as MCP server name in monorepos#43
20syldev wants to merge 1 commit into
antfu:mainfrom
20syldev:fix/monorepo-server-name-collision

Conversation

@20syldev
Copy link
Copy Markdown

@20syldev 20syldev commented Apr 9, 2026

Problem

In a monorepo with multiple Nuxt apps, every dev server writes its MCP entry under the same key ("nuxt") in .cursor/mcp.json, .vscode/mcp.json, and .mcp.json. Starting app B overwrites app A's entry, leaving only one server registered at a time.

Fix

Derive updateConfigServerName from the project's root directory basename instead of hardcoding 'nuxt':

- updateConfigServerName: 'nuxt',
+ const defaultServerName = `nuxt-${basename(nuxt.options.rootDir)}`
+ // ...
+ updateConfigServerName: defaultServerName,

Result for a monorepo with apps/web and apps/admin:

{
  "mcpServers": {
    "nuxt-web":   { "url": "http://localhost:3000/__mcp/sse" },
    "nuxt-admin": { "url": "http://localhost:3001/__mcp/sse" },
    "nuxt-docs":  { "url": "https://nuxt.com/mcp" }
  }
}

Each app gets its own stable key. Users can still set updateConfigServerName explicitly in nuxt.config to override the default.

Fixes #31

In a monorepo with multiple Nuxt apps, every app was writing its MCP
entry under the same key ('nuxt') in .cursor/mcp.json, .vscode/mcp.json
and .mcp.json.  Each new dev server start would overwrite the previous
app's entry, leaving only one server registered.

Derive the default updateConfigServerName from the project's root
directory basename (e.g. 'nuxt-app-web', 'nuxt-app-admin') so that
each app gets its own stable key.  Users can still set
updateConfigServerName explicitly in their nuxt.config to choose a
custom name.

Fixes antfu#31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MCP json file over-written with a new nuxt mcp object when multiple Nuxt servers are started in a monorepo setup

1 participant