:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
fix(mcp): emit canonical $mcp_tool_call from posthog-cli exec path (#66462)
Lucas Fariaad192c7040d5
diff --git a/services/mcp/src/cli/index.ts b/services/mcp/src/cli/index.tsindex f44e0ec62cd1..3a8d1ca2b6cc 100644--- a/services/mcp/src/cli/index.ts+++ b/services/mcp/src/cli/index.ts@@ -92,14 +92,17 @@ async function buildExec(config: CliConfig = resolveCliConfig()): Promise<BuiltECOMMAND_REFERENCE,'posthog-cli',(toolName, properties) => {- void context.trackEvent(AnalyticsEvent.MCP_TOOL_CALL, {+ const toolCallProperties = {tool_name: toolName,$mcp_tool_name: toolName,$mcp_duration_ms: properties.duration_ms,$mcp_is_error: !properties.success,output_format: properties.output_format,...(properties.error_message ? { error_message: properties.error_message } : {}),- })+ }+ void context.trackEvent(AnalyticsEvent.MCP_TOOL_CALL, toolCallProperties)+ // Legacy shim: remove with the hono shim once insights migrate off `mcp_tool_call`.+ void context.trackEvent(AnalyticsEvent.MCP_TOOL_CALL_LEGACY, toolCallProperties)},[],{ requireDestructiveConfirmation: true }diff --git a/services/mcp/src/lib/posthog/analytics.ts b/services/mcp/src/lib/posthog/analytics.tsindex d53a03c1b5e8..ee315a8e4e2b 100644--- a/services/mcp/src/lib/posthog/analytics.ts+++ b/services/mcp/src/lib/posthog/analytics.ts@@ -2,7 +2,8 @@ export enum AnalyticsEvent {MCP_INIT = 'mcp init',MCP_PROJECT_SWITCHED = 'mcp project switched',MCP_ORGANIZATION_SWITCHED = 'mcp organization switched',- MCP_TOOL_CALL = 'mcp_tool_call', // matching @posthog/mcp-analytics+ MCP_TOOL_CALL = '$mcp_tool_call',+ MCP_TOOL_CALL_LEGACY = 'mcp_tool_call', // dual-emitted during the migration to `$mcp_tool_call`MCP_FEEDBACK_SUBMITTED = 'mcp feedback submitted',}