inspector icon indicating copy to clipboard operation
inspector copied to clipboard

fix: declare commander as a direct dependency (#873)

Open NishchayMahor opened this issue 6 months ago • 0 comments

Closes #873.

What's wrong

The top-level `@modelcontextprotocol/inspector` package ships `cli/build/cli.js` as its `bin` (it's in the published `files` list). That file imports `commander` at runtime, but `commander` was only declared on the sibling `@modelcontextprotocol/inspector-cli` workspace package.

Under npm, the package resolves fine because npm flat-hoists `commander` to the top of `node_modules`. Under pnpm and other strict installers there's no hoisting, so users hit:

``` Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'commander' imported from node_modules/.pnpm/@[email protected]_.../node_modules/@modelcontextprotocol/inspector/cli/build/cli.js ```

What this PR does

Adds `"commander": "^13.1.0"` to the top-level `package.json` so the published bin script can resolve its runtime imports regardless of which installer (or hoisting strategy) the user has chosen. This is Option 1 from the issue, kept narrow so the rest of the publishing layout is unchanged.

I audited the rest of `cli/src/*.ts` for external imports. The only non-Node runtime packages it pulls are:

  • `commander` (this PR)
  • `@modelcontextprotocol/sdk` (already a top-level dep)
  • `spawn-rx` (already a top-level dep)

`express` is in `cli/package.json` but only used in `cli/tests/helpers/test-server-http.ts`, so it doesn't need to be hoisted to the published top-level.

Lockfile

I left `package-lock.json` alone in this PR because the project's CI runs `npm install --no-package-lock` and a fresh `npm install --package-lock-only` on my machine produced a noisy diff (~60 unrelated `peer: true` toggles from npm normalising my local resolution). Happy to fold a clean lockfile bump into the same commit if you'd prefer, just let me know.

NishchayMahor avatar May 28 '26 19:05 NishchayMahor