CLI/mcpdo: --connect-timeout "" (e.g. an unset shell variable) silently disables the timeout and the run never ends

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

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

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

调研方向

错误的值在 clients/cli/src/cli.ts 约第 1584 行被解析,那里的 Number(v) 在没有空值检查的情况下执行。请与 core/cli/handlers/load-parsers.ts 和 load-thresholds.ts 中的 --load-* 解析器进行比较,它们已经将空值或仅含空白的值视为无效。使用 --connect-timeout "" 运行复现步骤,并确认它现在会以用法错误退出,而不是挂起。同样的防护也应覆盖 mcpdo 的 --connect-timeout。

由索引模型根据 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
echo 'setInterval(()=>{},1000)' > hang.mjs     # stdio "server" that never answers
mcp-inspector --cli node hang.mjs --method tools/list --connect-timeout "$CONNECT_TIMEOUT"   # variable unset
mcpdo connect @h --connect-timeout "" -- node hang.mjs
Expected behavior

A blank value is a usage error. Number("") is 0, and 0 is documented as "no timeout", so the most common CI mistake turns off the safeguard docs/cli-smoke-testing.md says to always set ("Always bound the connect").

Actual behavior

Never exits (killed by timeout after 25 s, exit 124). Without the flag the same command exits 4 after the 15 s default. mcpdo hangs the same way (killed after 30 s).

Logs, errors, or screenshots

Cause: clients/cli/src/cli.ts:1584 does const n = Number(v) with no blank check. The --load-* parsers already guard this exact case: core/cli/handlers/load-parsers.ts:29 and load-thresholds.ts:57 use value.trim() === "" ? NaN : Number(value). The same one-liner fixes both clients.

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