Skip to content

fix: uninstall Claude Code plugin on removeServer, ignore missing legacy MCP entry#462

Draft
posthog[bot] wants to merge 1 commit into
mainfrom
posthog-code/fix-claude-code-uninstall-plugin
Draft

fix: uninstall Claude Code plugin on removeServer, ignore missing legacy MCP entry#462
posthog[bot] wants to merge 1 commit into
mainfrom
posthog-code/fix-claude-code-uninstall-plugin

Conversation

@posthog
Copy link
Copy Markdown

@posthog posthog Bot commented May 20, 2026

Problem

Users running npx @posthog/wizard to uninstall PostHog from Claude Code saw the removal silently fail ({ success: false }) with a noisy captured exception (Failed to remove server from Claude Code: ... No user-scoped MCP server found with name: posthog), even though the integration was present.

PR #428 switched the Claude Code add path to the new plugin interface (claude plugin install posthog), but the remove path in src/steps/add-mcp-server-to-clients/clients/claude-code.ts was not updated and kept executing the legacy claude mcp remove --scope user posthog. For anyone who installed via the plugin flow (or never had a user-scoped MCP entry), that command exits non-zero with "No user-scoped MCP server found", which analytics.captureException wrapped — visible as PostHog error tracking issue 019e4707-9ff5-7d12-8e14-baaf82e189ff on 2026-05-20.

Changes

removeServer() now mirrors the install path:

  • Runs claude plugin uninstall posthog first (matches the post-chore: plugin interface for claude and codex #428 install path).
  • Still runs the legacy claude mcp remove --scope user <serverName> afterwards to clean up entries created before chore: plugin interface for claude and codex #428.
  • Treats not installed / No user-scoped MCP server found as successful no-ops on both paths instead of captured exceptions.
  • Only counts genuine errors as failures: a real plugin- or MCP-side error sets success: false and is captured exactly once.

Test plan

  • Extended src/steps/add-mcp-server-to-clients/clients/__tests__/claude-code.test.ts with a new removeServer block covering:
    • plugin uninstall succeeds + legacy entry absent → success: true, no capture
    • plugin absent + legacy "No user-scoped MCP server found" → success: true, no capture (the regression case)
    • plugin absent + legacy entry removed → success: true, no capture
    • local: true → uses posthog-local for the legacy command
    • genuine plugin-uninstall error → success: false + capture
    • genuine mcp-remove error → success: false + capture
    • binary missing → success: false, no capture
  • pnpm build
  • pnpm jest src/steps/add-mcp-server-to-clients/ ✅ (62/62 pass)
  • pnpm lint ✅ (0 errors; pre-existing warnings only)

Created with PostHog Code

…cy MCP entry as no-op

PR #428 switched the Claude Code install path to the plugin interface but
left removeServer() running the legacy `claude mcp remove --scope user
posthog` command. For users who installed via the plugin flow (or never
had a user-scoped MCP entry), that command exits non-zero with "No
user-scoped MCP server found", which was wrapped in analytics.captureException
and surfaced to the user as success=false despite the integration being
present.

removeServer() now mirrors the install path: it runs
`claude plugin uninstall posthog` first and only treats unexpected errors
as failures. The legacy `mcp remove --scope user <serverName>` call still
runs to clean up entries created before #428, but "No user-scoped MCP
server found" and "not installed" are now treated as successful no-ops
rather than captured exceptions.

Generated-By: PostHog Code
Task-Id: f7d0abc3-428c-4851-bab9-c2079575e257
@github-actions
Copy link
Copy Markdown

🧙 Wizard CI

Run the Wizard CI and test your changes against wizard-workbench example apps by replying with a GitHub comment using one of the following commands:

Test all apps:

  • /wizard-ci all

Test all apps in a directory:

  • /wizard-ci basic-integration
  • /wizard-ci misc
  • /wizard-ci revenue

Test an individual app:

  • /wizard-ci basic-integration/android
  • /wizard-ci basic-integration/angular
  • /wizard-ci basic-integration/astro
Show more apps
  • /wizard-ci basic-integration/django
  • /wizard-ci basic-integration/fastapi
  • /wizard-ci basic-integration/flask
  • /wizard-ci basic-integration/javascript-node
  • /wizard-ci basic-integration/javascript-web
  • /wizard-ci basic-integration/laravel
  • /wizard-ci basic-integration/next-js
  • /wizard-ci basic-integration/nuxt
  • /wizard-ci basic-integration/python
  • /wizard-ci basic-integration/rails
  • /wizard-ci basic-integration/react-native
  • /wizard-ci basic-integration/react-router
  • /wizard-ci basic-integration/sveltekit
  • /wizard-ci basic-integration/swift
  • /wizard-ci basic-integration/tanstack-router
  • /wizard-ci basic-integration/tanstack-start
  • /wizard-ci basic-integration/vue
  • /wizard-ci misc/quack-quack
  • /wizard-ci revenue/stripe

Results will be posted here when complete.

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.

0 participants