Skip to content

fix(uninstall): remove MCP servers before deleting managed-mcp.json - #253

Merged
jeff-r2026 merged 2 commits into
mainfrom
fix/uninstall-mcp-order
Jul 28, 2026
Merged

fix(uninstall): remove MCP servers before deleting managed-mcp.json#253
jeff-r2026 merged 2 commits into
mainfrom
fix/uninstall-mcp-order

Conversation

@jeff-r2026

@jeff-r2026 jeff-r2026 commented Jul 28, 2026

Copy link
Copy Markdown
Collaborator

Summary

Uninstall intended to clean teamai-managed MCP servers via reconcileMcpForConfig(..., { removeAll: true }), but that call ran after executeRemoval deleted ~/.teamai/ (which holds managed-mcp.json). With an empty manifest, removeAll early-returns and leaves servers in ~/.claude.json / ~/.cursor/mcp.json / etc.

Hooks already avoid this by reading managed-hooks.json inside executeRemoval before the home directory is removed. MCP cleanup now runs first for the same reason.

Test plan

  • Unit test: uninstall removes a teamai-managed MCP server and keeps a hand-added one
  • E2E (offline): real CLI mcp injectuninstall --force → team server gone, user server kept, ~/.teamai removed
  • npx vitest run src/__tests__/uninstall.test.ts
  • npx vitest run --config vitest.e2e.config.ts src/__tests__/e2e/mcp-uninstall.test.ts

Uninstall called reconcileMcp with removeAll after executeRemoval had
already deleted ~/.teamai/, so the ownership manifest was gone and the
cleanup became a no-op. Run MCP removal first, matching how hooks use
the managed-hooks manifest before the home directory is removed.
Drive the real CLI against an offline HOME sandbox: inject a team server,
uninstall, and assert the managed entry is gone while a hand-added server
and the rest of ~/.claude.json stay. Catches the order bug where removeAll
ran after managed-mcp.json was already deleted.
@jeff-r2026
jeff-r2026 merged commit d96e84f into main Jul 28, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant