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

未关闭 适合新手
#3,067 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
78/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
cli, nodejs, typescript
领域
cli

调研方向

缺陷位于 clients/cli/src/cli.ts 第 2256–2272 行附近,这里使用 JSON.parse 解析 --tool-args-json,只检查结果是否为对象。请与 core/cli/handlers/run-method.ts(第 43 行)中的 assertJsonRoundTrips 进行对比,并将该检查复用到解析后的对象上。当 --tool-args-json '{"v":1e400}' 在发送任何帧之前以非零退出码报错,并且在现有的 --tool-arg v=1e400 用例旁边添加了回归测试时,即视为完成。

由索引模型根据 Issue 内容生成。

描述

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).
主要语言
TypeScript
星标
11.3k
派生
1.6k
平均合并
2 小时 28 分钟
30 天内合并 PR
111

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

modelcontextprotocol/inspector 的其他 Issue

查看 modelcontextprotocol/inspector 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。