inspector icon indicating copy to clipboard operation
inspector copied to clipboard

Phantom dependencies in `@modelcontextprotocol/inspector`

Open nick-pape opened this issue 2 months ago • 0 comments

Inspector Version

  • 0.17.1

Describe the bug When using a stricter package installer, such as pnpm, all dependencies that are directly imported by a package must be in their package.json. Packages which are not listed, but are imported are called "phantom dependencies". These work with npm because it hoists everything to the top level of node_modules, but with strict package managers like pnpm, we only get symlinks for things that are actually declared.

There's probably a couple of these, but right off the bat, I get an error:

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

Fix:

Option 1)

Add commander (and all dependencies used by repo) to top-level package.json

"commander": "^13.1.0"

Option 2)

Alternately, consider publishing @modelcontextprotocol/mcp-inspector from a different package, that takes dependencies on cli, server, etc. Rather than publishing copies of their code in this package (and also taking dependencies on them).

Option 3)

I think the actual root of the issue is the bin:

"bin": {
  "mcp-inspector": "cli/build/cli.js"
},

This reaches into the cli folder, when it probably should instead utilize the bin that gets installed as part of the cli. e.g. something like:

"bin": {
  "mcp-inspector": "node_modules/bin/mcp-inspector-cli"
},

To Reproduce Steps to reproduce the behavior:

  1. pnpm install @modelcontextprotocol/mcp-inspector
  2. mcp-inspector

Expected behavior mcp-inspector should resolve all dependencies.

Screenshots If applicable, add screenshots to help explain your problem.

Environment (please complete the following information):

  • OS: [e.g. iOS]
  • Browser [e.g. chrome, safari]

Additional context Add any other context about the problem here.

nick-pape avatar Oct 16 '25 13:10 nick-pape