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.

fix(mcp-analytics): attribute harness from vendor header and user-agent (#64545)

Paul D'Ambra7a18f3c3c153
diff --git a/products/mcp_analytics/frontend/dashboard/HarnessDonut.tsx b/products/mcp_analytics/frontend/dashboard/HarnessDonut.tsx
index 60dcf6aa31d2..63f4d5278442 100644
--- a/products/mcp_analytics/frontend/dashboard/HarnessDonut.tsx
+++ b/products/mcp_analytics/frontend/dashboard/HarnessDonut.tsx
@@ -16,7 +16,8 @@ import { type HarnessRow } from '../mcpDashboardOverviewLogic'
import { Card } from './Card'
import { ChartTooltip } from './ChartTooltip'
import { formatNumber } from './formatters'
-import { HARNESS_LOGOS, HarnessPill, harnessSliceColor } from './harness'
+import { HarnessPill } from './harness'
+import { harnessLogo, harnessSliceColor } from './harnessRegistry'
const HARNESS_DONUT_CONFIG: PieChartConfig = {
innerRadiusRatio: 0.6,
@@ -41,7 +42,7 @@ function HarnessSliceLabels(): JSX.Element | null {
const x = layout.cx + Math.sin(slice.centroidAngle) * midRadius
const y = layout.cy - Math.cos(slice.centroidAngle) * midRadius
const category = slice.series.label
- const logo = HARNESS_LOGOS[category]
+ const logo = harnessLogo(category)
return (
<div
key={slice.series.key}
diff --git a/products/mcp_analytics/frontend/dashboard/harness.tsx b/products/mcp_analytics/frontend/dashboard/harness.tsx
index 8122672bb7f2..917460a3d79b 100644
--- a/products/mcp_analytics/frontend/dashboard/harness.tsx
+++ b/products/mcp_analytics/frontend/dashboard/harness.tsx
@@ -1,37 +1,4 @@
-import { type ChartTheme } from '@posthog/quill-charts'
-
-import claudeLogo from '../harness-logos/claude.svg'
-import cursorLogo from '../harness-logos/cursor.svg'
-import openaiLogo from '../harness-logos/openai.svg'
-import vscodeLogo from '../harness-logos/vscode.svg'
-
-interface HarnessLogo {
- src: string
- alt: string
-}
-
-export const HARNESS_LOGOS: Record<string, HarnessLogo> = {
- 'Claude Code': { src: claudeLogo, alt: 'Claude Code logo' },
- 'Claude.ai': { src: claudeLogo, alt: 'Claude.ai logo' },
- 'OpenAI Codex': { src: openaiLogo, alt: 'OpenAI Codex logo' },
- Cursor: { src: cursorLogo, alt: 'Cursor logo' },
- 'VS Code': { src: vscodeLogo, alt: 'VS Code logo' },
-}
-
-// Per-harness slice color (index into the data-viz palette), chosen so the logo drawn on top keeps
-// enough contrast against its slice.
-const HARNESS_SLICE_COLOR_INDEX: Record<string, number> = {
- 'Claude Code': 0,
- 'Claude.ai': 2,
- 'OpenAI Codex': 1,
- Cursor: 12,
- 'VS Code': 11,
-}
-
-export function harnessSliceColor(theme: ChartTheme, category: string, fallbackIndex: number): string {
- const index = HARNESS_SLICE_COLOR_INDEX[category] ?? fallbackIndex
- return theme.colors[index % theme.colors.length]
-}
+import { harnessLogo } from './harnessRegistry'
// A single harness logo (or a neutral dot when no logo is known for the category).
export function HarnessLogo({
@@ -41,7 +8,7 @@ export function HarnessLogo({
category: string
className?: string
}): JSX.Element {
- const logo = HARNESS_LOGOS[category]
+ const logo = harnessLogo(category)
if (logo) {
return <img src={logo.src} alt={category} title={category} className={`${className} shrink-0 object-contain`} />
}
diff --git a/products/mcp_analytics/frontend/dashboard/harnessRegistry.ts b/products/mcp_analytics/frontend/dashboard/harnessRegistry.ts
new file mode 100644
index 000000000000..eca650619315
--- /dev/null
+++ b/products/mcp_analytics/frontend/dashboard/harnessRegistry.ts
@@ -0,0 +1,152 @@
+import { type ChartTheme } from '@posthog/quill-charts'
+
+import claudeLogo from '../harness-logos/claude.svg'
+import cursorLogo from '../harness-logos/cursor.svg'
+import openaiLogo from '../harness-logos/openai.svg'
+import vscodeLogo from '../harness-logos/vscode.svg'
+
+export interface HarnessLogo {
+ src: string
+ alt: string
+}
+
+interface HarnessDescriptor {
+ category: string
+ // Matches against the normalized client token: lowercased, with the
+ // "(via mcp-remote …)" suffix stripped (see categorizeHarness).
+ match: (normalized: string) => boolean
+ logo?: HarnessLogo
+ // Index into the data-viz palette, chosen so the logo drawn on top keeps
+ // enough contrast against its slice.
+ colorIndex?: number
+}
+
+// Single source of truth for harness identity — how a normalized client token maps
+// to a display category, its logo, and its slice colour. Adding a new harness is one
+// entry here. Categories were derived from sampling the top distinct client
+// identifiers seen in production (clientInfo.name, the x-anthropic-client vendor
+// header, and User-Agent product tokens) over the past 30 days. The bucket list
+// mirrors the HogQL in products/posthog_ai/skills/querying-posthog-data/references/models-mcp.md
+// — keep the two in sync until a materialized $mcp_harness property exists.
+//
+// The normalized token can carry a surface suffix the query lifts out of the
+// User-Agent's parenthetical, e.g. "claude-code cli", "claude-code claude-desktop",
+// "openai-mcp chatgpt". List surface-specific entries before the generic prefix
+// match so they win; clients whose parenthetical is platform/arch noise (e.g.
+// "cursor darwin arm64") still fold to one bucket via the generic startsWith.
+const HARNESS_REGISTRY: HarnessDescriptor[] = [
+ {
+ category: 'Claude Desktop',
+ match: (n) => n === 'claude-code claude-desktop',
+ logo: { src: claudeLogo, alt: 'Claude Desktop logo' },
+ colorIndex: 5,
+ },
+ {
+ category: 'Claude Code (VS Code)',
+ match: (n) => n === 'claude-code claude-vscode',
+ logo: { src: claudeLogo, alt: 'Claude Code logo' },
+ colorIndex: 6,
+ },
+ {
+ category: 'Claude Agent SDK',
+ match: (n) => n.startsWith('claude-code sdk'),
+ logo: { src: claudeLogo, alt: 'Claude Agent SDK logo' },
+ colorIndex: 7,
+ },
+ {
+ category: 'Claude Code',
+ match: (n) => n.startsWith('claude-code'),
+ logo: { src: claudeLogo, alt: 'Claude Code logo' },
+ colorIndex: 0,
+ },
+ {
+ category: 'Claude.ai',
+ match: (n) => n === 'claude-ai' || n === 'anthropic/claudeai' || n === 'claude-user',
+ logo: { src: claudeLogo, alt: 'Claude.ai logo' },
+ colorIndex: 2,
+ },
+ { category: 'Anthropic API', match: (n) => n === 'anthropic/api' },
+ { category: 'Cowork', match: (n) => n === 'cowork', logo: { src: claudeLogo, alt: 'Cowork logo' }, colorIndex: 3 },
+ {
+ category: 'Claude Design',
+ match: (n) => n === 'claude-design',
+ logo: { src: claudeLogo, alt: 'Claude Design logo' },
+ colorIndex: 4,
+ },
+ {
+ category: 'ChatGPT',
+ match: (n) => n === 'openai-mcp chatgpt',
+ logo: { src: openaiLogo, alt: 'ChatGPT logo' },
+ colorIndex: 8,
+ },
+ {
+ category: 'OpenAI Agent Builder',
+ match: (n) => n === 'openai-mcp agent builder',
+ logo: { src: openaiLogo, alt: 'OpenAI Agent Builder logo' },
+ colorIndex: 9,
+ },
+ {
+ category: 'OpenAI Responses API',
+ match: (n) => n === 'openai-mcp responses api',
+ logo: { src: openaiLogo, alt: 'OpenAI Responses API logo' },
+ colorIndex: 10,
+ },
+ {
+ category: 'OpenAI',
+ match: (n) => n.startsWith('openai-mcp'),
+ logo: { src: openaiLogo, alt: 'OpenAI logo' },
+ colorIndex: 1,
+ },
+ {
+ category: 'OpenAI Codex',
+ match: (n) => n.startsWith('codex'),
+ logo: { src: openaiLogo, alt: 'OpenAI Codex logo' },
+ colorIndex: 13,
+ },
+ {
+ category: 'Cursor',
+ match: (n) => n.startsWith('cursor'),
+ logo: { src: cursorLogo, alt: 'Cursor logo' },
+ colorIndex: 12,
+ },
+ {
+ category: 'VS Code',
+ match: (n) => n.startsWith('visual studio code'),
+ logo: { src: vscodeLogo, alt: 'VS Code logo' },
+ colorIndex: 11,
+ },
+ { category: 'Windsurf', match: (n) => n === 'windsurf' },
+ { category: 'Replit', match: (n) => n.startsWith('replit') },
+ { category: 'Lovable', match: (n) => n.startsWith('lovable') },
+ { category: 'Manus', match: (n) => n === 'manus' },
+ { category: 'CodeRabbit', match: (n) => n === 'coderabbit' },
+ { category: 'Notion', match: (n) => n.startsWith('notion') },
+ { category: 'Poke', match: (n) => n === 'poke' },
+ { category: 'opencode', match: (n) => n === 'opencode' },
+ { category: 'Kiro', match: (n) => n.startsWith('kiro') },
+ { category: 'Desktop Commander', match: (n) => n.startsWith('desktop-commander') },
+]
+
+const HARNESS_BY_CATEGORY: Record<string, HarnessDescriptor> = Object.fromEntries(
+ HARNESS_REGISTRY.map((entry) => [entry.category, entry])
+)
+
+export function categorizeHarness(raw: string): string {
+ const stripped = raw
+ .replace(/\s*\(via mcp-remote[^)]*\)\s*/i, '')
+ .trim()
+ .toLowerCase()
+ if (!stripped) {
+ return 'Other'
+ }
+ return HARNESS_REGISTRY.find((entry) => entry.match(stripped))?.category ?? 'Other'
+}
+
+export function harnessLogo(category: string): HarnessLogo | undefined {
+ return HARNESS_BY_CATEGORY[category]?.logo
+}
+
+export function harnessSliceColor(theme: ChartTheme, category: string, fallbackIndex: number): string {
+ const index = HARNESS_BY_CATEGORY[category]?.colorIndex ?? fallbackIndex
+ return theme.colors[index % theme.colors.length]
+}
diff --git a/products/mcp_analytics/frontend/mcpDashboardOverviewLogic.test.ts b/products/mcp_analytics/frontend/mcpDashboardOverviewLogic.test.ts
index 2e6cdc202b9b..0a493fa91b50 100644
--- a/products/mcp_analytics/frontend/mcpDashboardOverviewLogic.test.ts
+++ b/products/mcp_analytics/frontend/mcpDashboardOverviewLogic.test.ts
@@ -44,9 +44,21 @@ describe('mcpDashboardOverviewLogic', () => {
describe('categorizeHarness', () => {
it.each([
['claude-code/1.0.0', 'Claude Code'],
+ ['claude-code cli', 'Claude Code'],
+ ['claude-code claude-desktop', 'Claude Desktop'],
+ ['claude-code claude-vscode', 'Claude Code (VS Code)'],
+ ['claude-code sdk-ts', 'Claude Agent SDK'],
['claude-ai', 'Claude.ai'],
['anthropic/claudeai', 'Claude.ai'],
+ ['cowork', 'Cowork'],
+ ['claude-design', 'Claude Design'],
+ ['claude-user', 'Claude.ai'],
+ ['openai-mcp', 'OpenAI'],
+ ['openai-mcp chatgpt', 'ChatGPT'],
+ ['openai-mcp agent builder', 'OpenAI Agent Builder'],
+ ['openai-mcp responses api', 'OpenAI Responses API'],
['cursor/0.42', 'Cursor'],
+ ['cursor darwin arm64', 'Cursor'],
['codex-cli', 'OpenAI Codex'],
['visual studio code', 'VS Code'],
['something-nobody-knows', 'Other'],
diff --git a/products/mcp_analytics/frontend/mcpDashboardOverviewLogic.ts b/products/mcp_analytics/frontend/mcpDashboardOverviewLogic.ts
index a300382dc64e..0e8a129da5fa 100644
--- a/products/mcp_analytics/frontend/mcpDashboardOverviewLogic.ts
+++ b/products/mcp_analytics/frontend/mcpDashboardOverviewLogic.ts
@@ -12,9 +12,12 @@ import { HogQLFilters, HogQLQueryResponse, NodeKind } from '~/queries/schema/sch
import { IntervalType } from '~/types'
import { mcpClusteringLogic } from './clustering/mcpClusteringLogic'
+import { categorizeHarness } from './dashboard/harnessRegistry'
import type { MCPIntentClusterApi } from './generated/api.schemas'
import type { mcpDashboardOverviewLogicType } from './mcpDashboardOverviewLogicType'
+export { categorizeHarness }
+
export interface DateFilter {
dateFrom: string | null
dateTo: string | null
@@ -88,16 +91,39 @@ ORDER BY total_calls DESC
LIMIT 50
`
+// Newer Anthropic clients stopped sending clientInfo.name ($mcp_client_name) and
+// now report identity only via the x-anthropic-client header (mcp_vendor_client)
+// or the User-Agent, so reading $mcp_client_name alone buckets nearly everything
+// as "Other". Resolve an effective client per call: prefer the self-reported
+// name, then the vendor header (matched case-insensitively, as the MCP service's
+// own client detection does), then the User-Agent's leading product token plus
+// the first parenthetical token as a surface suffix — e.g. "claude-code cli",
+// "claude-code claude-desktop", "openai-mcp chatgpt". The version segment between
+// them is dropped so claude-code/2.1.x folds to one token; categorizeHarness then
+// buckets surface-specific tokens (Claude Desktop, ChatGPT, …) and folds the rest.
const HARNESS_ROWS_QUERY = `
SELECT
- toString(properties.$mcp_client_name) AS client,
+ coalesce(
+ nullIf(toString(properties.$mcp_client_name), ''),
+ multiIf(
+ lower(toString(properties.mcp_vendor_client)) = 'claudecode', 'claude-code',
+ lower(toString(properties.mcp_vendor_client)) = 'claudeai', 'claude-ai',
+ lower(toString(properties.mcp_vendor_client)) = 'cowork', 'cowork',
+ lower(toString(properties.mcp_vendor_client)) = 'claudedesign', 'claude-design',
+ nullIf(toString(properties.mcp_vendor_client), '')
+ ),
+ nullIf(trim(concat(
+ extract(toString(properties.$mcp_client_user_agent), '^([^/]+)'),
+ ' ',
+ extract(toString(properties.$mcp_client_user_agent), '[(]([^,)]+)')
+ )), ''),
+ ''
+ ) AS client,
count() AS total_calls,
countIf(toBool(properties.$mcp_is_error)) AS errors,
countDistinctIf(toString(properties.$mcp_session_id), toString(properties.$mcp_session_id) != '') AS sessions
FROM events
WHERE event = '$mcp_tool_call'
- AND properties.$mcp_client_name IS NOT NULL
- AND properties.$mcp_client_name != ''
AND {filters}
GROUP BY client
ORDER BY total_calls DESC
@@ -234,51 +260,6 @@ const EMPTY_KPIS: KPIData = {
p95LatencyMs: { ...EMPTY_METRIC, goodDirection: 'down' },
}
-// Harness categories derived from sampling the top 50 distinct $mcp_client_name
-// values seen in production over the past 30 days. We normalize the
-// "(via mcp-remote …)" suffix that mcp-remote injects so the underlying client
-// folds into its real harness bucket.
-const HARNESS_CATEGORIES: { category: string; match: (name: string) => boolean }[] = [
- { category: 'Claude Code', match: (n) => n.startsWith('claude-code') },
- {
- category: 'Claude.ai',
- match: (n) => n === 'claude-ai' || n === 'anthropic/claudeai',
- },
- { category: 'Anthropic API', match: (n) => n === 'anthropic/api' },
- {
- category: 'OpenAI Codex',
- match: (n) => n.startsWith('codex') || n.startsWith('openai-mcp'),
- },
- { category: 'Cursor', match: (n) => n.startsWith('cursor') },
- { category: 'VS Code', match: (n) => n.startsWith('visual studio code') },
- { category: 'Windsurf', match: (n) => n === 'windsurf' },
- { category: 'Replit', match: (n) => n.startsWith('replit') },
- { category: 'Lovable', match: (n) => n.startsWith('lovable') },
- { category: 'Manus', match: (n) => n === 'manus' },
- { category: 'CodeRabbit', match: (n) => n === 'coderabbit' },
- { category: 'Notion', match: (n) => n.startsWith('notion') },
- { category: 'Poke', match: (n) => n === 'poke' },
- { category: 'opencode', match: (n) => n === 'opencode' },
- { category: 'Kiro', match: (n) => n.startsWith('kiro') },
- { category: 'Desktop Commander', match: (n) => n.startsWith('desktop-commander') },
-]
-
-export function categorizeHarness(raw: string): string {
- const stripped = raw
- .replace(/\s*\(via mcp-remote[^)]*\)\s*/i, '')
- .trim()
- .toLowerCase()
- if (!stripped) {
- return 'Other'
- }
- for (const entry of HARNESS_CATEGORIES) {
- if (entry.match(stripped)) {
- return entry.category
- }
- }
- return 'Other'
-}
-
export function aggregateHarnessRows(raw: HarnessRawRow[]): HarnessRow[] {
const byCategory = new Map<string, HarnessRow>()
for (const row of raw) {
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 f45d5577bd4d..dac47d18deae 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
@@ -2,6 +2,8 @@
Any MCP server instrumented with the `@posthog/mcp` SDK — and PostHog's own MCP server — emits a `$mcp_tool_call` event on the shared `events` table every time an agent invokes a tool. There is **no dedicated ClickHouse table** — all fields live as `$mcp_*` properties on `events`, queried directly with `posthog:execute-sql`. This is the data behind the MCP analytics dashboard, tool-quality, and tool-detail screens; every metric on those screens is reproducible as HogQL over this event.
+Query the canonical `$`-prefixed event name. Servers instrumented with the `@posthog/mcp` SDK emit only `$mcp_tool_call` / `$mcp_initialize`; PostHog's own hosted server additionally dual-emits legacy un-prefixed `mcp_tool_call` / `mcp_initialize` aliases through a transition shim. Match the canonical name only — an `event IN ('mcp_tool_call', '$mcp_tool_call')` would double-count PostHog's own server.
+
**HogQL is the primary path here.** Session listing, per-session tool calls, tool-level metrics (error rate, latency, adoption), harness breakdowns, time series, and co-occurrence are all just aggregations over this event — query them with `execute-sql`. The only typed tools are for things 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).
## Key properties
@@ -25,7 +27,7 @@ Any MCP server instrumented with the `@posthog/mcp` SDK — and PostHog's own MC
coalesce(nullIf(toString(properties.$mcp_exec_tool_call_name), ''), toString(properties.$mcp_tool_name))
```
-**Failures with detail.** `$mcp_tool_call` carries `$mcp_is_error` + `$mcp_error_message`; richer stack/exception data is on `$exception` events (`$exception_message`), correlated by `$session_id` and timestamp.
+**Failures with detail.** `$mcp_tool_call` carries `$mcp_is_error` + `$mcp_error_message`; richer stack/exception data is on `$exception` events (`$exception_message`), correlated by `$mcp_session_id` / `$session_id` and timestamp.
## Example queries
@@ -77,7 +79,7 @@ GROUP BY day ORDER BY day
### Harness (client) bucketing
-`$mcp_client_name` is the raw client string the MCP client sends (`claude-code/1.2.3`, `Anthropic/ClaudeAI`, `windsurf`, sometimes with a `(via mcp-remote …)` suffix). A bare `GROUP BY properties.$mcp_client_name` therefore fragments a single harness across version/variant strings. To group by harness, normalize the raw client name in an inner subquery, then bucket it with `multiIf`. This mapping mirrors `HARNESS_CATEGORIES` / `categorizeHarness()` in `products/mcp_analytics/frontend/mcpDashboardOverviewLogic.ts` — keep the two in sync 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.)
+`$mcp_client_name` is the raw client string the MCP client sends (`claude-code/1.2.3`, `Anthropic/ClaudeAI`, `windsurf`, sometimes with a `(via mcp-remote …)` suffix), but newer Anthropic clients stopped sending it — they report identity only via the `x-anthropic-client` header (`mcp_vendor_client`: `ClaudeCode`, `ClaudeAI`, `Cowork`, `ClaudeDesign`) or the User-Agent (`$mcp_client_user_agent`). Grouping on `$mcp_client_name` alone therefore drops nearly all Claude traffic into "Other". Resolve an effective client first — prefer `$mcp_client_name`, then the vendor header (matched case-insensitively), then the User-Agent's leading product token plus its first parenthetical token as a surface suffix (e.g. `claude-code cli`, `claude-code claude-desktop`, `openai-mcp chatgpt`); the version segment between them is dropped so `claude-code/2.1.x` folds to one token. Then bucket with `multiIf`, listing surface-specific tokens before the generic prefix match. Clients whose parenthetical is platform/arch noise (e.g. `cursor darwin arm64`) still fold to one bucket via the generic `startsWith`. This mapping mirrors `HARNESS_REGISTRY` / `categorizeHarness()` in `products/mcp_analytics/frontend/dashboard/harnessRegistry.ts` — keep the two in sync 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.)
**Share of users by harness** (answers "what % of my users are on Claude Code"):
@@ -93,10 +95,19 @@ FROM (
SELECT
distinct_id,
multiIf(
+ h = 'claude-code claude-desktop', 'Claude Desktop',
+ h = 'claude-code claude-vscode', 'Claude Code (VS Code)',
+ startsWith(h, 'claude-code sdk'), 'Claude Agent SDK',
startsWith(h, 'claude-code'), 'Claude Code',
- h IN ('claude-ai', 'anthropic/claudeai'), 'Claude.ai',
+ h IN ('claude-ai', 'anthropic/claudeai', 'claude-user'), 'Claude.ai',
h = 'anthropic/api', 'Anthropic API',
- startsWith(h, 'codex') OR startsWith(h, 'openai-mcp'), 'OpenAI Codex',
+ h = 'cowork', 'Cowork',
+ h = 'claude-design', 'Claude Design',
+ h = 'openai-mcp chatgpt', 'ChatGPT',
+ h = 'openai-mcp agent builder', 'OpenAI Agent Builder',
+ h = 'openai-mcp responses api', 'OpenAI Responses API',
+ startsWith(h, 'openai-mcp'), 'OpenAI',
+ startsWith(h, 'codex'), 'OpenAI Codex',
startsWith(h, 'cursor'), 'Cursor',
startsWith(h, 'visual studio code'), 'VS Code',
h = 'windsurf', 'Windsurf',
@@ -114,7 +125,24 @@ FROM (
FROM (
SELECT
distinct_id,
- lower(trim(replaceRegexpOne(toString(properties.$mcp_client_name), '\\s*\\(via mcp-remote[^)]*\\)\\s*', ''))) AS h
+ lower(trim(replaceRegexpOne(
+ coalesce(
+ nullIf(toString(properties.$mcp_client_name), ''),
+ multiIf(
+ lower(toString(properties.mcp_vendor_client)) = 'claudecode', 'claude-code',
+ lower(toString(properties.mcp_vendor_client)) = 'claudeai', 'claude-ai',
+ lower(toString(properties.mcp_vendor_client)) = 'cowork', 'cowork',
+ lower(toString(properties.mcp_vendor_client)) = 'claudedesign', 'claude-design',
+ nullIf(toString(properties.mcp_vendor_client), '')
+ ),
+ nullIf(trim(concat(
+ extract(toString(properties.$mcp_client_user_agent), '^([^/]+)'),
+ ' ',
+ extract(toString(properties.$mcp_client_user_agent), '[(]([^,)]+)')
+ )), ''),
+ ''
+ ),
+ '\\s*\\(via mcp-remote[^)]*\\)\\s*', ''))) AS h
FROM events
WHERE event = '$mcp_tool_call' AND timestamp >= now() - INTERVAL 30 DAY
)