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.

chore(mcp-analytics): refresh mcp analytics skills (#70743)

Georgis Andonis4bdb263ef1eb
diff --git a/products/mcp_analytics/skills/exploring-mcp-intent-clusters/SKILL.md b/products/mcp_analytics/skills/exploring-mcp-intent-clusters/SKILL.md
index 42bc09d18994..d1c3bad1640c 100644
--- a/products/mcp_analytics/skills/exploring-mcp-intent-clusters/SKILL.md
+++ b/products/mcp_analytics/skills/exploring-mcp-intent-clusters/SKILL.md
@@ -16,7 +16,7 @@ clusters. Each cluster carries its tool distribution, call counts, and error
rates — answering "what are people _trying_ to do, and does it work?" rather
than "which tool was called".
-Unlike tool quality and sessions (which are plain HogQL over `$mcp_tool_call`),
+Unlike tool quality and sessions (which ultimately aggregate `$mcp_tool_call`),
clustering needs embeddings and is **not expressible in SQL**. It is served by
two typed tools backed by a stored snapshot.
@@ -63,8 +63,9 @@ posthog:mcp-analytics-intent-clusters-recompute
```
Returns immediately with `status: computing` (HTTP 202); the work runs in the
-background. Poll `...-retrieve` until `status` returns to `idle` (done) or
-`error`. Don't block waiting — tell the user to re-ask in a minute.
+background. Poll `posthog:mcp-analytics-intent-clusters-retrieve` until `status`
+returns to `idle` (done) or `error`. Don't block waiting — tell the user to
+re-ask in a minute.
## Constructing UI links
diff --git a/products/mcp_analytics/skills/exploring-mcp-sessions/SKILL.md b/products/mcp_analytics/skills/exploring-mcp-sessions/SKILL.md
index fcaf04e22ad0..810a1d442e0a 100644
--- a/products/mcp_analytics/skills/exploring-mcp-sessions/SKILL.md
+++ b/products/mcp_analytics/skills/exploring-mcp-sessions/SKILL.md
@@ -5,35 +5,121 @@ description: >
single agent made in one run, what it was trying to do, and where it went
wrong. Use when the user asks "what did this MCP session do?", "show me the
tool calls for session X", "what was the agent's goal?", "which sessions had
- errors?", or pastes an MCP analytics sessions URL.
+ errors?", "who is connecting to my MCP?", or pastes an MCP analytics sessions
+ URL.
---
# Exploring MCP sessions
-An MCP session is one agent run, identified by `$session_id` on the
-`$mcp_tool_call` event. A session is just the set of `$mcp_tool_call` events that
-share a `$session_id`, ordered by `timestamp`. Listing sessions and reading
-a session's tool calls are both plain HogQL over `events`; the full property
-schema and recipes are in the shared reference:
-[`products/posthog_ai/skills/querying-posthog-data/references/models-mcp.md`](../../../posthog_ai/skills/querying-posthog-data/references/models-mcp.md).
+An MCP session is one agent run: the set of `$mcp_tool_call` events sharing a
+`$session_id`, ordered by `timestamp`.
-The one thing SQL cannot do is summarise the agent's _goal_ in prose — that is
-the typed tool `posthog:mcp-analytics-sessions-generate-intent`.
+Listing sessions, reading a session's tool calls, and summarising its goal each
+have a **typed tool** — reach for those first. Drop to HogQL only for the three
+things the typed tools genuinely can't do (see
+[When to drop to SQL](#when-to-drop-to-sql)). The full `$mcp_*` property schema
+and query recipes live in the shared reference:
+[`models-mcp.md`](../../../posthog_ai/skills/querying-posthog-data/references/models-mcp.md).
## Tools
-| Tool | Purpose |
-| ------------------------------------------------ | ------------------------------------------------------------- |
-| `posthog:execute-sql` | List sessions and read a session's tool-call sequence (HogQL) |
-| `posthog:mcp-analytics-sessions-generate-intent` | Generate (or fetch cached) LLM summary of a session's goal |
+| Tool | Purpose |
+| ------------------------------------------------ | ---------------------------------------------------------- |
+| `posthog:mcp-analytics-sessions-list` | List sessions — one row per session, newest first |
+| `posthog:mcp-analytics-sessions-tool-calls` | One session's tool calls, chronological |
+| `posthog:mcp-analytics-sessions-generate-intent` | LLM summary of a session's goal (cached after first call) |
+| `posthog:execute-sql` | Errored sessions, effective tool names, cross-session cuts |
+
+The three `mcp-analytics-*` tools are gated behind the `mcp-analytics` flag and
+run the same code as the sessions UI, so results match the screen. If they aren't
+in your tool list, the project doesn't have the flag — fall back to
+`posthog:execute-sql`, which is ungated.
+
+## The date-window trap — read this first
+
+The two detail tools default to a **7-day lookback**. A session you found in a
+list that reaches further back will come back **empty** unless you pass its
+`session_start` as `date_from`:
+
+- `posthog:mcp-analytics-sessions-tool-calls` — `date_from` is an absolute ISO
+ timestamp; pass the `session_start` you got from
+ `posthog:mcp-analytics-sessions-list`.
+- `posthog:mcp-analytics-sessions-generate-intent` — same `date_from` query
+ param, same reason.
+
+Empty tool calls for a session that visibly exists is almost always this, not a
+data problem. Carry `session_start` forward from the list row.
## Workflow: list recent sessions
-Group `$mcp_tool_call` by `$session_id`, deriving start/end, duration, call
-count, error count, and the harness:
+```json
+posthog:mcp-analytics-sessions-list
+{ "date_from": "-7d", "order_by": "-session_start", "limit": 100 }
+```
+
+Each row: `session_id`, `tool_calls`, `session_start`, `session_end`,
+`tools_used`, `mcp_client_name`, `distinct_id` (+ resolved `person_email` /
+`person_name`), and `intent` (empty until generated). Response is
+`{ results, has_next }` — page with `limit` / `offset`.
+
+Three sharp edges:
+
+- **`order_by` takes column names, not response field names.** Sort call volume
+ as `tool_call_count` (not `tool_calls`). `duration_seconds` sorts fine even
+ though it isn't returned. An unrecognised key **silently** falls back to
+ newest-first — so verify the order you got is the order you asked for. Valid:
+ `session_id`, `session_start`, `session_end`, `duration_seconds`,
+ `tool_call_count`, `mcp_client_name`, `distinct_id`; prefix `-` to descend.
+- **There is no error filter and no error count on a session row.** "Which
+ sessions had errors?" is a SQL question — see below.
+- **`distinct_id_count` is always `0`.** The field is in the response but the
+ backend never populates it, so don't read it as "one distinct id per session"
+ — it says nothing. To count distinct ids in a session, use SQL.
+
+`search` does a case-insensitive substring match across `session_id`,
+`distinct_id`, `mcp_client_name`, and `tools_used`.
+
+## Workflow: read one session's tool calls
+
+```json
+posthog:mcp-analytics-sessions-tool-calls
+{ "id": "<session_id>", "date_from": "<session_start>", "limit": 500 }
+```
+
+Chronological `tool_name`, `intent`, `timestamp`, `duration_ms`, `is_error`,
+`error_message` — read top to bottom to reconstruct the run. `limit` defaults to
+500 (also the max), which is the whole page for almost every session; `has_next`
+tells you if more remain.
+
+**Caveat: `tool_name` here is the raw `$mcp_tool_name`.** Unlike the tool-quality
+and tool-detail tools, this endpoint does not resolve the inner tool of a
+single-exec wrapper call, so wrapper calls show the wrapper. When the inner tool
+is what matters (comparing against a tool-quality ranking, tracing a specific
+tool through a run), use the SQL recipe below instead. The same applies to
+`tools_used` on the session list.
+
+## Workflow: summarise the agent's goal
+
+```json
+posthog:mcp-analytics-sessions-generate-intent
+{ "id": "<session_id>", "date_from": "<session_start>" }
+```
+
+Summarises the session's recorded `$mcp_intent` values via an LLM and persists
+the result; later calls return the cached summary. Returns
+`{ session_id, intent }`. A 503 means LLM summarisation isn't configured — fall
+back to reading the raw `$mcp_intent` values from the tool-call list.
+
+## When to drop to SQL
+
+Four cases, all via `posthog:execute-sql`, which — unlike the typed tools above —
+is **not** gated behind the `mcp-analytics` flag.
+
+**1. The project doesn't have the `mcp-analytics` flag.** The typed tools simply
+won't be in your tool list. Everything below still works; this query is the
+plain session listing:
```sql
-posthog:execute-sql
SELECT
$session_id AS session_id,
min(timestamp) AS session_start,
@@ -51,44 +137,33 @@ ORDER BY session_start DESC
LIMIT 50
```
-Add `HAVING errors > 0` to surface only sessions that hit failures.
+**2. Errored sessions.** The session list can't filter or count errors — add
+`HAVING errors > 0` to the query above and order by `errors DESC`.
-## Workflow: read one session's tool calls
-
-The chronological sequence of what the agent did — the heart of debugging a run:
+**3. Effective tool names within a session** — the coalesce the typed tool-calls
+endpoint doesn't apply:
```sql
-posthog:execute-sql
SELECT
timestamp,
coalesce(nullIf(toString(properties.$mcp_exec_tool_call_name), ''), toString(properties.$mcp_tool_name)) AS tool,
toBool(properties.$mcp_is_error) AS is_error,
toString(properties.$mcp_error_message) AS error_message,
- round(toFloat(properties.$mcp_duration_ms)) AS duration_ms,
- toString(properties.$mcp_intent) AS intent
+ round(toFloat(properties.$mcp_duration_ms)) AS duration_ms
FROM events
WHERE event = '$mcp_tool_call'
AND $session_id = '<session_id>'
ORDER BY timestamp ASC
```
-Always use the effective-tool-name `coalesce(...)` so single-exec wrapper calls
-resolve to the real tool. Read these top to bottom to reconstruct the run.
-
-## Workflow: summarise the agent's goal
-
-When the user wants the _intent_ of a session in prose (not the raw tool list),
-call the typed tool — the first call summarises the recorded `$mcp_intent`
-values via an LLM and persists the result; later calls return the cached summary:
-
-```json
-posthog:mcp-analytics-sessions-generate-intent
-{ "id": "<session_id>" }
-```
+**4. Cross-session aggregation** — "sessions per day", "sessions that used tool
+X and then failed", custom breakdowns. Recipes in
+[`models-mcp.md`](../../../posthog_ai/skills/querying-posthog-data/references/models-mcp.md).
-Returns `{ "session_id": ..., "intent": "<prose summary>" }`. If it returns 503,
-LLM summarisation is unavailable — fall back to reading the raw `$mcp_intent`
-values from the tool-call query above.
+Note `$session_id` is a **materialised events column** — the same id as
+`$mcp_session_id`. Reference it bare, never as `properties.$session_id`: the
+`properties.` accessor renders null-wrapped in SELECT but as the raw column in
+HAVING/ORDER, so a `HAVING` search would mismatch the `GROUP BY` key.
## Constructing UI links
@@ -97,15 +172,18 @@ values from the tool-call query above.
## Tips
- A session with many calls but no errors that ends abruptly often means the
- agent gave up — check whether the last call returned a large/empty result
+ agent gave up — check whether the last call returned a large or empty result
- `$mcp_intent` is only present when the client supplied it; absence is common,
- so the generate-intent tool is the more reliable goal signal
+ so generate-intent is the more reliable goal signal
- To go from a failing tool (see
[`exploring-mcp-tool-quality`](../exploring-mcp-tool-quality/SKILL.md)) to the
- sessions that hit it, filter the sessions query on the effective tool name
+ sessions that hit it, `search` the session list by tool name — remembering
+ `tools_used` holds raw names, so search the registered name, not the inner one
## Related skills
+- [`exploring-mcp-tool-usage`](../exploring-mcp-tool-usage/SKILL.md) — the front
+ door: routes a broad "how is my MCP doing?" question to the right tool
- [`exploring-mcp-tool-quality`](../exploring-mcp-tool-quality/SKILL.md) — error
rates and latency across all tools
- [`exploring-mcp-intent-clusters`](../exploring-mcp-intent-clusters/SKILL.md) —
diff --git a/products/mcp_analytics/skills/exploring-mcp-tool-quality/SKILL.md b/products/mcp_analytics/skills/exploring-mcp-tool-quality/SKILL.md
index d201a14415ba..637b10a7af3c 100644
--- a/products/mcp_analytics/skills/exploring-mcp-tool-quality/SKILL.md
+++ b/products/mcp_analytics/skills/exploring-mcp-tool-quality/SKILL.md
@@ -26,7 +26,8 @@ UI, and is gated behind the `mcp-analytics` flag — no hand-written SQL needed.
**HogQL via `posthog:execute-sql` is the path for cross-tool questions** — the
"which tool errors most" ranking below has no typed tool, so rank with SQL, then
-drill into the worst tool with `posthog:query-mcp-tool-stats` / `-failures`. The full
+drill into the worst tool with `posthog:query-mcp-tool-stats` and
+`posthog:query-mcp-tool-failures`. The full
property schema and the canonical query recipes live in the shared MCP data
reference:
[`products/posthog_ai/skills/querying-posthog-data/references/models-mcp.md`](../../../posthog_ai/skills/querying-posthog-data/references/models-mcp.md).
@@ -136,8 +137,11 @@ Always surface a UI link so the user can verify visually.
- `$mcp_client_name` lets you cut quality by harness (Claude Code vs Cursor vs
…); the canonical bucketing `multiIf` is in
[models-mcp.md](../../../posthog_ai/skills/querying-posthog-data/references/models-mcp.md)
-- If the SQL contradicts the tool-quality screen, trust the screen and flag this
- skill for an update — the frontend bucketing logic is the source of truth
+- Harness bucketing is resolved **server-side** by
+ `products/mcp_analytics/backend/mcp_harness.py` — that's the source of truth,
+ and `posthog:query-mcp-harness-breakdown` runs it. If your hand-written SQL
+ disagrees with the screen, your bucketing has drifted from `mcp_harness.py`;
+ prefer the typed tool over re-deriving it
## Related skills
diff --git a/products/mcp_analytics/skills/exploring-mcp-tool-usage/SKILL.md b/products/mcp_analytics/skills/exploring-mcp-tool-usage/SKILL.md
index 894479a02e17..4b285a870156 100644
--- a/products/mcp_analytics/skills/exploring-mcp-tool-usage/SKILL.md
+++ b/products/mcp_analytics/skills/exploring-mcp-tool-usage/SKILL.md
@@ -40,6 +40,7 @@ Lead with these when the user is unsure what to ask:
| "What description is tool X registered with?" | `posthog:query-mcp-tool-descriptions` — distinct descriptions seen |
| "Which harnesses use my MCP, how reliably?" | `posthog:query-mcp-harness-breakdown` — calls/errors/sessions per client |
| "What are agents trying to do, across all tools?" | `exploring-mcp-intent-clusters` — semantic goal clusters |
+| "Who is connecting, and how active are they?" | `posthog:mcp-analytics-sessions-list` — one row per session, with client and person |
| "What did this one session do?" | `exploring-mcp-sessions` — a single agent run's tool sequence |
## Finding the tool name
@@ -60,16 +61,39 @@ Call it with the tool name and a window, e.g. for the headline numbers of a tool
posthog:query-mcp-tool-stats { "toolName": "<tool>", "dateRange": { "date_from": "-7d" } }
```
-Then offer a natural follow-up from the menu — e.g. after `stats` shows a high
-error rate, reach for `posthog:query-mcp-tool-failures`; after it shows broad reach, reach
-for `posthog:query-mcp-tool-top-users` or `posthog:query-mcp-tool-neighbors`.
+Then offer a natural follow-up from the menu — e.g. after
+`posthog:query-mcp-tool-stats` shows a high error rate, reach for
+`posthog:query-mcp-tool-failures`; after it shows broad reach, reach for
+`posthog:query-mcp-tool-top-users` or `posthog:query-mcp-tool-neighbors`.
## When to drop to SQL
-The tools cover the per-tool drill-downs and the harness cut. For cross-tool
-rankings (the tool-quality matrix), custom breakdowns, session listing, or
-per-session tool calls, query `$mcp_tool_call` directly with `posthog:execute-sql`
-— the schema and recipes are in
+**Covered by a typed tool — don't hand-write SQL for these:**
+
+| Question | Tool |
+| ---------------------------------- | ------------------------------------------- |
+| One tool's headline numbers | `posthog:query-mcp-tool-stats` |
+| One tool's day-by-day trend | `posthog:query-mcp-tool-daily-stats` |
+| One tool's top errors | `posthog:query-mcp-tool-failures` |
+| One tool's top callers | `posthog:query-mcp-tool-top-users` |
+| Tools called before/after one tool | `posthog:query-mcp-tool-neighbors` |
+| One tool's recent agent intents | `posthog:query-mcp-tool-sample-intents` |
+| One tool's registered descriptions | `posthog:query-mcp-tool-descriptions` |
+| Usage split by client harness | `posthog:query-mcp-harness-breakdown` |
+| List sessions | `posthog:mcp-analytics-sessions-list` |
+| One session's tool calls | `posthog:mcp-analytics-sessions-tool-calls` |
+
+**Not covered — use `posthog:execute-sql`:**
+
+- Cross-tool rankings (the tool-quality matrix — "which tool errors most?")
+- Errored-session filtering (the session list has no error filter or error count)
+- Effective tool names inside a session (`posthog:mcp-analytics-sessions-tool-calls`
+ returns the raw `$mcp_tool_name`, not the inner tool of a wrapper call)
+- Any custom breakdown
+
+`posthog:execute-sql` is also the fallback when the `mcp-analytics` flag is off —
+every tool in the table above is gated behind it, `execute-sql` is not. Query
+`$mcp_tool_call` directly; the schema and recipes are in
[`models-mcp.md`](../../../posthog_ai/skills/querying-posthog-data/references/models-mcp.md).
## Related skills
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.md
index bc78ad11833e..700f4080ac3c 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
@@ -18,23 +18,39 @@ Query the canonical `$`-prefixed event name. Servers instrumented with the `@pos
And `posthog:query-mcp-harness-breakdown` for the cross-tool harness cut (see below).
-**HogQL is the path for everything else** — cross-tool rankings (the tool-quality matrix), custom breakdowns, session listing, per-session tool calls — query them with `execute-sql`. Two more typed tools cover what SQL can't express: `posthog:mcp-analytics-intent-clusters-retrieve` / `...-recompute` (embedding-based intent clustering) and `posthog:mcp-analytics-sessions-generate-intent` (LLM session summary).
+**Sessions have typed tools too.** A session is one agent run — the `$mcp_tool_call` events sharing a `$session_id`:
+
+| question about sessions | tool |
+| ------------------------------------------------------- | ------------------------------------------------ |
+| list sessions (calls, start/end, tools, client, person) | `posthog:mcp-analytics-sessions-list` |
+| one session's calls, chronological | `posthog:mcp-analytics-sessions-tool-calls` |
+| LLM summary of one session's goal | `posthog:mcp-analytics-sessions-generate-intent` |
+
+Three things to know before using them:
+
+- **7-day lookback by default.** `posthog:mcp-analytics-sessions-tool-calls` and `posthog:mcp-analytics-sessions-generate-intent` both scan 7 days back, so an older session returns empty unless you pass its `session_start` as `date_from`. Carry that value forward from the list row.
+- **They report the raw `$mcp_tool_name`**, not the effective inner tool of a single-exec wrapper call — unlike the per-tool tools above.
+- **The session list has no error filter or error count.** "Which sessions failed?" is a SQL question.
+
+And two tools cover what SQL can't express at all: `posthog:mcp-analytics-intent-clusters-retrieve` and `posthog:mcp-analytics-intent-clusters-recompute` (embedding-based intent clustering).
+
+**HogQL is the path for everything else** — cross-tool rankings (the tool-quality matrix), custom breakdowns, errored-session filtering, effective tool names within a session — query them with `execute-sql`. It is also the fallback when the `mcp-analytics` flag is off: every typed tool above is gated behind it, `execute-sql` is not.
## 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/conversation id — the grouping key for a single agent run. Use the bare `$session_id` field, not `properties.$session_id`. |
-| `$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`). The dashboard buckets these into harnesses in the frontend; 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). |
+| 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). |
**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:
@@ -62,7 +78,7 @@ WHERE event = '$mcp_tool_call'
AND timestamp >= now() - INTERVAL 7 DAY
```
-**Tool-quality matrix** (error rate + latency percentiles + reach, one row per tool) — this cross-tool ranking has no typed tool; once you've picked a tool, drill into it with `posthog:query-mcp-tool-stats` / `-failures` / `-daily-stats`:
+**Tool-quality matrix** (error rate + latency percentiles + reach, one row per tool) — this cross-tool ranking has no typed tool; once you've picked a tool, drill into it with `posthog:query-mcp-tool-stats`, `posthog:query-mcp-tool-failures`, or `posthog:query-mcp-tool-daily-stats`:
```sql
SELECT
@@ -98,7 +114,7 @@ GROUP BY day ORDER BY day
A "harness" is the friendly product label for the MCP client that made a call — "Claude Agent SDK", "OpenAI Codex", "Cursor", … It is resolved **server-side** by `MCPHarnessBreakdownQueryRunner`, the single source of truth (`products/mcp_analytics/backend/mcp_harness.py`).
-**Prefer the typed tool.** For "which harnesses use our MCP, and how reliably?", call the `posthog:query-mcp-harness-breakdown` tool (gated behind the `mcp-analytics` flag). It returns calls / errors / error-rate / sessions per harness and accepts the same `dateRange` / `properties` / `filterTestAccounts` filters as the dashboard, so results match the UI exactly — no hand-written bucketing needed. (The session/feedback REST tools — `mcp-analytics-sessions-list` etc. — are disabled, so anything the typed tool doesn't express drops to `execute-sql` below.)
+**Prefer the typed tool.** For "which harnesses use our MCP, and how reliably?", call the `posthog:query-mcp-harness-breakdown` tool (gated behind the `mcp-analytics` flag). It returns calls / errors / error-rate / sessions per harness and accepts the same `dateRange` / `properties` / `filterTestAccounts` filters as the dashboard, so results match the UI exactly — no hand-written bucketing needed. It also accepts an optional `toolName` to scope the breakdown to one effective tool — but note that scoping **also restricts the result to new-SDK events** (`$mcp_source = 'posthog_mcp_analytics'`), so old-SDK and third-party calls for that tool are excluded and a harness can be undercounted. For a one-tool harness cut across all SDK sources, use `execute-sql`. Anything the typed tools don't express drops to `execute-sql` below.
**Use `execute-sql` for custom cuts** the typed tool doesn't cover (share-of-users, latency percentiles, per-tool, a trends breakdown). Resolution is two steps: resolve a normalized token from the strongest signal available, then bucket it. An event carries only raw signals — the `x-anthropic-client` header (`mcp_vendor_client`) is the only thing separating Anthropic's pooled surfaces (Cowork / Claude.ai / Claude Design); Claude Code's build (cli / sdk / vscode / desktop) rides in the User-Agent; the posthog-node MCP analytics SDK reports its `clientInfo.name` as `$mcp_client_name`, and the hosted server's session-pinned `mcp_session_client_name` covers everyone else; `$mcp_client_user_agent` and `$mcp_oauth_client_name` are last fallbacks. The SQL below mirrors `harness_label_sql` / `HARNESS_TOKEN_SQL` in `mcp_harness.py`; keep them in step until a materialized `$mcp_harness` property exists. (HogQL has no `WITH <expr> AS alias`, so the normalized name `h` is computed in a subquery, not a CTE.)