Skip to content

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

Closed

Description

@nosmile99

Bug report

Which version line? v2 — current
Which client? TUI
Inspector version: 2.11.0 (v2/main @ 074b810)
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 test(web): isolate integration OAuth state from ~/.mcp-inspector (#2670) #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.

Activity

  1. CloudCorpRecords commented on Oct 15, 2026

    @CloudCorpRecords

    Confirming the report, with a verified prototype. (Posting the detail here rather than a PR, per this repo's maintainer-only PR rule.)

    Reproduced on a fresh clone of v2/main: with HOME pointed at an empty scratch directory, running

    HOME= vitest run tests/App.test.tsx

    from clients/tui passes (130 tests) and leaves exactly 155 lines in /.mcp-inspector/auth.log, matching the count in the report.

    Prototype I verified: in clients/tui/tests/setup.ts, the setupFile every TUI test file already inherits, create a per-test-file temporary directory (fs.mkdtempSync under os.tmpdir()), set process.env.MCP_INSPECTOR_LOG_DIR to it before anything mounts the App, and remove the directory on process exit. Nothing else changes. logger.test.ts sets and restores this variable itself per test, so it is unaffected, and the lazy logger singleton resolves the override on first use in each test file, so per-file isolation also stops concurrent worktrees interleaving into one file.

    Results with the prototype in place: the full TUI suite passes (47 files, 636 tests), the scratch HOME is left completely empty, and the setup file is prettier-clean.

    If you would rather see the override somewhere else (a vitest config env entry, or per-suite setup in the mounting tests), I can re-run the verification against that shape instead.

  2. added
    v2
    bug
    on Oct 20, 2026
  3. cliffhall commented on Oct 20, 2026

    @cliffhall
    Member

    Triage: Priority Low (total 5)

    Board: #28, Status Incoming, awaiting maintainer review (no milestone yet).

  4. added this to the v2.12.0 milestone on Oct 20, 2026
  5. self-assigned this
    on Oct 20, 2026
  6. cliffhall commented on Oct 20, 2026

    @cliffhall
    Member

    Shipped in #2735.

  7. nosmile99 commented on Oct 20, 2026

    @nosmile99
    Author

    Thanks for shipping this, cliffhall — appreciate the triage and the quick fix in #2735.

  8. added a commit that references this issue on Oct 26, 2026
    d43559b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugv2

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions