Skip to content

Tests for setup's config writer: invalid, unchanged, read-failure and write-failure paths #407

Backlog

Description

@TMHSDigital

Summary

configureJsonClient edits users' MCP client config files, but only the happy path is tested. The invalid-JSON, unchanged, read-failure and write-failure branches have no tests.

Where

  • src/setup.ts:327-376
  • src/__tests__/setup.test.ts:118-125
  • src/__tests__/setup.test.ts:176-222

Details

configureJsonClient writes the user's MCP client config (Cursor, VS Code, Claude Desktop). mergeServerConfig is unit-tested for the invalid status (setup.test.ts:122-124, JSONC with comments, arrays). However, runSetup is only driven through the create, merge, conflict, dry-run and decline paths. In the per-line run, setup.ts lines 336-337 (read failure), 343-347 (unchanged and invalid messages and returns) and 373-374 (write failure) have 0 hits. The invalid return is the guard that stops setup from replacing a commented mcp.json.

Impact

A regression in the switch, such as a fall-through or a reordered case, would overwrite a user's JSONC config. A backup is taken first, so the damage is recoverable but confusing. Read and write failures are also unverified to exit non-zero.

Steps to reproduce

Delete return false; after the invalid message (setup.ts:347). setup.test.ts still passes.

Suggested fix

Add runSetup cases using the existing fakeDeps. (1) An existing VS Code mcp.json containing // comment, run with --yes: the file is unchanged, no .bak- file is created, the output mentions "left ... alone", and the exit code reflects the failure. (2) An already-identical entry: "already configured" and no write. (3) readFile throws: "could not read", no write. (4) writeFile throws: "could not write", and the result is false.

Acceptance criteria

  • Tests for each branch, using a temp config file

Getting started

  • Relevant files: src/setup.ts, src/__tests__/setup.test.ts
  • Run tests: npm test (also npm run typecheck and npm run lint); see CONTRIBUTING.md
  • If you change a tool's schema or description, run npm run docs

Filed by repo-audit/full-audit at f0e5ebd. Severity: low. Effort: S. audit-key: testing|src/setup.ts|configureJsonClient

Activity

  1. added
    good first issue
    priority: low
    testing
    effort: small
    on Nov 29, 2026
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

    effort: smallgood first issuepriority: lowtesting

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions