`-e KEY=` (empty value) is rejected on all four clients, though `--config` passes an empty env value through

Ouverte Adaptée aux débutants
#3,066 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Les mainteneurs répondent en général sous 1 jour

Personne n'a encore pris cette issue.

Évaluation

Difficulté
2/5
Temps estimé
1-3 heures
Accessibilité débutants
68/100
Type d'issue
Bug
Clarté
Plutôt claire
Activité
Active
Stack technique
node.js, typescript
Domaine
cli

Piste de recherche

Le rejet se trouve dans parseKeyValuePair dans core/mcp/node/config.ts (vers la ligne 55), qui lève une erreur lorsque la valeur est vide ; le chemin partagé est utilisé par les quatre clients. Lis-le en parallèle de core/cli/utils/prompt-args.ts, où q= était déjà autorisé. Le test dans clients/web/src/test/core/mcp/node/config.test.ts (vers la ligne 47) attend actuellement que key= lève une erreur ; vérifie si c'est délibéré avant de le modifier. C'est terminé lorsque -e EMPTY_VAR= produit une valeur de chaîne vide et que le test est mis à jour en conséquence.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

Which version line?

v2 — current (@modelcontextprotocol/inspector@latest)

Which client?

All / shared core

Inspector version

2.17.0

Node version

v26.13.1

Operating system (and browser, for the web client)

macOS 27.3 (arm64); headless Chrome for the web control runs

Transport

stdio

MCP server under inspection

A dependency-free stdio server (below) whose one tool, check_env, reports EMPTY_VAR as the server process sees it. Protocol era: legacy (default). OAuth: no.

Steps to reproduce
  1. In an empty folder, create env-server.mjs:
    import { createInterface } from "node:readline";
    const reply = (id, result) => process.stdout.write(JSON.stringify({ jsonrpc: "2.0", id, result }) + "\n");
    createInterface({ input: process.stdin }).on("line", (line) => {
      const { id, method, params } = JSON.parse(line);
      if (id === undefined) return;
      if (method === "initialize") reply(id, { protocolVersion: params.protocolVersion, capabilities: { tools: {} }, serverInfo: { name: "env-server", version: "0" } });
      else if (method === "tools/list") reply(id, { tools: [{ name: "check_env", inputSchema: { type: "object" } }] });
      else if (method === "tools/call") reply(id, { content: [{ type: "text", text: JSON.stringify({ set: "EMPTY_VAR" in process.env, value: process.env.EMPTY_VAR ?? null }) }] });
      else reply(id, {});
    });
    
  2. Run:
    insp() { npx -y @modelcontextprotocol/[email protected] "$@"; }
    insp --cli -e EMPTY_VAR=x node env-server.mjs --method tools/call --tool-name check_env     # {"set":true,"value":"x"}
    insp --cli -e EMPTY_VAR= node env-server.mjs --method tools/call --tool-name check_env      # exit 1, error below
    insp --cli -e 'EMPTY_VAR=""' node env-server.mjs --method tools/call --tool-name check_env  # {"set":true,"value":"\"\""}
    echo '{"mcpServers":{"s":{"command":"node","args":["env-server.mjs"],"env":{"EMPTY_VAR":""}}}}' > cfg.json
    insp --cli --config cfg.json --server s --method tools/call --tool-name check_env           # {"set":true,"value":""}
    MCP_AUTO_OPEN_ENABLED=false insp --web -e EMPTY_VAR= node env-server.mjs                    # exit 1
    insp --tui -e EMPTY_VAR= -- node env-server.mjs                                             # exit 1
    npx -y --package=@modelcontextprotocol/[email protected] mcpdo connect -e EMPTY_VAR= -- node env-server.mjs  # exit 1
    
Expected behavior

-e EMPTY_VAR= launches the server with EMPTY_VAR set to "", as the same entry in a --config file already does.

Actual behavior

All four clients exit 1 at startup. The quoted form isn't a workaround: the server receives two literal quote characters (CLI and mcpdo). With the CLI, setting EMPTY_VAR= in the parent shell doesn't reach the server either (it reports the variable as unset).

Logs, errors, or screenshots
CLI, mcpdo: {"error":{"code":"error","message":"Invalid parameter format: EMPTY_VAR=. Use key=value format."}}
Web, TUI:   Error running MCP Inspector: Invalid parameter format: EMPTY_VAR=. Use key=value format.

Controls, each confirmed by the server's own report: with EMPTY_VAR=x on -e, and with the --config file, the web client (connected in headless Chrome), the TUI and mcpdo all started and the server saw the expected value.

From reading the code on v2/main (218253575), not run: every client's -e uses parseKeyValuePair in core/mcp/node/config.ts:55, which rejects val === "". clients/web/src/test/core/mcp/node/config.test.ts:47 expects key= to throw, so the rejection may be deliberate (it came over with the v1.5 port). By contrast, #2890 made --prompt-args accept q= (core/cli/utils/prompt-args.ts:16-17).

Impact is small: a server that treats set-but-empty differently from unset can't be started in that state with -e; --config works. This is the v2 follow-up to v1 #629, where you asked to hear if it still happens in v2.

Not tested: Windows or Linux, other Node versions, or the web UI's server-settings env editor.

Already prototyped a fix?

No.

Before you submit
  • I searched existing issues and this is not a duplicate.
  • This is not a security vulnerability report (those go through the private advisory process).

AI disclosure: an AI coding agent ran these reproductions and wrote and filed this issue autonomously for this GitHub account (found by one Claude agent, independently re-run from scratch by a second, claude-opus-5-5, and reviewed by Claude Fable 5.2 in Claude Code before posting). No human testing is claimed.

Langage dominant
TypeScript
Étoiles
11.3k
Forks
1.6k
Merge moyen
2 h 28 min
PR mergées (30 j)
111

Préparer son environnement

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de modelcontextprotocol/inspector

Toutes les issues de modelcontextprotocol/inspector

Issues similaires

Plus d'issues TypeScript

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.