Skip to content

Conversation

richardkmichael
Copy link
Collaborator

@richardkmichael richardkmichael commented Jul 31, 2025

Invoke the server with an argument notation that tolerates a dash-option. Closes #649

Motivation and Context

There is an argument handling regression, and it is helpful to be able to pass a dash-option to the MCP server command.

How Has This Been Tested?

Running locally with both CLI and config file options.

Breaking Changes

No

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed

Additional context

This is not related to parsing of the initial command by cli/build/cli.js (package entry point)., i.e., no quoting or use of -- separation will address this bug. Arguments are parsed correctly, but the passing of the command and args during server invocation is the problem.

@richardkmichael richardkmichael changed the title Argument notation to allow parseArgs to parse leading dash-options fix: Argument notation to allow parseArgs to parse leading dash-options Jul 31, 2025
The server was invoked as:

`server/build/index.js --command comm --args arg1 arg2 arg3`

(`arg1 arg2 arg3` is a string in ARGV; the single value of `--args`.)

`util:parseArgs()` cannot handle an argument value with a leading dash
with this usage.

e.g.,

`server/build/index.js --command npm --args --silent --prefix path/to/servers/src/everything run start`

The above will throw, and indicate correct usage:

```
TypeError [ERR_PARSE_ARGS_INVALID_OPTION_VALUE]: Option '--args' argument is ambiguous.
Did you forget to specify the option argument for '--args'?
To specify an option argument starting with a dash use '--args=-XYZ'.
```

However, since users do not control the invocation of the server, they
cannot adjust the notation for their use-case.

`arguments`, and `command`, are unknown user input, so adjust the
argument form to the more lenient and robust notation.  Although a
`command` beginning with `-` seems unlikely, consistent handling of both
improves code clarity and simplicity.

Running the server directly (e.g., on the command line in development)
may continue to use: `--args arg1 arg2 arg3` if desired, so this is a
non-breaking change.
@richardkmichael
Copy link
Collaborator Author

@felixweinberger 👋 Any chance you could have a look? --command and --args were introduced in c7b90a1. Would be helpful before 0.16.3.

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.

Thank you!

@olaservo olaservo merged commit cf44b30 into modelcontextprotocol:main Aug 3, 2025
5 checks passed
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.

Server arguments cannot begin with a dash option
2 participants