: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
fix(mcp-analytics): count rejected calls against their target tool (#107924)
Vasco de Krijgere0dbe4267047
diff --git a/frontend/src/scenes/hog-functions/sub-templates/sub-templates.ts b/frontend/src/scenes/hog-functions/sub-templates/sub-templates.tsindex e1a15b5758da..cc35c96071bd 100644--- a/frontend/src/scenes/hog-functions/sub-templates/sub-templates.ts+++ b/frontend/src/scenes/hog-functions/sub-templates/sub-templates.ts@@ -21,9 +21,19 @@ export const errorTrackingIssueLinkHogTemplate = (medium: string): string =>`{project.url}/error_tracking/fingerprint/{replaceAll(replaceAll(encodeURLComponent(event.properties.fingerprint), '(', '%28'), ')', '%29')}?timestamp={event.properties.exception_timestamp}&utm_source=alert&utm_campaign=error_tracking_alert&utm_medium=${medium}`// In single-exec mode $mcp_tool_name is always the 'exec' dispatcher; the inner tool the agent-// actually invoked rides on $mcp_exec_tool_call_name, so fall back the same way the backend does.-const MCP_EFFECTIVE_TOOL_EXPR =- 'event.properties.$mcp_exec_tool_call_name ? event.properties.$mcp_exec_tool_call_name : event.properties.$mcp_tool_name'+// actually invoked rides on $mcp_exec_tool_call_name. Rejected calls only carry the target.+const MCP_EFFECTIVE_TOOL_EXPR = `(() -> {+ if (event.properties.$mcp_exec_tool_call_name) {+ return event.properties.$mcp_exec_tool_call_name;+ }+ if (event.properties.$mcp_tool_name = 'exec'+ and event.properties.$mcp_exec_verb = 'call'+ and event.properties.$mcp_exec_target_tool+ and event.properties.$mcp_exec_target_tool != 'unrecognized') {+ return event.properties.$mcp_exec_target_tool;+ }+ return event.properties.$mcp_tool_name;+})()`// How long one failing tool stays deduped. Long enough to collapse a retry loop, short enough that// a breakage that is still happening reappears in the channel.diff --git a/products/mcp_analytics/backend/hogql_queries/base.py b/products/mcp_analytics/backend/hogql_queries/base.pyindex fa199a685320..0b7fe7900321 100644--- a/products/mcp_analytics/backend/hogql_queries/base.py+++ b/products/mcp_analytics/backend/hogql_queries/base.py@@ -28,18 +28,22 @@ if TYPE_CHECKING:from posthog.models.user import User# The effective tool name for new-SDK events: the inner tool when the call went through the-# single-exec wrapper, else the directly-registered tool name. Shared by every runner that-# scopes to one tool, so the expression lives OnceAndOnlyOnce.-EFFECTIVE_TOOL_SQL = (- "coalesce(nullIf(toString(properties.$mcp_exec_tool_call_name), ''), toString(properties.$mcp_tool_name))"-)+# single-exec wrapper, including calls rejected before dispatch. Discovery verbs only+# describe a tool, so their target must not count as an execution attempt.+EFFECTIVE_TOOL_SQL = """coalesce(+ nullIf(toString(properties.$mcp_exec_tool_call_name), ''),+ if(properties.$mcp_tool_name = 'exec' AND properties.$mcp_exec_verb = 'call',+ nullIf(nullIf(toString(properties.$mcp_exec_target_tool), ''), 'unrecognized'), NULL),+ toString(properties.$mcp_tool_name)+)"""# The description of the *effective* tool: for single-exec calls the inner tool's# $mcp_exec_tool_call_description, else the directly-registered $mcp_tool_description.# Without this, an inner tool's description would resolve to the exec wrapper's text# (another tool's description) — a tool-level disclosure.EFFECTIVE_DESCRIPTION_SQL = ("coalesce(nullIf(toString(properties.$mcp_exec_tool_call_description), ''), "- "toString(properties.$mcp_tool_description))"+ f"if(({EFFECTIVE_TOOL_SQL}) = toString(properties.$mcp_tool_name), "+ "toString(properties.$mcp_tool_description), NULL))")# One MCP conversation: the SDK's own session id, falling back to the PostHog session id.CONVERSATION_ID_SQL = "coalesce(nullIf(toString(properties.$mcp_session_id), ''), toString(properties.$session_id))"diff --git a/products/mcp_analytics/backend/tests/test_tool_tables.py b/products/mcp_analytics/backend/tests/test_tool_tables.pyindex 39a35b8581c2..8653af3115d3 100644--- a/products/mcp_analytics/backend/tests/test_tool_tables.py+++ b/products/mcp_analytics/backend/tests/test_tool_tables.py@@ -149,6 +149,8 @@ class TestMCPToolFailuresQueryRunner(_MCPAnalyticsTeamScopedTestMixin, Clickhouserror_type: str | None = None,error_status: str | None = None,exec_tool: str | None = None,+ exec_verb: str | None = None,+ exec_target: str | None = None,timestamp: datetime | None = None,) -> None:properties: dict[str, Any] = {"$mcp_tool_name": tool_name, "$mcp_is_error": is_error}@@ -162,6 +164,10 @@ class TestMCPToolFailuresQueryRunner(_MCPAnalyticsTeamScopedTestMixin, Clickhousproperties["$mcp_error_status"] = error_statusif exec_tool is not None:properties["$mcp_exec_tool_call_name"] = exec_tool+ if exec_verb is not None:+ properties["$mcp_exec_verb"] = exec_verb+ if exec_target is not None:+ properties["$mcp_exec_target_tool"] = exec_target_create_event(team=self.team,event="$mcp_tool_call",@@ -232,9 +238,15 @@ class TestMCPToolFailuresQueryRunner(_MCPAnalyticsTeamScopedTestMixin, Clickhousself._emit(tool_name="other_tool", error_type="internal", client_name="claude-ai")# Single-exec wrapper: the effective tool is in $mcp_exec_tool_call_name, not $mcp_tool_name.self._emit(tool_name="exec", exec_tool="query_run", error_type="validation", client_name="cursor-vscode")+ self._emit(tool_name="exec", exec_verb="call", exec_target="query_run", error_type="validation")+ self._emit(tool_name="exec", exec_verb="info", exec_target="query_run", error_type="validation")+ self._emit(tool_name="exec", exec_verb="schema", exec_target="query_run", error_type="validation")+ self._emit(tool_name="other_tool", exec_verb="call", exec_target="query_run", error_type="validation")flush_persons_and_events()- assert [r.message for r in self._run(tool_name="query_run")] == ["validation"]+ rows = self._run(tool_name="query_run")+ assert [row.message for row in rows] == ["validation"]+ assert rows[0].occurrences == 2def test_excludes_events_without_new_sdk_source(self) -> None:self._emit(source=None, error_type="internal", client_name="claude-ai")@@ -415,6 +427,8 @@ def _emit_tool_call(client_name: str | None = None,session_id: str | None = None,exec_tool: str | None = None,+ exec_verb: str | None = None,+ exec_target: str | None = None,timestamp: datetime | None = None,) -> None:properties: dict[str, Any] = {"$mcp_tool_name": tool_name, "$mcp_is_error": is_error}@@ -434,6 +448,10 @@ def _emit_tool_call(properties["$mcp_session_id"] = session_idif exec_tool is not None:properties["$mcp_exec_tool_call_name"] = exec_tool+ if exec_verb is not None:+ properties["$mcp_exec_verb"] = exec_verb+ if exec_target is not None:+ properties["$mcp_exec_target_tool"] = exec_target_create_event(team=team,event="$mcp_tool_call",@@ -454,10 +472,22 @@ class TestMCPToolStatsQueryRunner(_MCPAnalyticsTeamScopedTestMixin, ClickhouseTedef test_empty_when_no_calls(self) -> None:assert self._run() == []- def test_aggregates_scalars_and_intent_coverage(self) -> None:+ @parameterized.expand([("direct", False), ("rejected_exec", True)])+ def test_aggregates_scalars_and_intent_coverage(self, _name: str, rejected_exec: bool) -> None:_emit_tool_call(self.team, distinct_id="d1", duration_ms=100, intent='{"goal":"x"}', session_id="s1")- _emit_tool_call(self.team, distinct_id="d1", duration_ms=300, is_error=True, session_id="s1")+ _emit_tool_call(+ self.team,+ distinct_id="d1",+ duration_ms=300,+ is_error=True,+ session_id="s1",+ tool_name="exec" if rejected_exec else "query_run",+ exec_verb="call" if rejected_exec else None,+ exec_target="query_run" if rejected_exec else None,+ )_emit_tool_call(self.team, distinct_id="d2", duration_ms=200, intent="{}", session_id="s2")+ for verb in ("info", "schema"):+ _emit_tool_call(self.team, tool_name="exec", exec_verb=verb, exec_target="query_run", is_error=True)# Off-tool event must not leak into the aggregation (shared tool filter wiring)._emit_tool_call(self.team, distinct_id="d3", tool_name="other", duration_ms=999)flush_persons_and_events()@@ -598,6 +628,25 @@ class TestMCPToolDescriptionsQueryRunner(_MCPAnalyticsTeamScopedTestMixin, Clickassert [r.description for r in rows] == ["real"]+ def test_rejected_exec_call_does_not_attribute_wrapper_description_to_target(self) -> None:+ _create_event(+ team=self.team,+ event="$mcp_tool_call",+ distinct_id="rejected-call",+ timestamp=datetime.now(tz=UTC),+ properties={+ "$mcp_source": NEW_SDK_SOURCE,+ "$mcp_tool_name": "exec",+ "$mcp_tool_description": "Run an MCP command",+ "$mcp_exec_verb": "call",+ "$mcp_exec_target_tool": "query_run",+ "$mcp_is_error": True,+ },+ )+ flush_persons_and_events()++ assert self._run() == []+class TestMCPToolSampleIntentsQueryRunner(_MCPAnalyticsTeamScopedTestMixin, ClickhouseTestMixin, APIBaseTest):def _run(self, tool_name: str = "query_run") -> list[Any]:diff --git a/products/mcp_analytics/frontend/components/toolCallFeedQuery.ts b/products/mcp_analytics/frontend/components/toolCallFeedQuery.tsindex 9d23645f7f05..167f167fea1f 100644--- a/products/mcp_analytics/frontend/components/toolCallFeedQuery.ts+++ b/products/mcp_analytics/frontend/components/toolCallFeedQuery.ts@@ -14,7 +14,12 @@ export const MCP_ACTIVITY_SESSION_COLUMN = 'properties.$session_id -- Session'export const MCP_ACTIVITY_COLUMNS = ['*',- "coalesce(nullIf(toString(properties.$mcp_exec_tool_call_name), ''), toString(properties.$mcp_tool_name)) -- Tool",+ `coalesce(+ nullIf(toString(properties.$mcp_exec_tool_call_name), ''),+ if(properties.$mcp_tool_name = 'exec' AND properties.$mcp_exec_verb = 'call',+ nullIf(nullIf(toString(properties.$mcp_exec_target_tool), ''), 'unrecognized'), NULL),+ toString(properties.$mcp_tool_name)+ ) -- Tool`,MCP_ACTIVITY_INTENT_COLUMN,MCP_ACTIVITY_ERROR_COLUMN,'properties.$mcp_duration_ms -- Duration (ms)',diff --git a/products/mcp_analytics/frontend/notifications/mcpNotificationExamplesLogic.ts b/products/mcp_analytics/frontend/notifications/mcpNotificationExamplesLogic.tsindex 7f430a4a9540..a1979476b981 100644--- a/products/mcp_analytics/frontend/notifications/mcpNotificationExamplesLogic.ts+++ b/products/mcp_analytics/frontend/notifications/mcpNotificationExamplesLogic.ts@@ -20,7 +20,7 @@ export type MCPNotificationExamples = Partial<Record<MCPNotificationUseCase, MCP//// The effective-tool expression mirrors EFFECTIVE_TOOL_SQL in// products/mcp_analytics/backend/hogql_queries/base.py — the inner tool when the call came through-// the single-exec wrapper, else the directly-registered name.+// the single-exec wrapper, including rejected calls, else the directly-registered name.const EXAMPLES_QUERY = `SELECT'tool-error' AS use_case,@@ -28,7 +28,12 @@ SELECTargMax(toString(properties.$mcp_server_name), timestamp) AS server_name,argMax(toString(properties.$mcp_intent), timestamp) AS intent,argMax(- coalesce(nullIf(toString(properties.$mcp_exec_tool_call_name), ''), toString(properties.$mcp_tool_name)),+ coalesce(+ nullIf(toString(properties.$mcp_exec_tool_call_name), ''),+ if(properties.$mcp_tool_name = 'exec' AND properties.$mcp_exec_verb = 'call',+ nullIf(nullIf(toString(properties.$mcp_exec_target_tool), ''), 'unrecognized'), NULL),+ toString(properties.$mcp_tool_name)+ ),timestamp) AS tool_nameFROM eventsdiff --git a/products/mcp_analytics/frontend/notifications/recurringReportDefinitions.ts b/products/mcp_analytics/frontend/notifications/recurringReportDefinitions.tsindex a1ce60482d15..687616b7c43e 100644--- a/products/mcp_analytics/frontend/notifications/recurringReportDefinitions.ts+++ b/products/mcp_analytics/frontend/notifications/recurringReportDefinitions.ts@@ -53,7 +53,10 @@ export const MCP_RECURRING_REPORTS: MCPRecurringReport[] = [title: 'MCP tool health',prompt: ['Report on our MCP server’s health for the last week using $mcp_tool_call events.',- 'Cover total calls, calls per tool (use $mcp_exec_tool_call_name when set, else $mcp_tool_name),',+ 'Cover total calls and calls per tool. Use $mcp_exec_tool_call_name when non-empty.',+ 'Otherwise, for $mcp_tool_name = exec and $mcp_exec_verb = call, use $mcp_exec_target_tool',+ 'when it is non-empty and not unrecognized. Fall back to $mcp_tool_name in all other cases.',+ 'Include discovery requests under exec, not the tool they describe. Cover','the error rate from $mcp_is_error, the most common $mcp_error_type values with example','$mcp_error_message text, and p95 of $mcp_duration_ms per tool.','Highlight tools whose error rate or latency is clearly worse than the weeks before,',diff --git a/products/signals/skills/signals-scout-mcp-tool-calls/SKILL.md b/products/signals/skills/signals-scout-mcp-tool-calls/SKILL.mdindex 10e09ace36b2..143e5c1d1ebd 100644--- a/products/signals/skills/signals-scout-mcp-tool-calls/SKILL.md+++ b/products/signals/skills/signals-scout-mcp-tool-calls/SKILL.md@@ -44,13 +44,13 @@ MCP tool calls land on the `$mcp_tool_call` event, emitted by both PostHog's own**Tier 1 — always present (build detection on these):**-| Field | Access | Use |-| ------------ | ---------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------- |-| failure flag | `toBool(properties.$mcp_is_error)` | failure rate |-| duration | `toFloat(properties.$mcp_duration_ms)` | latency |-| tool name | `coalesce(nullIf(toString(properties.$mcp_exec_tool_call_name), ''), toString(properties.$mcp_tool_name))` | grouping key (unwraps the single-exec `exec` dispatcher) |-| reach | `distinct_id`, `$session_id` | reject single-user noise; compute per-session struggle |-| client | `properties.$mcp_client_name` | localize a client-specific break (most reliable harness field) |+| Field | Access | Use |+| ------------ | ------------------------------------------------------------------------ | -------------------------------------------------------------- |+| failure flag | `toBool(properties.$mcp_is_error)` | failure rate |+| duration | `toFloat(properties.$mcp_duration_ms)` | latency |+| tool name | Effective tool expression in [the query cookbook](references/queries.md) | grouping key (includes rejected calls to known targets) |+| reach | `distinct_id`, `$session_id` | reject single-user noise; compute per-session struggle |+| client | `properties.$mcp_client_name` | localize a client-specific break (most reliable harness field) |**Tier 2 — sometimes present (enrichment; localizes the cause, gate on coverage):**diff --git a/products/signals/skills/signals-scout-mcp-tool-calls/references/queries.md b/products/signals/skills/signals-scout-mcp-tool-calls/references/queries.mdindex 4befb1b44e00..c802b808fe12 100644--- a/products/signals/skills/signals-scout-mcp-tool-calls/references/queries.md+++ b/products/signals/skills/signals-scout-mcp-tool-calls/references/queries.md@@ -9,8 +9,9 @@ throughout:(both PostHog's hono server and external customer servers), excludes pre-SDK legacy events.If a project's counts look suspiciously low, re-run the coverage probe without this filterto check for legacy-only instrumentation.-- Effective tool name (always use this — unwraps the single-exec `exec` dispatcher):- `coalesce(nullIf(toString(properties.$mcp_exec_tool_call_name), ''), toString(properties.$mcp_tool_name))`+- Effective tool name: prefer the dispatched inner tool, then a known target rejected before dispatch.+ Only `exec` with verb `call` uses the target; discovery verbs and unrecognized targets stay under `exec`:+ `coalesce(nullIf(toString(properties.$mcp_exec_tool_call_name), ''), if(properties.$mcp_tool_name = 'exec' AND properties.$mcp_exec_verb = 'call', nullIf(nullIf(toString(properties.$mcp_exec_target_tool), ''), 'unrecognized'), NULL), toString(properties.$mcp_tool_name))`- **Presence check = `isNotNull(properties.X)`.** This is the one reliable way to test whether anenrichment field is populated. Do **not** use `!= ''` or `NOT IN ('', 'None')` as a presence test —both resolve unreliably in HogQL for the MCP props (verified: they returned >100% coverage and@@ -98,7 +99,7 @@ Ranks tools by failures over a volume floor, with rate and reach. Uses only alwa```sqlSELECT- coalesce(nullIf(toString(properties.$mcp_exec_tool_call_name), ''), toString(properties.$mcp_tool_name)) AS tool,+ coalesce(nullIf(toString(properties.$mcp_exec_tool_call_name), ''), if(properties.$mcp_tool_name = 'exec' AND properties.$mcp_exec_verb = 'call', nullIf(nullIf(toString(properties.$mcp_exec_target_tool), ''), 'unrecognized'), NULL), toString(properties.$mcp_tool_name)) AS tool,any(properties.$mcp_tool_category) AS category,count() AS calls,countIf(toBool(properties.$mcp_is_error)) AS errors,@@ -138,7 +139,7 @@ SELECTFROM (SELECT$session_id AS session,- coalesce(nullIf(toString(properties.$mcp_exec_tool_call_name), ''), toString(properties.$mcp_tool_name)) AS tool,+ coalesce(nullIf(toString(properties.$mcp_exec_tool_call_name), ''), if(properties.$mcp_tool_name = 'exec' AND properties.$mcp_exec_verb = 'call', nullIf(nullIf(toString(properties.$mcp_exec_target_tool), ''), 'unrecognized'), NULL), toString(properties.$mcp_tool_name)) AS tool,any(properties.$mcp_tool_category) AS category,count() AS calls,countIf(toBool(properties.$mcp_is_error)) AS errors@@ -179,7 +180,7 @@ FROM eventsWHERE event = '$mcp_tool_call'AND properties.$mcp_source = 'posthog_mcp_analytics'AND toBool(properties.$mcp_is_error)- AND coalesce(nullIf(toString(properties.$mcp_exec_tool_call_name), ''), toString(properties.$mcp_tool_name)) = '<tool>'+ AND coalesce(nullIf(toString(properties.$mcp_exec_tool_call_name), ''), if(properties.$mcp_tool_name = 'exec' AND properties.$mcp_exec_verb = 'call', nullIf(nullIf(toString(properties.$mcp_exec_target_tool), ''), 'unrecognized'), NULL), toString(properties.$mcp_tool_name)) = '<tool>'AND timestamp >= now() - INTERVAL 7 DAYGROUP BY error_typeORDER BY errors DESC@@ -208,7 +209,7 @@ FROM eventsWHERE event = '$mcp_tool_call'AND properties.$mcp_source = 'posthog_mcp_analytics'AND toBool(properties.$mcp_is_error)- AND coalesce(nullIf(toString(properties.$mcp_exec_tool_call_name), ''), toString(properties.$mcp_tool_name)) = '<tool>'+ AND coalesce(nullIf(toString(properties.$mcp_exec_tool_call_name), ''), if(properties.$mcp_tool_name = 'exec' AND properties.$mcp_exec_verb = 'call', nullIf(nullIf(toString(properties.$mcp_exec_target_tool), ''), 'unrecognized'), NULL), toString(properties.$mcp_tool_name)) = '<tool>'AND properties.$mcp_error_message != ''AND timestamp >= now() - INTERVAL 7 DAYGROUP BY message@@ -223,7 +224,7 @@ failures in the hono regime.```sqlSELECT- coalesce(nullIf(toString(properties.$mcp_exec_tool_call_name), ''), toString(properties.$mcp_tool_name)) AS tool,+ coalesce(nullIf(toString(properties.$mcp_exec_tool_call_name), ''), if(properties.$mcp_tool_name = 'exec' AND properties.$mcp_exec_verb = 'call', nullIf(nullIf(toString(properties.$mcp_exec_target_tool), ''), 'unrecognized'), NULL), toString(properties.$mcp_tool_name)) AS tool,any(properties.$mcp_tool_category) AS category,count() AS calls,round(quantile(0.5)(toFloat(properties.$mcp_duration_ms))) AS p50_ms,@@ -253,7 +254,7 @@ SELECTFROM eventsWHERE event = '$mcp_tool_call'AND properties.$mcp_source = 'posthog_mcp_analytics'- AND coalesce(nullIf(toString(properties.$mcp_exec_tool_call_name), ''), toString(properties.$mcp_tool_name)) = '<tool>'+ AND coalesce(nullIf(toString(properties.$mcp_exec_tool_call_name), ''), if(properties.$mcp_tool_name = 'exec' AND properties.$mcp_exec_verb = 'call', nullIf(nullIf(toString(properties.$mcp_exec_target_tool), ''), 'unrecognized'), NULL), toString(properties.$mcp_tool_name)) = '<tool>'AND isNotNull(properties.$mcp_intent)AND timestamp >= now() - INTERVAL 7 DAYGROUP BY intent, source@@ -268,7 +269,7 @@ tool is broken universally or only for one client/harness — a different improv```sqlSELECT- coalesce(nullIf(toString(properties.$mcp_exec_tool_call_name), ''), toString(properties.$mcp_tool_name)) AS tool,+ coalesce(nullIf(toString(properties.$mcp_exec_tool_call_name), ''), if(properties.$mcp_tool_name = 'exec' AND properties.$mcp_exec_verb = 'call', nullIf(nullIf(toString(properties.$mcp_exec_target_tool), ''), 'unrecognized'), NULL), toString(properties.$mcp_tool_name)) AS tool,coalesce(nullIf(nullIf(toString(properties.$mcp_client_name), ''), 'None'), 'unknown') AS client,count() AS calls,countIf(toBool(properties.$mcp_is_error)) AS errors,@@ -276,7 +277,7 @@ SELECTFROM eventsWHERE event = '$mcp_tool_call'AND properties.$mcp_source = 'posthog_mcp_analytics'- AND coalesce(nullIf(toString(properties.$mcp_exec_tool_call_name), ''), toString(properties.$mcp_tool_name)) = '<tool>'+ AND coalesce(nullIf(toString(properties.$mcp_exec_tool_call_name), ''), if(properties.$mcp_tool_name = 'exec' AND properties.$mcp_exec_verb = 'call', nullIf(nullIf(toString(properties.$mcp_exec_target_tool), ''), 'unrecognized'), NULL), toString(properties.$mcp_tool_name)) = '<tool>'AND timestamp >= now() - INTERVAL 7 DAYGROUP BY tool, clientHAVING calls >= 20@@ -297,7 +298,7 @@ worst offenders rather than every tool.```sqlSELECT- coalesce(nullIf(toString(properties.$mcp_exec_tool_call_name), ''), toString(properties.$mcp_tool_name)) AS tool,+ coalesce(nullIf(toString(properties.$mcp_exec_tool_call_name), ''), if(properties.$mcp_tool_name = 'exec' AND properties.$mcp_exec_verb = 'call', nullIf(nullIf(toString(properties.$mcp_exec_target_tool), ''), 'unrecognized'), NULL), toString(properties.$mcp_tool_name)) AS tool,count() AS calls,countIf(toBool(properties.$mcp_is_error)) AS errors,countIf(toBool(properties.$mcp_is_error)) - countIf(toBool(properties.$mcp_is_error) AND toString(properties.$mcp_error_type) IN ('internal', 'validation', 'api_4xx', 'api_5xx', 'permission', 'timeout', 'rate_limited', 'missing_context')) AS undiagnosable_errors@@ -323,7 +324,7 @@ and are estimates, hono-only.```sqlSELECT- coalesce(nullIf(toString(properties.$mcp_exec_tool_call_name), ''), toString(properties.$mcp_tool_name)) AS tool,+ coalesce(nullIf(toString(properties.$mcp_exec_tool_call_name), ''), if(properties.$mcp_tool_name = 'exec' AND properties.$mcp_exec_verb = 'call', nullIf(nullIf(toString(properties.$mcp_exec_target_tool), ''), 'unrecognized'), NULL), toString(properties.$mcp_tool_name)) AS tool,count() AS calls,round(quantile(0.5)(toFloat(properties.output_tokens))) AS p50_output_tokens,round(quantile(0.95)(toFloat(properties.output_tokens))) AS p95_output_tokens@@ -359,7 +360,7 @@ SELECTgroupArrayIf((tool, calls, errors, tool_error_rate_pct, users), calls >= 50 AND tool_error_rate_pct >= 10) AS problem_tool_detailsFROM (SELECT- coalesce(nullIf(toString(properties.$mcp_exec_tool_call_name), ''), toString(properties.$mcp_tool_name)) AS tool,+ coalesce(nullIf(toString(properties.$mcp_exec_tool_call_name), ''), if(properties.$mcp_tool_name = 'exec' AND properties.$mcp_exec_verb = 'call', nullIf(nullIf(toString(properties.$mcp_exec_target_tool), ''), 'unrecognized'), NULL), toString(properties.$mcp_tool_name)) AS tool,any(properties.$mcp_tool_category) AS category,count() AS calls,countIf(toBool(properties.$mcp_is_error)) AS errors,@@ -416,7 +417,7 @@ WITH per_session AS (coalesce(nullIf(nullIf(toString(properties.source), ''), 'None'), 'unknown') AS source_bucket,$session_id AS session,any(distinct_id) AS user,- coalesce(nullIf(toString(properties.$mcp_exec_tool_call_name), ''), toString(properties.$mcp_tool_name)) AS tool,+ coalesce(nullIf(toString(properties.$mcp_exec_tool_call_name), ''), if(properties.$mcp_tool_name = 'exec' AND properties.$mcp_exec_verb = 'call', nullIf(nullIf(toString(properties.$mcp_exec_target_tool), ''), 'unrecognized'), NULL), toString(properties.$mcp_tool_name)) AS tool,coalesce(nullIf(nullIf(toString(any(properties.$mcp_tool_category)), ''), 'None'), 'Uncategorized') AS category,timestamp >= now() - INTERVAL 7 DAY AS is_current,count() AS calls@@ -504,7 +505,7 @@ times, or failed and was called again.```sqlWITH calls AS (SELECT- coalesce(nullIf(toString(properties.$mcp_exec_tool_call_name), ''), toString(properties.$mcp_tool_name)) AS tool,+ coalesce(nullIf(toString(properties.$mcp_exec_tool_call_name), ''), if(properties.$mcp_tool_name = 'exec' AND properties.$mcp_exec_verb = 'call', nullIf(nullIf(toString(properties.$mcp_exec_target_tool), ''), 'unrecognized'), NULL), toString(properties.$mcp_tool_name)) AS tool,properties.$mcp_tool_category AS raw_category,$session_id AS session,distinct_id,