Skip to content

squad init writes squad_state_<hash> to ~/.copilot/mcp-config.json on every init, contradicting iter-8 design #1296

Closed

Description

@tamirdresher

squad init (at any state backend) unconditionally writes squad_state_<hash> to ~/.copilot/mcp-config.json via ensureSquadStateMcpInUserConfig (packages/squad-cli/src/cli/core/init.ts:408). One entry per project accumulates in HOME with no GC.

This contradicts the explicit iter-8 design intent documented at packages/squad-cli/src/cli/core/mcp-root.ts:1-27:

iter-7: wrote squad_state_<hash> into the user's HOME ~/.copilot/mcp-config.json. That polluted HOME with one entry per Squad project and required a stale-entry GC that we never built. It also touched a file outside the project, which is surprising for squad init / squad upgrade.

iter-8 flips it back inside the project: we write squad_state to a repo-root .mcp.json ... No HOME modifications.

But init.ts:408 then turns around and modifies HOME anyway. The accompanying comment // Also pin to user-level config for external 'copilot -p' compatibility claims this is for copilot -p mode, but copilot -p reads .mcp.json from the cwd too — the repo-root write at line 403 is already sufficient for that case.

Repro

`powershell
mkdir C:\temp\squad-home-pollution-repro; cd C:\temp\squad-home-pollution-repro; git init
squad init
(Get-Content ~/.copilot/mcp-config.json -Raw | ConvertFrom-Json).mcpServers.PSObject.Properties.Name | Where-Object { -match '^squad_state_' }

→ squad_state_ ← polluted

`

Impact

  • Each new squad init adds another squad_state_<hash> entry; stale entries point at deleted/moved projects
  • The keys are opaque hashes, so users have no obvious way to clean them
  • squad upgrade (upgrade.ts:738) ALSO calls ensureSquadStateMcpInUserConfig, amplifying the problem
  • Defeats the iter-8 goal of "init/upgrade should not modify HOME"

Fix

Remove the two ensureSquadStateMcpInUserConfig calls (init.ts:408 and upgrade.ts:738). The repo-root .mcp.json writes (line 403 / line 728) cover all documented Copilot CLI launch modes including copilot -p from the project root.

For users who do invoke copilot -p from somewhere other than the project root, the right fix is to teach them --additional-mcp-config @.mcp.json (which init.ts:494 already documents as the recommended pattern).

Cleanup helper

A follow-up could add squad doctor --mcp-prune to walk ~/.copilot/mcp-config.json, find squad_state_<hash> entries whose target directory no longer exists, and remove them.

cc: discovered in the v0.10 stabilization weekend session.

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