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

TUI tests append to the developer's real ~/.mcp-inspector/auth.log (App.test.tsx mounts the real getTuiLogger)

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

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

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

调研方向

从 clients/tui/src/logger.ts 开始,其中 getTuiLogger() 从 MCP_INSPECTOR_LOG_DIR 或 HOME 解析其目录;同时查看 __tests__/App.test.tsx,它挂载 App 并触发该调用。将 HOME 设为一个空的临时目录并运行该文件,检查是否存在 .mcp-inspector/auth.log,以此复现问题。参照 vitest.config.ts 中现有的 MCP_INSPECTOR_SECRET_STORE 固定方式,新增一个 setup 文件,将 MCP_INSPECTOR_LOG_DIR 设为每个文件独立的临时目录。当使用临时 HOME 的运行不在 HOME 下创建任何日志,且 logger.test.ts 仍然通过时,即视为完成。

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

描述

Bug report

Which version line? v2 — current
Which client? TUI
Inspector version: 2.11.0 (v2/main @ 074b8108)
Node version: v24.20.0
Operating system: Linux (also applies anywhere HOME resolves)
Transport: Not applicable / never connected

Problem

The TUI test suite writes to the developer's real ~/.mcp-inspector/auth.log. clients/tui/src/logger.ts's getTuiLogger() is a lazy singleton that resolves its log directory from MCP_INSPECTOR_LOG_DIR ?? HOME/.mcp-inspector, and __tests__/App.test.tsx mounts App, which calls getTuiLogger() on startup — so a normal test run appends ~155 lines of test noise ("msg":"TUI started", test-process pid/hostname) to the real log. Concurrent worktree gates interleave into the same file. This is the same class of bug as #2670 / #2719 (tests touching the real ~/.mcp-inspector), one directory up: the log file rather than the OAuth state.

logger.test.ts itself is clean — it tests each resolution arm with vi.resetModules(), per-test env save/restore, and a temp HOME. The leak comes from the app-mounting suites, which never set the override.

Reproduce

Point HOME at an empty scratch dir and run the suite; the log file appears under the scratch home:

cd clients/tui
H=$(mktemp -d)
HOME=$H npx vitest run __tests__/App.test.tsx
find $H -name 'auth.log'   # → $H/.mcp-inspector/auth.log, ~155 lines of {"msg":"TUI started",...}

Scope checked (same scratch-HOME sweep)

  • All 49 clients/tui/__tests__ files swept individually: only App.test.tsx leaks; the rest are clean.
  • clients/mcpdo OAuth-touching suites (connection-stored-auth, daemon-connections, ema, ema-login-helper, mcp-auth-coverage) are clean — they set MCP_INSPECTOR_OAUTH_STATE_PATH per test.
  • clients/launcher has no storage-touching tests.
  • clients/web unit tests use a recording backend for OAuth persistence (integration was isolated in #2677).

Expected

No TUI test reads or writes the developer's real ~/.mcp-inspector/auth.log.

Suggested fix shape

The #2677 shape, one directory over: a TUI vitest setup file that pins MCP_INSPECTOR_LOG_DIR at a per-file mkdtemp directory (plus a guard that fails if the resolved path escapes tmpdir). logger.test.ts's fallback-arm cases are unaffected — they delete the variable and set their own HOME per test with a fresh module import. The tui project already pins MCP_INSPECTOR_SECRET_STORE: "memory" in vitest.config.ts; this would be the log-dir counterpart.

Actual behavior

~/.mcp-inspector/auth.log is created/appended on the developer's real home directory on every tui test run that mounts App.


I searched existing issues and this is not a duplicate (nearest are #2670 / #2719, which cover the OAuth state file, not the TUI log). This is not a security vulnerability report.

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

环境准备

从这里开始

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

modelcontextprotocol/inspector 的其他 Issue

查看 modelcontextprotocol/inspector 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

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