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

オープン 初心者向け
#3,067 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
78/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
cli, nodejs, typescript
領域
cli

調査の方向性

バグは clients/cli/src/cli.ts の2256〜2272行付近にあります。ここでは --tool-args-json を JSON.parse で解析し、オブジェクトであるかどうかしか確認していません。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分
マージ済み PR(30日)
111

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

modelcontextprotocol/inspector のほかの issue

modelcontextprotocol/inspector の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。