Skip to content

test: MCP tests fail when the developer's ~/.claude.json has MCP servers (HOME is not sandboxed) #1386

Description

@sahrizvi

Found while running the full suite for the v0.12.4 release.

test/mcp/headers.test.ts (5 tests) and test/server/httpapi-mcp.test.ts ("serves status endpoint") fail on any machine whose real ~/.claude.json has an entry under mcpServers. MCP discovery reads that file from the real $HOME, so the discovered server is created alongside the test's own servers: it has no requestInit, which breaks the headers assertions, and it changes the status endpoint's result.

test/preload.ts sandboxes the XDG directories but not HOME, so other home-directory config sources may leak the same way.

Reproduced on main (93fe816). With HOME pointed at an empty temporary directory, the same three files pass (15/15).

Suggested fix: point HOME (or the discovery's home-directory lookup) at a temporary directory in test/preload.ts, or have MCP discovery honour a test override, so the suite never reads the developer's own editor and assistant configs.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions