Skip to content

: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.

docs(mcp-analytics): document the stateless protocol and the new session model (#79219)

Lucas Fariab1f25d9a45b9
diff --git a/products/mcp_analytics/skills/debugging-mcp-analytics/SKILL.md b/products/mcp_analytics/skills/debugging-mcp-analytics/SKILL.md
index 0b4c4f4286ec..351ce85bd384 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`. Internals: `docs/ARCHITECTURE.md` |
-| **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` 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 |
**Don't conflate:**
@@ -101,7 +101,14 @@ These are the failure modes that produce a plausible-looking answer rather than
**custom-dispatcher** (`PostHogMCP`) path rather than `instrument()`, so behaviour living
only in the `instrument()` path — stable sessions, `$identify` deduplication, `_meta`-based
client identity — has never applied to it at any version.
-6. **There are no SQL template files.** Every dashboard and tool-quality query is a typed
+6. **Know which session model produced the data.** Under the stateless spec there is no
+ transport session, so `$session_id` is only stable if the server opted into conversation
+ anchoring — `enableConversationId`, which is **off by default**. With it off, a stateless
+ client's sessions fragment (often one per request); with it on, `$session_id` is derived
+ from an agent-echoed handle and survives reconnects, restarts, and pods. Check the flag
+ before diagnosing "fragmented sessions" as an ingestion problem. See
+ [references/stateless-and-sessions.md](references/stateless-and-sessions.md).
+7. **There are no SQL template files.** Every dashboard and tool-quality query is a typed
query runner behind the generic `/query/` endpoint. A `backend/templates/*.sql` referenced
by older notes no longer exists.
@@ -120,9 +127,20 @@ and exec-mode properties the SDK does not define — live in `posthog/taxonomy/t
`$mcp_resource_read` / `$mcp_resources_list`, `$mcp_prompt_get` / `$mcp_prompts_list`,
`$identify`, `$exception`.
-> **`$mcp_initialize` is not a universal session anchor.** The MCP 2026-07-28 stateless
-> revision removes the `initialize` handshake, so clients on that revision never emit it.
-> Anchor on the first `$mcp_tool_call` instead.
+> **`$mcp_initialize` is not a reliable session anchor — but check whose server you're looking
+> at.** The 2026-07-28 revision removes the `initialize` handshake, so a customer server on the
+> SDK's `instrument()` path emits nothing for a stateless client. **PostHog's own server is the
+> exception**: `services/mcp` fires the same `$mcp_initialize` event from `server/discover` as
+> from `initialize` (`dispatcher.ts::recordDiscoveryRequest` covers both entry points), so the
+> event is present in dogfood data either way. Treat its absence as meaningful only for
+> customer servers. The real anchor is now the conversation handle when the server enables it —
+> [references/stateless-and-sessions.md](references/stateless-and-sessions.md) covers the
+> resolution order and the delivery protocol. Live consequence, for customer servers only:
+> `frontend/mcpAnalyticsOnboardingLogic.ts` derives `has_initialize` from this event, so a
+> stateless customer server reads as `not-instrumented` until its first tool call. Onboarding
+> still completes — `hasToolCall` is checked first, in both that selector and
+> `statusFromProbeDefinitions`. Projects on `services/mcp` are unaffected, since it emits the
+> event from `server/discover`.
Full property tables — split by provenance (SDK-emitted vs stamped by PostHog's own server vs
exec-mode only), the identifier distinctions, per-version SDK behaviour, and TypeScript/Python
@@ -273,16 +291,28 @@ The wizard install flow, the skill-distribution channels, and the in-app onboard
## Current state
-Verified against `master` and the SDK's `main` on 2026-07-31. 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 rather than trusting this section.
-
-Recently shipped: structured intent themes, first-party notification destinations and
-recurring reports, `mcp_analytics` access control, the shared `ProductEmptyState` adoption,
+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
+`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 this
+section.
+
+**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).
+[references/stateless-and-sessions.md](references/stateless-and-sessions.md) is the reference
+for all of it.
+
+Also shipped: structured intent themes, first-party notification destinations and recurring
+reports, `mcp_analytics` access control, the shared `ProductEmptyState` adoption,
failure-occurrence drill-down with "create fix task", the migration of every chart to typed
query 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`), and the
-product is still behind the `mcp-analytics` flag, so a project without it sees nothing. For
-status and planned work, read mega-issue #64016 rather than trusting a snapshot here.
+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.
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.md
index f654e2d5feec..7cf206a5fffd 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
@@ -31,27 +31,27 @@ 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, stamped on `$mcp_initialize` **and every subsequent event of the session**. Use it to track spec-revision adoption or to break metrics down by revision. |
-| `$mcp_conversation_id` | Agent-supplied conversation id. **Survives reconnects** — see identifiers below. |
-| `$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_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
@@ -65,7 +65,12 @@ server, so never rely on them in customer-facing queries or docs without checkin
non-`$`-prefixed `mcp_runtime` (`hono`) and `mcp_vendor_client` — the last of which is the
**top-priority harness signal**, so it appears inside harness SQL.
-Per-event additions: `$mcp_error_status` (upstream HTTP status), `$mcp_error_code` (machine-readable leaf failure code: the API's validation error code or the exec rejection reason), and `$mcp_error_field` (the validation error's field path, array indexes normalized to `N`, e.g. `actions__N__inputs__email`) — all stamped by `services/mcp/src/hono/tool-executor.ts` — **server-side, despite sitting next to the SDK's typed error properties in queries**; and `tool_count`, `read_only`, `via_sse_redirect` on `$mcp_initialize`. `execute-sql` calls additionally emit a separate `$ai_generation` event
+Per-event additions: `$mcp_error_status` (upstream HTTP status), `$mcp_error_code` (machine-readable leaf failure code: the API's validation error code or the exec rejection reason), and `$mcp_error_field` (the validation error's field path, array indexes normalized to `N`, e.g. `actions__N__inputs__email`) — all stamped by `services/mcp/src/hono/tool-executor.ts` — **server-side, despite sitting next to the SDK's typed error properties in queries**; and `tool_count`, `read_only`, `via_sse_redirect` on `$mcp_initialize`. Failed calls may also carry
+`$mcp_validation_fields` and `$mcp_validation_input_keys` (which fields failed validation, and
+which keys the caller actually sent), and exec-mode calls carry `$mcp_exec_verb` (which dispatcher
+verb ran) and `$mcp_exec_target_tool` (the tool that `info`/`schema`/`call` named). Those four are
+stamped in `tool-executor.ts` but are **not registered in `posthog/taxonomy/taxonomy.py`**, so they
+have no descriptions in the property picker — they still query fine. `execute-sql` calls additionally emit a separate `$ai_generation` event
carrying `$ai_trace_id`, `$ai_input`, `$ai_output_choices`, and `$ai_latency`.
## Exec-mode properties
@@ -94,13 +99,18 @@ returns no tools at all, that absence is the first thing to check.
## The three identifiers
+> Under the stateless spec `$session_id` may be derived from the conversation handle rather than
+> the transport — see [stateless-and-sessions.md](stateless-and-sessions.md) for the resolution
+> order before relying on the model below.
+
A frequent source of wrong session math:
- **`$session_id`** — the standard PostHog session id, a materialized column. The default
grouping key for "a session" in this product.
- **`$mcp_session_id`** — transport-level, from the `Mcp-Session-Id` header. **Rotates on
reconnect**, so counting it overcounts sessions.
-- **`$mcp_conversation_id`** — agent-supplied. **Survives reconnects**, so it is the right key
+- **`$mcp_conversation_id`** — server-minted on the first call, agent-echoed after (an invented
+ value is rejected and replaced). **Survives reconnects**, so it is the right key
for "one agent conversation" spanning drops.
## Library identity
@@ -144,6 +154,12 @@ semantics rather than the API surface.
- **0.10.2** — exception messages and large binary payload encodings are redacted
automatically, through the same sanitizer as parameters and responses. Unconditional, with
no configuration knob.
+- **0.10.3-0.10.7** — argument-preservation, per-server logger isolation, missing-capability
+ name collisions, and a fix for concurrent requests leaking identity/session attribution.
+- **0.10.8** — the largest data-semantics change in this list: `$session_id` can now be anchored
+ 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 from
+ this list alone.
## Python SDK parity
diff --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.md
new file mode 100644
index 000000000000..b5d32440619d
--- /dev/null
+++ b/products/mcp_analytics/skills/debugging-mcp-analytics/references/stateless-and-sessions.md
@@ -0,0 +1,266 @@
+# The stateless protocol and how sessions survive it
+
+The MCP `2026-07-28` revision makes the protocol **stateless**. That removes the two things
+analytics used to key attribution on — the `initialize` handshake and the `Mcp-Session-Id`
+header — so "what is one session?" had to be rebuilt at the application layer. This file is the
+reference 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
+dotcom master. Versions move fast — re-check before trusting a number here.
+
+## What the spec actually changed
+
+Read the spec itself rather than a summary when it matters:
+`docs/specification/2026-07-28/` in `modelcontextprotocol/modelcontextprotocol`. `draft` is
+currently byte-identical in substance (its changelog reads "Changes since the most recent release
+will accumulate here"), so `2026-07-28` is the live revision.
+
+Two SEPs did the work: **SEP-2575** (Make MCP Stateless) and **SEP-2567** (Sessionless MCP via
+Explicit State Handles).
+
+- **`initialize` is removed, not deprecated.** It appears nowhere in the revision, and isn't in
+ the deprecated registry either. `basic/versioning.mdx` defines "legacy" as protocols that
+ "establish a session with an `initialize` handshake (`2025-11-25` and earlier)". Its
+ replacement is `server/discover`, an **optional** probe: servers must implement it, clients
+ need not call it.
+- **`Mcp-Session-Id` is removed**, and a server must actively ignore one if a legacy client sends
+ it: "ignore it, and do not mint or echo session IDs" (`basic/transports/streamable-http.mdx`).
+ `Last-Event-ID` and stream resumability go too; GET/DELETE to the endpoint now return 405.
+- **No negotiation at all.** "There is no negotiation handshake. Every request carries its
+ protocol version, and the server accepts or rejects each request independently."
+- **Connections are explicitly not sessions.** "an open connection, such as a STDIO process, is
+ not a conversation or session: clients may interleave unrelated requests on the same transport,
+ and a server must not treat connection or process identity as a proxy for conversation or
+ session continuity."
+- **Continuity is the application's job.** "State that needs to span multiple requests ... MUST be
+ referenced by an explicit identifier the client passes on each request." That is SEP-2567's
+ explicit-state-handle model, and it is the whole basis for what PostHog does below.
+
+Per-request `_meta` keys replace the handshake for identity:
+
+| Key | Required? | Carries |
+| -------------------------------------------- | --------------------- | ------------------------------------------------------------------------------- |
+| `io.modelcontextprotocol/protocolVersion` | required | the version for _this_ request (also the `MCP-Protocol-Version` header on HTTP) |
+| `io.modelcontextprotocol/clientCapabilities` | required | capabilities in use for this request |
+| `io.modelcontextprotocol/clientInfo` | optional, SHOULD send | client name + version |
+| `io.modelcontextprotocol/serverInfo` | server -> client | server name + version |
+
+Two constraints worth internalising:
+
+- **`clientInfo` and `serverInfo` are self-reported and unverified.** The spec says
+ implementations "SHOULD NOT rely on them for security decisions" — the rule covers both. Harness attribution built on it is an assertion, not a fact.
+- **Read it fresh per request.** There is no handshake to cache it from, and nothing guarantees a
+ client sends identical `clientInfo` across a run.
+
+**There is no `conversation_id` in the spec.** Grepping the revision for `conversationId` /
+`conversation_id` / `agentId` returns nothing. PostHog's conversation handle is our own
+application-level state handle, implementing SEP-2567's pattern — don't go looking for it in the
+spec, and don't assume another vendor's server has one.
+
+If you add custom `_meta` keys: any prefix whose **second** dot-label is `modelcontextprotocol` or
+`mcp` is reserved. `com.posthog/` is fine; `io.mcp.posthog/` is not.
+
+Smaller changes that occasionally bite: `structuredContent` may now be any JSON value rather than
+an object, `ping` and `logging/setLevel` are gone, and tasks moved to the
+`io.modelcontextprotocol/tasks` extension (so `io.modelcontextprotocol/related-task` no longer
+exists).
+
+## How `$session_id` is resolved now
+
+`packages/mcp/src/extensions/session.ts::getSessionId` resolves **first match wins**:
+
+1. **The agent's `conversation_id` tool argument** — if present and shape-valid.
+ `$session_id = deriveSessionIdFromConversation(handle)`, a deterministic unsalted hash into the
+ `ses_` namespace. Deterministic is the point: two pods that never shared state derive the same
+ id from the same handle. This branch deliberately does **not** write the shared
+ `sessionId`/`lastActivity`, because that would leak one chat's session onto a concurrent
+ chat's `tools/list`. It does still call `applyTokenClientIdentity`, writing client
+ name/version/protocol version into `sessionInfo` — per-connection identity, not per-chat
+ session.
+2. **A request-carried session id** — the SDK's own token on `Mcp-Session-Id` (`decodeSessionId`),
+ else the transport's raw `extra.sessionId` hashed. This is the legacy `2025-11-25` path.
+3. **In-memory** — the id this server instance already holds, rolling over after
+ `INACTIVITY_TIMEOUT_IN_MINUTES` (30) of inactivity. Covers stdio and anything carrying
+ neither of the above.
+
+Subtle, and worth knowing before you debug a session that changed mid-conversation: the handle
+branch does not advance `lastActivity`, and — narrowing it — `getSessionIdFromMemory` only
+rotates when `sessionSource === 'generated'`; once a token or transport id has been read the
+source is `'token'`/`'mcp'` and no rotation happens. Where it does apply, so a conversation that always echoes lets the
+in-memory fallback age past that timeout. A later call that arrives _without_ a handle therefore
+rotates to a fresh session. That is intended — by then the fallback session really has been idle
+that long — but it means "the agent stopped echoing" and "the session rotated" look the same in
+the data.
+
+So the conversation handle is a _new step 1_ in front of the mechanism the older docs describe —
+the legacy paths still work and still matter for legacy clients.
+
+> **`enableConversationId` is off by default.** When off it is "fully inert: no parameter is
+> injected, no schema is touched, no prompt-back is appended, and `$session_id` resolves exactly
+> as it did before". So a stateless client against a server with the flag off has no transport
+> session _and_ no handle, and lands on step 3 — sessions fragment, often to one per request.
+> **That is the first thing to check when someone reports fragmented or single-call sessions.**
+
+`$session_id` and `$mcp_conversation_id` are different values on the same event: `$session_id` is
+`ses_<hash-of-handle>`, `$mcp_conversation_id` is the raw handle.
+
+## The session handle: mint, deliver, echo, verify
+
+The handle is the `conversation_id` seen from the wire side — how the agent learns the value it
+must send back.
+
+**Mint.** `conversation-id.ts::resolveConversationId` decides per call: disabled -> none; the agent
+echoed a handle the SDK could have minted -> use it; anything else (absent, or invented) -> mint a
+fresh uuidv7 and prompt it back.
+
+**Verify — and why the shape gate exists.** Only a value matching the uuidv7 shape the SDK mints
+is accepted. From the source, and worth quoting in full because the reasoning is the rule:
+
+> The shape check matters because this value becomes `$session_id`, and the derivation is
+> deterministic so that two pods agree — which also means two _callers_ sending the same string
+> land in the same session. The strings agents invent are not random (`conv-1`, `1`, `session`),
+> so trusting them verbatim would silently merge unrelated conversations, potentially across
+> users.
+
+A compliant agent echoing the minted uuidv7 is unaffected. The gate narrows the risk rather than
+eliminating it — two callers independently choosing the same well-formed uuidv7 would still merge.
+That residual is accepted because `$session_id` is an analytics grouping key, not a security
+boundary. Don't treat it as one.
+
+**Deliver.** Two channels, because one was not enough:
+
+| Channel | When | Where |
+| ------------------------------------- | -------------------------------------------------------------------------------------- | ----------------------------------------- |
+| 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` |
+
+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).
+
+**The mirror's real gate is not "the schema declares the key" — it is "this instance served the
+listing".** `instrumentation.ts::getActiveAnalyticsParameterOwnership` requires
+`listed?.outputInstructions === true`, and `listed` comes from a per-instance `Map` written only
+by the `tools/list` handler. The source is blunt about the consequence: "an instance that never
+serves a listing never writes the mirror at all. That is the per-request server pattern —
+`tools/list` lands on one instance, `tools/call` on a cold one — where the handle falls back to
+the `content` block and a structuredContent-only client misses it." Failing closed is deliberate
+(writing an undeclared key fails the whole result), and the noted fix — a process-scoped cache —
+has not landed. So under exactly the per-request-instance deployments this revision encourages,
+the recovery channel is the one most likely to be absent.
+
+Worse on the **low-level `Server` path**: `instrument-lowlevel.ts::handleToolCallRequest` passes
+no ownership override, so `conversationId` collapses to `listed?.conversationId` too. A cold
+per-request low-level instance resolves no handle at all — step 1 of the resolution order never
+fires. 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.
+
+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
+told about.
+
+**`_mcp_instructions` is a hard prerequisite, not decoration.** MCP clients ajv-validate
+`structuredContent` against the schema from `tools/list` under `additionalProperties: false`. An
+undeclared key doesn't get dropped — it fails the _entire_ tool result. So #4430 shipped the schema
+declaration alone (inert), and only then could #4431 write into it. If you add anything to
+`structuredContent`, declare it first or you break the tool.
+
+Also as of #4433 the handle reaches the virtual `get_more_tools` tool, so a reported capability gap
+groups with the work that hit it instead of falling back to the transport session.
+
+## Where each repo stands
+
+> **None of the session model above applies to PostHog's own dogfood data yet.** `services/mcp`
+> uses the custom-dispatcher (`PostHogMCP`) path, pins `@posthog/[email protected]`, and sources
+> `$mcp_conversation_id` from an **`mcp-conversation-id` HTTP header** rather than a tool
+> argument (`src/index.ts`) — its `$session_id` is not derived from it. The code comment says the
+> tool-arg path arrives "once the SDK is bumped with `enableConversationId`". So when you query
+> project 2, you are looking at header-supplied conversation ids and transport-derived sessions,
+> not the mint/echo loop.
+
+**`services/mcp` — dual-dialect at the protocol layer, already shipped.** `src/lib/stateless-protocol.ts` (#72223)
+defines `STATELESS_PROTOCOL_VERSION = '2026-07-28'`, the reserved `_meta` keys, `server/discover`,
+the SEP-2243 operation headers (`MCP-Protocol-Version`, `Mcp-Method`, `Mcp-Name`), and error codes
+`-32022` (unsupported protocol version) and `-32020` (header mismatch). `dispatcher.ts` picks the
+dialect per request from `_meta`'s protocol-version key or the header, then branches: legacy
+clients still get `initialize`/`ping`, modern clients get `server/discover` and **no session
+minting**. 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.
+
+## Telling which model produced a session, from the data
+
+The mechanism above is invisible in the events unless you know what to look at, and two things
+that look diagnostic are not:
+
+- **The `ses_` prefix does not discriminate.** All three branches mint `ses_`-prefixed ids
+ (`newPrefixedId('ses')` and `deterministicPrefixedId('ses', ...)` in `session.ts`), so the
+ prefix tells you nothing about which one ran.
+- **You cannot recompute the hash.** `deriveSessionIdFromConversation` is not exported from the
+ package entry point, so you cannot verify from outside that a given `$session_id` derives from
+ a given handle.
+
+What you _can_ read off the events:
+
+| Signal | Reading |
+| --------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------- |
+| `$mcp_protocol_version` = `2026-07-28` | the request came in on the stateless dialect |
+| `$mcp_conversation_id` populated | `enableConversationId` is on **and** the handle reached the agent and came back — this session is conversation-anchored |
+| `$mcp_conversation_id` empty on a stateless request | either the flag is off, or the handle never completed the round trip |
+| one `$session_id` per `$mcp_tool_call`, repeatedly | fragmentation — the symptom that sends people here |
+
+So the useful first query on a suspect project is a count of distinct `$session_id` against
+distinct `$mcp_conversation_id` and calls, sliced by `$mcp_protocol_version`. Sessions roughly
+equal to calls, with `$mcp_conversation_id` empty, is the fragmentation signature.
+
+**If the flag is on and sessions still fragment**, the handle is not completing the round trip.
+In order of likelihood: the tool has no declared output schema, so the `structuredContent` mirror
+can't carry the handle and a structured-output client never sees the `content` text block; the
+agent is echoing a value that isn't the minted uuidv7, which the SDK treats as absent rather than
+as a session key; or the minting call returned a result with no `content` array and no declared
+schema, in which case the SDK deliberately drops the handle rather than report a conversation the
+agent was never told about.
+
+## Consequences for queries and debugging
+
+- **Fragmented or one-call sessions** on a stateless client almost always means
+ `enableConversationId` is off (or the agent isn't echoing the handle). Check the flag before
+ suspecting ingestion.
+- **`$mcp_initialize` is not a session-start anchor, and whether it fires at all depends on whose
+ server you're looking at.** A customer server on the SDK's `instrument()` path emits nothing for
+ a stateless client — that path patches the `initialize` handler and knows nothing of
+ `server/discover`. PostHog's own `services/mcp` does emit it, from both entry points
+ (`dispatcher.ts::recordDiscoveryRequest`). Live consequence, customer servers only: the
+ onboarding query in `frontend/mcpAnalyticsOnboardingLogic.ts` computes
+ `countIf(event = '$mcp_initialize') > 0 AS has_initialize`, and `manifest.tsx` lists
+ `waitingEvents: ['$mcp_initialize']`. Onboarding still _completes_ — `hasToolCall` is checked
+ first in both that selector and `statusFromProbeDefinitions` — but the intermediate "connected,
+ no calls yet" state is unreachable, so such a project reads as `not-instrumented` until its
+ first tool call. No fix is in flight; don't diagnose it as ingestion.
+- **`$session_id` grouping is only as good as handle delivery.** A tool with no declared output
+ schema, called by a structured-output client, may never receive the handle.
+- **Protocol version is per-request now.** `$mcp_protocol_version` can legitimately differ between
+ events that a legacy mental model would call "one session" — break metrics down by it rather
+ than assuming one value per session.
+- **Error codes were renumbered at the revision boundary** (`-32001` -> `-32020`, `-32003` ->
+ `-32021`, `-32004` -> `-32022`, resource-not-found `-32002` -> `-32602`). Anything bucketing on
+ the raw code silently miscategorises across that boundary.
+- **Harness/client attribution is self-reported** under the stateless model, per the spec's own
+ warning. Fine for product analytics, not for anything trust-bearing.
diff --git a/products/mcp_analytics/skills/debugging-mcp-analytics/references/wizard-and-onboarding.md b/products/mcp_analytics/skills/debugging-mcp-analytics/references/wizard-and-onboarding.md
index 6f467facdb95..e4294864459a 100644
--- a/products/mcp_analytics/skills/debugging-mcp-analytics/references/wizard-and-onboarding.md
+++ b/products/mcp_analytics/skills/debugging-mcp-analytics/references/wizard-and-onboarding.md
@@ -137,7 +137,10 @@ Two entry paths coexist, sharing one install hero.
`emptyStateStatusForOnboardingState()`. **Projects that have never been set up render the
setup screen in place — there is no redirect into the app-wide `/onboarding` flow.**
`manifest.tsx` declares the `setupProbe` (`hasDataEvents: ['$mcp_tool_call']`,
- `waitingEvents: ['$mcp_initialize']`).
+ `waitingEvents: ['$mcp_initialize']`). That `waitingEvents` probe never resolves for a
+ stateless-only server, which emits no `$mcp_initialize`: such a project reads as
+ `needs-setup` until its first tool call and then goes straight to `has-data`, skipping
+ `waiting-for-data`. See [stateless-and-sessions.md](stateless-and-sessions.md).
2. **The legacy app-wide `/onboarding` flow** is still registered, under
`frontend/src/scenes/onboarding/legacy/stepProviderRegistry.ts` — the `legacy/` segment
signals it is being phased out. Registering a product there takes roughly six touches: