fix(cli): resolve package metadata from module path#1337
Open
2830500285 wants to merge 1 commit into
Open
Conversation
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.
Summary
Fixes CLI package metadata lookup so
--climode resolves package.json relative to the built module instead of the process working directory.Type of Change
Changes Made
import.meta.url-relative package.json URLs.@modelcontextprotocol/inspector-cliwith../package.json@modelcontextprotocol/inspectorwith../../package.jsoncli/package.json, then runs from a cwd where../package.jsonexists.Related Issues
Fixes #1334
Testing
Test Results and/or Instructions
Passed locally on Windows with Node v24.13.0:
I also ran
npm run test-cli; the full suite has existing Windows/Node 24 HTTP transport subprocess failures where the CLI prints the expected JSON but exits withAssertion failed: !(handle->flags & UV_HANDLE_CLOSING), file src\win\async.c, line 76. The new stdio regression test passes independently and avoids that unrelated Windows HTTP teardown path.Checklist
npm run prettier-fixequivalent on changed files)Breaking Changes
None.
Additional Context
The previous existence check used cwd-relative strings (
../package.json/../../package.json) to decide which module-relative JSON import to perform. If a caller ran the published root package from a cwd where../package.jsonexisted, the CLI could choose../package.jsonand then fail because that file is not included undercli/in the root package layout.