Skip to content

fix: skip npx prefix for globally installed binaries in MCP registration#115

Open
franklad wants to merge 3 commits intowevm:mainfrom
franklad:fix/mcp-global-binary-detection
Open

fix: skip npx prefix for globally installed binaries in MCP registration#115
franklad wants to merge 3 commits intowevm:mainfrom
franklad:fix/mcp-global-binary-detection

Conversation

@franklad
Copy link
Copy Markdown
Contributor

@franklad franklad commented Apr 8, 2026

Summary

  • When a CLI is installed globally (npm i -g), MCP registration now detects that process.argv[1] is outside node_modules/ and registers the bare command name (e.g. my-cli --mcp) instead of wrapping it in npx unnecessarily
  • Replaces naive command.split(' ') in registerAmp with a quote-aware tokenizer so paths containing spaces (e.g. "/path/to my/cli" --mcp) split correctly
  • Consolidates the node_modules/ heuristic into a single nodeModulesRoot() helper shared by both register() and detectPackageSpecifier()

Test plan

  • New test: global binary install produces my-cli --mcp (no runner prefix)
  • New test: node_modules install still produces npx my-cli --mcp
  • New test: quoted command paths with spaces split correctly into command + args
  • All 16 existing + new tests pass

When a CLI is installed globally (e.g. `npm i -g`), `process.argv[1]`
resolves outside `node_modules/`. The MCP registration now detects this
and registers the bare command name instead of wrapping it in npx/pnpx/bunx.

Also replaces naive `command.split(' ')` in registerAmp with a
quote-aware tokenizer so command paths containing spaces are handled
correctly.
@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Apr 8, 2026

Open in StackBlitz

npm i https://pkg.pr.new/incur@115

commit: 0cb0a0e

Replace duplicate node_modules/ regex checks with a single
nodeModulesRoot() helper that returns the path prefix or null.
Both register() and detectPackageSpecifier() now call the same function.
@franklad franklad force-pushed the fix/mcp-global-binary-detection branch from 418d75f to 2938f99 Compare April 8, 2026 14:56
CI uses pnpm so detectRunner() returns pnpx, not npx. Match any
valid runner (npx, pnpx, bunx) instead of hardcoding npx.
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 8, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (main@72edc87). Learn more about missing BASE report.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #115   +/-   ##
=======================================
  Coverage        ?   93.03%           
=======================================
  Files           ?       23           
  Lines           ?     2857           
  Branches        ?     1159           
=======================================
  Hits            ?     2658           
  Misses          ?      166           
  Partials        ?       33           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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