: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(experiments): strip generated SQL from MCP results tool responses (#79565)
Juraj Majerik424ffdb5c7be
diff --git a/products/experiments/mcp/tools.yaml b/products/experiments/mcp/tools.yamlindex 15783a7f4d37..f91f47f32db6 100644--- a/products/experiments/mcp/tools.yaml+++ b/products/experiments/mcp/tools.yaml@@ -762,6 +762,18 @@ tools:param_overrides:id:cast: string-int+ response:+ exclude:+ - results.*.result.hogql+ - results.*.result.clickhouse_sql+ - results.*.result.cache_key+ - results.*.result.is_cached+ - results.*.result.cache_target_age+ - results.*.result.next_allowed_client_refresh+ - results.*.result.calculation_trigger+ - results.*.result.query_status+ - results.*.result.stats_version+ - results.*.result.insightexperiment-metrics-recalculation-retrieve:operation: experiments_metrics_recalculation_retrieveenabled: true@@ -793,6 +805,18 @@ tools:param_overrides:id:cast: string-int+ response:+ exclude:+ - results.*.result.hogql+ - results.*.result.clickhouse_sql+ - results.*.result.cache_key+ - results.*.result.is_cached+ - results.*.result.cache_target_age+ - results.*.result.next_allowed_client_refresh+ - results.*.result.calculation_trigger+ - results.*.result.query_status+ - results.*.result.stats_version+ - results.*.result.insightexperiment-pause:operation: experiments_pause_createenabled: true@@ -1115,6 +1139,18 @@ tools:id:cast: string-intui_app: experiment-results+ response:+ exclude:+ - timeseries.*.hogql+ - timeseries.*.clickhouse_sql+ - timeseries.*.cache_key+ - timeseries.*.is_cached+ - timeseries.*.cache_target_age+ - timeseries.*.next_allowed_client_refresh+ - timeseries.*.calculation_trigger+ - timeseries.*.query_status+ - timeseries.*.stats_version+ - timeseries.*.insightexperiment-unarchive:operation: experiments_unarchive_createenabled: truediff --git a/services/mcp/src/tools/generated/experiments.ts b/services/mcp/src/tools/generated/experiments.tsindex 04d9a3b3a766..9f19499aa2c9 100644--- a/services/mcp/src/tools/generated/experiments.ts+++ b/services/mcp/src/tools/generated/experiments.ts@@ -52,7 +52,7 @@ import {import { withUiApp } from '@/resources/ui-apps'import { SavedMetricsAttachSchema } from '@/schema/tool-inputs'import { castStringToInt } from '@/tools/cast-helpers'-import { withPostHogUrl, pickResponseFields, type WithPostHogUrl } from '@/tools/tool-utils'+import { withPostHogUrl, pickResponseFields, omitResponseFields, type WithPostHogUrl } from '@/tools/tool-utils'import type { Context, ToolBase, ZodObjectAny } from '@/tools/types'const ExperimentActivitySchema = ExperimentsActivityRetrieveParams.omit({ project_id: true })@@ -754,7 +754,19 @@ const experimentMetricsRecalculationLatestRetrieve = (): ToolBase<method: 'GET',path: `/api/projects/${encodeURIComponent(String(projectId))}/experiments/${encodeURIComponent(String(params.id))}/metrics_recalculation/latest/`,})- return await withPostHogUrl(context, result, `/experiments/${params.id}`)+ const filtered = omitResponseFields(result, [+ 'results.*.result.hogql',+ 'results.*.result.clickhouse_sql',+ 'results.*.result.cache_key',+ 'results.*.result.is_cached',+ 'results.*.result.cache_target_age',+ 'results.*.result.next_allowed_client_refresh',+ 'results.*.result.calculation_trigger',+ 'results.*.result.query_status',+ 'results.*.result.stats_version',+ 'results.*.result.insight',+ ]) as typeof result+ return await withPostHogUrl(context, filtered, `/experiments/${params.id}`)},})@@ -774,7 +786,19 @@ const experimentMetricsRecalculationRetrieve = (): ToolBase<method: 'GET',path: `/api/projects/${encodeURIComponent(String(projectId))}/experiments/${encodeURIComponent(String(params.id))}/metrics_recalculation/${encodeURIComponent(String(params.recalculation_id))}/`,})- return await withPostHogUrl(context, result, `/experiments/${params.id}`)+ const filtered = omitResponseFields(result, [+ 'results.*.result.hogql',+ 'results.*.result.clickhouse_sql',+ 'results.*.result.cache_key',+ 'results.*.result.is_cached',+ 'results.*.result.cache_target_age',+ 'results.*.result.next_allowed_client_refresh',+ 'results.*.result.calculation_trigger',+ 'results.*.result.query_status',+ 'results.*.result.stats_version',+ 'results.*.result.insight',+ ]) as typeof result+ return await withPostHogUrl(context, filtered, `/experiments/${params.id}`)},})@@ -1062,7 +1086,19 @@ const experimentTimeseriesResults = (): ToolBase<typeof ExperimentTimeseriesResumetric_uuid: params.metric_uuid,},})- return result+ const filtered = omitResponseFields(result, [+ 'timeseries.*.hogql',+ 'timeseries.*.clickhouse_sql',+ 'timeseries.*.cache_key',+ 'timeseries.*.is_cached',+ 'timeseries.*.cache_target_age',+ 'timeseries.*.next_allowed_client_refresh',+ 'timeseries.*.calculation_trigger',+ 'timeseries.*.query_status',+ 'timeseries.*.stats_version',+ 'timeseries.*.insight',+ ]) as typeof result+ return filtered},})