Skip to content

fix(pi): rebuild the MCP wiring on createMcpAdapter (adapter ~2.15) - #981

Merged
gewenyu99 merged 8 commits into
mainfrom
posthog-code/fix-pi-mcp-adapter-import
Jul 27, 2026
Merged

fix(pi): rebuild the MCP wiring on createMcpAdapter (adapter ~2.15)#981
gewenyu99 merged 8 commits into
mainfrom
posthog-code/fix-pi-mcp-adapter-import

Conversation

@gewenyu99

@gewenyu99 gewenyu99 commented Jul 25, 2026

Copy link
Copy Markdown
Collaborator

Fixes 2.51.0 prod orchestrator runs losing the PostHog MCP (adapter 2.12's exports map broke our .ts subpath imports, every dashboard task failed): the extension is now built with createMcpAdapter — the adapter's supported embedding API — with an isolated in-memory config and eager lifecycle, deleting the mcp.json write/restore dance and the reach into unexported internals; server instructions come from one standard-SDK handshake, and the jiti-loaded pi family is tilde-pinned.

2.12.x added an exports map that breaks the wizard's jiti .ts subpath
imports (index/server-manager/metadata-cache) — fresh prod installs
resolved ^2.9.0 to 2.12.1, the posthog MCP never attached to pi tasks,
and every 2.51.0 orchestrator run failed its dashboard step and aborted.
Pin the version the lockfile and CI actually test.

Generated-By: PostHog Code
Task-Id: 2d43c175-646e-4d73-a974-760280c8c95b
@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 mcp-analytics
  • /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 mcp-analytics/custom-dispatcher
  • /wizard-ci mcp-analytics/typescript-sdk
  • /wizard-ci revenue/stripe

Results will be posted here when complete.

@gewenyu99
gewenyu99 marked this pull request as ready for review July 25, 2026 01:19
@gewenyu99
gewenyu99 requested a review from a team as a code owner July 25, 2026 01:19
Try the .ts subpath (adapter ≤2.10, no exports map), fall back to
resolving the package root and importing the file by absolute path,
which exports maps cannot gate — so ≥2.12 packaging loads too. Proven
against both versions from the packed tarball.

Generated-By: PostHog Code
Task-Id: 2d43c175-646e-4d73-a974-760280c8c95b
Fresh user installs resolve package.json ranges, not our lockfile — the
pi-mcp-adapter 2.12 breakage shipped through exactly that gap. Pin every
dep to the lockfile's resolved version; lockfile specifiers rewritten in
place so resolutions are unchanged (verified by frozen install, trust
policy untouched).

Generated-By: PostHog Code
Task-Id: 2d43c175-646e-4d73-a974-760280c8c95b
@gewenyu99 gewenyu99 changed the title fix(pi): pin pi-mcp-adapter to exact 2.10.0 fix(pi): load the MCP adapter across packaging versions; exact-pin all deps Jul 27, 2026
Blanket exact pins were overkill — revert to main's ranges everywhere
except the jiti-live-loaded pi family (pi-mcp-adapter, pi-ai,
pi-coding-agent), which gets tilde: patch drift allowed, the minor bumps
that break packaging blocked.

Generated-By: PostHog Code
Task-Id: 2d43c175-646e-4d73-a974-760280c8c95b
… absolutely

Generated-By: PostHog Code
Task-Id: 2d43c175-646e-4d73-a974-760280c8c95b
…or the unexported warm internals

Generated-By: PostHog Code
Task-Id: 2d43c175-646e-4d73-a974-760280c8c95b
…~2.15

The file-config dance (write mcp.json, restore on cleanup) and the
pre-warm reach into unexported internals existed because the adapter had
no embedding API at 2.10. It does now: createMcpAdapter takes an
isolated in-memory config, and lifecycle "eager" connects at extension
load so direct tools register without a session_start. Instructions come
from one standard-SDK handshake instead of the adapter's private client.

Generated-By: PostHog Code
Task-Id: 2d43c175-646e-4d73-a974-760280c8c95b
@gewenyu99 gewenyu99 changed the title fix(pi): load the MCP adapter across packaging versions; exact-pin all deps fix(pi): rebuild the MCP wiring on createMcpAdapter (adapter ~2.15) Jul 27, 2026
…l client version, diff noise out

Generated-By: PostHog Code
Task-Id: 2d43c175-646e-4d73-a974-760280c8c95b
@gewenyu99
gewenyu99 merged commit 070d9da into main Jul 27, 2026
16 checks passed
@gewenyu99
gewenyu99 deleted the posthog-code/fix-pi-mcp-adapter-import branch July 27, 2026 04:03
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.

2 participants