:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
chore(mcp-analytics): refresh debugging skill for SDK 0.11.x and Python parity (#88872)
Lucas Faria6e667394cfa1
diff --git a/products/mcp_analytics/skills/debugging-mcp-analytics/SKILL.md b/products/mcp_analytics/skills/debugging-mcp-analytics/SKILL.mdindex 351ce85bd384..0ddfed5ed82a 100644--- a/products/mcp_analytics/skills/debugging-mcp-analytics/SKILL.md+++ b/products/mcp_analytics/skills/debugging-mcp-analytics/SKILL.md@@ -38,17 +38,17 @@ GitHub is the source of truth for where the code lives. Paths below are in-repo;repos outside this monorepo, resolve a local checkout via[references/local-repos.md](references/local-repos.md) rather than assuming a location.-| Concern | Repo | Where to look |-| --------------------------------- | ----------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |-| **Product / dashboard** | `PostHog/posthog` (this repo) | `products/mcp_analytics/` — Django/DRF + HogQL query runners + Temporal, Kea frontend, the `query-mcp-*` tool registry, and the analysis skills |-| **Self-instrumented server** | `PostHog/posthog` (this repo) | `services/mcp/` — PostHog's own MCP server (Hono); the dogfood event producer. Also hosts the _generated_ `query-mcp-*` handlers |-| **Shared query reference** | `PostHog/posthog` (this repo) | `products/posthog_ai/skills/querying-posthog-data/references/models-mcp.md` |-| **TypeScript SDK** `@posthog/mcp` | `PostHog/posthog-js` | `packages/mcp/` — the library customers install. Vocabulary source of truth: `src/extensions/constants.ts`. `docs/ARCHITECTURE.md` is stale on the session model (it predates conversation anchoring) — trust `CHANGELOG.md` and the source |-| **Python SDK** `posthog.mcp` | `PostHog/posthog-python` | `posthog/mcp/` — mirrors `posthog.ai`. Ships inside `posthog` (`pip install posthog`); `mcp`/`fastmcp` are lazily-imported peer deps, **no `[mcp]` extra** |-| **Docs** | `PostHog/posthog.com` | `contents/docs/mcp-analytics/` (incl. `surfaces/`), plus `src/hooks/productData/mcp_analytics.tsx` and the `mcp_analytics` entry in `src/data/tools.ts` |-| **Install codemod** | `PostHog/context-mill` | `context/skills/mcp-analytics/{config.yaml,description.md}` |-| **Wizard CLI** | `PostHog/wizard` | `bin.ts`, `src/commands/mcp-analytics.ts`, `src/lib/programs/mcp-analytics/` |-| **Wizard test harness** | `PostHog/wizard-workbench` | `apps/mcp-analytics/` fixtures |+| Concern | Repo | Where to look |+| --------------------------------- | ----------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |+| **Product / dashboard** | `PostHog/posthog` (this repo) | `products/mcp_analytics/` — Django/DRF + HogQL query runners + Temporal, Kea frontend, the `query-mcp-*` tool registry, and the analysis skills |+| **Self-instrumented server** | `PostHog/posthog` (this repo) | `services/mcp/` — PostHog's own MCP server (Hono); the dogfood event producer. Also hosts the _generated_ `query-mcp-*` handlers |+| **Shared query reference** | `PostHog/posthog` (this repo) | `products/posthog_ai/skills/querying-posthog-data/references/models-mcp.md` |+| **TypeScript SDK** `@posthog/mcp` | `PostHog/posthog-js` | `packages/mcp/` — the library customers install. Vocabulary source of truth: `src/extensions/constants.ts`. `docs/ARCHITECTURE.md` now covers conversation anchoring (ADR-0004) but trails the newest era handling — where it and `CHANGELOG.md` disagree, trust the changelog and the source |+| **Python SDK** `posthog.mcp` | `PostHog/posthog-python` | `posthog/mcp/` — mirrors `posthog.ai`. Ships inside `posthog` (`pip install posthog`); `mcp`/`fastmcp` are lazily-imported peer deps, **no `[mcp]` extra**. At TS parity since 7.40.0-7.42.1 — MCP Python SDK v2, conversation anchoring, typed errors, client UA/vendor |+| **Docs** | `PostHog/posthog.com` | `contents/docs/mcp-analytics/` (incl. `surfaces/`), plus `src/hooks/productData/mcp_analytics.tsx` and the `mcp_analytics` entry in `src/data/tools.ts` |+| **Install codemod** | `PostHog/context-mill` | `context/skills/mcp-analytics/{config.yaml,description.md}` |+| **Wizard CLI** | `PostHog/wizard` | `bin.ts`, `src/commands/mcp-analytics.ts`, `src/lib/programs/mcp-analytics/` |+| **Wizard test harness** | `PostHog/wizard-workbench` | `apps/mcp-analytics/` fixtures |**Don't conflate:**@@ -291,19 +291,25 @@ The wizard install flow, the skill-distribution channels, and the in-app onboard## Current state-Verified against `master`, `@posthog/mcp` 0.10.8, `posthog` 7.38.0, and MCP spec `2026-07-28`-on 2026-08-06. Treat versions and open threads as perishable: re-check+Verified against `master`, `@posthog/mcp` 0.11.7, `posthog` 7.44.0, and MCP spec `2026-07-28`+on 2026-08-25. Treat versions and open threads as perishable: re-check`packages/mcp/CHANGELOG.md`, the pinned alias in `services/mcp/package.json`, and[mega-issue 64016](https://github.com/PostHog/posthog/issues/64016) rather than trusting thissection.-**The stateless protocol is the live piece of work.** `services/mcp` already speaks both-dialects (`src/lib/stateless-protocol.ts` — per-request dialect detection, `server/discover`, no-session minting for modern clients). The TypeScript SDK shipped conversation-anchored sessions-through 0.10.8. The Python SDK is the part still in flight: conversation-id exists, but-`_meta`-based client identity and true 2026-07-28 support are open in-[posthog-python 803](https://github.com/PostHog/posthog-python/pull/803) and-[830](https://github.com/PostHog/posthog-python/pull/830).+**Both SDKs now speak the stateless spec and the v2 MCP SDKs.** `services/mcp` speaks both+dialects at the protocol layer (`src/lib/stateless-protocol.ts` — per-request dialect+detection, `server/discover`, no session minting for modern clients). The TypeScript SDK's+0.10.9-0.11.7 run instruments MCP TypeScript SDK v2 servers (structural detection in+`detect.ts`, both `@modelcontextprotocol` peers optional), resolves client identity and+protocol version through a per-request fallback chain, gates `Mcp-Session-Id` minting on the+revision each request declares, and captures `$mcp_client_user_agent` / `$mcp_vendor_client`.+The Python SDK caught up in `posthog` 7.40.0-7.42.1: MCP Python SDK v2, conversation-anchored+sessions byte-compatible with TS (`derive_session_id_from_conversation`), typed+`$mcp_error_type` / `$mcp_error_message`, and the same UA/vendor capture. The old parity+threads ([posthog-python 803](https://github.com/PostHog/posthog-python/pull/803) and+[830](https://github.com/PostHog/posthog-python/pull/830)) were **closed unmerged and+superseded** — don't cite them as the source of what landed.[references/stateless-and-sessions.md](references/stateless-and-sessions.md) is the referencefor all of it.@@ -312,7 +318,12 @@ reports, `mcp_analytics` access control, the shared `ProductEmptyState` adoptionfailure-occurrence drill-down with "create fix task", the migration of every chart to typedquery runners, the demo seeder, and exec-mode inner-tool breakout (Hard rule 1).-Two code-facing facts that shape debugging, both checkable in this repo: the `services/mcp` SDK-pin can lag the published SDK (Hard rule 5 — read the alias in its `package.json`; it is on-0.10.2 while the SDK is 0.10.8), and the product is still behind the `mcp-analytics` flag, so a-project without it sees nothing.+What still lags, all checkable in this repo: the `services/mcp` alias pin is `0.10.2` against a+0.11.7 SDK (Hard rule 5 — no 0.11.x SDK-side fix or SDK-emitted property reaches dogfood data,+though the server independently stamps `$mcp_client_user_agent` and the non-`$`+`mcp_vendor_client` regardless of the pin);+harness resolution does not read the SDK-emitted `$mcp_vendor_client` yet (`HARNESS_TOKEN_SQL`+consumes `$mcp_client_user_agent`, but its top-priority vendor signal is still the+server-stamped non-`$` `mcp_vendor_client`); the exec-property emitter is still absent from+master (Hard rule 1); the clustering schedule still covers only `GUARANTEED_TEAM_IDS = [2]`;+and the product remains behind the `mcp-analytics` flag, so a project without it sees nothing.diff --git a/products/mcp_analytics/skills/debugging-mcp-analytics/references/event-vocabulary.md b/products/mcp_analytics/skills/debugging-mcp-analytics/references/event-vocabulary.mdindex 82dfdb56ea0c..00a7d3967f06 100644--- a/products/mcp_analytics/skills/debugging-mcp-analytics/references/event-vocabulary.md+++ b/products/mcp_analytics/skills/debugging-mcp-analytics/references/event-vocabulary.md@@ -32,27 +32,28 @@ name it is given rather than `$mcp_custom`.On `$mcp_tool_call` unless noted. These are the properties any instrumented server produces.-| Property | Notes |-| ------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |-| `$mcp_tool_name` | The tool the agent called. In single-exec mode this holds the resolved inner tool, or the literal `exec` when unrecognized — see exec-mode below. |-| `$mcp_tool_description` | The description the agent saw. In single-exec mode this is the dispatcher's static text on every call. |-| `$mcp_tool_category` | Server-assigned grouping. Used by the Signals scout to group problem tools. |-| `$mcp_intent` | Why the agent made the call — the product's differentiator. Populated from the injected `context` argument, or a configured fallback. |-| `$mcp_intent_source` | `context_parameter` or `inferred`. Tells you whether the agent actually filled the context argument. |-| `$mcp_is_error` | Boolean failure flag. **The canonical failure signal.** |-| `$mcp_duration_ms` | Call latency. Cast before aggregating: `quantile(0.95)(toFloat(properties.$mcp_duration_ms))`. |-| `$mcp_parameters` | Captured arguments, sanitized. |-| `$mcp_response` | Captured response, sanitized. May be empty by configuration. |-| `$mcp_listed_tool_names` | On `$mcp_tools_list`. JSON array of advertised tools. Diff against called tool names for zombie tools. In single-exec mode `$mcp_exec_inner_tool_names` is the intended catalog field, but is unemitted today — see exec-mode below. |-| `$mcp_error_type` | Since TS 0.8.0. Low-cardinality label — `validation`, `permission`, `timeout`, `rate_limited`, etc. Defaults to the thrown error's type; hosts can pass an explicit label. |-| `$mcp_error_message` | Since TS 0.8.0. Redacted automatically as of TS 0.10.2. |-| `$mcp_client_name` / `$mcp_client_version` | The calling client as _it_ reported itself. One mid-priority input to harness resolution — not the harness label. |-| `$mcp_server_name` / `$mcp_server_version` | The instrumented server's own identity. |-| `$mcp_protocol_version` | Since TS 0.10.0. The negotiated MCP spec version. On legacy `initialize`-handshake sessions it is stamped on `$mcp_initialize` and every subsequent event of that session; under the 2026-07-28 revision it is **per request**, so one `$session_id` can legitimately span more than one value — don't treat it as a session constant. See [stateless-and-sessions.md](stateless-and-sessions.md). |-| `$mcp_conversation_id` | The conversation handle: **server-minted on the first call, agent-echoed thereafter** (an invented value is rejected and replaced). **Survives reconnects, but only when the server sets `enableConversationId`** (off by default) — see identifiers below and [stateless-and-sessions.md](stateless-and-sessions.md). |-| `$mcp_resource_name` | On resource events. |-| `$session_id` | The standard PostHog session id, materialized. The usual grouping key. |-| `$mcp_source` | Always `posthog_mcp_analytics`. The reliable way to isolate MCP events from everything else on the `events` table. |+| Property | Notes |+| ----------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |+| `$mcp_tool_name` | The tool the agent called. In single-exec mode this holds the resolved inner tool, or the literal `exec` when unrecognized — see exec-mode below. |+| `$mcp_tool_description` | The description the agent saw. In single-exec mode this is the dispatcher's static text on every call. |+| `$mcp_tool_category` | Server-assigned grouping. Used by the Signals scout to group problem tools. |+| `$mcp_intent` | Why the agent made the call — the product's differentiator. Populated from the injected `context` argument, or a configured fallback. |+| `$mcp_intent_source` | `context_parameter` or `inferred`. Tells you whether the agent actually filled the context argument. |+| `$mcp_is_error` | Boolean failure flag. **The canonical failure signal.** |+| `$mcp_duration_ms` | Call latency. Cast before aggregating: `quantile(0.95)(toFloat(properties.$mcp_duration_ms))`. |+| `$mcp_parameters` | Captured arguments, sanitized. |+| `$mcp_response` | Captured response, sanitized. May be empty by configuration. |+| `$mcp_listed_tool_names` | On `$mcp_tools_list`. JSON array of advertised tools. Diff against called tool names for zombie tools. In single-exec mode `$mcp_exec_inner_tool_names` is the intended catalog field, but is unemitted today — see exec-mode below. |+| `$mcp_error_type` | Since TS 0.8.0. Low-cardinality label — `validation`, `permission`, `timeout`, `rate_limited`, etc. Defaults to the thrown error's type; hosts can pass an explicit label. |+| `$mcp_error_message` | Since TS 0.8.0. Redacted automatically as of TS 0.10.2. |+| `$mcp_client_name` / `$mcp_client_version` | The calling client as _it_ reported itself. One mid-priority input to harness resolution — not the harness label. |+| `$mcp_client_user_agent` / `$mcp_vendor_client` | Since TS 0.11.0 / Python 7.42.0. The raw `User-Agent` and vendor header (e.g. `x-anthropic-client`) — `clientInfo.name` can't tell one vendor surface from another (`claude-code` is the CLI, the Agent SDK, the VS Code extension, and the desktop app alike). HTTP transports only; stdio and in-memory servers carry no headers. Captured raw and resolved to labels at query time. `HARNESS_TOKEN_SQL` reads `$mcp_client_user_agent`, but **not** `$mcp_vendor_client` yet — its vendor signal is still the server-stamped non-`$` `mcp_vendor_client`. |+| `$mcp_server_name` / `$mcp_server_version` | The instrumented server's own identity. |+| `$mcp_protocol_version` | Since TS 0.10.0. The negotiated MCP spec version. On legacy `initialize`-handshake sessions it is stamped on `$mcp_initialize` and every subsequent event of that session; under the 2026-07-28 revision it is **per request**, so one `$session_id` can legitimately span more than one value — don't treat it as a session constant. See [stateless-and-sessions.md](stateless-and-sessions.md). |+| `$mcp_conversation_id` | The conversation handle: **server-minted on the first call, agent-echoed thereafter** (an invented value is rejected and replaced). **Survives reconnects, but only when the server sets `enableConversationId`** (off by default) — see identifiers below and [stateless-and-sessions.md](stateless-and-sessions.md). |+| `$mcp_resource_name` | On resource events. |+| `$session_id` | The standard PostHog session id, materialized. The usual grouping key. |+| `$mcp_source` | Always `posthog_mcp_analytics`. The reliable way to isolate MCP events from everything else on the `events` table. |## Server-stamped properties@@ -61,7 +62,8 @@ Added by PostHog's own server (`services/mcp/src/hono/analytics.ts::buildBaseProserver, so never rely on them in customer-facing queries or docs without checking.`$mcp_session_id` (transport-level), `$mcp_region`, `$mcp_mode`, `$mcp_consumer`,-`$mcp_version`, `$mcp_client_user_agent`, `$mcp_transport`, `$mcp_auth_method`,+`$mcp_version`, `$mcp_client_user_agent` (no longer dogfood-only — the SDKs emit it too since+TS 0.11.0 / Python 7.42.0), `$mcp_transport`, `$mcp_auth_method`,`$mcp_organization_id`, `$mcp_project_id`, `$mcp_project_uuid`, `$mcp_project_name`,`$ai_product` (`mcp`), and the non-`$`-prefixed `mcp_runtime` (`hono`) and`mcp_vendor_client` — the last of which is the **top-priority harness signal**, so it@@ -176,22 +178,53 @@ semantics rather than the API surface.to an agent-echoed `conversation_id`, and tool results may carry an `_mcp_instructions` key.See [stateless-and-sessions.md](stateless-and-sessions.md); do not reason about sessions fromthis list alone.+- **0.10.9 / 0.11.1** — MCP TypeScript SDK **v2** servers are instrumented at all: string-keyed+ `setRequestHandler` registrations are wrapped, and `registerTool()`-only high-level servers+ pass the compatibility gate (structural probes in `detect.ts`). Both `@modelcontextprotocol`+ peers are optional as of 0.11.2. Before these, a v2 server produced **zero `$mcp_*` events,+ silently** — the first thing to check when a v2 customer reports no data.+- **0.11.0** — `$mcp_client_user_agent` / `$mcp_vendor_client` (above). HTTP transports only;+ on the `PostHogMCP` custom-dispatcher path they are caller-supplied capture arguments.+- **0.11.2 / 0.11.3** — client name/version and `$mcp_protocol_version` resolve through a+ per-request fallback chain: the v2 request envelope, then `params._meta`, then the+ `MCP-Protocol-Version` header (the one carrier 2025-11-25 traffic has on every+ post-`initialize` request), then the server's own accessors. Fills identity that v2 and+ per-request-instance servers previously dropped.+- **0.11.4** — `Mcp-Session-Id` is minted only for requests declaring a pre-2026-07-28+ revision, and `$mcp_error_message` is read before the conversation prompt-back is appended.+ Before this, a recurring failure on a conversation-enabled server embedded a fresh uuid in+ its message and split into a new error group on every occurrence.+- **0.11.5** — `$mcp_intent` is captured on servers that build a fresh instance per request+ (previously the `context` argument was discarded there); the `tools/list` response envelope+ is preserved (`nextCursor`, `ttlMs`/`cacheScope`, `_meta` — instrumenting a paginated+ catalogue used to hide its later pages); `identify` resolves on `tools/list` too.+- **0.11.6** — `$mcp_tool_call` and `$mcp_initialize` attribute to the client that made the+ request, rather than to whichever handshake last arrived on the same server instance.+- **0.11.7** — the conversation-handle prompt-back is plain JSON data in the `content` block,+ and `_mcp_instructions` carries `{ conversation_id }` only — the imperative `instructions`+ sentence was dropped because clients flagged it as prompt-injection-shaped.## Python SDK parity`posthog/mcp/` in `PostHog/posthog-python`, mirroring the `posthog.ai` layout. `instrument()`-covers the official SDK's FastMCP and low-level `Server`, **and** jlowin's standalone-fastmcp 2.0 (routed via its `_mcp_server`, stripping the injected `context` because that-library rejects unexpected kwargs). `PostHogMCP` covers custom dispatchers.--Has: stateless sessions, `$mcp_protocol_version`, once-per-session `$identify`, payload-sanitization. Resources and prompts are intentionally omitted, matching TS `instrument()`.--**Known gaps against the TypeScript SDK** — verify before promising parity:--- no typed `$mcp_error_type` / `$mcp_error_message` taxonomy (the largest gap)-- no `_meta`-based client identity for the 2026-07-28 stateless revision-- no `instrumentMutator` equivalent+covers the official SDK's FastMCP and low-level `Server` on **both majors** — since `posthog`+7.40.0 that includes MCP Python SDK v2 (`mcp.server.mcpserver.MCPServer`, the renamed FastMCP,+and the v2 low-level `Server`, late `add_request_handler` registrations included) — **and**+jlowin's standalone fastmcp 2.0 (routed via its `_mcp_server`, stripping the injected `context`+because that library rejects unexpected kwargs). An unsupported or unrecognized SDK degrades to+a logged no-op rather than raising. `PostHogMCP` covers custom dispatchers.++At TS parity as of 7.40.0-7.42.1: conversation-anchored sessions+(`derive_session_id_from_conversation`, byte-compatible with TS), per-request client identity+and `$mcp_protocol_version` on both protocol eras, typed `$mcp_error_type` /+`$mcp_error_message` (7.41.0, redacted before send like TS), `$mcp_client_user_agent` /+`$mcp_vendor_client` (7.42.0), `get_request_headers(extra)`, stateless session tokens,+once-per-session `$identify`, and payload sanitization. 7.42.1 adds loud warnings when the+stateless session-mint middleware never attached (an ASGI app built before `instrument()` ran)+— the previously-silent cause of per-process session fragmentation. Resources and prompts are+intentionally omitted, matching TS `instrument()`.++**Remaining gap against the TypeScript SDK**: no `instrumentMutator` equivalent.## Query gotchasdiff --git a/products/mcp_analytics/skills/debugging-mcp-analytics/references/stateless-and-sessions.md b/products/mcp_analytics/skills/debugging-mcp-analytics/references/stateless-and-sessions.mdindex b5d32440619d..d984eae8bd2e 100644--- a/products/mcp_analytics/skills/debugging-mcp-analytics/references/stateless-and-sessions.md+++ b/products/mcp_analytics/skills/debugging-mcp-analytics/references/stateless-and-sessions.md@@ -5,7 +5,7 @@ analytics used to key attribution on — the `initialize` handshake and the `Mcpheader — so "what is one session?" had to be rebuilt at the application layer. This file is thereference for that: what the spec says, what the SDK does about it, and what it means for a query.-Verified 2026-08-06 against spec `2026-07-28`, `@posthog/mcp` 0.10.8, `posthog` 7.38.0, and+Verified 2026-08-25 against spec `2026-07-28`, `@posthog/mcp` 0.11.7, `posthog` 7.44.0, anddotcom master. Versions move fast — re-check before trusting a number here.## What the spec actually changed@@ -134,6 +134,10 @@ boundary. Don't treat it as one.| Text block in `content` | only on the call that **minted** it, plus errored results (#4433) | `injectConversationIdPromptBack` || `structuredContent._mcp_instructions` | every response **from an instance that served the `tools/list`** for that tool (#4431) | `mirrorInstructionsIntoStructuredContent` |+Since 0.11.7 (#4542) both channels carry **plain JSON data** — the `content` block is+`{"conversation_id": "…"}` — rather than an imperative "reuse this id" server sentence, which+clients had started flagging as prompt-injection-shaped.+The second exists because clients that read structured results never see the `content` text block— correlation for those tools measured 0/15 against Claude Code before the fix, 15/15 after(figures from the #4430/#4431 PR bodies; they aren't reproducible from source).@@ -154,8 +158,9 @@ no ownership override, so `conversationId` collapses to `listed?.conversationId`per-request low-level instance resolves no handle at all — step 1 of the resolution order neverfires. The high-level path is saved by an explicit override; the low-level path is not.-Shape under the `_mcp_instructions` key: `{ conversation_id: string, instructions: string }`, where-`instructions` is the fixed line telling the agent to send the id on every subsequent call.+Shape under the `_mcp_instructions` key: `{ conversation_id: string }`. The `instructions`+sentence that used to ride along was dropped in 0.11.7, for the same prompt-injection reason as+above — a document describing the old two-field shape is stale.If neither channel can carry it (no declared output schema, and a result with no `content` array),the SDK clears `event.conversationId` rather than reporting a conversation the agent was never@@ -188,22 +193,44 @@ dialect per request from `_meta`'s protocol-version key or the header, then branclients still get `initialize`/`ping`, modern clients get `server/discover` and **no sessionminting**. So the server speaks both today.-**TypeScript SDK — shipped through 0.10.8.** The session model above is current.--**Python SDK (`posthog` 7.38.0) — this is the part still in flight.** Conversation-id already-exists (`posthog/mcp/_conversation_id.py`), and 7.30.0/7.33.0 brought multi-pod session tokens and-`$mcp_protocol_version`. But those are the _legacy_ handshake mechanism scaled across pods, not-spec-stateless support. Open and unmerged:--- **posthog-python#803** — read client identity from request `_meta`, closing the parity gap with- TS 0.10.1.-- **posthog-python#830** — MCP 2026-07-28 + mcp 2.x SDK support: an adapter via the official- `ServerMiddleware`, plus `_derived_sessions.py` deriving `$session_id` from- `(distinct_id, client_name, client_version)` per SEP-2567 guidance now the header is gone. Adds- `$mcp_result_type` and `$mcp_session_id_source`.--Treat Python as _not yet_ spec-stateless until those land, and don't promise TS/Python parity on-`_meta` identity.+**TypeScript SDK — shipped through 0.11.7.** The session model above is current, plus the+0.11.x era work on top of it:++- MCP TypeScript SDK **v2** servers are instrumented at all (0.10.9/0.11.1 — structural probes+ in `detect.ts`; before that, a v2 server silently produced no events).+- Client identity and `$mcp_protocol_version` resolve per request through a fallback chain —+ the v2 request envelope, then `params._meta`, then the `MCP-Protocol-Version` header, then+ the server's own accessors (0.11.2/0.11.3).+- `Mcp-Session-Id` is minted **only** for requests declaring a pre-2026-07-28 revision+ (0.11.4). The "era detection is an open follow-up" note in the SDK's `ARCHITECTURE.md`+ predates this — it shipped. One server serves both revisions request by request; an unknown+ version counts as legacy, so a v1 client that declares nothing keeps its header.+- `$mcp_intent` is captured on per-request server instances, and the `tools/list` envelope+ (`nextCursor`, caching directives) survives instrumentation (0.11.5).++**Python SDK (`posthog` >= 7.40.0) — spec-stateless, at TS parity.** The old parity threads —+posthog-python#803 (`_meta` client identity) and #830 (2026-07-28 + mcp 2.x support) — were+**closed unmerged and superseded**; the properties they proposed (`$mcp_result_type`,+`$mcp_session_id_source`) never shipped, so don't look for them in data. What landed instead,+across 7.40.0-7.42.1:++- MCP Python SDK v2 (`mcp.server.mcpserver.MCPServer`, the renamed FastMCP, and the v2+ low-level `Server`), with identity and `$mcp_protocol_version` resolved per request on both+ eras; an unsupported SDK degrades to a logged no-op instead of raising `ImportError` (7.40.0).+- Conversation-anchored sessions byte-compatible with TS: `derive_session_id_from_conversation`+ (exported), the same uuidv7 shape gate, both delivery channels including the+ `_mcp_instructions` mirror, and prompt-backs on errored results (7.40.0).+- Typed `$mcp_error_type` / `$mcp_error_message`, read from the same `$exception_list` the+ sibling event carries and redacted before send (7.41.0).+- `$mcp_client_user_agent` / `$mcp_vendor_client` on HTTP transports (7.42.0).+- Loud warnings when the stateless session-mint middleware never attached — an ASGI app built+ or mounted before `instrument()` runs cannot be retrofitted, and every session falls back to+ a fragmented per-process id (7.42.1). On a fragmented **Python** server, rule this out+ alongside the `enable_conversation_id` check above.++Host callbacks receive the SDK's own per-request context as `extra["ctx"]` identically on both+majors, with `get_request_headers(extra)` to read HTTP headers off it portably — a hand-rolled+read that works on one major silently returns nothing on the other.## Telling which model produced a session, from the data@@ -262,5 +289,9 @@ agent was never told about.- **Error codes were renumbered at the revision boundary** (`-32001` -> `-32020`, `-32003` ->`-32021`, `-32004` -> `-32022`, resource-not-found `-32002` -> `-32602`). Anything bucketing onthe raw code silently miscategorises across that boundary.+- **Error grouping is polluted in pre-TS-0.11.4 data.** On a conversation-enabled server, a+ failed call's `$mcp_error_message` used to embed the freshly-minted prompt-back — a new uuid+ per occurrence — so one recurring failure fragments into a new error group each time. Fixed+ in 0.11.4; expect the signature in older rows.- **Harness/client attribution is self-reported** under the stateless model, per the spec's ownwarning. Fine for product analytics, not for anything trust-bearing.