CLI --tool-args-json silently sends 1e400 as null (round-trip guard missing; mcpdo rejects it)

Đang mở Phù hợp với người mới
#3,067 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, nodejs, typescript
Lĩnh vực
cli

Hướng nghiên cứu

Lỗi nằm trong clients/cli/src/cli.ts, khoảng dòng 2256–2272, nơi --tool-args-json được phân tích bằng JSON.parse và chỉ được kiểm tra xem có phải là một đối tượng hay không. Hãy so sánh với assertJsonRoundTrips trong core/cli/handlers/run-method.ts (dòng 43) và tái sử dụng kiểm tra đó trên đối tượng đã phân tích. Hoàn thành khi --tool-args-json '{"v":1e400}' thoát với mã khác không và báo lỗi trước khi gửi bất kỳ frame nào, đồng thời có một bài kiểm tra hồi quy nằm cạnh trường hợp hiện có --tool-arg v=1e400.

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-args-json '{"v":1e400}'
Expected behavior

Rejected before sending, as --tool-arg v=1e400 is (#1910) and as mcpdo's --tool-args-json is on the same commit:

$ mcpdo tools/call echo_raw --tool-args-json '{"v":1e400}'
{"error":{"code":"error","message":"Invalid --tool-args-json: Infinity has no JSON representation (it would silently reach the tool as null)."}}
Actual behavior

Exit 0; the tool receives null. The tools/call frame on the wire (stdin of the server):

{"method":"tools/call","params":{"name":"echo_raw","arguments":{"v":null}},"jsonrpc":"2.0","id":2}
Logs, errors, or screenshots

Cause: clients/cli/src/cli.ts (~2256–2272) JSON.parses --tool-args-json and only checks it is an object. The same guard already exists in core/cli/handlers/run-method.ts:43 (assertJsonRoundTrips, used for --input-responses), in clients/mcpdo/src/connection/parse-tool-args.ts:9, and via isSerializableJson for --tool-arg.

This was mentioned under "Related" in #2859; that fix (#2890) covered --prompt-args only.

Suggested fix: run the existing round-trip check on the parsed object, plus a regression test next to the --tool-arg v=1e400 case.

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.