Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

CLI tests seed the developer's real ~/.mcp-inspector/mcp.json (cli.test.ts, completion.test.ts)

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

维护者通常 1 天内回复

@cliffhall 已经在做这个了。

开始于 2026年10月25日。

  • #2793 来自 @cliffhall —— 已合并

评估

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

调研方向

阅读 clients/cli/__tests__/cli.test.ts 和 clients/cli/__tests__/completion.test.ts,然后追踪 serverList 如何解析目录的默认路径,并与 #2728 的设置进行比较。为目录使用每个文件各自的临时目录,并添加一项保护检查,如果其路径解析到 os.tmpdir() 之外就失败。运行指定的两个 Vitest 文件,并确认它们没有改动真实的 home 目录。

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

描述

bug v2

Found during the v2.12.0 release smoke (#2764), while verifying #2719.

Problem

Two CLI test files still write the developer's real ~/.mcp-inspector/mcp.json: clients/cli/__tests__/cli.test.ts and clients/cli/__tests__/completion.test.ts. #2719 isolated the OAuth state file (oauth.json*) and #2723 isolated the TUI's auth.log. Nothing isolates the default server catalog, though, so on a machine with no catalog yet, a CLI test run seeds {"mcpServers": {}} into the real home directory.

Neither test file changed since 2.11.0, so this predates the v2.12.0 milestone and is not a regression.

Reproduce

cd clients/cli
for f in __tests__/*.test.ts; do H=$(mktemp -d); HOME=$H npx vitest run $f >/dev/null 2>&1; [ -e $H/.mcp-inspector ] && echo "$f -> $(cd $H && find .mcp-inspector -type f)"; done

Observed on the v2.12.0 merge tree:

__tests__/cli.test.ts -> .mcp-inspector/mcp.json
__tests__/completion.test.ts -> .mcp-inspector/mcp.json

Expected

A CLI test run leaves HOME untouched. The fix should use the same shape as #2728: point the catalog path (MCP_STORAGE_DIR, or whatever serverList resolves the default catalog from) at a per-file mkdtemp directory in a setup file. It should also add a guard that fails a test whose catalog path resolves outside os.tmpdir().

Impact

The seed only happens when no catalog exists, so an existing mcp.json is never overwritten. The impact is a stray empty catalog on a fresh machine, plus concurrent worktree runs sharing one file.

主要语言
TypeScript
星标
11.1k
派生
1.6k
平均合并
4 小时 56 分钟
30 天内合并 PR
155

环境准备

从这里开始

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

modelcontextprotocol/inspector 的其他 Issue

查看 modelcontextprotocol/inspector 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

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