From dc5fa6a0f52517638dc9be6cdb5ddd1520b7e145 Mon Sep 17 00:00:00 2001 From: Richard Michael Date: Wed, 30 Jul 2025 23:53:17 -0700 Subject: [PATCH] fix: Argument notation to allow parseArgs to parse leading dash-options 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. --- client/bin/start.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/client/bin/start.js b/client/bin/start.js index ae6e9259..0b5e84e2 100755 --- a/client/bin/start.js +++ b/client/bin/start.js @@ -91,10 +91,10 @@ async function startProdServer(serverOptions) { "node", [ inspectorServerPath, - ...(command ? [`--command`, command] : []), - ...(mcpServerArgs && mcpServerArgs.length > 0 - ? [`--args`, mcpServerArgs.join(" ")] - : []), + command ? `--command=${command}` : "", + mcpServerArgs && mcpServerArgs.length > 0 + ? `--args=${mcpServerArgs.join(" ")}` + : "", ], { env: {