fix(mcp): only derive a package from the manager's executor subcommand - #34
Open
alexviktorov wants to merge 1 commit into
Open
alexviktorov wants to merge 1 commit into
alexviktorov wants to merge 1 commit into
Conversation
alexviktorov
force-pushed
the
fix/mcp-run-script-detection
branch
from
May 27, 2026 19:18
a600a96 to
b05327c
Compare
Author
|
@adel-pplx Let me know if you need any context on this. Basically after scanning my Mac I saw several records listing "start" as the package, where it's evidently a command. Specifically it was for some Claude official plugins. This PR fixes the discrepancy and instead you get the actual names, similar to other places in code. Tested on my local config and generated synthetic unit tests from real world examples. Thank you! |
alexviktorov
force-pushed
the
fix/mcp-run-script-detection
branch
from
July 5, 2026 06:52
b05327c to
189cd77
Compare
MCP servers launched through a package-manager script runner leaked the script or file name as the package. The official Claude messaging plugins use `bun run … start` and were recorded as package_name "start" — a real npm package, so an advisory for it would spuriously match. `bun server.ts` / `bun run src/index.ts` leaked the file path, and bare `yarn dev` / `pnpm build` leaked the script name the same way. The parser already handles this for uv: `uv run <script>` without --from yields no package identity and the record falls back to the server id at low confidence. Apply the same rule to the npm family, per manager: only `npm exec`/`npm x`, `pnpm dlx`, `yarn dlx` and `bun x` (or the separate npx/bunx) fetch and run a published package. `exec` under pnpm, yarn and bun runs a local bin or a shell command, so it is not an executor there (`yarn exec node dist/index.js` must not become the package "node"). Every other first token — `run <script>`, lifecycle aliases, bare scripts, files, create/init — returns no spec. Executor launches are unchanged: --package, the -- terminator and credential-bearing value flags keep their identity. Trade-off: a bare `yarn <installed-bin>` also falls back to the server id, the same conservative choice as `uv run`. Updates the inferPackageFromArgs doc comment and docs/inventory-sources.md; adds unit rows and corpus entries that fail on main with the leaked values.
alexviktorov
force-pushed
the
fix/mcp-run-script-detection
branch
from
September 15, 2026 20:32
189cd77 to
cea5055
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
For
npm/pnpm/yarn/bun, derive a package identity only from the manager'spackage executor:
npm exec/npm x,pnpm dlx,yarn dlx,bun x(or the separatenpx/bunx). Any other first token runs a local script, file, or binary, so it yieldsno spec and the record falls back to the server id at
confidence=low— the same rule theparser already applies to
uv run <script>.Bug
MCP servers launched through a script runner had the script or file name recorded as the
package. The
claude-plugins-officialmessaging plugins launch their bundled server with{ "command": "bun", "args": ["run", "--cwd", "${CLAUDE_PLUGIN_ROOT}", "--shell=bun", "--silent", "start"] }and a
baselinescan of a machine with them installed recordspackage_name="start"fordiscord,imessage,telegramandfakechat.startis a real npm package, so a catalogentry for it would spuriously match. The same leak shows up as:
mainrecordsbun run … startstartbun server.ts/bun run src/index.tsserver.ts/src/index.tsyarn devdevyarn exec node dist/index.js,pnpm exec node …node(a real npm package)execfetches a published package only under npm. pnpmexecruns a locally installed bin,and yarn/bun
execrun a shell command, so it is not an executor there — hence aper-manager
packageExecutorstable rather than one shared subcommand set.Evidence
The new unit rows and corpus entries fail on
mainwith the leaked values (13 rows, 5 entries):Package executors are unchanged:
npx/bunx,--package, the--terminator andcredential-bearing value flags keep their identity (existing tests, plus a new
--registry … exec @scope/pkgrow).Trade-off, pinned in a test: a bare
yarn <installed-bin>also falls back to the server id.The scanner cannot tell a script from a bin without reading
package.json, and alow-confidence server id beats a wrong package guess.
Files
internal/ecosystem/mcp/mcp.go(per-managerpackageExecutors, doc comment),internal/ecosystem/mcp/mcp_test.go,docs/inventory-sources.md. Rebased on currentmain;go build,go vet,gofmt -l,go test -race ./...andbumblebee selftestpass.