Skip to content

Server arguments cannot begin with a dash option #649

@richardkmichael

Description

@richardkmichael

Describe the bug

Server argument handling does not permit the first argument to command to be a dash option, and the Inspector crashes.

(This was previously supported, and is helpful.)

To Reproduce

Using either the command line or a config file:

  1. Command line example:
npx @modelcontextprotocol/inspector npm --silent --prefix /path/to/modelcontextprotocol/servers/src/everything run start
  1. Config file example:

everything_server.json:

{
  "mcpServers": {
    "everything": {
      "command": "npm",
      "args": [
        "--silent",
        "--prefix",
        "/path/to/modelcontextprotocol/servers/src/everything",
        "run",
        "start"
      ]
    }
  }
}
  1. npx @modelcontextprotocol/[email protected] --config everything_server.json --server everything

Expected behavior

Open the Inspector with UI values filled.

Logs

0.16.2

 $ npx @modelcontextprotocol/[email protected] --config everything-server.json --server everything

Starting MCP inspector...

node:internal/util/parse_args/parse_args:87
    throw new ERR_PARSE_ARGS_INVALID_OPTION_VALUE(errorMessage);
          ^

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'.
    at checkOptionLikeValue (node:internal/util/parse_args/parse_args:87:11)
    at node:internal/util/parse_args/parse_args:382:9
    at Array.forEach (<anonymous>)
    at parseArgs (node:internal/util/parse_args/parse_args:378:3)
    at file:///Users/rmichael/.npm/_npx/df57308fae79a8ba/node_modules/@modelcontextprotocol/inspector/server/build/index.js:25:20
    at ModuleJob.run (node:internal/modules/esm/module_job:274:25)
    at async onImport.tracePromise.__proto__ (node:internal/modules/esm/loader:644:26)
    at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:117:5) {
  code: 'ERR_PARSE_ARGS_INVALID_OPTION_VALUE'
}

Additional context

I opened a PR a few days ago with tests which should catch this, but it needs an update for this corner case.

This relates to #636.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions