CLI/mcpdo: a timeout above 2147483647 ms fires after 1 ms, and the error says to raise it further

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

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

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

调研方向

从 clients/cli/src/cli.ts 中约 1581-1589 行的 --connect-timeout 解析器开始,它目前只检查值是否为有限数且非负。同时检查目录中的 connectionTimeout 以及 --wait-for-auth 的值如何传入 setTimeout。完成标准是:超过 2147483647 ms 的值被钳制或以用法错误拒绝,并且轮询期间不会出现 TimeoutOverflowWarning。

由索引模型根据 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/list --connect-timeout 2147483648

Also:

  • "connectionTimeout": 2147483648 in a --config / catalog entry
  • mcpdo connect @h --connect-timeout 2147483648 -- node server.mjs
  • --wait-for-auth 3000000 (seconds, > 2^31 ms)
Expected behavior

Clamp to 2^31-1 ms (≈24.8 days, effectively unbounded) or reject values above it as a usage error. A huge value means "very long"; 0 already means "no timeout".

Actual behavior

Exits 4 after ~0.4 s against a healthy server:

(node) TimeoutOverflowWarning: 2147483648 does not fit into a 32-bit signed integer.
Timeout duration was set to 1.
{"error":{"code":"unreachable","message":"Connection timed out after 2147483648 ms. To accommodate a slower server, pass a larger --connect-timeout <ms>, or set connectionTimeout on the server's catalog or config entry."}}

The remedy makes it worse. 2147483647 works. The config connectionTimeout and mcpdo connect fail the same way (mcpdo after ~2 s). --wait-for-auth 3000000 does not fail but prints a TimeoutOverflowWarning on every poll (40 in 20 s), flooding the stderr that carries the one-line envelope.

Logs, errors, or screenshots

Cause: the --connect-timeout parser (clients/cli/src/cli.ts:1581–1589) only checks Number.isFinite(n) && n >= 0; the catalog connectionTimeout is not range-checked either. Node's setTimeout treats anything above 2^31-1 as 1.

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 摘要。