: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
docs(mcp-analytics): sync models-mcp.md properties with constants.ts/taxonomy.py (#76735)
Lucas Fariad3a069be36ea
diff --git a/products/posthog_ai/skills/querying-posthog-data/references/models-mcp.md b/products/posthog_ai/skills/querying-posthog-data/references/models-mcp.mdindex 5f7caa46025f..44f536f9f67b 100644--- a/products/posthog_ai/skills/querying-posthog-data/references/models-mcp.md+++ b/products/posthog_ai/skills/querying-posthog-data/references/models-mcp.md@@ -39,19 +39,38 @@ And two tools cover what SQL can't express at all: `posthog:mcp-analytics-intent## Key properties-| Property | Meaning |-| -------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |-| `$mcp_tool_name` | Registered tool name. |-| `$mcp_exec_tool_call_name` | Inner tool name when the call went through the new-SDK single-exec wrapper. See effective-tool-name note below. |-| `$mcp_is_error` | Whether the call failed. Always read via `toBool(properties.$mcp_is_error)`. |-| `$mcp_error_type` | Semantic failure bucket when `$mcp_is_error` is true (`internal`, `validation`, `api_4xx`, `api_5xx`, `permission`, `timeout`, `rate_limited`, `missing_context`). Only newer SDK/server paths set it. |-| `$mcp_error_status` | HTTP status code for an errored call, when the failure came from an HTTP call. |-| `$mcp_duration_ms` | Wall-clock duration; cast with `toFloat(...)`. |-| `$session_id` | Session id — the grouping key for a single agent run, and the same id as `$mcp_session_id` (`$session_id` is its materialised column). Use the bare `$session_id` field, not `properties.$session_id`: the `properties.` accessor renders null-wrapped in SELECT but as the raw column in HAVING/ORDER, so a search HAVING would mismatch the GROUP BY key. Some per-tool runners still read `coalesce(properties.$mcp_session_id, properties.$session_id)` — same id, just a defensive fallback. |-| `$mcp_intent` | The agent's stated intent for the call, when supplied. |-| `$mcp_client_name` | Raw client string (e.g. `claude-code/1.2.3`). Bucketed into harnesses **server-side** by `products/mcp_analytics/backend/mcp_harness.py` (`HARNESS_TOKEN_SQL` / `harness_label_sql`) — the single source of truth. The frontend only maps the resolved label to a logo. There is no `category` column. |-| `$mcp_tool_category` | Tool category, when tagged. |-| `$mcp_tool_description` | Tool description as seen by the agent (revisions over time), clipped to 512 chars on capture. Gap warning: the hono migration silently dropped this stamp, so there is a window (roughly Jun–Jul 2026) with no descriptions on PostHog's hosted server; `notEmpty(...)` filters are mandatory. |+`Source` says where the property comes from: **SDK** — set by `@posthog/mcp` (`packages/mcp/src/extensions/constants.ts`), present on any instrumented customer server; **server** — stamped only by PostHog's own hosted MCP server (`services/mcp`), so it exists only for PostHog's dogfood data; **exec** — only present when the server runs in single-exec mode (one `exec` dispatcher tool instead of one tool per name).++| Property | Source | Meaning |+| --------------------------------- | ------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |+| `$mcp_tool_name` | SDK | Registered tool name. |+| `$mcp_exec_tool_call_name` | exec | Inner tool name when the call went through the new-SDK single-exec wrapper. See effective-tool-name note below. |+| `$mcp_exec_tool_call_description` | exec | Inner tool's description — the dispatcher's own `$mcp_tool_description` is static "exec" boilerplate on every call, so this is the useful one in single-exec mode. |+| `$mcp_is_error` | SDK | Whether the call failed. Always read via `toBool(properties.$mcp_is_error)`. |+| `$mcp_error_type` | SDK | Semantic failure bucket when `$mcp_is_error` is true (`internal`, `validation`, `api_4xx`, `api_5xx`, `permission`, `timeout`, `rate_limited`, `missing_context`). Only newer SDK/server paths set it. |+| `$mcp_error_status` | server | HTTP status code for an errored call, when the failure came from an HTTP call. Stamped by PostHog's own server (`services/mcp/src/hono/tool-executor.ts`) — not part of the SDK's field set, so an externally-instrumented server on the SDK alone won't emit it. |+| `$mcp_duration_ms` | SDK | Wall-clock duration; cast with `toFloat(...)`. |+| `$session_id` | — | Session id — the grouping key for a single agent run, and the same id as `$mcp_session_id` (`$session_id` is its materialised column). Use the bare `$session_id` field, not `properties.$session_id`: the `properties.` accessor renders null-wrapped in SELECT but as the raw column in HAVING/ORDER, so a search HAVING would mismatch the GROUP BY key. Some per-tool runners still read `coalesce(properties.$mcp_session_id, properties.$session_id)` — same id, just a defensive fallback. See "Three identifiers" below. |+| `$mcp_intent` | SDK | The agent's stated intent for the call, when supplied. |+| `$mcp_intent_source` | SDK | Where `$mcp_intent` came from: `context_parameter` (client supplied it directly on the call) or `inferred` (server derived it via `intentFallback`). |+| `$mcp_conversation_id` | SDK | Stable, agent-echoed identifier that survives reconnects. See "Three identifiers" below. Only present when the server has `enableConversationId` turned on. |+| `$mcp_parameters` | SDK | Arguments passed to the tool call. Large strings and sensitive keys are redacted before capture. |+| `$mcp_response` | SDK | The response the MCP server returned, redacted the same way as `$mcp_parameters`. Stays empty on PostHog's hosted server. |+| `$mcp_client_name` | SDK | Raw client string (e.g. `claude-code/1.2.3`). Bucketed into harnesses **server-side** by `products/mcp_analytics/backend/mcp_harness.py` (`HARNESS_TOKEN_SQL` / `harness_label_sql`) — the single source of truth. The frontend only maps the resolved label to a logo. There is no `category` column. |+| `$mcp_client_version` | SDK | Version of the MCP client that initiated the connection. |+| `$mcp_tool_category` | server | Tool category, when tagged. Stamped from PostHog's tool catalog; external servers can declare one per tool. |+| `$mcp_tool_description` | SDK | Tool description as seen by the agent (revisions over time), clipped to 512 chars on capture. Gap warning: the hono migration silently dropped this stamp, so there is a window (roughly Jun-Jul 2026) with no descriptions on PostHog's hosted server; `notEmpty(...)` filters are mandatory. |+| `$mcp_listed_tool_names` | SDK | Every tool name advertised on a `tools/list` call, in multi-tool mode (JSON array; filter with `contains`). Diff against `$mcp_tool_name` to find zombie tools (advertised, never called). In single-exec mode, `$mcp_exec_inner_tool_names` carries the catalog instead. |+| `$mcp_exec_inner_tool_names` | exec | Every inner tool name available at `tools/list` time, in single-exec mode (JSON array; filter with `contains`). Diff against `$mcp_exec_tool_call_name` to find zombie tools. |+| `$mcp_server_name` | SDK | Advertised name of the MCP server that handled the request (e.g. `PostHog`). |+| `$mcp_server_version` | SDK | Advertised version of the MCP server that handled the request. |+| `$mcp_protocol_version` | SDK | MCP spec version negotiated at `initialize` (added in SDK v0.10.0). Stamped on `$mcp_initialize` and on every subsequent event of the session. |+| `$mcp_resource_name` | SDK | Name of the MCP resource/prompt/tool the event refers to (resource-read and prompt-get events). |+| `$mcp_source` | SDK | Constant identifier for the analytics SDK that emitted the event (e.g. `posthog_mcp_analytics`). Lets you separate SDK-emitted events from other/legacy MCP paths. |++**Server-stamped extras (PostHog's own server only, not the SDK):** `$mcp_session_id` (transport-level session handle — see "Three identifiers" below), `$mcp_region` (cloud region that handled the request, e.g. `us`/`eu`), `$mcp_mode` (`cli` for single-exec, `tools` for one-tool-per-name), `$mcp_consumer` (upstream surface, e.g. `posthog-code`/`slack`), and the non-`$`-prefixed `mcp_vendor_client` (vendor/client identity from the `x-anthropic-client` header, e.g. `ClaudeCode`/`ClaudeAI` — used to resolve the harness in the bucketing SQL below) and `mcp_runtime` (server runtime, e.g. `hono`).++**Three identifiers, not one.** `$session_id` is the materialised column — `GROUP BY`/join on this one. `$mcp_session_id` is the transport-level handle the MCP SDK observed (MCP `extra.sessionId` or a framework session cookie); it rotates on process restart, reconnect, or framework boundary. `$mcp_conversation_id` is agent-echoed and stable across reconnects — reach for it when a "session" needs to survive a client reconnecting mid-task. In practice `$session_id` and `$mcp_session_id` carry the same value; `$mcp_conversation_id` is the more durable one when they diverge.**Effective tool name.** New-SDK events wrap the real tool in a single-exec call, so to filter/group by the tool the agent actually invoked, use:@@ -67,7 +86,7 @@ JSONExtract(coalesce(toString(properties.$mcp_listed_tool_names), '[]'), 'Array(The `coalesce(..., '[]')` is required: the property accessor is Nullable, and `JSONExtract` of a Nullable into `Array(String)` is a ClickHouse type error.-**Failures with detail.** `$mcp_tool_call` carries `$mcp_is_error` plus a semantic `$mcp_error_type` and, for HTTP failures, `$mcp_error_status`. `posthog:query-mcp-tool-failures` groups errored tool calls by these two fields and returns each bucket's raw `error_type`/`error_status`; pass those to `posthog:query-mcp-tool-failure-occurrences` for individual errored calls with the free-text `$mcp_error_message` (sanitized, truncated to 2048 chars — empty on events captured before PostHog's server started emitting it). `$mcp_response` stays empty on PostHog's hosted server. PostHog's own tool calls also don't emit `$exception` events — those only exist for separately-instrumented MCP servers.+**Failures with detail.** `$mcp_tool_call` carries `$mcp_is_error` plus a semantic `$mcp_error_type` and, for HTTP failures, `$mcp_error_status` (see the Source column above: `$mcp_error_type` is an SDK field that PostHog's own server also stamps itself, while `$mcp_error_status` is stamped only by PostHog's server, so a separately-instrumented server on the SDK alone won't emit it). `posthog:query-mcp-tool-failures` groups errored tool calls by these two fields and returns each bucket's raw `error_type`/`error_status`; pass those to `posthog:query-mcp-tool-failure-occurrences` for individual errored calls with the free-text `$mcp_error_message` (sanitized, truncated to 2048 chars — empty on events captured before PostHog's server started emitting it). `$mcp_response` stays empty on PostHog's hosted server. PostHog's own tool calls also don't emit `$exception` events — those only exist for separately-instrumented MCP servers.## Example queries