Fix cli package.json import #839
Merged
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.
Description
cli/src/index.ts
package.json
from../
or../../
depending on file existence in parent.package.json
intocallMethod
function, which is the only place it is used, and is closer to where it is referenced.Motivation and Context
In #544, a change to
cli/src/index.ts
was introduced that readspackage.json
from one level up (../package.json
). As reported in #834, It fails when running@modelcontextprotocol/inspector
from the command line.package.json
of the workspace packages are present.inspector
build, so it does not work in@modelcontextprotocol/inspector
.../../package.json
) the in main inspector package.@modelcontextprotocol/inspector-cli
, the location of the workspace'spackage.json
will be in../
and../../package.json
will not exist.Therefore, this PR reads
../package.json
if present, otherwise it reads../../package.json
. One of the two will exist.Location of
index.js
in maininspector
packageNo
package.json
in../
Present at
../../package.json
Location of
index.js
ininspector-cli
packagePresent at
../package.json
How Has This Been Tested?
Locally, running a CLI command
node cli/build/cli.js --cli https://mcp.paypal.com/mcp --transport http --method tools/list --header "Authorization: Bearer <token>"
This is a problem that we only saw once published, but given the above known locations of the
package.json
in either published package, I'm confident it will work as expected. All tests still pass.Breaking Changes
Nope.
Types of changes
Checklist
Additional context
Fixes #834