fix: align Claude Code removeServer with plugin-based install path#491
Draft
posthog[bot] wants to merge 1 commit into
Draft
fix: align Claude Code removeServer with plugin-based install path#491posthog[bot] wants to merge 1 commit into
posthog[bot] wants to merge 1 commit into
Conversation
isServerInstalled() delegates to isPluginInstalled() (greps `claude plugin list`),
but removeServer() only shelled out to `claude mcp remove --scope user posthog`.
Any user who installed via the plugin path without also registering a user-scoped
MCP server would hit `No user-scoped MCP server found with name: posthog` during
uninstall, wrap it in a captured exception, and get `success: false`.
removeServer() now mirrors the install path: it first attempts
`claude plugin uninstall posthog` when isPluginInstalled() is true, then attempts
`claude mcp remove --scope user <serverName>` independently. Both are best-effort
— the known benign error strings ("No user-scoped MCP server found" and plugin
not-installed messages) are treated as no-ops, and only genuine unexpected
failures are reported to analytics.captureException.
Adds removeServer test coverage for plugin-present + MCP-absent and
MCP-present + plugin-absent, plus unexpected-failure and binary-missing paths.
Generated-By: PostHog Code
Task-Id: 2f489aa4-8bf6-424d-b112-22bc9b814a63
🧙 Wizard CIRun 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:
Test all apps in a directory:
Test an individual app:
Show more apps
Results will be posted here when complete. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
After commit 557ec08 introduced the Claude Code plugin install path,
ClaudeCodeMCPClientended up with a structural mismatch between its install check and its removal path:isServerInstalled()(src/steps/add-mcp-server-to-clients/clients/claude-code.ts:91-93) delegates toisPluginInstalled(), which grepsclaude plugin listforposthog.removeServer()only shelled out toclaude mcp remove --scope user posthog.Any user who installed PostHog via the plugin path without also registering a user-scoped MCP server is classified as "installed" by
getInstalledClients(), but then the removal command fails with:The error is wrapped via
analytics.captureExceptionand the wizard returnssuccess: falsefor the Claude Code client. PostHog error tracking surfaced this as a new issue (fingerprint19e2817…) on 2026-05-29 — currently 1 occurrence / 1 user, but it will reproduce for anyone on the plugin-only install path.Changes
In
claude-code.ts,removeServer()now mirrors the install path:isPluginInstalled()is true, runclaude plugin uninstall posthog.claude mcp remove --scope user <serverName>.No user-scoped MCP server foundand plugin not-installed variants — are treated as no-ops. Only genuinely unexpected failures get reported viaanalytics.captureException.The function returns
success: truewhen nothing unexpected blew up, including the common case where one of the two surfaces simply has nothing to remove.Test coverage added for:
local=trueusesposthog-localTest plan
pnpm buildpnpm jest src/steps/add-mcp-server-to-clients/clients/__tests__/claude-code.test.ts— 16/16 passpnpm lint— no new errorspnpm test— only an unrelated, pre-existing flaky timeout insrc/__tests__/provision-cli.test.ts(passes in isolation, passes on main)Created with PostHog Code