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.

feat(mcp-analytics): rewire tool-detail by-harness table onto the runner (#65521)

Paul D'Ambra723b6886fbbe
diff --git a/products/mcp_analytics/frontend/MCPAnalyticsToolDetail.tsx b/products/mcp_analytics/frontend/MCPAnalyticsToolDetail.tsx
index 04d93cf0b3a3..ada054aebfa5 100644
--- a/products/mcp_analytics/frontend/MCPAnalyticsToolDetail.tsx
+++ b/products/mcp_analytics/frontend/MCPAnalyticsToolDetail.tsx
@@ -614,9 +614,9 @@ export function MCPAnalyticsToolDetail({ toolName }: { toolName: string }): JSX.
header: 'Harness',
expand: true,
render: (r) => {
- const raw = String(r[0] ?? '')
- return raw ? (
- <HarnessPill category={categorizeHarness(raw)} title={raw} />
+ const label = String(r[0] ?? '')
+ return label ? (
+ <HarnessPill category={label} title={label} />
) : (
<span className="text-muted">Unknown</span>
)
@@ -634,7 +634,7 @@ export function MCPAnalyticsToolDetail({ toolName }: { toolName: string }): JSX.
},
{ header: 'Error rate', align: 'right', render: (r) => `${Number(r[3] ?? 0)}%` },
{
- header: 'Users',
+ header: 'Sessions',
align: 'right',
render: (r) => humanFriendlyNumber(Number(r[4] ?? 0)),
},
diff --git a/products/mcp_analytics/frontend/mcpAnalyticsToolDetailLogic.ts b/products/mcp_analytics/frontend/mcpAnalyticsToolDetailLogic.ts
index caf3ac61ee8a..810f5c96cf4f 100644
--- a/products/mcp_analytics/frontend/mcpAnalyticsToolDetailLogic.ts
+++ b/products/mcp_analytics/frontend/mcpAnalyticsToolDetailLogic.ts
@@ -4,7 +4,8 @@ import { loaders } from 'kea-loaders'
import api from 'lib/api'
import { dayjs } from 'lib/dayjs'
-import { HogQLQueryResponse, NodeKind } from '~/queries/schema/schema-general'
+import { HogQLQueryResponse, MCPHarnessBreakdownItem, NodeKind } from '~/queries/schema/schema-general'
+import { PropertyFilterType } from '~/types'
import type { mcpAnalyticsToolDetailLogicType } from './mcpAnalyticsToolDetailLogicType'
@@ -332,23 +333,30 @@ LIMIT 5
byHarnessRows: [
[] as ResultRows,
{
- loadByHarnessRows: async (): Promise<ResultRows> =>
- queryRows(`
-SELECT
- toString(properties.$mcp_client_name) AS harness,
- count() AS calls,
- countIf(toBool(properties.$mcp_is_error)) AS errors,
- round(countIf(toBool(properties.$mcp_is_error)) * 100.0 / count(), 1) AS error_rate_pct,
- uniq(distinct_id) AS users
-FROM events
-WHERE event = '$mcp_tool_call'
- AND timestamp >= now() - INTERVAL 7 DAY
- AND ${buildToolFilter(props.toolName)}
- AND notEmpty(toString(properties.$mcp_client_name))
-GROUP BY harness
-ORDER BY calls DESC
-LIMIT 10
-`),
+ // Server-resolved harness labels via the same runner as the dashboard, so the
+ // pill matches the dashboard's bucketing exactly. The per-tool, new-SDK filter
+ // rides along as a HogQL property so the runner applies it inside its WHERE.
+ loadByHarnessRows: async (): Promise<ResultRows> => {
+ const response = (await api.query({
+ kind: NodeKind.MCPHarnessBreakdownQuery,
+ // Absolute from/to give an exact 168h window. A relative '-7d' is rounded to
+ // the start of that day by QueryDateRange, which would widen this table's
+ // window past the page's other `now() - INTERVAL 7 DAY` queries and let its
+ // counts drift from the summary / Top users sections after midnight.
+ dateRange: {
+ date_from: dayjs().subtract(7, 'day').toISOString(),
+ date_to: dayjs().toISOString(),
+ },
+ properties: [{ type: PropertyFilterType.HogQL, key: buildToolFilter(props.toolName) }],
+ })) as { results?: MCPHarnessBreakdownItem[] }
+ return (response?.results ?? []).map((r) => [
+ r.harness,
+ r.total_calls,
+ r.errors,
+ r.error_rate_pct,
+ r.sessions,
+ ])
+ },
},
],
topUserRows: [