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

Aperta Adatta ai principianti
#3,066 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
68/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
node.js, typescript
Ambito
cli

Direzione di ricerca

Il rifiuto si trova in parseKeyValuePair in core/mcp/node/config.ts (intorno alla riga 55), che lancia un errore quando il valore è vuoto; il percorso condiviso è usato da tutti e quattro i client. Leggilo insieme a core/cli/utils/prompt-args.ts, dove q= era già consentito. Il test in clients/web/src/test/core/mcp/node/config.test.ts (intorno alla riga 47) attualmente si aspetta che key= lanci un errore, quindi verifica se questo è intenzionale prima di modificarlo. Il lavoro è completo quando -e EMPTY_VAR= produce un valore stringa vuoto e il test viene aggiornato di conseguenza.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.

Lingua principale
TypeScript
Stelle
11.3k
Fork
1.6k
Merge medio
2h 28m
PR unite (30g)
111

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di modelcontextprotocol/inspector

Tutte le issue di modelcontextprotocol/inspector

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.