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): resolve harness from SDK-emitted $mcp_vendor_client, simplify chain to 3 properties (#93189)

Georgis Andonisb6c6a3330564
diff --git a/frontend/src/taxonomy/core-filter-definitions-by-group.json b/frontend/src/taxonomy/core-filter-definitions-by-group.json
index 9fcc0920e95a..93bd95a553c4 100644
--- a/frontend/src/taxonomy/core-filter-definitions-by-group.json
+++ b/frontend/src/taxonomy/core-filter-definitions-by-group.json
@@ -2424,6 +2424,15 @@
],
"label": "MCP transport"
},
+ "$mcp_vendor_client": {
+ "description": "Vendor client header the MCP client sent on the transport (x-anthropic-client), captured raw. The strongest harness signal: clientInfo.name can't tell one vendor surface from another, but this header can.",
+ "examples": [
+ "ClaudeCode",
+ "ClaudeAI",
+ "Cowork"
+ ],
+ "label": "MCP vendor client"
+ },
"$mcp_version": {
"description": "Server-resolved MCP version. May differ from the version the client reported because of the mcp-version-2 feature flag.",
"examples": [
@@ -3739,12 +3748,12 @@
"label": "MCP transport (unprefixed)"
},
"mcp_vendor_client": {
- "description": "Vendor/client identity derived from the request context for the MCP call (e.g. the coding agent or app behind the request).",
+ "description": "Older unprefixed variant of $mcp_vendor_client, stamped only by PostHog's hosted MCP server. Coalesce both keys when querying vendor identity directly; the harness resolution in MCP analytics already does.",
"examples": [
"ClaudeCode",
"ClaudeAI"
],
- "label": "MCP vendor client"
+ "label": "MCP vendor client (legacy)"
},
"mcp_version": {
"description": "Older unprefixed variant of $mcp_version. Emitted on events from the pre-@posthog/mcp code paths; prefer $mcp_version for new dashboards.",
@@ -4680,6 +4689,15 @@
],
"label": "MCP transport"
},
+ "$mcp_vendor_client": {
+ "description": "Vendor client header the MCP client sent on the transport (x-anthropic-client), captured raw. The strongest harness signal: clientInfo.name can't tell one vendor surface from another, but this header can.",
+ "examples": [
+ "ClaudeCode",
+ "ClaudeAI",
+ "Cowork"
+ ],
+ "label": "MCP vendor client"
+ },
"$mcp_version": {
"description": "Server-resolved MCP version. May differ from the version the client reported because of the mcp-version-2 feature flag.",
"examples": [
@@ -7493,6 +7511,15 @@
],
"label": "MCP transport"
},
+ "$mcp_vendor_client": {
+ "description": "Vendor client header the MCP client sent on the transport (x-anthropic-client), captured raw. The strongest harness signal: clientInfo.name can't tell one vendor surface from another, but this header can.",
+ "examples": [
+ "ClaudeCode",
+ "ClaudeAI",
+ "Cowork"
+ ],
+ "label": "MCP vendor client"
+ },
"$mcp_version": {
"description": "Server-resolved MCP version. May differ from the version the client reported because of the mcp-version-2 feature flag.",
"examples": [
@@ -8803,12 +8830,12 @@
"label": "MCP transport (unprefixed)"
},
"mcp_vendor_client": {
- "description": "Vendor/client identity derived from the request context for the MCP call (e.g. the coding agent or app behind the request).",
+ "description": "Older unprefixed variant of $mcp_vendor_client, stamped only by PostHog's hosted MCP server. Coalesce both keys when querying vendor identity directly; the harness resolution in MCP analytics already does.",
"examples": [
"ClaudeCode",
"ClaudeAI"
],
- "label": "MCP vendor client"
+ "label": "MCP vendor client (legacy)"
},
"mcp_version": {
"description": "Older unprefixed variant of $mcp_version. Emitted on events from the pre-@posthog/mcp code paths; prefer $mcp_version for new dashboards.",
diff --git a/posthog/taxonomy/taxonomy.py b/posthog/taxonomy/taxonomy.py
index e16c9b109c9a..d44a14c3b43e 100644
--- a/posthog/taxonomy/taxonomy.py
+++ b/posthog/taxonomy/taxonomy.py
@@ -2888,6 +2888,11 @@ CORE_FILTER_DEFINITIONS_BY_GROUP: dict[str, dict[str, CoreFilterDefinition]] = {
"description": "Full User-Agent string the MCP client sent on the transport. Often includes the agent name, version, and runtime mode — useful when $mcp_client_name and $mcp_client_version alone don't disambiguate the caller.",
"examples": ["claude-code/2.1.141 (cli)", "Anthropic/ClaudeAI"],
},
+ "$mcp_vendor_client": {
+ "label": "MCP vendor client",
+ "description": "Vendor client header the MCP client sent on the transport (x-anthropic-client), captured raw. The strongest harness signal: clientInfo.name can't tell one vendor surface from another, but this header can.",
+ "examples": ["ClaudeCode", "ClaudeAI", "Cowork"],
+ },
"$mcp_intent": {
"label": "MCP intent",
"description": "Free-text description of why the agent is calling this tool, written by the agent itself. Comes from a context argument the client supplied at call time, or — if none was supplied — from an intentFallback the MCP server provides.",
@@ -3099,8 +3104,8 @@ CORE_FILTER_DEFINITIONS_BY_GROUP: dict[str, dict[str, CoreFilterDefinition]] = {
"examples": ["hono"],
},
"mcp_vendor_client": {
- "label": "MCP vendor client",
- "description": "Vendor/client identity derived from the request context for the MCP call (e.g. the coding agent or app behind the request).",
+ "label": "MCP vendor client (legacy)",
+ "description": "Older unprefixed variant of $mcp_vendor_client, stamped only by PostHog's hosted MCP server. Coalesce both keys when querying vendor identity directly; the harness resolution in MCP analytics already does.",
"examples": ["ClaudeCode", "ClaudeAI"],
},
"mcp_session_client_name": {
diff --git a/products/mcp_analytics/backend/mcp_harness.py b/products/mcp_analytics/backend/mcp_harness.py
index 414ed9f8d837..96cb31ba24c3 100644
--- a/products/mcp_analytics/backend/mcp_harness.py
+++ b/products/mcp_analytics/backend/mcp_harness.py
@@ -5,13 +5,13 @@ A "harness" is the friendly product label for the MCP client that made a call
self-reported identity signals; resolving them to a label is a two-step,
query-time computation:
- 1. Resolve a normalized token from the strongest available signal (the
- x-anthropic-client vendor header, then Claude Code's User-Agent surface,
- then the Grok User-Agent surface,
- then the clientInfo.name — `$mcp_client_name` as reported by the posthog-node
- MCP analytics SDK, or `mcp_session_client_name` as reported by PostHog's hosted
- MCP server — then the User-Agent product token, then the OAuth client name) —
- `HARNESS_TOKEN_SQL`.
+ 1. Resolve a normalized token from the strongest available signal, over exactly
+ three properties — the ones the `@posthog/mcp` / `posthog.mcp` SDK schemas can
+ emit: the x-anthropic-client vendor header (`$mcp_vendor_client`, with the
+ legacy server-stamped `mcp_vendor_client` as a fallback for historical rows),
+ then Claude Code's User-Agent surface, then the Grok User-Agent surface, then
+ the clientInfo.name (`$mcp_client_name`), then the generic User-Agent product
+ token (`$mcp_client_user_agent`) — `HARNESS_TOKEN_SQL`.
2. Bucket that token into a customer label — `harness_label_sql` when the result must
stay inside `HARNESS_LABELS`, or `harness_label_or_token_sql` when an unrecognized
client is better named by its own self-report than collapsed into "Other".
@@ -43,13 +43,26 @@ _UA_PRODUCT = "extract(toString(properties.$mcp_client_user_agent), '^([^/]+)')"
# (step 2, to keep the CLI/SDK/IDE split) and as the generic fallback (step 4).
_UA_TOKEN = f"trim(concat({_UA_PRODUCT}, ' ', extract(toString(properties.$mcp_client_user_agent), '[(]([^,)]+)')))"
-# The ordered resolution steps, mirroring HARNESS_ROWS_QUERY in the frontend.
+# The x-anthropic-client vendor header, coalesced across both wire keys it is
+# captured under: `$mcp_vendor_client` (the SDK name) and the unprefixed
+# `mcp_vendor_client` (PostHog's own server). The unprefixed arm is load-bearing,
+# not cosmetic: rows carrying only it often self-report a wrong clientInfo.name
+# (Claude Code as "Anthropic/ClaudeAI"), so without it they misattribute.
+_VENDOR = (
+ "lower(coalesce(nullIf(toString(properties.$mcp_vendor_client), ''),"
+ " nullIf(toString(properties.mcp_vendor_client), '')))"
+)
+
+# The ordered resolution steps: vendor header, then the two User-Agent surfaces
+# that outrank clientInfo.name, then clientInfo.name, then the generic UA token.
_RAW_TOKEN = f"""coalesce(
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',
+ -- The header is captured verbatim and its value arrives in both spellings
+ -- ('ClaudeCode' and 'claude-code'), so each vendor matches both.
+ {_VENDOR} IN ('claudecode', 'claude-code'), 'claude-code',
+ {_VENDOR} IN ('claudeai', 'claude-ai'), 'claude-ai',
+ {_VENDOR} = 'cowork', 'cowork',
+ {_VENDOR} IN ('claudedesign', 'claude-design'), 'claude-design',
NULL
),
if(lower({_UA_PRODUCT}) = 'claude-code', {_UA_TOKEN}, NULL),
@@ -60,9 +73,7 @@ _RAW_TOKEN = f"""coalesce(
-- clientInfo.name and buckets to Grok without help.)
if(startsWith(lower({_UA_PRODUCT}), 'grok'), {_UA_TOKEN}, NULL),
nullIf(nullIf(toString(properties.$mcp_client_name), ''), 'mcp'),
- nullIf(nullIf(toString(properties.mcp_session_client_name), ''), 'mcp'),
nullIf({_UA_TOKEN}, ''),
- nullIf(toString(properties.$mcp_oauth_client_name), ''),
''
)"""
diff --git a/products/mcp_analytics/backend/tests/test_api.py b/products/mcp_analytics/backend/tests/test_api.py
index d07e5fccd8c1..9099b8e9b1c3 100644
--- a/products/mcp_analytics/backend/tests/test_api.py
+++ b/products/mcp_analytics/backend/tests/test_api.py
@@ -723,10 +723,10 @@ class TestActivityOverview(_MCPAnalyticsTeamScopedTestMixin, ClickhouseTestMixin
assert overview.clients == [contracts.ActivityClientRow(client="Claude Code", calls=6)]
def test_counts_one_client_reached_by_two_identity_signals_once(self) -> None:
- # Codex arrives both as a session-pinned clientInfo name and as a user-agent
- # surface. Those are two different tokens but one client, so counting tokens
+ # Codex arrives both as a clientInfo name and as a user-agent surface.
+ # Those are two different tokens but one client, so counting tokens
# would report "2 clients" next to a Clients card showing a single row.
- self._emit_call({"mcp_session_client_name": "codex-mcp-client"}, count=3)
+ self._emit_call({"$mcp_client_name": "codex-mcp-client"}, count=3)
self._emit_call({"$mcp_client_user_agent": "openai-mcp/1.0.0 (Codex)"}, count=2)
overview = api.get_activity_overview(self.team)
@@ -736,26 +736,34 @@ class TestActivityOverview(_MCPAnalyticsTeamScopedTestMixin, ClickhouseTestMixin
@parameterized.expand(
[
- # `$mcp_client_name` rides on `initialize` only, so a mid-session tool call
- # carries the session-pinned name instead. Reading the raw property alone left
- # every one of these unattributed.
- ("session_pinned_name", {"mcp_session_client_name": "codex-mcp-client"}, "OpenAI Codex"),
+ ("client_name", {"$mcp_client_name": "codex-mcp-client"}, "OpenAI Codex"),
# Codex's other spelling: the User-Agent surface. The generic `openai-mcp`
# prefix used to swallow this and report it as plain "OpenAI".
("codex_user_agent_surface", {"$mcp_client_user_agent": "openai-mcp/1.0 (Codex)"}, "OpenAI Codex"),
- ("vendor_header", {"mcp_vendor_client": "ClaudeCode"}, "Claude Code"),
- ("oauth_client_name", {"$mcp_oauth_client_name": "cursor-vscode"}, "Cursor"),
+ # The vendor header resolves from both wire keys it is captured under:
+ # $mcp_vendor_client (SDKs) and the unprefixed mcp_vendor_client
+ # (PostHog's own server).
+ ("sdk_vendor_header", {"$mcp_vendor_client": "ClaudeCode"}, "Claude Code"),
+ ("legacy_vendor_header", {"mcp_vendor_client": "ClaudeCode"}, "Claude Code"),
# An unrecognized client is still named — its own self-report beats "Other".
("unrecognized_named_verbatim", {"$mcp_client_name": "openclaw-bundle-mcp"}, "openclaw-bundle-mcp"),
# ...and keeps its own capitalization: matching lower-cases the token, but the
# name shown back is the one the client reported.
("unrecognized_keeps_casing", {"$mcp_client_name": "NexusAgent"}, "NexusAgent"),
+ ("no_identity_at_all", {}, mcp_harness.UNIDENTIFIED_HARNESS_LABEL),
+ # Not resolution signals: the SDKs never emit these properties and the
+ # server folds the session-pinned name into per-event $mcp_client_name,
+ # so on their own they attribute nothing.
(
- "unrecognized_keeps_casing_via_session",
- {"mcp_session_client_name": "Concept Connectors"},
- "Concept Connectors",
+ "session_name_no_longer_read",
+ {"mcp_session_client_name": "codex-mcp-client"},
+ mcp_harness.UNIDENTIFIED_HARNESS_LABEL,
+ ),
+ (
+ "oauth_name_no_longer_read",
+ {"$mcp_oauth_client_name": "cursor-vscode"},
+ mcp_harness.UNIDENTIFIED_HARNESS_LABEL,
),
- ("no_identity_at_all", {}, mcp_harness.UNIDENTIFIED_HARNESS_LABEL),
]
)
def test_attributes_clients_from_every_identity_signal(
diff --git a/products/mcp_analytics/backend/tests/test_harness_breakdown.py b/products/mcp_analytics/backend/tests/test_harness_breakdown.py
index 7c94f22daf5e..d526763b4cc3 100644
--- a/products/mcp_analytics/backend/tests/test_harness_breakdown.py
+++ b/products/mcp_analytics/backend/tests/test_harness_breakdown.py
@@ -117,12 +117,21 @@ class TestMCPHarnessBreakdownQueryRunner(_MCPAnalyticsTeamScopedTestMixin, Click
@parameterized.expand(
[
- ("vendor_cowork", {"mcp_vendor_client": "Cowork"}, "Cowork"),
- ("vendor_claudecode", {"mcp_vendor_client": "ClaudeCode"}, "Claude Code"),
- ("session_codex", {"mcp_session_client_name": "codex-mcp-client"}, "OpenAI Codex"),
- ("session_cursor", {"mcp_session_client_name": "cursor-vscode"}, "Cursor"),
- # The posthog-node MCP analytics SDK reports clientInfo.name as $mcp_client_name,
- # not the hosted server's mcp_session_client_name. Both must classify.
+ # The vendor header resolves from both wire keys it is captured under
+ # ($mcp_vendor_client from the SDKs, unprefixed mcp_vendor_client from
+ # PostHog's own server) and in both value spellings.
+ ("sdk_vendor_cowork", {"$mcp_vendor_client": "Cowork"}, "Cowork"),
+ ("sdk_vendor_claudecode", {"$mcp_vendor_client": "ClaudeCode"}, "Claude Code"),
+ ("sdk_vendor_hyphenated", {"$mcp_vendor_client": "claude-code"}, "Claude Code"),
+ ("legacy_vendor_cowork", {"mcp_vendor_client": "Cowork"}, "Cowork"),
+ ("legacy_vendor_claudecode", {"mcp_vendor_client": "ClaudeCode"}, "Claude Code"),
+ (
+ "sdk_vendor_wins_over_legacy",
+ {"$mcp_vendor_client": "Cowork", "mcp_vendor_client": "ClaudeCode"},
+ "Cowork",
+ ),
+ ("client_name_codex", {"$mcp_client_name": "codex-mcp-client"}, "OpenAI Codex"),
+ ("client_name_cursor", {"$mcp_client_name": "cursor-vscode"}, "Cursor"),
("sdk_client_name_claudeai", {"$mcp_client_name": "claude-ai"}, "Claude.ai"),
(
"sdk_client_name_mcp_remote_stripped",
@@ -159,14 +168,19 @@ class TestMCPHarnessBreakdownQueryRunner(_MCPAnalyticsTeamScopedTestMixin, Click
),
# xAI API surface: no grok UA, buckets via its grok- clientInfo.name.
("grok_shell_client_name", {"$mcp_client_name": "grok-shell-posthog"}, "Grok"),
- ("session_librechat", {"mcp_session_client_name": "@librechat/api-client"}, "LibreChat"),
+ ("client_name_librechat", {"$mcp_client_name": "@librechat/api-client"}, "LibreChat"),
(
"mcp_remote_suffix_stripped",
- {"mcp_session_client_name": "codex-mcp-client (via mcp-remote 0.1.37)"},
+ {"$mcp_client_name": "codex-mcp-client (via mcp-remote 0.1.37)"},
"OpenAI Codex",
),
- ("oauth_fallback", {"$mcp_oauth_client_name": "lovable"}, "Lovable"),
- ("unknown_to_other", {"mcp_session_client_name": "totally-unknown-thing"}, "Other"),
+ ("client_name_lovable", {"$mcp_client_name": "lovable"}, "Lovable"),
+ ("unknown_to_other", {"$mcp_client_name": "totally-unknown-thing"}, "Other"),
+ # Not resolution signals: the SDKs never emit these properties and the
+ # server folds the session-pinned name into per-event $mcp_client_name,
+ # so on their own they attribute nothing.
+ ("session_name_no_longer_read", {"mcp_session_client_name": "codex-mcp-client"}, "Other"),
+ ("oauth_name_no_longer_read", {"$mcp_oauth_client_name": "lovable"}, "Other"),
]
)
def test_resolves_harness_label(self, _name: str, properties: dict[str, Any], expected: str) -> None:
@@ -178,10 +192,11 @@ class TestMCPHarnessBreakdownQueryRunner(_MCPAnalyticsTeamScopedTestMixin, Click
assert expected in by_harness, f"expected {expected!r}, got {sorted(by_harness)}"
assert by_harness[expected].total_calls == 1
- def test_vendor_header_wins_over_generic_session_name(self) -> None:
+ def test_vendor_header_wins_over_generic_client_name(self) -> None:
# Anthropic's pooled surfaces self-report the generic "Anthropic/ClaudeAI"
- # session name; the vendor header is what separates Cowork from Claude.ai.
- self._emit(properties={"mcp_vendor_client": "Cowork", "mcp_session_client_name": "Anthropic/ClaudeAI"})
+ # clientInfo.name; the vendor header is what separates Cowork from Claude.ai —
+ # including when it arrives under the unprefixed wire key.
+ self._emit(properties={"mcp_vendor_client": "Cowork", "$mcp_client_name": "Anthropic/ClaudeAI"})
flush_persons_and_events()
by_harness = self._breakdown()
@@ -190,9 +205,9 @@ class TestMCPHarnessBreakdownQueryRunner(_MCPAnalyticsTeamScopedTestMixin, Click
assert "Claude.ai" not in by_harness
def test_aggregates_calls_errors_and_sessions(self) -> None:
- self._emit(properties={"mcp_session_client_name": "codex-mcp-client"}, session_id="a", is_error=False)
- self._emit(properties={"mcp_session_client_name": "codex-mcp-client"}, session_id="a", is_error=True)
- self._emit(properties={"mcp_session_client_name": "codex-mcp-client"}, session_id="b", is_error=False)
+ self._emit(properties={"$mcp_client_name": "codex-mcp-client"}, session_id="a", is_error=False)
+ self._emit(properties={"$mcp_client_name": "codex-mcp-client"}, session_id="a", is_error=True)
+ self._emit(properties={"$mcp_client_name": "codex-mcp-client"}, session_id="b", is_error=False)
flush_persons_and_events()
row = self._breakdown()["OpenAI Codex"]
@@ -204,8 +219,8 @@ class TestMCPHarnessBreakdownQueryRunner(_MCPAnalyticsTeamScopedTestMixin, Click
def test_date_range_excludes_older_events(self) -> None:
now = datetime.now(tz=UTC)
- self._emit(properties={"mcp_session_client_name": "codex-mcp-client"}, timestamp=now - timedelta(days=30))
- self._emit(properties={"mcp_session_client_name": "cursor-vscode"}, timestamp=now)
+ self._emit(properties={"$mcp_client_name": "codex-mcp-client"}, timestamp=now - timedelta(days=30))
+ self._emit(properties={"$mcp_client_name": "cursor-vscode"}, timestamp=now)
flush_persons_and_events()
by_harness = self._breakdown(date_from="-7d")
@@ -216,8 +231,8 @@ class TestMCPHarnessBreakdownQueryRunner(_MCPAnalyticsTeamScopedTestMixin, Click
def test_property_filter_applies(self) -> None:
# properties is the only user-supplied input reaching the WHERE clause;
# confirm it actually filters (via property_to_expr), not just passes through.
- self._emit(properties={"mcp_session_client_name": "codex-mcp-client", "$mcp_tool_name": "query_run"})
- self._emit(properties={"mcp_session_client_name": "cursor-vscode", "$mcp_tool_name": "insight_get"})
+ self._emit(properties={"$mcp_client_name": "codex-mcp-client", "$mcp_tool_name": "query_run"})
+ self._emit(properties={"$mcp_client_name": "cursor-vscode", "$mcp_tool_name": "insight_get"})
flush_persons_and_events()
runner = MCPHarnessBreakdownQueryRunner(
diff --git a/products/mcp_analytics/skills/debugging-mcp-analytics/SKILL.md b/products/mcp_analytics/skills/debugging-mcp-analytics/SKILL.md
index a8e9739d574d..dacc80108dc5 100644
--- a/products/mcp_analytics/skills/debugging-mcp-analytics/SKILL.md
+++ b/products/mcp_analytics/skills/debugging-mcp-analytics/SKILL.md
@@ -167,18 +167,22 @@ tools. They are declared in `products/mcp_analytics/mcp/tools.yaml`.
**Harness** is the friendly label for the calling client (Claude Code, Cursor, ChatGPT,
Windsurf, and ~30 other buckets). It is resolved at query time only, with no stored column:
-`mcp_harness.py::HARNESS_TOKEN_SQL` picks the strongest available signal in priority order
-(`mcp_vendor_client` -> Claude Code user-agent surface -> Grok user-agent -> `$mcp_client_name`
--> `mcp_session_client_name` -> generic user-agent token -> `$mcp_oauth_client_name`), then
+`mcp_harness.py::HARNESS_TOKEN_SQL` picks the strongest available signal in priority order,
+over exactly three properties — the ones the SDK schemas can emit
+(`$mcp_vendor_client`, with the legacy non-`$` `mcp_vendor_client` coalesced for historical
+rows -> Claude Code user-agent surface -> Grok user-agent -> `$mcp_client_name` -> generic
+user-agent token, both from `$mcp_client_user_agent`), then
`harness_label_sql()` buckets it (or `harness_label_or_token_sql()`, which names an
unrecognized client verbatim instead of collapsing it into "Other" — use it for ranked
top-N lists, never where labels feed an array or unbounded GROUP BY).
**`$mcp_client_name` is one mid-priority input, not a synonym for harness** — grouping by
-it directly gives a different, messier answer. It rides on the session's `initialize` and
-is absent from the tool calls that follow, so on its own it leaves most traffic
-unattributed; `mcp_session_client_name` is the session-pinned fallback the token chain
-reaches for next.
+it directly gives a different, messier answer: on old SDK versions it rode only on the
+session's `initialize`, and Anthropic's pooled surfaces self-report a generic
+`Anthropic/ClaudeAI` that only the vendor header can disambiguate. The dogfood-only
+`mcp_session_client_name` and `$mcp_oauth_client_name` are **no longer read** by harness
+resolution — the server folds the session-pinned name into per-event `$mcp_client_name`,
+and neither property ever resolved an event alone.
For hand-written SQL, [`models-mcp.md`](../../../posthog_ai/skills/querying-posthog-data/references/models-mcp.md)
carries the property reference and worked query examples.
@@ -325,10 +329,9 @@ query runners, the demo seeder, and exec-mode inner-tool breakout (Hard rule 1).
What still lags, all checkable in this repo: the `services/mcp` alias pin is `0.10.2` against a
0.11.7 SDK (Hard rule 5 — no 0.11.x SDK-side fix or SDK-emitted property reaches dogfood data,
-though the server independently stamps `$mcp_client_user_agent` and the non-`$`
-`mcp_vendor_client` regardless of the pin);
-harness resolution does not read the SDK-emitted `$mcp_vendor_client` yet (`HARNESS_TOKEN_SQL`
-consumes `$mcp_client_user_agent`, but its top-priority vendor signal is still the
-server-stamped non-`$` `mcp_vendor_client`); the exec-property emitter is still absent from
+though the server independently stamps `$mcp_client_user_agent` and the legacy non-`$`
+`mcp_vendor_client` regardless of the pin; harness resolution reads the SDK-emitted
+`$mcp_vendor_client` first and coalesces the legacy name for those rows);
+the exec-property emitter is still absent from
master (Hard rule 1); the clustering schedule still covers only `GUARANTEED_TEAM_IDS = [2]`;
and the product remains behind the `mcp-analytics` flag, so a project without it sees nothing.
diff --git a/products/mcp_analytics/skills/debugging-mcp-analytics/references/event-vocabulary.md b/products/mcp_analytics/skills/debugging-mcp-analytics/references/event-vocabulary.md
index 5fe69fc2535f..4e684409112c 100644
--- a/products/mcp_analytics/skills/debugging-mcp-analytics/references/event-vocabulary.md
+++ b/products/mcp_analytics/skills/debugging-mcp-analytics/references/event-vocabulary.md
@@ -32,28 +32,28 @@ name it is given rather than `$mcp_custom`.
On `$mcp_tool_call` unless noted. These are the properties any instrumented server produces.
-| Property | Notes |
-| ----------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
-| `$mcp_tool_name` | The tool the agent called. In single-exec mode this holds the resolved inner tool, or the literal `exec` when unrecognized — see exec-mode below. |
-| `$mcp_tool_description` | The description the agent saw. In single-exec mode this is the dispatcher's static text on every call. |
-| `$mcp_tool_category` | Server-assigned grouping. Used by the Signals scout to group problem tools. |
-| `$mcp_intent` | Why the agent made the call — the product's differentiator. Populated from the injected `context` argument, or a configured fallback. |
-| `$mcp_intent_source` | `context_parameter` or `inferred`. Tells you whether the agent actually filled the context argument. |
-| `$mcp_is_error` | Boolean failure flag. **The canonical failure signal.** |
-| `$mcp_duration_ms` | Call latency. Cast before aggregating: `quantile(0.95)(toFloat(properties.$mcp_duration_ms))`. |
-| `$mcp_parameters` | Captured arguments, sanitized. |
-| `$mcp_response` | Captured response, sanitized. May be empty by configuration. |
-| `$mcp_listed_tool_names` | On `$mcp_tools_list`. JSON array of advertised tools. Diff against called tool names for zombie tools. In single-exec mode `$mcp_exec_inner_tool_names` is the intended catalog field, but is unemitted today — see exec-mode below. |
-| `$mcp_error_type` | Since TS 0.8.0. Low-cardinality label — `validation`, `permission`, `timeout`, `rate_limited`, etc. Defaults to the thrown error's type; hosts can pass an explicit label. |
-| `$mcp_error_message` | Since TS 0.8.0. Redacted automatically as of TS 0.10.2. |
-| `$mcp_client_name` / `$mcp_client_version` | The calling client as _it_ reported itself. One mid-priority input to harness resolution — not the harness label. |
-| `$mcp_client_user_agent` / `$mcp_vendor_client` | Since TS 0.11.0 / Python 7.42.0. The raw `User-Agent` and vendor header (e.g. `x-anthropic-client`) — `clientInfo.name` can't tell one vendor surface from another (`claude-code` is the CLI, the Agent SDK, the VS Code extension, and the desktop app alike). HTTP transports only; stdio and in-memory servers carry no headers. Captured raw and resolved to labels at query time. `HARNESS_TOKEN_SQL` reads `$mcp_client_user_agent`, but **not** `$mcp_vendor_client` yet — its vendor signal is still the server-stamped non-`$` `mcp_vendor_client`. |
-| `$mcp_server_name` / `$mcp_server_version` | The instrumented server's own identity. |
-| `$mcp_protocol_version` | Since TS 0.10.0. The negotiated MCP spec version. On legacy `initialize`-handshake sessions it is stamped on `$mcp_initialize` and every subsequent event of that session; under the 2026-07-28 revision it is **per request**, so one `$session_id` can legitimately span more than one value — don't treat it as a session constant. See [stateless-and-sessions.md](stateless-and-sessions.md). |
-| `$mcp_conversation_id` | The conversation handle: **server-minted on the first call, agent-echoed thereafter** (an invented value is rejected and replaced). **Survives reconnects, but only when the server sets `enableConversationId`** (off by default) — see identifiers below and [stateless-and-sessions.md](stateless-and-sessions.md). |
-| `$mcp_resource_name` | On resource events. |
-| `$session_id` | The standard PostHog session id, materialized. The usual grouping key. |
-| `$mcp_source` | Always `posthog_mcp_analytics`. The reliable way to isolate MCP events from everything else on the `events` table. |
+| Property | Notes |
+| ----------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
+| `$mcp_tool_name` | The tool the agent called. In single-exec mode this holds the resolved inner tool, or the literal `exec` when unrecognized — see exec-mode below. |
+| `$mcp_tool_description` | The description the agent saw. In single-exec mode this is the dispatcher's static text on every call. |
+| `$mcp_tool_category` | Server-assigned grouping. Used by the Signals scout to group problem tools. |
+| `$mcp_intent` | Why the agent made the call — the product's differentiator. Populated from the injected `context` argument, or a configured fallback. |
+| `$mcp_intent_source` | `context_parameter` or `inferred`. Tells you whether the agent actually filled the context argument. |
+| `$mcp_is_error` | Boolean failure flag. **The canonical failure signal.** |
+| `$mcp_duration_ms` | Call latency. Cast before aggregating: `quantile(0.95)(toFloat(properties.$mcp_duration_ms))`. |
+| `$mcp_parameters` | Captured arguments, sanitized. |
+| `$mcp_response` | Captured response, sanitized. May be empty by configuration. |
+| `$mcp_listed_tool_names` | On `$mcp_tools_list`. JSON array of advertised tools. Diff against called tool names for zombie tools. In single-exec mode `$mcp_exec_inner_tool_names` is the intended catalog field, but is unemitted today — see exec-mode below. |
+| `$mcp_error_type` | Since TS 0.8.0. Low-cardinality label — `validation`, `permission`, `timeout`, `rate_limited`, etc. Defaults to the thrown error's type; hosts can pass an explicit label. |
+| `$mcp_error_message` | Since TS 0.8.0. Redacted automatically as of TS 0.10.2. |
+| `$mcp_client_name` / `$mcp_client_version` | The calling client as _it_ reported itself. One mid-priority input to harness resolution — not the harness label. |
+| `$mcp_client_user_agent` / `$mcp_vendor_client` | Since TS 0.11.0 / Python 7.42.0. The raw `User-Agent` and vendor header (e.g. `x-anthropic-client`) — `clientInfo.name` can't tell one vendor surface from another (`claude-code` is the CLI, the Agent SDK, the VS Code extension, and the desktop app alike). HTTP transports only; stdio and in-memory servers carry no headers. Captured raw and resolved to labels at query time. Together with `$mcp_client_name` these are the **only** properties `HARNESS_TOKEN_SQL` reads — `$mcp_vendor_client` is its top-priority signal (the legacy server-stamped non-`$` `mcp_vendor_client` is coalesced behind it for historical rows). |
+| `$mcp_server_name` / `$mcp_server_version` | The instrumented server's own identity. |
+| `$mcp_protocol_version` | Since TS 0.10.0. The negotiated MCP spec version. On legacy `initialize`-handshake sessions it is stamped on `$mcp_initialize` and every subsequent event of that session; under the 2026-07-28 revision it is **per request**, so one `$session_id` can legitimately span more than one value — don't treat it as a session constant. See [stateless-and-sessions.md](stateless-and-sessions.md). |
+| `$mcp_conversation_id` | The conversation handle: **server-minted on the first call, agent-echoed thereafter** (an invented value is rejected and replaced). **Survives reconnects, but only when the server sets `enableConversationId`** (off by default) — see identifiers below and [stateless-and-sessions.md](stateless-and-sessions.md). |
+| `$mcp_resource_name` | On resource events. |
+| `$session_id` | The standard PostHog session id, materialized. The usual grouping key. |
+| `$mcp_source` | Always `posthog_mcp_analytics`. The reliable way to isolate MCP events from everything else on the `events` table. |
## Server-stamped properties
@@ -68,8 +68,8 @@ TS 0.11.0 / Python 7.42.0), `$mcp_transport`, `$mcp_auth_method`,
`scout`, `research`, `implementation`, `sandbox` for any other server-minted run, or `user` for a person's own token; `research` and `implementation` need the scratchpad scopes and do not occur yet),
`$mcp_organization_id`, `$mcp_project_id`, `$mcp_project_uuid`, `$mcp_project_name`,
`$ai_product` (`mcp`), and the non-`$`-prefixed `mcp_runtime` (`hono`) and
-`mcp_vendor_client` — the last of which is the **top-priority harness signal**, so it
-appears inside harness SQL.
+`mcp_vendor_client` — the last of which is the **legacy spelling of `$mcp_vendor_client`**,
+still coalesced behind it in harness SQL so historical rows keep resolving.
`$mcp_auth_method` (`oauth`, `personal_api_key`, `id_jag`, `none`, `unknown`) comes from the
bearer token's prefix. It is the only way to tell an OAuth connector apart from an API-key
diff --git a/products/mcp_analytics/skills/exploring-mcp-tool-original-user-motive/SKILL.md b/products/mcp_analytics/skills/exploring-mcp-tool-original-user-motive/SKILL.md
index 324b15e466af..847269b74383 100644
--- a/products/mcp_analytics/skills/exploring-mcp-tool-original-user-motive/SKILL.md
+++ b/products/mcp_analytics/skills/exploring-mcp-tool-original-user-motive/SKILL.md
@@ -90,7 +90,7 @@ sess AS (
max(if(toString(person.properties.email) ILIKE '%@posthog.com', 1, 0)) AS is_staff,
coalesce(nullIf(any(toString(properties.$mcp_consumer)), ''), '') AS consumer,
coalesce(nullIf(any(toString(properties.$mcp_client_name)), ''), '') AS client,
- coalesce(nullIf(any(toString(properties.mcp_vendor_client)), ''), '') AS vendor,
+ coalesce(nullIf(any(toString(properties.$mcp_vendor_client)), ''), nullIf(any(toString(properties.mcp_vendor_client)), ''), '') AS vendor,
coalesce(
nullIf(any(toString(properties.$mcp_organization_id)), ''),
nullIf(any(toString(properties.organization_id)), ''),
@@ -124,15 +124,18 @@ SELECT
-- Caller and org are client-controlled and end up transcribed into Python
-- source, so they are constrained here rather than trusted later. The
-- charset excludes quotes, backslashes, newlines and the pipe delimiter.
+ -- The vendor outranks the client name: Anthropic's pooled surfaces all
+ -- report the generic "Anthropic/ClaudeAI" client name, and only the vendor
+ -- header separates Claude Code from Cowork from Claude.ai.
if(match(multiIf(
o.consumer != '', concat('consumer:', o.consumer),
- o.client != '', o.client,
o.vendor != '', o.vendor,
+ o.client != '', o.client,
'unattributed'), '^[A-Za-z0-9 ()._:/-]{1,60}$'),
multiIf(
o.consumer != '', concat('consumer:', o.consumer),
- o.client != '', o.client,
o.vendor != '', o.vendor,
+ o.client != '', o.client,
'unattributed'),
'unsafe-caller-value') AS caller,
if(match(o.org, '^[0-9a-fA-F-]{1,40}$'), o.org, 'unsafe-org-value') AS org,
@@ -164,7 +167,7 @@ Names are what makes the output actionable, though — nobody follows up with `0
Session ids have no readable equivalent and should not get one. They are transport handles, and the useful upgrade is a trace link (see "Linking an intention to real sessions"), not a label.
-**Never paste a telemetry value into Python or SQL source without constraining it first.** `$mcp_client_name`, `$mcp_consumer` and `mcp_vendor_client` are set by the calling client, so a customer chooses their contents. Those values end up transcribed into a `DATA = '''...'''` literal that the notebook kernel executes, and a value carrying a triple quote closes the literal and runs whatever follows. A pipe would corrupt the parse more quietly.
+**Never paste a telemetry value into Python or SQL source without constraining it first.** `$mcp_client_name`, `$mcp_consumer` and `$mcp_vendor_client` / `mcp_vendor_client` are set by the calling client, so a customer chooses their contents. Those values end up transcribed into a `DATA = '''...'''` literal that the notebook kernel executes, and a value carrying a triple quote closes the literal and runs whatever follows. A pipe would corrupt the parse more quietly.
Measured over 30 days, the pattern above accepts 16,424,323 caller values and rejects 3, so it costs no real data. No live value carries a quote, backslash, newline or pipe today — the hole is latent, and the query closes it by construction rather than relying on anyone noticing. The rejections were all over-length, and inspecting them is what the fallback is for: this field has carried a pasted credential, which is precisely the kind of value that must never reach a shareable notebook. Do not widen the pattern to preserve an odd-looking caller. Rendering it as `unsafe-caller-value` is the correct outcome.
@@ -209,12 +212,12 @@ Report both shares — the automated one is a real finding, not noise to hide.
Caller identity is spread across four properties, and you have to check all of them, in this order:
-| Property | Identifies | Example values |
-| ------------------------ | ---------------------- | ------------------------------------------------------------------------- |
-| `$mcp_client_user_agent` | PostHog's own programs | `posthog/wizard; version: 2.45.0; program: nextjs` |
-| `$mcp_consumer` | the upstream surface | `posthog-code` (Desktop), `slack`, `plugin`, `posthog-cli` |
-| `$mcp_client_name` | the calling agent | `claude-code`, `cowork`, `claude-ai`, `cursor-vscode`, `codex-mcp-client` |
-| `mcp_vendor_client` | vendor identity | `ClaudeCode`, `Cowork`, `ClaudeAI` |
+| Property | Identifies | Example values |
+| ------------------------ | ---------------------- | ------------------------------------------------------------------------------------------------ |
+| `$mcp_client_user_agent` | PostHog's own programs | `posthog/wizard; version: 2.45.0; program: nextjs` |
+| `$mcp_consumer` | the upstream surface | `posthog-code` (Desktop), `slack`, `plugin`, `posthog-cli` |
+| `$mcp_vendor_client` | vendor identity | `ClaudeCode`, `Cowork`, `ClaudeAI` (coalesce the legacy `mcp_vendor_client` for historical rows) |
+| `$mcp_client_name` | the calling agent | `claude-code`, `cowork`, `claude-ai`, `cursor-vscode`, `codex-mcp-client` |
**Checking only `$mcp_client_name` will mislead you.** The setup wizard sets none of client, consumer, or vendor — it identifies itself solely in the user agent. Group by client alone and every wizard session collapses into an `unknown` bucket that looks like missing instrumentation — on a wizard-heavy tool that bucket is the largest row in the table.
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 cab35c121d00..ffe911e04fd5 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
@@ -68,7 +68,7 @@ And two tools cover what SQL can't express at all: `posthog:mcp-analytics-intent
| `$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`), plus `$mcp_auth_method` (which credential the request authenticated with, from the bearer token's prefix: `oauth`, `personal_api_key`, `id_jag`, `none`, `unknown`), plus `$mcp_scope_preset` (which kind of caller minted the token, worked out from its scope set: `scout`, `research`, `implementation`, `sandbox` for any other server-minted run, or `user` for a person's own token; `research` and `implementation` need the scratchpad scopes and do not occur yet).
+**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 legacy `mcp_vendor_client` (older variant of `$mcp_vendor_client`, the `x-anthropic-client` vendor header, e.g. `ClaudeCode`/`ClaudeAI` — still coalesced when resolving the harness for historical rows) and `mcp_runtime` (server runtime, e.g. `hono`), plus `$mcp_auth_method` (which credential the request authenticated with, from the bearer token's prefix: `oauth`, `personal_api_key`, `id_jag`, `none`, `unknown`), plus `$mcp_scope_preset` (which kind of caller minted the token, worked out from its scope set: `scout`, `research`, `implementation`, `sandbox` for any other server-minted run, or `user` for a person's own token; `research` and `implementation` need the scratchpad scopes and do not occur yet).
**Refused requests are a separate event.** A request the PostHog API rejects dies before any session, organization, or project is resolved, so it emits none of the events above — it emits `$mcp_auth_failed` instead, with `$mcp_auth_failure_reason` (`insufficient_scope`, `inactive_oauth_token`, `invalid_api_key`, `unknown`), `$mcp_missing_scope` when the API named a scope, and `$mcp_auth_status` (401/403). Only PostHog's own server emits it, so it is absent for customer-instrumented servers.
@@ -150,7 +150,7 @@ A "harness" is the friendly product label for the MCP client that made a call
**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.)
+**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, over exactly three properties — the `x-anthropic-client` header (`$mcp_vendor_client`, with the legacy `mcp_vendor_client` coalesced for historical rows) 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 (`$mcp_client_user_agent`, also the generic last fallback); and `clientInfo.name` arrives as `$mcp_client_name`. 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.)
**Share of users by harness** (answers "what % of my users are on Claude Code"):
@@ -211,11 +211,14 @@ FROM (
distinct_id,
trim(replaceRegexpAll(lower(
coalesce(
+ -- Vendor header: the SDKs emit $mcp_vendor_client; the unprefixed
+ -- mcp_vendor_client is the legacy name on historical rows from
+ -- PostHog's own server. Both spellings of the value occur.
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',
+ lower(coalesce(nullIf(toString(properties.$mcp_vendor_client), ''), nullIf(toString(properties.mcp_vendor_client), ''))) IN ('claudecode', 'claude-code'), 'claude-code',
+ lower(coalesce(nullIf(toString(properties.$mcp_vendor_client), ''), nullIf(toString(properties.mcp_vendor_client), ''))) IN ('claudeai', 'claude-ai'), 'claude-ai',
+ lower(coalesce(nullIf(toString(properties.$mcp_vendor_client), ''), nullIf(toString(properties.mcp_vendor_client), ''))) = 'cowork', 'cowork',
+ lower(coalesce(nullIf(toString(properties.$mcp_vendor_client), ''), nullIf(toString(properties.mcp_vendor_client), ''))) IN ('claudedesign', 'claude-design'), 'claude-design',
NULL
),
if(lower(extract(toString(properties.$mcp_client_user_agent), '^([^/]+)')) = 'claude-code',
@@ -227,13 +230,11 @@ FROM (
trim(concat(extract(toString(properties.$mcp_client_user_agent), '^([^/]+)'), ' ', extract(toString(properties.$mcp_client_user_agent), '[(]([^,)]+)'))),
NULL),
nullIf(nullIf(toString(properties.$mcp_client_name), ''), 'mcp'),
- nullIf(nullIf(toString(properties.mcp_session_client_name), ''), 'mcp'),
nullIf(trim(concat(
extract(toString(properties.$mcp_client_user_agent), '^([^/]+)'),
' ',
extract(toString(properties.$mcp_client_user_agent), '[(]([^,)]+)')
)), ''),
- nullIf(toString(properties.$mcp_oauth_client_name), ''),
''
)
), '\\s*\\(via mcp-remote[^)]*\\)\\s*', '')) AS h