Built-in MCP servers fail in pnpm repos because Claude Code launches them via npx from the project cwd
Resolved 💬 3 comments Opened Mar 24, 2026 by dmallory42 Closed Mar 28, 2026
Description
Bug Description
In a pnpm monorepo, npm reads the local package.json and .npmrc, sees that the repo requires pnpm, and exits before the MCP package starts.
This affects built-in MCP servers such as:
context7chrome-devtools
Environment Details
- Host OS: macOS
- Node:
v22.18.0 - npm /
npx:10.9.3 - Repo package manager:
pnpm
Repo configuration:
Root package.json contains:
{
"devEngines": {
"runtime": {
"name": "node",
"onFail": "error"
},
"packageManager": {
"name": "pnpm",
"onFail": "error"
}
},
"engines": {
"node": ">=22.18.0",
"pnpm": ">=10.16.0"
},
"packageManager": "pnpm@10.18.0+sha512..."
}
Root .npmrc contains:
engine-strict=true
Steps to Reproduce
- Open a repo whose root
package.jsondeclarespackageManager: "pnpm@...". - Add
devEngines.packageManager = { "name": "pnpm", "onFail": "error" }. - Set
engine-strict=truein.npmrc. - From that repo root, run:
npx -y cowsay hi
- Observe that npm exits before the package runs.
- In Claude Code, open the same repo and try to use a built-in MCP plugin server that is launched via
npx.
Actual Behavior
The process fails with:
npm error code EBADDEVENGINES
npm error EBADDEVENGINES The developer of this package has specified the following through devEngines
npm error EBADDEVENGINES Invalid engine "packageManager"
npm error EBADDEVENGINES Invalid name "pnpm" does not match "npm" for "packageManager"
npm error EBADDEVENGINES {
npm error EBADDEVENGINES current: { name: 'npm', version: '10.9.3' },
npm error EBADDEVENGINES required: { name: 'pnpm', onFail: 'error' }
npm error EBADDEVENGINES }
Built-in MCP servers do not start.
Expected Behavior
Built-in MCP servers should start regardless of the current project's package-manager policy.
Why this seems to be a Claude Code bug
- The repo configuration is valid for a pnpm monorepo.
- npm is behaving consistently when invoked from that cwd.
- The failure only happens because Claude Code appears to start built-in MCP servers via
npxfrom the target repo directory.
That makes tool startup depend on the app repo's package-manager constraints, which seems like the wrong isolation boundary.
Workarounds
The following workarounds avoid the failure:
- Override the built-in MCP servers with explicit project/user MCP config that uses
pnpminstead ofnpx. - Launch the MCP server from a neutral working directory such as
/tmp. - Use a wrapper script that
cds out of the repo before starting the server. - Install the MCP server package in a stable user-level location and invoke it directly.
Suggested Fix
Any of these would address the problem:
- Launch built-in MCP servers from a neutral cwd such as a temp/cache directory.
- Avoid
npxfor built-in MCP startup and use a dedicated Claude-managed install/cache path. - Detect
packageManager/devEnginesincompatibility in the current repo and automatically switch launch strategies.
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗