Skip to content

fix(mcp): ask before adding the PostHog MCP to coding agents - #1624

Open
Ankur1911 wants to merge 1 commit into
PostHog:mainfrom
Ankur1911:fl/ask-before-mcp-install
Open

Ankur1911 wants to merge 1 commit into
PostHog:mainfrom
Ankur1911:fl/ask-before-mcp-install

Conversation

@Ankur1911

Copy link
Copy Markdown

Problem

The setup flow's MCP step installs the PostHog MCP into every detected coding agent without asking. After the outro it goes straight from detectClients() to installAll(local) and writes a posthog server into each agent's user-wide config (for example VS Code's user-level mcp.json), outside the project the wizard was pointed at. Only the remove flow has an ask phase, and the AI-assistants step already lets the user skip, so the two steps behave differently.

Closes #1620

Changes

  • McpScreen takes a new confirmInstall prop. When set, install mode stops in the existing Phase.Ask after detection, lists the detected coding agents and offers "Add the PostHog MCP" or "Skip". Nothing is written until the user picks Add. esc also skips.
  • Skipping completes the step as McpOutcome.Skipped, and goes on to the AI-assistants step when the user has account clients (the outcome is kept, so leaving that step reports skipped with no installed clients).
  • The core ScreenId.Mcp screen, the one the setup flow shows, sets confirmInstall. mcp add leaves it off: running that command is the request, so it installs straight away as before. mcp remove is unchanged.
  • The remove picker's esc binding is shared with the new ask, so it is now keyed on mode.

Left out on purpose: a --no-mcp flag or env variable for scripted runs (also suggested in the issue). The TUI is the only host that shows this step, so I kept this to the prompt; happy to add the flag in a follow-up if you want it.

Test plan

  • src/tui/__tests__/mcp-screen-outcome.test.tsx: four new tests. With confirmInstall the installer is not called until the user agrees; Add installs and shows the results; Skip and esc install nothing and complete as skipped with one mcp complete event; after Skip the AI-assistants step is still offered and completes as skipped. The existing install tests (no confirmInstall) are unchanged and pass.
  • e2e-harness/__tests__/keyboard-equivalence.test.tsx: the MCP pair now types Enter twice (agree, then leave the results); a new pair covers esc against set_mcp_outcome with skipped.
  • frames/mcp-*.txt snapshots updated: the setup flow's MCP screen now opens on the question.
  • pnpm typecheck clean, pnpm lint 0 errors (existing warnings only), vitest run 4846 passed. Under full-suite load a few timing-sensitive tests (cli.test.ts --region, wizard-ci-driver, run-offer-delivery, migrated-from) time out intermittently; each passes when run alone, with and without this change.
  • Not run: pnpm build / the smoke tests, and a real install into editors on a desktop (the screen is tested against a fake installer).

The MCP step of the setup flow wrote a posthog server into every detected
coding agent's user-wide config right after the outro, with no question.
McpScreen now takes a confirmInstall prop. The setup flow sets it: the screen
lists the detected agents and offers Add or Skip (esc also skips) before it
touches any config. Skipping completes the step as skipped and still goes on to
the AI assistants step when there is one. mcp add leaves the prop off, since
running that command is the request.
@Ankur1911
Ankur1911 requested a review from a team as a code owner November 28, 2026 01:09
@signed-commit-check

Copy link
Copy Markdown

A quick word from the signature department

Hey @Ankur1911, thanks for the PR! GitHub couldn't verify the signature on this commit:

  • 98d6529: Unsigned

PostHog requires verified commit signatures before merging. So we've built a bot to do the nagging. You're talking to it.

Let's get this verified

If signing isn't set up yet, follow our signing guide or GitHub's guide.

Already signed? Make sure GitHub recognizes your key. SSH keys must be registered as a Signing Key, not only as an Authentication Key.

Once signing is set up, if the unsigned commit is your latest commit, run:

git commit --amend --no-edit -S
git push --force-with-lease

Those commands fix only your latest commit. Older unsigned commits need signing too. Coordinate with anyone else using the branch before rewriting its history.

Save your future self another visit from me:

git config --local commit.gpgsign true

That enables signing for future commits; it doesn't sign existing ones. A Signed-off-by line isn't a cryptographic signature.

I'll check again after your next push and update this comment.

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.

The setup wizard installs the PostHog MCP into every coding agent it finds without asking

1 participant