Bug
The CLI (--cli mode) is completely broken from v0.17.0 through v0.22.0 (latest). Every npx @modelcontextprotocol/inspector@0.17+ --cli ... invocation fails immediately with ERR_MODULE_NOT_FOUND.
Error
Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/root/.npm/_npx/<hash>/node_modules/@modelcontextprotocol/inspector/cli/package.json' imported from '/root/.npm/_npx/<hash>/node_modules/@modelcontextprotocol/inspector/cli/build/index.js'
Did you mean to import "../../../../../../../../package.json"?
Root cause
cli/build/index.js (added in v0.17.0) contains:
import packageJson from "../package.json" with { type: "json" };
This resolves to cli/package.json, but the published package's files field is:
"files": ["client/bin", "client/dist", "server/build", "cli/build"]
cli/package.json is not in the files array, so it's not included in the published npm tarball. The import fails at startup.
Versions tested
| Version |
Status |
| 0.16.8 |
✅ Works (no package.json import in cli/build/index.js) |
| 0.17.0 |
❌ Broken (import packageJson from "../package.json" added) |
| 0.18.0 |
❌ Broken |
| 0.19.0 |
❌ Broken |
| 0.20.0 |
❌ Broken |
| 0.21.0 |
❌ Broken |
| 0.21.2 |
❌ Broken |
| 0.22.0 |
❌ Broken |
Reproduction
# Works (v0.16.8):
npx @modelcontextprotocol/inspector@0.16.8 --cli https://example.com/mcp --transport http --method tools/list
# Fails (v0.17.0+):
npx @modelcontextprotocol/inspector@0.17.0 --cli https://example.com/mcp --transport http --method tools/list
Fix options
Option A (smallest diff): Add "cli/package.json" to the files array in the root package.json:
"files": ["client/bin", "client/dist", "server/build", "cli/build", "cli/package.json"]
Option B: Change the import to reference the root package.json:
import packageJson from "../../package.json" with { type: "json" };
Option A is preferable because it doesn't change the import path and keeps the cli/ directory self-contained.
Environment
- Node.js v22.22.1
- npm 10.9.4
- Linux x86_64
- Tested via
npx (clean cache, no global install)
Bug
The CLI (
--climode) is completely broken from v0.17.0 through v0.22.0 (latest). Everynpx @modelcontextprotocol/inspector@0.17+ --cli ...invocation fails immediately withERR_MODULE_NOT_FOUND.Error
Root cause
cli/build/index.js(added in v0.17.0) contains:This resolves to
cli/package.json, but the published package'sfilesfield is:cli/package.jsonis not in thefilesarray, so it's not included in the published npm tarball. The import fails at startup.Versions tested
package.jsonimport incli/build/index.js)import packageJson from "../package.json"added)Reproduction
Fix options
Option A (smallest diff): Add
"cli/package.json"to thefilesarray in the rootpackage.json:Option B: Change the import to reference the root
package.json:Option A is preferable because it doesn't change the import path and keeps the
cli/directory self-contained.Environment
npx(clean cache, no global install)