CLI/mcpdo reject empty values for --tool-arg k=, -e VAR= and --header "X:" (--prompt-args q= and config env accept them)

Đang mở Phù hợp với người mới
#3,069 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
78/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
cli, typescript
Lĩnh vực
cli

Hướng nghiên cứu

Bắt đầu từ core/mcp/node/config.ts tại parseKeyValuePair (khoảng dòng 55), sau đó là bản sao trong CLI ở clients/cli/src/cli.ts và parseKeyValue trong clients/mcpdo/src/connection/mcp.ts (khoảng dòng 2033), cùng với parseHeaderPair. Tái hiện lỗi bằng bốn lệnh trong issue; đường xử lý đối số của prompt đã chấp nhận giá trị rỗng và cho thấy hành vi mong muốn. Hoàn thành khi k= và X-Empty: được phân tích thành chuỗi rỗng, khóa rỗng vẫn bị từ chối và các kiểm thử CLI hiện có đều đạt.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

bug
Which version line?

v2 — current (@modelcontextprotocol/inspector@latest)

Which client?

CLI

Inspector version

2.17.0 (main @ 2069a1a, built from source)

Node version

v22.23.5

Operating system (and browser, for the web client)

Linux

Transport

stdio

MCP server under inspection

Minimal echo server (probe-echo.mjs), SDK 2.4.0:

import * as z from "zod/v4";
import { McpServer } from "@modelcontextprotocol/server";
import { StdioServerTransport } from "@modelcontextprotocol/server/stdio";
const server = new McpServer({ name: "probe-echo", version: "1.0.0" });
server.registerTool("echo_raw", { description: "Echo raw arguments", inputSchema: z.object({}).passthrough() },
  async (args) => ({ content: [{ type: "text", text: JSON.stringify(args) }] }));
server.registerPrompt("echo_prompt", { description: "Echo", argsSchema: { a: z.string().optional(), b: z.string().optional() } },
  async (args) => ({ messages: [{ role: "user", content: { type: "text", text: JSON.stringify(args) } }] }));
await server.connect(new StdioServerTransport());
Steps to reproduce
mcp-inspector --cli node probe-echo.mjs --method tools/call --tool-name echo_raw --tool-arg s=
mcp-inspector --cli node server.mjs -e DEBUG= --method tools/list
mcp-inspector --cli --transport http --server-url http://127.0.0.1:8799/mcp --header "X-Empty:" --method tools/list
mcpdo tools/call echo_raw --tool-arg s=

These accept an empty value:

mcp-inspector --cli node probe-echo.mjs --method prompts/get --prompt-name echo_prompt --prompt-args b=   # sends {"b":""}

…and a --config entry with "env": {"EMPTY": ""} reaches the server as EMPTY="".

Expected behavior

k= means the empty string, as it already does for --prompt-args (README: "q= sends \"\""). An empty env var is legitimate (blank an inherited NODE_OPTIONS/DEBUG, satisfy a presence check), and the config file can already express it. An empty header field value is valid HTTP (RFC 9110 §5.5).

Actual behavior

Each is rejected as a syntax error, exit 1:

{"error":{"code":"error","message":"Invalid parameter format: s=. Use key=value format."}}
{"error":{"code":"error","message":"Invalid parameter format: DEBUG=. Use key=value format."}}
{"error":{"code":"error","message":"Invalid header format: X-Empty:. Use \"HeaderName: Value\" format."}}

--tool-arg has a workaround (s='""'); -e has none on the command line, so a server setup that works from --config cannot be expressed ad hoc.

Logs, errors, or screenshots

Cause: val === "" is rejected in parseKeyValuePair (core/mcp/node/config.ts:55, used for -e), in the CLI's own parseKeyValuePair (clients/cli/src/cli.ts), and in mcpdo's parseKeyValue (clients/mcpdo/src/connection/mcp.ts:2033); parseHeaderPair rejects an empty value too. Only the key/name needs to be non-empty.

Already prototyped a fix?

No response

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).
Ngôn ngữ chính
TypeScript
Star
11.3k
Fork
1.6k
Merge trung bình
2 giờ 28 phút
Pull request đã merge (30 ngày)
111

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của modelcontextprotocol/inspector

Tất cả issue của modelcontextprotocol/inspector

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.