Skip to content

fix: declare bundled runtime dependencies for strict package managers#1144

Open
herakles-dev wants to merge 1 commit into
modelcontextprotocol:mainfrom
herakles-dev:fix/phantom-dependencies
Open

fix: declare bundled runtime dependencies for strict package managers#1144
herakles-dev wants to merge 1 commit into
modelcontextprotocol:mainfrom
herakles-dev:fix/phantom-dependencies

Conversation

@herakles-dev

@herakles-dev herakles-dev commented Mar 13, 2026

Copy link
Copy Markdown

Summary

Adds the five runtime dependencies the root package's bundled code imports but doesn't
declare, so the Inspector installs and runs under strict package managers (pnpm hoist=false,
Yarn PnP). Rebased on v1.0.0.

Type of Change

  • Bug fix (non-breaking change that fixes an issue)

Changes Made

The root package ships the built cli/server/client output via the files field and runs
it through the mcp-inspector bin. Those bundled files import commander, cors, express,
express-rate-limit, and serve-handler, but root package.json doesn't declare them — they
only resolve because pnpm hoists by default. Under hoist=false or Yarn PnP the bin fails with
ERR_MODULE_NOT_FOUND (#873, also hit via pnpm dlx in #1513).

This adds those five to root dependencies at the ranges the workspace packages already use.
ws and ajv/ajv-formats are left out on purpose — ws is only reached through the SDK, and
ajv/ajv-formats are bundled into the client's Vite build, not resolved at runtime. The
lockfile change is mechanical: the five edges plus commander re-homing to 13.x at the root (the
cli package already pinned ^13.1.0; lint-staged keeps its own 14.x nested copy).

Related Issues

Fixes #873. Related: #1513.

Testing

  • Manual testing performed

Test Results and/or Instructions

Packed the root package and installed the tarball into a fresh project with .npmrc set to
hoist=false (strict resolution):

  • Before: node node_modules/@modelcontextprotocol/inspector/cli/build/cli.js --help
    Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'commander'
  • After: the same command prints usage, and the server module loads and reaches
    "Proxy server listening".

npm ci validates against the regenerated lockfile.

Checklist

  • Code follows the style guidelines (ran npm run prettier-fix)
  • Self-review completed
  • Code is commented where necessary
  • Documentation updated (README, comments, etc.)

Breaking Changes

None.

Additional Context

The root package bundles cli/server/client build output via `files` and runs it
through the mcp-inspector bin, but does not declare the runtime deps those bundled
files import (commander, cors, express, express-rate-limit, serve-handler). They
only resolve under default pnpm hoisting; strict resolvers (pnpm hoist=false, Yarn
PnP) fail with ERR_MODULE_NOT_FOUND.

Fixes modelcontextprotocol#873.
@herakles-dev
herakles-dev force-pushed the fix/phantom-dependencies branch from f6434fd to 1681a0d Compare July 18, 2026 06:56
@herakles-dev

Copy link
Copy Markdown
Author

Rebased on v1.0.0 — still missing there, so this still applies. It's now hitting a stable release, and #873/#1513 have picked up renewed interest. Verified under pnpm hoist=false: the CLI and proxy server both start after this. Happy to adjust the shape if you'd prefer.

@herakles-dev herakles-dev changed the title Add missing runtime dependencies for strict package managers fix: declare bundled runtime dependencies for strict package managers Jul 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Phantom dependencies in @modelcontextprotocol/inspector

2 participants