Skip to content

feat(skills): mcp-analytics instruments Python MCP servers too#205

Merged
lucasheriques merged 2 commits into
mainfrom
posthog-code/mcp-analytics-python
Jun 26, 2026
Merged

feat(skills): mcp-analytics instruments Python MCP servers too#205
lucasheriques merged 2 commits into
mainfrom
posthog-code/mcp-analytics-python

Conversation

@lucasheriques

Copy link
Copy Markdown
Contributor

The Python SDK (posthog.mcp, shipped inside posthog v7.21.0 — already on PyPI) is live, so the wizard mcp-analytics codemod should instrument Python servers instead of aborting on them. This makes Python onboarding as one-line as TS/JS.

What changed (context/skills/mcp-analytics/)

description.md — the codemod is now bilingual:

  • Guardrail routes by language in STEP 1 (TS/JS or Python); only aborts on other languages (Go, Rust, …).
  • Each step has a TypeScript / JavaScript part and a Python part:
    • Detect a Python MCP server: official mcp FastMCP/Server, jlowin's fastmcp 2.0, or a custom FastAPI/Starlette/edge dispatcher.
    • Install posthog>=7.21 (the mcp/fastmcp SDK is a peer dependency the user already has — don't add it; PostHogMCP-only projects need nothing beyond posthog).
    • Wrap with instrument(server, posthog) (path P1) or use PostHogMCP + capture_tool_call/capture_initialize (path P2).
    • Flush on exit (await analytics.flush()posthog.shutdown()), and keep STDIO clean (never print() to stdout; logger to stderr).

config.yaml — broadened the description and added a python variant (tags: [python, mcp]) so the wizard offers mcp-analytics on Python projects.

Notes

  • Wizard command word is unchanged (still mcp-analytics), so no wizard-repo PR is needed — this resolves at runtime from the context-mill release.
  • Release gate: reaches users on the next context-mill release — merge with the mcp-publish + minor labels.
  • Validated: vitest run scripts/lib/tests (70/70 pass), config YAML parses with both variants.

Related: SDK PostHog/posthog-python#691 (merged, shipped v7.21.0), docs PostHog/posthog.com#17827.


Created with PostHog Code

The Python SDK (posthog.mcp, shipped inside posthog v7.21.0) is live, so the
wizard codemod should handle Python instead of aborting on it.

- Guardrail: route by language in STEP 1 (TS/JS or Python); only abort on other
  languages, not Python.
- Each step now has a TS/JS part and a Python part: detect a Python MCP server
  (official mcp FastMCP/Server, jlowin fastmcp 2.0, or a custom dispatcher),
  install `posthog>=7.21` (the mcp/fastmcp SDK is a peer dep already present),
  wrap with `instrument(server, posthog)` or use `PostHogMCP`, flush on exit, and
  keep STDIO clean (no print() to stdout; logger to stderr).
- config.yaml: broaden the description and add a `python` variant (tags: [python,
  mcp]) so the wizard offers mcp-analytics on Python projects.

Reaches users on the next context-mill release (merge with the `mcp-publish` +
`minor` labels). Wizard command word is unchanged, so no wizard-repo PR needed.

Generated-By: PostHog Code
Task-Id: b21bc954-5de3-4512-a0d5-6bec2371f782
@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 error-tracking-upload-source-maps
  • /wizard-ci mcp-analytics
  • /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 error-tracking-upload-source-maps/android
  • /wizard-ci error-tracking-upload-source-maps/cicd-docker-node-raw
  • /wizard-ci error-tracking-upload-source-maps/cicd-github-actions-docker-node-raw
  • /wizard-ci error-tracking-upload-source-maps/cicd-github-actions-nested-docker-node-raw
  • /wizard-ci error-tracking-upload-source-maps/cicd-github-actions-node-raw
  • /wizard-ci error-tracking-upload-source-maps/cicd-github-actions-single-stage-docker-node-raw
  • /wizard-ci error-tracking-upload-source-maps/cicd-gitlab-node-raw
  • /wizard-ci error-tracking-upload-source-maps/cicd-monorepo-pnpm-node-react
  • /wizard-ci error-tracking-upload-source-maps/cicd-monorepo-raw-node-react
  • /wizard-ci error-tracking-upload-source-maps/cicd-ssh-vps-node-raw
  • /wizard-ci error-tracking-upload-source-maps/flutter
  • /wizard-ci error-tracking-upload-source-maps/ios
  • /wizard-ci error-tracking-upload-source-maps/next
  • /wizard-ci error-tracking-upload-source-maps/next-no-posthog
  • /wizard-ci error-tracking-upload-source-maps/node-raw
  • /wizard-ci error-tracking-upload-source-maps/node-rollup
  • /wizard-ci error-tracking-upload-source-maps/node-rollup-typescript-plugin
  • /wizard-ci error-tracking-upload-source-maps/node-webpack
  • /wizard-ci error-tracking-upload-source-maps/nuxt-3-6
  • /wizard-ci error-tracking-upload-source-maps/nuxt-4-3
  • /wizard-ci error-tracking-upload-source-maps/react-native
  • /wizard-ci error-tracking-upload-source-maps/react-vite
  • /wizard-ci error-tracking-upload-source-maps/rust
  • /wizard-ci mcp-analytics/custom-dispatcher
  • /wizard-ci mcp-analytics/typescript-sdk
  • /wizard-ci misc/quack-quack
  • /wizard-ci revenue/stripe

Results will be posted here when complete.

…Python paths

#204 (NestJS Path D) merged to main while this branch was in review. Keep both:
the bilingual TS/JS + Python structure, with the @rekog/mcp-nest Path D folded
into the JS side (STEP 1 signals, STEP 2 paths, STEP 4 instrumentMutator snippet)
and added to the config description.

Generated-By: PostHog Code
Task-Id: b21bc954-5de3-4512-a0d5-6bec2371f782
@lucasheriques lucasheriques merged commit 0311d6d into main Jun 26, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant