Skip to content

bugfix: fix npx @modelcontextprotoco/inspector failing on main #681

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 5, 2025

Conversation

felixweinberger
Copy link
Contributor

@felixweinberger felixweinberger commented Aug 5, 2025

Summary

This fixes the regression introduced in dc5fa6a where npx . (without any arguments) fails with:

TypeError [ERR_PARSE_ARGS_UNEXPECTED_POSITIONAL]: Unexpected argument ''. This command does not take positional arguments

Problem

Commit dc5fa6a changed the argument passing from using spread syntax to directly including empty strings when no command/args are provided. The parseArgs function in the server interprets these empty strings as unexpected positional arguments.

Solution

Reverted to using the spread operator approach that was used before dc5fa6a. This is more idiomatic and avoids creating empty strings that would need to be filtered out.

Test plan

Before After
CleanShot 2025-08-05 at 12 02 13@2x CleanShot 2025-08-05 at 12 01 21@2x
  • Verified npx . now starts without the parseArgs error
  • Verified npx . command args still works correctly
  • All existing tests pass

This fixes the regression introduced in dc5fa6a where empty strings
were passed as arguments when no command or args were provided,
causing parseArgs to fail with "Unexpected argument ''" error.

The spread operator approach is more idiomatic and avoids creating
empty strings that need to be filtered out.
Copy link

github-actions bot commented Aug 5, 2025

🎭 Playwright E2E Test Results

✅  15 passed

Details

15 tests across 2 suites
 21.1 seconds
 de16a18
ℹ️  Test Environment: Ubuntu Latest, Node.js v22.17.1
Browsers: Chromium, Firefox

📊 View Detailed HTML Report (download artifacts)

@felixweinberger felixweinberger changed the title fix: use spread operator to avoid empty string arguments bugfix: npx @modelcontextprotoco/inspector fails on master Aug 5, 2025
@felixweinberger felixweinberger changed the title bugfix: npx @modelcontextprotoco/inspector fails on master bugfix: fix npx @modelcontextprotoco/inspector failing on main Aug 5, 2025
@felixweinberger
Copy link
Contributor Author

Found this as I was trying to address comments on #661 and in testing found that dc5fa6a (cc: @richardkmichael as FYI) wasn't handling the case when there are no command line arguments. We end up passing "" as a command line argument which doesn't work.

Copy link
Member

@olaservo olaservo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Was a little hasty to merge the other PR and should have tested more scenarios before merging this one.

@olaservo olaservo merged commit aa6a98a into main Aug 5, 2025
8 checks passed
@olaservo olaservo deleted the fweinberger/fix-npx-no-args branch August 5, 2025 12:14
@richardkmichael
Copy link
Collaborator

@felixweinberger Thank you! I was hasty in the simplification to strings. 😓 I'll add a test.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants