Skip to content

fix(plugin): start the installed clawdcursor without npx wrapper processes - #491

Open
AmrDab wants to merge 1 commit into
mainfrom
fix/plugin-no-npx-chain
Open

AmrDab wants to merge 1 commit into
mainfrom
fix/plugin-no-npx-chain

Conversation

@AmrDab

@AmrDab AmrDab commented Nov 29, 2026

Copy link
Copy Markdown
Owner

What

The Claude Code plugin starts its MCP server through scripts/plugin-mcp.cjs instead of npx -y clawdcursor@<pin>. When the pinned version is already on disk, the launcher loads it in its own process, so there are no wrapper processes. Either a global install or an npx cache entry counts. Otherwise it runs npx exactly as before.

Why

npx stays alive above the server for the whole session:

  • Windows: cmd.exe → npx node → cmd.exe → server.
  • macOS: an npm exec node above the server.

Measured on one Windows PC with 11 open Claude sessions: 33 wrapper processes, 323 MB. The npx node alone grows to ~95 MB after use. On the Mac: one npm exec wrapper per session. npx also checks the registry at every session start.

How

  • plugin.json: "command": "node", "args": ["${CLAUDE_PLUGIN_ROOT}/scripts/plugin-mcp.cjs", "clawdcursor@2.3.0", "mcp", "--compact"]. The clawdcursor@X.Y.Z literal is unchanged, so sync-version still bumps it; --check passes.
  • Lookup order: the clawdcursor launcher on PATH (on macOS/Linux via realpath, which covers Homebrew), then %APPDATA%\npm\node_modules, then the two layouts next to the node binary, then <npm cache>/_npx/*/node_modules.
  • Match: only an exact name and version match counts, the same pin semantics as npx. The CLI comes from the package's bin.clawdcursor.
  • Found: it sets process.argv = [execPath, cli, ...args], then require(cli). The CLI reads its args by script path (userArgs), so it sees mcp --compact.
  • Not found: it spawns npx -y clawdcursor@<pin> ... with inherited stdio, forwards SIGINT/SIGTERM, and passes through the exit code.
  • stdout: never written to, because it is the MCP channel.
  • npm package: unchanged. The plugin runs from the repo checkout (marketplace source ./).

Tests

  • tests/plugin-mcp.test.ts: the resolver against temp layouts (npx cache, Windows global next to the PATH shim, next to node, wrong version or name, nothing found).
  • tests/plugin-mcp.system.test.ts: spawns the launcher against a fake pinned package in a temp npx cache. It asserts the CLI ran in the SAME pid with argv ['mcp','--compact'], and it fails if the launcher spawns a child.
  • typecheck, typecheck:tests, lint (0 errors, the 3 warnings as on main), npm run test:ci: 4303 passed, 80 skipped, 0 failed.
  • Real host: claude --plugin-dir <this branch> mcp list → plugin:clawdcursor:clawdcursor: node …/scripts/plugin-mcp.cjs clawdcursor@2.3.0 mcp --compact - ✔ Connected. That loaded the published 2.3.0 global install in-process, and Claude Code expands ${CLAUDE_PLUGIN_ROOT}.
  • MCP initialize: run through the launcher against this branch's build, it answers with 6 tools.

Check before release

The claude.ai account plugin is also run by the Claude app itself, outside Claude Code: chat on Windows and macOS. Confirm the server still starts there, i.e. that ${CLAUDE_PLUGIN_ROOT} is expanded. I haven't tested that host.

The npx fallback on Windows uses shell: true (Node 20+ refuses to spawn .cmd files without a shell). Arguments with spaces or cmd metacharacters are quoted, and the plugin's own args contain neither. That path isn't covered by a test.

No release: for the 2.4 train.

🤖 Generated with Claude Code

…esses

The plugin launched the MCP server through npx, which kept 2-3 wrapper
processes (cmd.exe/sh and an npm-exec node) alive per session and checked
the registry at every start. plugin.json now runs scripts/plugin-mcp.cjs,
which finds an installed clawdcursor of the exact pinned version (global
install, node prefix, or npx cache) and loads its CLI in the same process.
When none is on disk it runs `npx -y clawdcursor@<pin>` as before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
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.

1 participant