Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

chore(mcp-analytics): migrate queries to canonical $mcp_tool_call (#64575)

Thomas Obermüllerc4a4f39c9787
diff --git a/posthog/temporal/mcp_analytics/intent_clustering/team_discovery.py b/posthog/temporal/mcp_analytics/intent_clustering/team_discovery.py
index ac00b77ace60..744f56cd243f 100644
--- a/posthog/temporal/mcp_analytics/intent_clustering/team_discovery.py
+++ b/posthog/temporal/mcp_analytics/intent_clustering/team_discovery.py
@@ -45,7 +45,7 @@ async def get_team_ids_for_mcp_analytics(inputs: TeamDiscoveryInput) -> list[int
"""Return the deterministic list of teams to cluster intents for.
v1: returns ``GUARANTEED_TEAM_IDS`` sorted. A future PR will optionally
- union with a ClickHouse-sampled set of teams that have ``mcp_tool_call``
+ union with a ClickHouse-sampled set of teams that have ``$mcp_tool_call``
events in the configured window.
"""
async with Heartbeater():
diff --git a/products/mcp_analytics/backend/intent_clustering.py b/products/mcp_analytics/backend/intent_clustering.py
index 31d1ef1129a1..ded97baba377 100644
--- a/products/mcp_analytics/backend/intent_clustering.py
+++ b/products/mcp_analytics/backend/intent_clustering.py
@@ -36,6 +36,7 @@ from posthog.clickhouse.query_tagging import Feature, Product, tags_context
from posthog.models.team.team import Team
from posthog.sync import database_sync_to_async
+from products.mcp_analytics.backend.constants import MCP_TOOL_CALL_EVENT
from products.mcp_analytics.backend.models import MCPIntentEmbeddingCache, MCPSession
# Constants
@@ -132,7 +133,7 @@ def fetch_intent_corpus(
"""Return ``(records, intent_by_session)`` for clustering.
The intent text comes from posthog_mcp_session (Postgres), one row per
- MCP session. Tool stats come from ClickHouse mcp_tool_call events joined
+ MCP session. Tool stats come from ClickHouse $mcp_tool_call events joined
by session_id. Same intent string repeated across sessions aggregates.
``intent_by_session`` is exposed so callers can later join session-level
@@ -168,7 +169,7 @@ def fetch_intent_corpus(
query = parse_select(
_SESSION_TOOL_STATS_SQL,
placeholders={
- "event": ast.Constant(value="mcp_tool_call"),
+ "event": ast.Constant(value=MCP_TOOL_CALL_EVENT),
"session_ids": ast.Tuple(exprs=[ast.Constant(value=sid) for sid in session_ids]),
"lookback_days": ast.Constant(value=lookback_days),
},
@@ -236,7 +237,7 @@ def fetch_session_journeys(
query = parse_select(
_SESSION_JOURNEY_SQL,
placeholders={
- "event": ast.Constant(value="mcp_tool_call"),
+ "event": ast.Constant(value=MCP_TOOL_CALL_EVENT),
"session_ids": ast.Tuple(exprs=[ast.Constant(value=sid) for sid in session_ids]),
"lookback_days": ast.Constant(value=lookback_days),
},
diff --git a/products/mcp_analytics/backend/management/commands/cluster_mcp_intents.py b/products/mcp_analytics/backend/management/commands/cluster_mcp_intents.py
index 030bf2b1d23f..e1a6c6fdcf0b 100644
--- a/products/mcp_analytics/backend/management/commands/cluster_mcp_intents.py
+++ b/products/mcp_analytics/backend/management/commands/cluster_mcp_intents.py
@@ -79,7 +79,7 @@ class Command(BaseCommand):
self.stdout.write(f" n_clusters produced: {meta.get('n_clusters', 0)}")
if not clusters:
- self.stdout.write(self.style.WARNING("\nNo clusters — likely no mcp_tool_call events with $mcp_intent."))
+ self.stdout.write(self.style.WARNING("\nNo clusters — likely no $mcp_tool_call events with $mcp_intent."))
self.stdout.write("Try: ./manage.py seed_mcp_sessions --team-id N")
return
diff --git a/products/mcp_analytics/backend/models.py b/products/mcp_analytics/backend/models.py
index 533560ca173a..d2ffaacf5f13 100644
--- a/products/mcp_analytics/backend/models.py
+++ b/products/mcp_analytics/backend/models.py
@@ -110,7 +110,7 @@ class MCPIntentEmbeddingCache(UUIDModel, TeamScopedRootMixin):
class MCPSession(UUIDModel, TeamScopedRootMixin):
# On-demand intent store keyed by (team, session_id). The session list itself
- # is aggregated on the fly from mcp_tool_call events (see logic.py); the
+ # is aggregated on the fly from $mcp_tool_call events (see logic.py); the
# backfill that once populated session_start/_end/duration/etc. is gone.
team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE)
session_id = models.CharField(max_length=64)
diff --git a/products/mcp_analytics/backend/presentation/serializers.py b/products/mcp_analytics/backend/presentation/serializers.py
index 00232f724c8b..da76aba9a643 100644
--- a/products/mcp_analytics/backend/presentation/serializers.py
+++ b/products/mcp_analytics/backend/presentation/serializers.py
@@ -123,7 +123,7 @@ class MCPFeedbackCreateSerializer(MCPAnalyticsSubmissionContextSerializer):
class MCPToolCallSerializer(serializers.Serializer):
- event_id = serializers.CharField(read_only=True, help_text="ClickHouse uuid of the mcp_tool_call event.")
+ event_id = serializers.CharField(read_only=True, help_text="ClickHouse uuid of the $mcp_tool_call event.")
timestamp = serializers.DateTimeField(read_only=True, help_text="When the tool call was captured.")
tool_name = serializers.CharField(read_only=True, help_text="Tool that was invoked ($mcp_tool_name).")
intent = serializers.CharField(
@@ -141,16 +141,16 @@ class MCPToolCallSerializer(serializers.Serializer):
class MCPSessionSerializer(serializers.Serializer):
session_id = serializers.CharField(
- read_only=True, help_text="$mcp_session_id grouping all mcp_tool_call events in the session."
+ read_only=True, help_text="$mcp_session_id grouping all $mcp_tool_call events in the session."
)
tool_calls = serializers.IntegerField(
- read_only=True, help_text="Total number of mcp_tool_call events in the session."
+ read_only=True, help_text="Total number of $mcp_tool_call events in the session."
)
session_start = serializers.DateTimeField(
- read_only=True, help_text="Timestamp of the first mcp_tool_call event in the session."
+ read_only=True, help_text="Timestamp of the first $mcp_tool_call event in the session."
)
session_end = serializers.DateTimeField(
- read_only=True, help_text="Timestamp of the most recent mcp_tool_call event in the session."
+ read_only=True, help_text="Timestamp of the most recent $mcp_tool_call event in the session."
)
distinct_id_count = serializers.IntegerField(
read_only=True, help_text="Number of distinct PostHog distinct_ids that produced events in the session."
@@ -255,7 +255,7 @@ class MCPIntentClusterSerializer(serializers.Serializer):
read_only=True, help_text="Number of MCP sessions whose summarised intent belongs to this cluster."
)
call_count = serializers.IntegerField(
- read_only=True, help_text="Total number of mcp_tool_call events represented by this cluster."
+ read_only=True, help_text="Total number of $mcp_tool_call events represented by this cluster."
)
error_count = serializers.IntegerField(
read_only=True, help_text="Total number of error responses observed across the cluster."
diff --git a/products/mcp_analytics/backend/presentation/views.py b/products/mcp_analytics/backend/presentation/views.py
index b80589de38c7..f122af593545 100644
--- a/products/mcp_analytics/backend/presentation/views.py
+++ b/products/mcp_analytics/backend/presentation/views.py
@@ -159,7 +159,7 @@ class MCPSessionViewSet(TeamAndOrgViewSetMixin, viewsets.GenericViewSet):
@extend_schema(
operation_id="mcp_analytics_sessions_list",
- description="List MCP sessions for the current project, derived by grouping mcp_tool_call events by $mcp_session_id. Ordered by newest session start first by default.",
+ description="List MCP sessions for the current project, derived by grouping $mcp_tool_call events by $mcp_session_id. Ordered by newest session start first by default.",
parameters=[
OpenApiParameter(
name="search",
@@ -196,7 +196,7 @@ class MCPSessionViewSet(TeamAndOrgViewSetMixin, viewsets.GenericViewSet):
@extend_schema(
operation_id="mcp_analytics_sessions_tool_calls",
- description="List all mcp_tool_call events that belong to a given $session_id, in chronological order.",
+ description="List all $mcp_tool_call events that belong to a given $session_id, in chronological order.",
responses={200: MCPToolCallSerializer(many=True)},
)
@action(detail=True, methods=["get"], url_path="tool_calls")
diff --git a/products/mcp_analytics/backend/templates/tool_quality.sql b/products/mcp_analytics/backend/templates/tool_quality.sql
index e5dd0ceccca8..cff849f6cb4b 100644
--- a/products/mcp_analytics/backend/templates/tool_quality.sql
+++ b/products/mcp_analytics/backend/templates/tool_quality.sql
@@ -3,7 +3,7 @@
-- One row per $mcp_tool_name with call volume, error rate, latency percentiles,
-- and reach (unique users / sessions / first / last seen).
--
--- Source events: `mcp_tool_call`, emitted by the MCP analytics SDK on every
+-- Source events: `$mcp_tool_call`, emitted by the MCP analytics SDK on every
-- tool invocation. Expected properties:
-- $mcp_tool_name string
-- $mcp_is_error boolean
@@ -24,7 +24,7 @@ SELECT
min(timestamp) AS first_seen,
max(timestamp) AS last_seen
FROM events
-WHERE event = 'mcp_tool_call'
+WHERE event = '$mcp_tool_call'
AND properties.$mcp_tool_name IS NOT NULL
AND properties.$mcp_tool_name != ''
AND {filters}
diff --git a/products/mcp_analytics/backend/tests/test_intent_clustering.py b/products/mcp_analytics/backend/tests/test_intent_clustering.py
index ee2dfd121527..408b195cede4 100644
--- a/products/mcp_analytics/backend/tests/test_intent_clustering.py
+++ b/products/mcp_analytics/backend/tests/test_intent_clustering.py
@@ -240,7 +240,7 @@ class TestBuildSnapshot:
class TestFetchIntentCorpus(_MCPAnalyticsTeamScopedTestMixin, ClickhouseTestMixin, BaseTest):
- """End-to-end: posthog_mcp_session in Postgres + mcp_tool_call in ClickHouse."""
+ """End-to-end: posthog_mcp_session in Postgres + $mcp_tool_call in ClickHouse."""
def _seed_session(
self,
@@ -256,7 +256,7 @@ class TestFetchIntentCorpus(_MCPAnalyticsTeamScopedTestMixin, ClickhouseTestMixi
def _seed_tool_call(self, session_id: str, tool_name: str, is_error: bool = False) -> None:
_create_event(
event_uuid=uuid.uuid4(),
- event="mcp_tool_call",
+ event="$mcp_tool_call",
team=self.team,
distinct_id="seed",
timestamp=datetime.now(tz=UTC) - timedelta(hours=1),
diff --git a/products/mcp_analytics/backend/tests/test_tool_quality_sql.py b/products/mcp_analytics/backend/tests/test_tool_quality_sql.py
index 1b864139cb22..a5d5d1b51a22 100644
--- a/products/mcp_analytics/backend/tests/test_tool_quality_sql.py
+++ b/products/mcp_analytics/backend/tests/test_tool_quality_sql.py
@@ -37,8 +37,8 @@ def test_tool_quality_sql_supports_filters_and_sort_placeholders() -> None:
assert "__ORDER_DIRECTION__" in sql
-def test_tool_quality_sql_targets_mcp_tool_call_event() -> None:
+def test_tool_quality_sql_targets_canonical_mcp_tool_call_event() -> None:
sql = TOOL_QUALITY_SQL_PATH.read_text()
- assert "event = 'mcp_tool_call'" in sql
+ assert "event = '$mcp_tool_call'" in sql
assert "$mcp_tool_name" in sql
diff --git a/products/mcp_analytics/frontend/generated/api.schemas.ts b/products/mcp_analytics/frontend/generated/api.schemas.ts
index e7812d64c3f7..dbd4218412c4 100644
--- a/products/mcp_analytics/frontend/generated/api.schemas.ts
+++ b/products/mcp_analytics/frontend/generated/api.schemas.ts
@@ -209,7 +209,7 @@ export interface MCPIntentClusterApi {
readonly intent_count: number
/** Number of MCP sessions whose summarised intent belongs to this cluster. */
readonly session_count: number
- /** Total number of mcp_tool_call events represented by this cluster. */
+ /** Total number of $mcp_tool_call events represented by this cluster. */
readonly call_count: number
/** Total number of error responses observed across the cluster. */
readonly error_count: number
@@ -309,13 +309,13 @@ export interface MCPMissingCapabilityCreateApi {
}
export interface MCPSessionApi {
- /** $mcp_session_id grouping all mcp_tool_call events in the session. */
+ /** $mcp_session_id grouping all $mcp_tool_call events in the session. */
readonly session_id: string
- /** Total number of mcp_tool_call events in the session. */
+ /** Total number of $mcp_tool_call events in the session. */
readonly tool_calls: number
- /** Timestamp of the first mcp_tool_call event in the session. */
+ /** Timestamp of the first $mcp_tool_call event in the session. */
readonly session_start: string
- /** Timestamp of the most recent mcp_tool_call event in the session. */
+ /** Timestamp of the most recent $mcp_tool_call event in the session. */
readonly session_end: string
/** Number of distinct PostHog distinct_ids that produced events in the session. */
readonly distinct_id_count: number
@@ -347,7 +347,7 @@ export interface MCPSessionIntentApi {
}
export interface MCPToolCallApi {
- /** ClickHouse uuid of the mcp_tool_call event. */
+ /** ClickHouse uuid of the $mcp_tool_call event. */
readonly event_id: string
/** When the tool call was captured. */
readonly timestamp: string
diff --git a/products/mcp_analytics/frontend/generated/api.ts b/products/mcp_analytics/frontend/generated/api.ts
index 1653db615e32..4b0657d97d64 100644
--- a/products/mcp_analytics/frontend/generated/api.ts
+++ b/products/mcp_analytics/frontend/generated/api.ts
@@ -180,7 +180,7 @@ export const getMcpAnalyticsSessionsListUrl = (projectId: string, params?: McpAn
}
/**
- * List MCP sessions for the current project, derived by grouping mcp_tool_call events by $mcp_session_id. Ordered by newest session start first by default.
+ * List MCP sessions for the current project, derived by grouping $mcp_tool_call events by $mcp_session_id. Ordered by newest session start first by default.
*/
export const mcpAnalyticsSessionsList = async (
projectId: string,
@@ -232,7 +232,7 @@ export const getMcpAnalyticsSessionsToolCallsUrl = (
}
/**
- * List all mcp_tool_call events that belong to a given $session_id, in chronological order.
+ * List all $mcp_tool_call events that belong to a given $session_id, in chronological order.
*/
export const mcpAnalyticsSessionsToolCalls = async (
projectId: string,
diff --git a/products/mcp_analytics/frontend/mcpAnalyticsToolDetailLogic.ts b/products/mcp_analytics/frontend/mcpAnalyticsToolDetailLogic.ts
index ec0fe2347064..caf3ac61ee8a 100644
--- a/products/mcp_analytics/frontend/mcpAnalyticsToolDetailLogic.ts
+++ b/products/mcp_analytics/frontend/mcpAnalyticsToolDetailLogic.ts
@@ -101,7 +101,7 @@ function escapeHogQLString(value: string): string {
return value.replace(/\\/g, '\\\\').replace(/'/g, "\\'")
}
-// Standard "this tool, new-SDK only" filter shared by the mcp_tool_call queries.
+// Standard "this tool, new-SDK only" filter shared by the $mcp_tool_call queries.
function buildToolFilter(toolName: string): string {
return `${EFFECTIVE_TOOL_HOGQL} = '${escapeHogQLString(toolName)}' AND ${NEW_SDK_FILTER}`
}
@@ -121,7 +121,7 @@ WITH tool_calls AS (
timestamp,
${EFFECTIVE_TOOL_HOGQL} AS tool
FROM events
- WHERE event = 'mcp_tool_call'
+ WHERE event = '$mcp_tool_call'
AND timestamp >= now() - INTERVAL 7 DAY
AND ${NEW_SDK_FILTER}
AND notEmpty(coalesce(nullIf(toString(properties.$mcp_session_id), ''), toString(properties.$session_id)))
@@ -162,7 +162,7 @@ SELECT
uniq(distinct_id) AS users,
uniq(coalesce(nullIf(toString(properties.$mcp_session_id), ''), toString(properties.$session_id))) AS conversations
FROM events
-WHERE event = 'mcp_tool_call'
+WHERE event = '$mcp_tool_call'
AND timestamp >= now() - INTERVAL 7 DAY
AND ${toolFilter}
`,
@@ -194,7 +194,7 @@ SELECT
toString(properties.$mcp_tool_description) AS description,
toString(max(timestamp)) AS last_seen
FROM events
-WHERE event = 'mcp_tool_call'
+WHERE event = '$mcp_tool_call'
AND timestamp >= now() - INTERVAL 30 DAY
AND ${toolFilter}
AND notEmpty(toString(properties.$mcp_tool_description))
@@ -222,7 +222,7 @@ SELECT
countIf(notEmpty(toString(properties.$mcp_intent)) AND toString(properties.$mcp_intent) != '{}') AS with_intent,
count() AS total
FROM events
-WHERE event = 'mcp_tool_call'
+WHERE event = '$mcp_tool_call'
AND timestamp >= now() - INTERVAL 7 DAY
AND ${toolFilter}
`,
@@ -252,7 +252,7 @@ SELECT
uniq(distinct_id) AS users,
uniq(coalesce(nullIf(toString(properties.$mcp_session_id), ''), toString(properties.$session_id))) AS sessions
FROM events
-WHERE event = 'mcp_tool_call'
+WHERE event = '$mcp_tool_call'
AND timestamp >= now() - INTERVAL 30 DAY
AND ${toolFilter}
GROUP BY day
@@ -283,7 +283,7 @@ SELECT
arrayStringConcat(arraySort(arrayDistinct(groupArray(toString(properties.$mcp_client_name)))), ', ') AS harnesses
FROM events
-- $exception events don't carry the new-SDK markers ($mcp_source / $mcp_exec_tool_call_name), so
--- unlike the mcp_tool_call queries this matches the raw $mcp_tool_name without EFFECTIVE_TOOL_HOGQL/NEW_SDK_FILTER.
+-- unlike the $mcp_tool_call queries this matches the raw $mcp_tool_name without EFFECTIVE_TOOL_HOGQL/NEW_SDK_FILTER.
WHERE event = '$exception'
AND timestamp >= now() - INTERVAL 7 DAY
AND toString(properties.$mcp_tool_name) = '${escapeHogQLString(props.toolName)}'
@@ -305,7 +305,7 @@ SELECT
toString(properties.$mcp_intent_source) AS source,
toString(properties.$mcp_client_name) AS harness
FROM events
-WHERE event = 'mcp_tool_call'
+WHERE event = '$mcp_tool_call'
AND timestamp >= now() - INTERVAL 7 DAY
AND ${buildToolFilter(props.toolName)}
AND notEmpty(toString(properties.$mcp_intent))
@@ -341,7 +341,7 @@ SELECT
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'
+WHERE event = '$mcp_tool_call'
AND timestamp >= now() - INTERVAL 7 DAY
AND ${buildToolFilter(props.toolName)}
AND notEmpty(toString(properties.$mcp_client_name))
@@ -364,7 +364,7 @@ SELECT
arrayStringConcat(arraySort(arrayDistinct(groupArray(toString(properties.$mcp_client_name)))), ', ') AS harnesses,
max(timestamp) AS last_seen
FROM events
-WHERE event = 'mcp_tool_call'
+WHERE event = '$mcp_tool_call'
AND timestamp >= now() - INTERVAL 7 DAY
AND ${buildToolFilter(props.toolName)}
GROUP BY distinct_id
diff --git a/products/mcp_analytics/frontend/mcpAnalyticsToolQualityLogic.ts b/products/mcp_analytics/frontend/mcpAnalyticsToolQualityLogic.ts
index 63467cfb795c..98fcddd5b4ac 100644
--- a/products/mcp_analytics/frontend/mcpAnalyticsToolQualityLogic.ts
+++ b/products/mcp_analytics/frontend/mcpAnalyticsToolQualityLogic.ts
@@ -16,14 +16,14 @@ import { type AnyPropertyFilter, PropertyFilterType, PropertyOperator } from '~/
import toolQualityQueryTemplate from '../backend/templates/tool_quality.sql?raw'
import type { mcpAnalyticsToolQualityLogicType } from './mcpAnalyticsToolQualityLogicType'
-// `$mcp_tool_category` is stamped onto every mcp_tool_call event by the producer
+// `$mcp_tool_category` is stamped onto every $mcp_tool_call event by the producer
// (PostHog's MCP server from its catalog; external servers via the SDK). We read
// the available categories straight from the data so the scope selector works for
// any project's taxonomy without a hardcoded tool→category map.
const CATEGORIES_QUERY = hogql`
SELECT DISTINCT toString(properties.$mcp_tool_category) AS category
FROM events
-WHERE event = 'mcp_tool_call'
+WHERE event = '$mcp_tool_call'
AND timestamp >= now() - INTERVAL 30 DAY
AND properties.$mcp_tool_category IS NOT NULL
AND properties.$mcp_tool_category != ''
@@ -36,7 +36,7 @@ ORDER BY category
const CATEGORY_COUNTS_QUERY = hogql`
SELECT toString(properties.$mcp_tool_category) AS category, count() AS calls
FROM events
-WHERE event = 'mcp_tool_call'
+WHERE event = '$mcp_tool_call'
AND timestamp >= now() - INTERVAL 7 DAY
GROUP BY category
`
@@ -295,7 +295,7 @@ SELECT
round(quantile(0.95)(toFloat(properties.$mcp_duration_ms))) AS p95,
round(quantile(0.99)(toFloat(properties.$mcp_duration_ms))) AS p99
FROM events
-WHERE event = 'mcp_tool_call'
+WHERE event = '$mcp_tool_call'
AND properties.$mcp_tool_name IS NOT NULL
AND properties.$mcp_tool_name != ''
AND {filters}
diff --git a/products/posthog_ai/skills/querying-posthog-data/SKILL.md b/products/posthog_ai/skills/querying-posthog-data/SKILL.md
index aea4418bca68..7a0e39311581 100644
--- a/products/posthog_ai/skills/querying-posthog-data/SKILL.md
+++ b/products/posthog_ai/skills/querying-posthog-data/SKILL.md
@@ -50,7 +50,7 @@ Schema reference for PostHog's core system models, organized by domain:
- [AI observability events (`posthog.ai_events`)](./references/models-ai-observability-events.md)
- [AI observability reviews](./references/models-ai-observability-reviews.md)
- [Logs (`logs` data plane + saved views and alerts)](./references/models-logs.md)
-- [MCP analytics (`mcp_tool_call` events)](./references/models-mcp.md)
+- [MCP analytics (`$mcp_tool_call` events)](./references/models-mcp.md)
- [Metrics (`posthog.metrics`)](./references/models-metrics.md)
- [Notebooks](./references/models-notebooks.md)
- [Session Recording Playlists](./references/models-session-recording-playlists.md)
diff --git a/services/mcp/ARCHITECTURE.md b/services/mcp/ARCHITECTURE.md
index f2f4a869cc91..d3a521148550 100644
--- a/services/mcp/ARCHITECTURE.md
+++ b/services/mcp/ARCHITECTURE.md
@@ -77,13 +77,13 @@ This produces one structured JSON log per request, making it easier to query in
There are three independent layers that emit signals about each MCP request:
-1. **PostHog analytics events** — `mcp_tool_call` and friends, captured for product analytics.
+1. **PostHog analytics events** — `$mcp_tool_call` and friends, captured for product analytics.
2. **Outbound API headers** — propagated when the MCP server calls PostHog's Django backend, so backend log lines and OTLP spans can correlate with the originating MCP request.
3. **Wide structured logs** — single JSON record per request from the Worker itself (see [Wide Logging Pattern](#wide-logging-pattern) above).
-#### `mcp_tool_call` event paths
+#### `$mcp_tool_call` event paths
-Three distinct code paths emit `mcp_tool_call` events; which one fires depends on the server mode and on the `mcp-posthog-analytics-sdk` feature flag:
+Three distinct code paths emit the tool-call event (canonical `$mcp_tool_call`, with a legacy unprefixed `mcp_tool_call` alias still dual-emitted during the cutover — see the transition shim in `hono/analytics.ts`); which one fires depends on the server mode and on the `mcp-posthog-analytics-sdk` feature flag:
- **`hono/analytics.ts`** — homegrown PostHog capture. Used by the exec-mode wrapper to emit events for inner tool calls. Properties use the bare form: `mcp_session_id`, `mcp_conversation_id`, `mcp_client_name`, etc.
- **`lib/mcpcat.ts`** — legacy MCPcat SDK path. Same bare property names.
diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.ts
index 4f91c00cc743..21618ed4f25d 100644
--- a/services/mcp/src/api/generated.ts
+++ b/services/mcp/src/api/generated.ts
@@ -27303,7 +27303,7 @@ export namespace Schemas {
readonly intent_count: number;
/** Number of MCP sessions whose summarised intent belongs to this cluster. */
readonly session_count: number;
- /** Total number of mcp_tool_call events represented by this cluster. */
+ /** Total number of $mcp_tool_call events represented by this cluster. */
readonly call_count: number;
/** Total number of error responses observed across the cluster. */
readonly error_count: number;
@@ -27505,13 +27505,13 @@ export namespace Schemas {
}
export interface MCPSession {
- /** $mcp_session_id grouping all mcp_tool_call events in the session. */
+ /** $mcp_session_id grouping all $mcp_tool_call events in the session. */
readonly session_id: string;
- /** Total number of mcp_tool_call events in the session. */
+ /** Total number of $mcp_tool_call events in the session. */
readonly tool_calls: number;
- /** Timestamp of the first mcp_tool_call event in the session. */
+ /** Timestamp of the first $mcp_tool_call event in the session. */
readonly session_start: string;
- /** Timestamp of the most recent mcp_tool_call event in the session. */
+ /** Timestamp of the most recent $mcp_tool_call event in the session. */
readonly session_end: string;
/** Number of distinct PostHog distinct_ids that produced events in the session. */
readonly distinct_id_count: number;
@@ -27537,7 +27537,7 @@ export namespace Schemas {
}
export interface MCPToolCall {
- /** ClickHouse uuid of the mcp_tool_call event. */
+ /** ClickHouse uuid of the $mcp_tool_call event. */
readonly event_id: string;
/** When the tool call was captured. */
readonly timestamp: string;