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.

feat(mcp): let agents pick the sql and retention charts the app offers (#113807)

posthog[bot]1a25c6b5a09e
diff --git a/frontend/src/queries/schema.json b/frontend/src/queries/schema.json
index f4c2b3456d02..0abf895b60fc 100644
--- a/frontend/src/queries/schema.json
+++ b/frontend/src/queries/schema.json
@@ -2513,6 +2513,19 @@
"$ref": "#/definitions/AssistantDataVisualizationYAxisSettings",
"description": "Settings for the left Y axis."
},
+ "legendPosition": {
+ "description": "Where the legend sits. Defaults to right for pie and donut, top for other charts.",
+ "enum": ["top", "bottom", "left", "right"],
+ "type": "string"
+ },
+ "metric": {
+ "$ref": "#/definitions/AssistantDataVisualizationMetricSettings",
+ "description": "Settings for `Metric`. `summary` defaults to `latest`."
+ },
+ "pie": {
+ "$ref": "#/definitions/PieChartSettings",
+ "description": "Settings for `ActionsPie` and `ActionsDonut`."
+ },
"rightYAxisSettings": {
"$ref": "#/definitions/AssistantDataVisualizationYAxisSettings",
"description": "Settings for the right Y axis. Only applies when a Y series uses `settings.display.yAxisPosition: \"right\"`."
@@ -2560,13 +2573,16 @@
"type": "object"
},
"AssistantDataVisualizationDisplayType": {
- "description": "Subset of `ChartDisplayType` values supported by `AssistantDataVisualizationNode`.\n\n- `ActionsTable` — render rows as a data table. This is the default when `display` is omitted.\n- `BoldNumber` — big-number display for single-value results (first numeric column of the first row).\n- `ActionsLineGraph` — line chart. Requires at least two columns, including one numeric column.\n- `ActionsBar` — bar chart with one bar per X-axis value.\n- `ActionsPie` — pie chart for categorical proportions. Requires one label column and one numeric column.\n- `ActionsStackedBar` — bar chart stacked by a series breakdown column.\n- `ActionsAreaGraph` — area chart. Requires at least two columns, including one numeric column.\n- `TwoDimensionalHeatmap` — 2D heatmap. Requires an X column, a Y column, and a numeric value column.\n- `ScatterPlot` — scatter plot of one measure against another. Requires two numeric columns, one per axis.\n- `BoxPlot` — box plot from pre-aggregated SQL rows. Requires six numeric summary columns.",
+ "description": "Subset of `ChartDisplayType` values supported by `AssistantDataVisualizationNode`.\n\n- `ActionsTable` — render rows as a data table. This is the default when `display` is omitted.\n- `BoldNumber` — big-number display for single-value results (first numeric column of the first row).\n- `Metric` — big number with a change pill and a sparkline (a KPI or scorecard). Uses the first numeric Y column, one value per row.\n- `ActionsLineGraph` — line chart. Requires at least two columns, including one numeric column.\n- `ActionsBar` — bar chart with one bar per X-axis value.\n- `ActionsBarValue` — horizontal bar chart (bar ranking) with one bar per category. Requires a category column and a numeric column.\n- `ActionsPie` — pie chart for categorical proportions. Requires one label column and one numeric column.\n- `ActionsDonut` — donut (ring) chart with the total in the center. Same columns as `ActionsPie`.\n- `ActionsStackedBar` — bar chart stacked by a series breakdown column.\n- `ActionsAreaGraph` — area chart. Requires at least two columns, including one numeric column.\n- `TwoDimensionalHeatmap` — 2D heatmap. Requires an X column, a Y column, and a numeric value column.\n- `ScatterPlot` — scatter plot of one measure against another. Requires two numeric columns, one per axis.\n- `BoxPlot` — box plot from pre-aggregated SQL rows. Requires six numeric summary columns.",
"enum": [
"ActionsTable",
"BoldNumber",
+ "Metric",
"ActionsLineGraph",
"ActionsBar",
+ "ActionsBarValue",
"ActionsPie",
+ "ActionsDonut",
"ActionsStackedBar",
"ActionsAreaGraph",
"TwoDimensionalHeatmap",
@@ -2590,6 +2606,19 @@
"required": ["label", "value"],
"type": "object"
},
+ "AssistantDataVisualizationMetricSettings": {
+ "additionalProperties": false,
+ "properties": {
+ "showChange": {
+ "type": "boolean"
+ },
+ "summary": {
+ "enum": ["total", "average", "latest"],
+ "type": "string"
+ }
+ },
+ "type": "object"
+ },
"AssistantDataVisualizationNode": {
"additionalProperties": false,
"description": "SQL-backed visualization. Use this when the analysis requires custom SQL that cannot be expressed as a standard product-analytics insight — cross-source joins with the data warehouse, window functions, or bespoke aggregations.\n\nPrefer `AssistantInsightVizNode` for standard product analytics (trends, funnels, retention, paths, stickiness, lifecycle). Only reach for this node when SQL is strictly necessary.",
@@ -2600,7 +2629,7 @@
},
"display": {
"$ref": "#/definitions/AssistantDataVisualizationDisplayType",
- "description": "Visualization type. Defaults to `ActionsTable` when omitted.\n\nGuidance:\n- Single-value result (one numeric column, one row) → `BoldNumber`.\n- Time series → `ActionsLineGraph` or `ActionsAreaGraph`.\n- Categorical proportions → `ActionsPie`.\n- Categorical comparison → `ActionsBar` or `ActionsStackedBar`.\n- Two-dimensional aggregation → `TwoDimensionalHeatmap`.\n- Relationship between two numeric measures, one point per row → `ScatterPlot`.\n- Distribution summaries from pre-aggregated SQL rows → `BoxPlot` with `chartSettings.boxPlot`.\n- Otherwise → `ActionsTable`."
+ "description": "Visualization type. Defaults to `ActionsTable` when omitted.\n\nGuidance:\n- Single-value result (one numeric column, one row) → `BoldNumber`.\n- Headline number with its change over time (KPI, scorecard) → `Metric`.\n- Time series → `ActionsLineGraph` or `ActionsAreaGraph`.\n- Categorical proportions → `ActionsPie` or `ActionsDonut`.\n- Categorical comparison → `ActionsBar` or `ActionsStackedBar`.\n- Ranking of categories by one value (top N, horizontal bars) → `ActionsBarValue`.\n- Two-dimensional aggregation → `TwoDimensionalHeatmap`.\n- Relationship between two numeric measures, one point per row → `ScatterPlot`.\n- Distribution summaries from pre-aggregated SQL rows → `BoxPlot` with `chartSettings.boxPlot`.\n- Otherwise → `ActionsTable`."
},
"kind": {
"const": "DataVisualizationNode",
@@ -4600,6 +4629,10 @@
"required": ["kind", "source"],
"type": "object"
},
+ "AssistantRetentionDisplayType": {
+ "enum": ["ActionsLineGraph", "ActionsBar"],
+ "type": "string"
+ },
"AssistantRetentionEntity": {
"anyOf": [
{
@@ -4663,6 +4696,10 @@
"description": "Whether retention should be rolling (aka unbounded, cumulative). Rolling retention means that a user coming back in period 5 makes them count towards all the previous periods.",
"type": "boolean"
},
+ "display": {
+ "$ref": "#/definitions/AssistantRetentionDisplayType",
+ "description": "`ActionsLineGraph` (default) draws lines. `ActionsBar` draws bars."
+ },
"meanRetentionCalculation": {
"description": "Whether an additional series should be shown, showing the mean conversion for each period across cohorts.",
"enum": ["simple", "weighted", "none"],
@@ -41058,11 +41095,11 @@
"additionalProperties": false,
"properties": {
"showTotal": {
- "description": "Whether to show the aggregation total below the chart. Defaults to on.",
+ "description": "Whether to show the aggregation total. Defaults to on only when slices show values.",
"type": "boolean"
},
"sliceContent": {
- "description": "What to render on each slice. Defaults to labels.",
+ "description": "What to render on each slice. Defaults to values.",
"enum": ["labels", "values", "none"],
"type": "string"
},
diff --git a/frontend/src/queries/schema/schema-assistant-queries.ts b/frontend/src/queries/schema/schema-assistant-queries.ts
index 3ffaff7a2e74..9bbcdbd69795 100644
--- a/frontend/src/queries/schema/schema-assistant-queries.ts
+++ b/frontend/src/queries/schema/schema-assistant-queries.ts
@@ -26,6 +26,7 @@ import {
MultipleBreakdownType,
Node,
NodeKind,
+ PieChartSettings,
type RecordingOrder,
type RecordingOrderDirection,
RetentionFilterLegacy,
@@ -984,8 +985,12 @@ export interface AssistantRetentionFilter {
* @default event
*/
aggregationPropertyType?: 'event' | 'person' | 'data_warehouse'
+ /** `ActionsLineGraph` (default) draws lines. `ActionsBar` draws bars. */
+ display?: AssistantRetentionDisplayType
}
+export type AssistantRetentionDisplayType = ChartDisplayType.ActionsLineGraph | ChartDisplayType.ActionsBar
+
export interface AssistantRetentionQuery extends AssistantInsightsQueryBase {
kind: NodeKind.RetentionQuery
/** Properties specific to the retention insight */
@@ -1824,9 +1829,12 @@ export interface AssistantInsightVizNode {
*
* - `ActionsTable` — render rows as a data table. This is the default when `display` is omitted.
* - `BoldNumber` — big-number display for single-value results (first numeric column of the first row).
+ * - `Metric` — big number with a change pill and a sparkline (a KPI or scorecard). Uses the first numeric Y column, one value per row.
* - `ActionsLineGraph` — line chart. Requires at least two columns, including one numeric column.
* - `ActionsBar` — bar chart with one bar per X-axis value.
+ * - `ActionsBarValue` — horizontal bar chart (bar ranking) with one bar per category. Requires a category column and a numeric column.
* - `ActionsPie` — pie chart for categorical proportions. Requires one label column and one numeric column.
+ * - `ActionsDonut` — donut (ring) chart with the total in the center. Same columns as `ActionsPie`.
* - `ActionsStackedBar` — bar chart stacked by a series breakdown column.
* - `ActionsAreaGraph` — area chart. Requires at least two columns, including one numeric column.
* - `TwoDimensionalHeatmap` — 2D heatmap. Requires an X column, a Y column, and a numeric value column.
@@ -1836,9 +1844,12 @@ export interface AssistantInsightVizNode {
export type AssistantDataVisualizationDisplayType =
| ChartDisplayType.ActionsTable
| ChartDisplayType.BoldNumber
+ | ChartDisplayType.Metric
| ChartDisplayType.ActionsLineGraph
| ChartDisplayType.ActionsBar
+ | ChartDisplayType.ActionsBarValue
| ChartDisplayType.ActionsPie
+ | ChartDisplayType.ActionsDonut
| ChartDisplayType.ActionsStackedBar
| ChartDisplayType.ActionsAreaGraph
| ChartDisplayType.TwoDimensionalHeatmap
@@ -1934,6 +1945,11 @@ export interface AssistantDataVisualizationBoxPlotSettings {
excludeOutliers?: boolean
}
+export interface AssistantDataVisualizationMetricSettings {
+ summary?: 'total' | 'average' | 'latest'
+ showChange?: boolean
+}
+
export interface AssistantDataVisualizationChartSettings {
/**
* Column used as the X axis. Typically a time bucket or categorical column, but `ScatterPlot`
@@ -1962,6 +1978,12 @@ export interface AssistantDataVisualizationChartSettings {
stackBars100?: boolean
/** Show the chart legend. */
showLegend?: boolean
+ /** Where the legend sits. Defaults to right for pie and donut, top for other charts. */
+ legendPosition?: 'top' | 'bottom' | 'left' | 'right'
+ /** Settings for `ActionsPie` and `ActionsDonut`. */
+ pie?: PieChartSettings
+ /** Settings for `Metric`. `summary` defaults to `latest`. */
+ metric?: AssistantDataVisualizationMetricSettings
/** Render each data point's value as a label directly on the series. */
showValuesOnSeries?: boolean
/** Replace null aggregation results with zero. */
@@ -1996,9 +2018,11 @@ export interface AssistantDataVisualizationNode {
*
* Guidance:
* - Single-value result (one numeric column, one row) → `BoldNumber`.
+ * - Headline number with its change over time (KPI, scorecard) → `Metric`.
* - Time series → `ActionsLineGraph` or `ActionsAreaGraph`.
- * - Categorical proportions → `ActionsPie`.
+ * - Categorical proportions → `ActionsPie` or `ActionsDonut`.
* - Categorical comparison → `ActionsBar` or `ActionsStackedBar`.
+ * - Ranking of categories by one value (top N, horizontal bars) → `ActionsBarValue`.
* - Two-dimensional aggregation → `TwoDimensionalHeatmap`.
* - Relationship between two numeric measures, one point per row → `ScatterPlot`.
* - Distribution summaries from pre-aggregated SQL rows → `BoxPlot` with `chartSettings.boxPlot`.
diff --git a/frontend/src/queries/schema/schema-general.ts b/frontend/src/queries/schema/schema-general.ts
index 0b9f171e209f..cfe672729c5d 100644
--- a/frontend/src/queries/schema/schema-general.ts
+++ b/frontend/src/queries/schema/schema-general.ts
@@ -1482,12 +1482,12 @@ export interface HeatmapSettings {
}
export interface PieChartSettings {
- /** What to render on each slice. Defaults to labels. */
+ /** What to render on each slice. Defaults to values. */
sliceContent?: 'labels' | 'values' | 'none'
/** Whether slice values show as absolute amounts or shares of the total. Only applies when
* `sliceContent` is `values`. */
valueDisplay?: 'absolute' | 'percentage'
- /** Whether to show the aggregation total below the chart. Defaults to on. */
+ /** Whether to show the aggregation total. Defaults to on only when slices show values. */
showTotal?: boolean
}
diff --git a/posthog/schema.py b/posthog/schema.py
index 9b986d07d672..f34f853b2380 100644
--- a/posthog/schema.py
+++ b/posthog/schema.py
@@ -49,6 +49,7 @@ from posthog.schema_enums import (
AssistantMessageType as AssistantMessageType,
AssistantNavigateUrl as AssistantNavigateUrl,
AssistantNumericValuePropertyFilterOperator as AssistantNumericValuePropertyFilterOperator,
+ AssistantRetentionDisplayType as AssistantRetentionDisplayType,
AssistantSetPropertyFilterOperator as AssistantSetPropertyFilterOperator,
AssistantStickinessDisplayType as AssistantStickinessDisplayType,
AssistantStringOrBooleanValuePropertyFilterOperator as AssistantStringOrBooleanValuePropertyFilterOperator,
@@ -599,6 +600,14 @@ class AssistantDataVisualizationGoalLine(BaseModel):
value: float = Field(..., description="Y-axis value at which the goal line is drawn.")
+class AssistantDataVisualizationMetricSettings(BaseModel):
+ model_config = ConfigDict(
+ extra="forbid",
+ )
+ showChange: bool | None = None
+ summary: Summary | None = None
+
+
class AssistantDataVisualizationYAxisSettings(BaseModel):
model_config = ConfigDict(
extra="forbid",
@@ -2844,10 +2853,10 @@ class PieChartSettings(BaseModel):
)
showTotal: bool | None = Field(
default=None,
- description=("Whether to show the aggregation total below the chart. Defaults to on."),
+ description=("Whether to show the aggregation total. Defaults to on only when slices show values."),
)
sliceContent: SliceContent | None = Field(
- default=None, description="What to render on each slice. Defaults to labels."
+ default=None, description="What to render on each slice. Defaults to values."
)
valueDisplay: ValueDisplay | None = Field(
default=None,
@@ -3800,6 +3809,15 @@ class AssistantDataVisualizationChartSettings(BaseModel):
leftYAxisSettings: AssistantDataVisualizationYAxisSettings | None = Field(
default=None, description="Settings for the left Y axis."
)
+ legendPosition: LegendPosition | None = Field(
+ default=None,
+ description=("Where the legend sits. Defaults to right for pie and donut, top for other charts."),
+ )
+ metric: AssistantDataVisualizationMetricSettings | None = Field(
+ default=None,
+ description="Settings for `Metric`. `summary` defaults to `latest`.",
+ )
+ pie: PieChartSettings | None = Field(default=None, description="Settings for `ActionsPie` and `ActionsDonut`.")
rightYAxisSettings: AssistantDataVisualizationYAxisSettings | None = Field(
default=None,
description=(
@@ -9989,13 +10007,16 @@ class AssistantDataVisualizationNode(BaseModel):
description=(
"Visualization type. Defaults to `ActionsTable` when"
" omitted.\n\nGuidance:\n- Single-value result (one numeric column, one"
- " row) → `BoldNumber`.\n- Time series → `ActionsLineGraph` or"
- " `ActionsAreaGraph`.\n- Categorical proportions → `ActionsPie`.\n-"
- " Categorical comparison → `ActionsBar` or `ActionsStackedBar`.\n-"
- " Two-dimensional aggregation → `TwoDimensionalHeatmap`.\n- Relationship"
- " between two numeric measures, one point per row → `ScatterPlot`.\n-"
- " Distribution summaries from pre-aggregated SQL rows → `BoxPlot` with"
- " `chartSettings.boxPlot`.\n- Otherwise → `ActionsTable`."
+ " row) → `BoldNumber`.\n- Headline number with its change over time (KPI,"
+ " scorecard) → `Metric`.\n- Time series → `ActionsLineGraph` or"
+ " `ActionsAreaGraph`.\n- Categorical proportions → `ActionsPie` or"
+ " `ActionsDonut`.\n- Categorical comparison → `ActionsBar` or"
+ " `ActionsStackedBar`.\n- Ranking of categories by one value (top N,"
+ " horizontal bars) → `ActionsBarValue`.\n- Two-dimensional aggregation →"
+ " `TwoDimensionalHeatmap`.\n- Relationship between two numeric measures,"
+ " one point per row → `ScatterPlot`.\n- Distribution summaries from"
+ " pre-aggregated SQL rows → `BoxPlot` with `chartSettings.boxPlot`.\n-"
+ " Otherwise → `ActionsTable`."
),
)
kind: Literal["DataVisualizationNode"] = "DataVisualizationNode"
@@ -10529,6 +10550,10 @@ class AssistantRetentionFilter(BaseModel):
" towards all the previous periods."
),
)
+ display: AssistantRetentionDisplayType | None = Field(
+ default=None,
+ description=("`ActionsLineGraph` (default) draws lines. `ActionsBar` draws bars."),
+ )
meanRetentionCalculation: MeanRetentionCalculation | None = Field(
default=None,
description=(
diff --git a/posthog/schema_enums.py b/posthog/schema_enums.py
index 5d4578e5d533..cd39b7f9712d 100644
--- a/posthog/schema_enums.py
+++ b/posthog/schema_enums.py
@@ -246,12 +246,22 @@ class Style(StrEnum):
PERCENT = "percent"
+class LegendPosition(StrEnum):
+ TOP = "top"
+ BOTTOM = "bottom"
+ LEFT = "left"
+ RIGHT = "right"
+
+
class AssistantDataVisualizationDisplayType(StrEnum):
ACTIONS_TABLE = "ActionsTable"
BOLD_NUMBER = "BoldNumber"
+ METRIC = "Metric"
ACTIONS_LINE_GRAPH = "ActionsLineGraph"
ACTIONS_BAR = "ActionsBar"
+ ACTIONS_BAR_VALUE = "ActionsBarValue"
ACTIONS_PIE = "ActionsPie"
+ ACTIONS_DONUT = "ActionsDonut"
ACTIONS_STACKED_BAR = "ActionsStackedBar"
ACTIONS_AREA_GRAPH = "ActionsAreaGraph"
TWO_DIMENSIONAL_HEATMAP = "TwoDimensionalHeatmap"
@@ -259,6 +269,12 @@ class AssistantDataVisualizationDisplayType(StrEnum):
BOX_PLOT = "BoxPlot"
+class Summary(StrEnum):
+ TOTAL = "total"
+ AVERAGE = "average"
+ LATEST = "latest"
+
+
class Scale(StrEnum):
LINEAR = "linear"
LOGARITHMIC = "logarithmic"
@@ -414,6 +430,11 @@ class Key5(StrEnum):
SNAPSHOT_SOURCE = "snapshot_source"
+class AssistantRetentionDisplayType(StrEnum):
+ ACTIONS_LINE_GRAPH = "ActionsLineGraph"
+ ACTIONS_BAR = "ActionsBar"
+
+
class AggregationPropertyType(StrEnum):
EVENT = "event"
PERSON = "person"
@@ -789,13 +810,6 @@ class ChartDisplayType(StrEnum):
SCATTER_PLOT = "ScatterPlot"
-class LegendPosition(StrEnum):
- TOP = "top"
- BOTTOM = "bottom"
- LEFT = "left"
- RIGHT = "right"
-
-
class Curve(StrEnum):
LINEAR = "linear"
SMOOTH = "smooth"
@@ -2108,12 +2122,6 @@ class MetaAdsDefaultSources(StrEnum):
THREADS = "threads"
-class Summary(StrEnum):
- TOTAL = "total"
- AVERAGE = "average"
- LATEST = "latest"
-
-
class MetricsAggregation(StrEnum):
SUM = "sum"
AVG = "avg"
diff --git a/products/dashboards/frontend/generated/api.schemas.ts b/products/dashboards/frontend/generated/api.schemas.ts
index 371613e04396..12f1a9a7f83f 100644
--- a/products/dashboards/frontend/generated/api.schemas.ts
+++ b/products/dashboards/frontend/generated/api.schemas.ts
@@ -9202,9 +9202,9 @@ export const ValueDisplayApi = {
} as const
export interface PieChartSettingsApi {
- /** Whether to show the aggregation total below the chart. Defaults to on. */
+ /** Whether to show the aggregation total. Defaults to on only when slices show values. */
showTotal?: boolean | null
- /** What to render on each slice. Defaults to labels. */
+ /** What to render on each slice. Defaults to values. */
sliceContent?: SliceContentApi | null
/** Whether slice values show as absolute amounts or shares of the total. Only applies when `sliceContent` is `values`. */
valueDisplay?: ValueDisplayApi | null
diff --git a/products/product_analytics/frontend/generated/api.schemas.ts b/products/product_analytics/frontend/generated/api.schemas.ts
index 772ac81e5a7b..2cd405816e19 100644
--- a/products/product_analytics/frontend/generated/api.schemas.ts
+++ b/products/product_analytics/frontend/generated/api.schemas.ts
@@ -8129,9 +8129,9 @@ export const ValueDisplayApi = {
} as const
export interface PieChartSettingsApi {
- /** Whether to show the aggregation total below the chart. Defaults to on. */
+ /** Whether to show the aggregation total. Defaults to on only when slices show values. */
showTotal?: boolean | null
- /** What to render on each slice. Defaults to labels. */
+ /** What to render on each slice. Defaults to values. */
sliceContent?: SliceContentApi | null
/** Whether slice values show as absolute amounts or shares of the total. Only applies when `sliceContent` is `values`. */
valueDisplay?: ValueDisplayApi | null
diff --git a/products/product_analytics/mcp/tools.yaml b/products/product_analytics/mcp/tools.yaml
index 1747768e38d1..332edbd5cbb0 100644
--- a/products/product_analytics/mcp/tools.yaml
+++ b/products/product_analytics/mcp/tools.yaml
@@ -79,12 +79,12 @@ tools:
- Many breakdown rows that a person reads rather than compares: `ActionsTable`.
- - Totals per country from a `$geoip_country_name` breakdown: `WorldMap`.
+ - Totals per country from a `$geoip_country_code` breakdown: `WorldMap`.
In a TrendsQuery, `ActionsBar` is a time series with one bar per interval and the breakdown values stacked
in each bar. It is not one bar per category. In a SQL `DataVisualizationNode`, `ActionsBar` is one bar per
- X-axis value.
+ X-axis value, and `ActionsBarValue` draws the same bars horizontally.
agent_note: >
When you tell the user about this insight, name the display you chose and one or two other displays that
also fit this query, in one short sentence, and offer to change it. If the user agrees, change it with
@@ -94,7 +94,7 @@ tools:
- Trends (`trendsFilter.display`): for change over time `ActionsLineGraph`, `ActionsAreaGraph`, `ActionsBar`
or `ActionsUnstackedBar`; for totals per breakdown value or series `ActionsBarValue`, `ActionsPie` or
`ActionsTable`; for one number `Metric` or `BoldNumber`, never with a breakdown or more than one series;
- `WorldMap` only for a `$geoip_country_name` breakdown.
+ `WorldMap` only for a `$geoip_country_code` breakdown.
- Funnels (`funnelsFilter.funnelVizType`): `steps` for drop-off per step, `trends` for conversion over time,
or `time_to_convert` for how long users take.
diff --git a/services/mcp/schema/generated-tool-definitions.json b/services/mcp/schema/generated-tool-definitions.json
index d2ef6c76e87b..60494da3bbd6 100644
--- a/services/mcp/schema/generated-tool-definitions.json
+++ b/services/mcp/schema/generated-tool-definitions.json
@@ -7157,7 +7157,7 @@
}
},
"insight-create": {
- "description": "Create a new saved insight from a name and query definition. Test queries with query-trends / query-funnel /\nquery-retention / query-paths / query-stickiness / query-lifecycle first to confirm the shape, then save.\nReturns insight metadata only — after creating, call the insight-query tool with the returned `short_id` if\nyou want to see the computed results.\n\nPut the insight definition in `query.source`, under the wrapper node that matches it. Use\n`InsightVizNode` for a product analytics query and `DataVisualizationNode` for a SQL one:\n\n```json\n{ \"name\": \"Example\", \"query\": { \"kind\": \"DataVisualizationNode\", \"source\": { \"kind\": \"HogQLQuery\", \"query\": \"SELECT 1\" } } }\n```\n\nA bare query is accepted too. `{ \"kind\": \"TrendsQuery\", ... }` and `{ \"kind\": \"HogQLQuery\", ... }` are each\nwrapped for you, so a query you just ran through one of the `query-*` tools can be passed straight through.\n\nChoose the TrendsQuery `trendsFilter.display` from the question the insight answers:\n- Change over time: `ActionsLineGraph` (default), `ActionsAreaGraph`, or `ActionsBar`.\n- Compare breakdown values or series as totals (\"top pages\", \"failures by reason\"): `ActionsBarValue`, or `ActionsPie` for the share of a whole with a few values.\n- One number for the period, or this period against the previous one: `Metric` with `compareFilter.compare: true` for a comparison, or `BoldNumber` when a trend has no meaning.\n- Many breakdown rows that a person reads rather than compares: `ActionsTable`.\n- Totals per country from a `$geoip_country_name` breakdown: `WorldMap`.\n\nIn a TrendsQuery, `ActionsBar` is a time series with one bar per interval and the breakdown values stacked in each bar. It is not one bar per category. In a SQL `DataVisualizationNode`, `ActionsBar` is one bar per X-axis value.",
+ "description": "Create a new saved insight from a name and query definition. Test queries with query-trends / query-funnel /\nquery-retention / query-paths / query-stickiness / query-lifecycle first to confirm the shape, then save.\nReturns insight metadata only — after creating, call the insight-query tool with the returned `short_id` if\nyou want to see the computed results.\n\nPut the insight definition in `query.source`, under the wrapper node that matches it. Use\n`InsightVizNode` for a product analytics query and `DataVisualizationNode` for a SQL one:\n\n```json\n{ \"name\": \"Example\", \"query\": { \"kind\": \"DataVisualizationNode\", \"source\": { \"kind\": \"HogQLQuery\", \"query\": \"SELECT 1\" } } }\n```\n\nA bare query is accepted too. `{ \"kind\": \"TrendsQuery\", ... }` and `{ \"kind\": \"HogQLQuery\", ... }` are each\nwrapped for you, so a query you just ran through one of the `query-*` tools can be passed straight through.\n\nChoose the TrendsQuery `trendsFilter.display` from the question the insight answers:\n- Change over time: `ActionsLineGraph` (default), `ActionsAreaGraph`, or `ActionsBar`.\n- Compare breakdown values or series as totals (\"top pages\", \"failures by reason\"): `ActionsBarValue`, or `ActionsPie` for the share of a whole with a few values.\n- One number for the period, or this period against the previous one: `Metric` with `compareFilter.compare: true` for a comparison, or `BoldNumber` when a trend has no meaning.\n- Many breakdown rows that a person reads rather than compares: `ActionsTable`.\n- Totals per country from a `$geoip_country_code` breakdown: `WorldMap`.\n\nIn a TrendsQuery, `ActionsBar` is a time series with one bar per interval and the breakdown values stacked in each bar. It is not one bar per category. In a SQL `DataVisualizationNode`, `ActionsBar` is one bar per X-axis value, and `ActionsBarValue` draws the same bars horizontally.",
"category": "Product analytics",
"feature": "product_analytics",
"summary": "Create insight",
diff --git a/services/mcp/schema/tool-definitions-all.json b/services/mcp/schema/tool-definitions-all.json
index 9932bb0712e2..17bb2520b7de 100644
--- a/services/mcp/schema/tool-definitions-all.json
+++ b/services/mcp/schema/tool-definitions-all.json
@@ -7354,7 +7354,7 @@
}
},
"insight-create": {
- "description": "Create a new saved insight from a name and query definition. Test queries with query-trends / query-funnel /\nquery-retention / query-paths / query-stickiness / query-lifecycle first to confirm the shape, then save.\nReturns insight metadata only — after creating, call the insight-query tool with the returned `short_id` if\nyou want to see the computed results.\n\nPut the insight definition in `query.source`, under the wrapper node that matches it. Use\n`InsightVizNode` for a product analytics query and `DataVisualizationNode` for a SQL one:\n\n```json\n{ \"name\": \"Example\", \"query\": { \"kind\": \"DataVisualizationNode\", \"source\": { \"kind\": \"HogQLQuery\", \"query\": \"SELECT 1\" } } }\n```\n\nA bare query is accepted too. `{ \"kind\": \"TrendsQuery\", ... }` and `{ \"kind\": \"HogQLQuery\", ... }` are each\nwrapped for you, so a query you just ran through one of the `query-*` tools can be passed straight through.\n\nChoose the TrendsQuery `trendsFilter.display` from the question the insight answers:\n- Change over time: `ActionsLineGraph` (default), `ActionsAreaGraph`, or `ActionsBar`.\n- Compare breakdown values or series as totals (\"top pages\", \"failures by reason\"): `ActionsBarValue`, or `ActionsPie` for the share of a whole with a few values.\n- One number for the period, or this period against the previous one: `Metric` with `compareFilter.compare: true` for a comparison, or `BoldNumber` when a trend has no meaning.\n- Many breakdown rows that a person reads rather than compares: `ActionsTable`.\n- Totals per country from a `$geoip_country_name` breakdown: `WorldMap`.\n\nIn a TrendsQuery, `ActionsBar` is a time series with one bar per interval and the breakdown values stacked in each bar. It is not one bar per category. In a SQL `DataVisualizationNode`, `ActionsBar` is one bar per X-axis value.",
+ "description": "Create a new saved insight from a name and query definition. Test queries with query-trends / query-funnel /\nquery-retention / query-paths / query-stickiness / query-lifecycle first to confirm the shape, then save.\nReturns insight metadata only — after creating, call the insight-query tool with the returned `short_id` if\nyou want to see the computed results.\n\nPut the insight definition in `query.source`, under the wrapper node that matches it. Use\n`InsightVizNode` for a product analytics query and `DataVisualizationNode` for a SQL one:\n\n```json\n{ \"name\": \"Example\", \"query\": { \"kind\": \"DataVisualizationNode\", \"source\": { \"kind\": \"HogQLQuery\", \"query\": \"SELECT 1\" } } }\n```\n\nA bare query is accepted too. `{ \"kind\": \"TrendsQuery\", ... }` and `{ \"kind\": \"HogQLQuery\", ... }` are each\nwrapped for you, so a query you just ran through one of the `query-*` tools can be passed straight through.\n\nChoose the TrendsQuery `trendsFilter.display` from the question the insight answers:\n- Change over time: `ActionsLineGraph` (default), `ActionsAreaGraph`, or `ActionsBar`.\n- Compare breakdown values or series as totals (\"top pages\", \"failures by reason\"): `ActionsBarValue`, or `ActionsPie` for the share of a whole with a few values.\n- One number for the period, or this period against the previous one: `Metric` with `compareFilter.compare: true` for a comparison, or `BoldNumber` when a trend has no meaning.\n- Many breakdown rows that a person reads rather than compares: `ActionsTable`.\n- Totals per country from a `$geoip_country_code` breakdown: `WorldMap`.\n\nIn a TrendsQuery, `ActionsBar` is a time series with one bar per interval and the breakdown values stacked in each bar. It is not one bar per category. In a SQL `DataVisualizationNode`, `ActionsBar` is one bar per X-axis value, and `ActionsBarValue` draws the same bars horizontally.",
"category": "Product analytics",
"feature": "product_analytics",
"summary": "Create insight",
diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.ts
index a27409854249..aefe2dba974c 100644
--- a/services/mcp/src/api/generated.ts
+++ b/services/mcp/src/api/generated.ts
@@ -10521,9 +10521,9 @@ export namespace Schemas {
} as const;
export interface PieChartSettings {
- /** Whether to show the aggregation total below the chart. Defaults to on. */
+ /** Whether to show the aggregation total. Defaults to on only when slices show values. */
showTotal?: boolean | null;
- /** What to render on each slice. Defaults to labels. */
+ /** What to render on each slice. Defaults to values. */
sliceContent?: SliceContent | null;
/** Whether slice values show as absolute amounts or shares of the total. Only applies when `sliceContent` is `values`. */
valueDisplay?: ValueDisplay | null;
diff --git a/services/mcp/src/tools/generated/product_analytics.ts b/services/mcp/src/tools/generated/product_analytics.ts
index 1773b47baca2..79544054c4f1 100644
--- a/services/mcp/src/tools/generated/product_analytics.ts
+++ b/services/mcp/src/tools/generated/product_analytics.ts
@@ -61,6 +61,28 @@ const AssistantDataVisualizationYAxisSettings = z.object({
startAtZero: z.coerce.boolean().describe('Whether this Y axis should start at zero.').optional(),
})
+const AssistantDataVisualizationMetricSettings = z.object({
+ showChange: z.coerce.boolean().optional(),
+ summary: z.enum(['total', 'average', 'latest']).optional(),
+})
+
+const PieChartSettings = z.object({
+ showTotal: z.coerce
+ .boolean()
+ .describe('Whether to show the aggregation total. Defaults to on only when slices show values.')
+ .optional(),
+ sliceContent: z
+ .enum(['labels', 'values', 'none'])
+ .describe('What to render on each slice. Defaults to values.')
+ .optional(),
+ valueDisplay: z
+ .enum(['absolute', 'percentage'])
+ .describe(
+ 'Whether slice values show as absolute amounts or shares of the total. Only applies when `sliceContent` is `values`.'
+ )
+ .optional(),
+})
+
const AssistantDataVisualizationAxisDisplaySettings = z.object({
color: z.string().describe('Custom color for this series as a hex string (e.g. `#1d4aff`).').optional(),
displayType: z
@@ -125,6 +147,14 @@ const AssistantDataVisualizationChartSettings = z.object({
.describe('Horizontal goal lines drawn across the chart.')
.optional(),
leftYAxisSettings: AssistantDataVisualizationYAxisSettings.describe('Settings for the left Y axis.').optional(),
+ legendPosition: z
+ .enum(['top', 'bottom', 'left', 'right'])
+ .describe('Where the legend sits. Defaults to right for pie and donut, top for other charts.')
+ .optional(),
+ metric: AssistantDataVisualizationMetricSettings.describe(
+ 'Settings for `Metric`. `summary` defaults to `latest`.'
+ ).optional(),
+ pie: PieChartSettings.describe('Settings for `ActionsPie` and `ActionsDonut`.').optional(),
rightYAxisSettings: AssistantDataVisualizationYAxisSettings.describe(
'Settings for the right Y axis. Only applies when a Y series uses `settings.display.yAxisPosition: "right"`.'
).optional(),
@@ -162,9 +192,12 @@ const AssistantDataVisualizationChartSettings = z.object({
const AssistantDataVisualizationDisplayType = z.enum([
'ActionsTable',
'BoldNumber',
+ 'Metric',
'ActionsLineGraph',
'ActionsBar',
+ 'ActionsBarValue',
'ActionsPie',
+ 'ActionsDonut',
'ActionsStackedBar',
'ActionsAreaGraph',
'TwoDimensionalHeatmap',
@@ -186,7 +219,7 @@ const AssistantDataVisualizationNode = z.object({
'Chart configuration. Ignored when `display` is `ActionsTable` or `BoldNumber`.'
).optional(),
display: AssistantDataVisualizationDisplayType.describe(
- 'Visualization type. Defaults to `ActionsTable` when omitted.\n\nGuidance:\n- Single-value result (one numeric column, one row) → `BoldNumber`.\n- Time series → `ActionsLineGraph` or `ActionsAreaGraph`.\n- Categorical proportions → `ActionsPie`.\n- Categorical comparison → `ActionsBar` or `ActionsStackedBar`.\n- Two-dimensional aggregation → `TwoDimensionalHeatmap`.\n- Relationship between two numeric measures, one point per row → `ScatterPlot`.\n- Distribution summaries from pre-aggregated SQL rows → `BoxPlot` with `chartSettings.boxPlot`.\n- Otherwise → `ActionsTable`.'
+ 'Visualization type. Defaults to `ActionsTable` when omitted.\n\nGuidance:\n- Single-value result (one numeric column, one row) → `BoldNumber`.\n- Headline number with its change over time (KPI, scorecard) → `Metric`.\n- Time series → `ActionsLineGraph` or `ActionsAreaGraph`.\n- Categorical proportions → `ActionsPie` or `ActionsDonut`.\n- Categorical comparison → `ActionsBar` or `ActionsStackedBar`.\n- Ranking of categories by one value (top N, horizontal bars) → `ActionsBarValue`.\n- Two-dimensional aggregation → `TwoDimensionalHeatmap`.\n- Relationship between two numeric measures, one point per row → `ScatterPlot`.\n- Distribution summaries from pre-aggregated SQL rows → `BoxPlot` with `chartSettings.boxPlot`.\n- Otherwise → `ActionsTable`.'
).optional(),
kind: z.literal('DataVisualizationNode').default('DataVisualizationNode'),
source: z.record(z.string(), z.unknown()).describe('HogQL query object that produces the rows to visualize.'),
@@ -315,7 +348,7 @@ const insightCreate = (): ToolBase<
]) as typeof result
return withAgentNote(
await withPostHogUrl(context, filtered, `/insights/${filtered.short_id}`),
- 'When you tell the user about this insight, name the display you chose and one or two other displays that also fit this query, in one short sentence, and offer to change it. If the user agrees, change it with insight-update. Suggest only displays that the insight kind supports and that fit the question:\n\n- Trends (`trendsFilter.display`): for change over time `ActionsLineGraph`, `ActionsAreaGraph`, `ActionsBar` or `ActionsUnstackedBar`; for totals per breakdown value or series `ActionsBarValue`, `ActionsPie` or `ActionsTable`; for one number `Metric` or `BoldNumber`, never with a breakdown or more than one series; `WorldMap` only for a `$geoip_country_name` breakdown.\n- Funnels (`funnelsFilter.funnelVizType`): `steps` for drop-off per step, `trends` for conversion over time, or `time_to_convert` for how long users take.\n- Retention (`retentionFilter.display`): `ActionsLineGraph` or `ActionsBar`.\n- Stickiness (`stickinessFilter.display`): `ActionsLineGraph`, `ActionsBar` or `ActionsAreaGraph`.\n- Lifecycle: stacked or side-by-side bars (`lifecycleFilter.stacked`).\n- SQL (`DataVisualizationNode` `display`): only displays that fit the columns the query returns.\n- Paths: suggest nothing.\n\nUse the chart names a person sees, such as "bar chart per category" or "line chart", not enum values or tool names. If the user named the chart they want, do not suggest others. If you create several insights in this task, give one short list of alternatives at the end, not one per insight.\n\nAfter creating a Trends, SQL (HogQL), Funnels or Metrics insight, call insight-query with the returned short_id, read the current value, and offer an alert when the metric is one someone would act on if it moved sharply (signups, active users, revenue, conversion rate, error or failure counts, latency). Name an actual number, never a placeholder such as X, for example "want me to alert you when daily signups drop below 400?". A count sitting at zero, such as errors or failures, is a strong case, so offer an upper bound of 1. Offer nothing when the insight returned no rows. When no absolute number fits and the insight supports it, offer a relative-change alert on a sudden increase or decrease. Skip metrics nobody acts on, such as raw pageview or event-volume counts, and skip high-cardinality breakdowns. Judge the metric, not the request. A newly created insight, or one the user just asked to see, is not throwaway for that reason. If the user already declined an alert in this conversation, do not offer again. If alert-create is unavailable, say nothing about alerts. Wait for the user to accept before creating an alert.\n'
+ 'When you tell the user about this insight, name the display you chose and one or two other displays that also fit this query, in one short sentence, and offer to change it. If the user agrees, change it with insight-update. Suggest only displays that the insight kind supports and that fit the question:\n\n- Trends (`trendsFilter.display`): for change over time `ActionsLineGraph`, `ActionsAreaGraph`, `ActionsBar` or `ActionsUnstackedBar`; for totals per breakdown value or series `ActionsBarValue`, `ActionsPie` or `ActionsTable`; for one number `Metric` or `BoldNumber`, never with a breakdown or more than one series; `WorldMap` only for a `$geoip_country_code` breakdown.\n- Funnels (`funnelsFilter.funnelVizType`): `steps` for drop-off per step, `trends` for conversion over time, or `time_to_convert` for how long users take.\n- Retention (`retentionFilter.display`): `ActionsLineGraph` or `ActionsBar`.\n- Stickiness (`stickinessFilter.display`): `ActionsLineGraph`, `ActionsBar` or `ActionsAreaGraph`.\n- Lifecycle: stacked or side-by-side bars (`lifecycleFilter.stacked`).\n- SQL (`DataVisualizationNode` `display`): only displays that fit the columns the query returns.\n- Paths: suggest nothing.\n\nUse the chart names a person sees, such as "bar chart per category" or "line chart", not enum values or tool names. If the user named the chart they want, do not suggest others. If you create several insights in this task, give one short list of alternatives at the end, not one per insight.\n\nAfter creating a Trends, SQL (HogQL), Funnels or Metrics insight, call insight-query with the returned short_id, read the current value, and offer an alert when the metric is one someone would act on if it moved sharply (signups, active users, revenue, conversion rate, error or failure counts, latency). Name an actual number, never a placeholder such as X, for example "want me to alert you when daily signups drop below 400?". A count sitting at zero, such as errors or failures, is a strong case, so offer an upper bound of 1. Offer nothing when the insight returned no rows. When no absolute number fits and the insight supports it, offer a relative-change alert on a sudden increase or decrease. Skip metrics nobody acts on, such as raw pageview or event-volume counts, and skip high-cardinality breakdowns. Judge the metric, not the request. A newly created insight, or one the user just asked to see, is not throwaway for that reason. If the user already declined an alert in this conversation, do not offer again. If alert-create is unavailable, say nothing about alerts. Wait for the user to accept before creating an alert.\n'
)
},
})
diff --git a/services/mcp/src/tools/generated/query-wrappers.ts b/services/mcp/src/tools/generated/query-wrappers.ts
index 727c18efaf17..32164d5debe9 100644
--- a/services/mcp/src/tools/generated/query-wrappers.ts
+++ b/services/mcp/src/tools/generated/query-wrappers.ts
@@ -957,6 +957,8 @@ const AssistantFunnelsQuery = z.object({
.describe('Events or actions to include. Prioritize the more popular and fresh events and actions.'),
})
+const AssistantRetentionDisplayType = z.enum(['ActionsLineGraph', 'ActionsBar'])
+
const RetentionPeriod = z.enum(['Hour', 'Day', 'Week', 'Month'])
const RetentionType = z.enum(['retention_recurring', 'retention_first_time', 'retention_first_ever_occurrence'])
@@ -1017,6 +1019,9 @@ const AssistantRetentionFilter = z.object({
'Whether retention should be rolling (aka unbounded, cumulative). Rolling retention means that a user coming back in period 5 makes them count towards all the previous periods.'
)
.optional(),
+ display: AssistantRetentionDisplayType.describe(
+ '`ActionsLineGraph` (default) draws lines. `ActionsBar` draws bars.'
+ ).optional(),
meanRetentionCalculation: z
.enum(['simple', 'weighted', 'none'])
.describe(
diff --git a/services/mcp/src/ui-apps/components/Component.tsx b/services/mcp/src/ui-apps/components/Component.tsx
index 62b8cc237fea..611e473bb70c 100644
--- a/services/mcp/src/ui-apps/components/Component.tsx
+++ b/services/mcp/src/ui-apps/components/Component.tsx
@@ -130,6 +130,8 @@ export function Component({ data }: ComponentProps): ReactElement {
case 'retention':
return (
<RetentionVisualizer
+ // The host updates `data` in place, so key on the query to re-seed state per result.
+ key={JSON.stringify(payload.query)}
query={payload.query as RetentionQuery}
results={payload.results as RetentionResult}
/>
diff --git a/services/mcp/src/ui-apps/components/RetentionVisualizer.tsx b/services/mcp/src/ui-apps/components/RetentionVisualizer.tsx
index 90bcba4816e4..98660d22f114 100644
--- a/services/mcp/src/ui-apps/components/RetentionVisualizer.tsx
+++ b/services/mcp/src/ui-apps/components/RetentionVisualizer.tsx
@@ -23,7 +23,9 @@ const CHART_MODE_OPTIONS = [
const TOOLTIP_CONFIG: TooltipConfig = { pinnable: true, placement: 'top' }
export function RetentionVisualizer({ query, results }: RetentionVisualizerProps): ReactElement {
- const [chartMode, setChartMode] = useState<ChartMode>('line')
+ const [chartMode, setChartMode] = useState<ChartMode>(
+ query?.retentionFilter?.display === 'ActionsBar' ? 'bar' : 'line'
+ )
const theme = useMcpChartTheme()
// No cohort cap — mirrors the web, which renders every cohort and lets colors wrap past the palette.
diff --git a/services/mcp/src/ui-apps/components/types.ts b/services/mcp/src/ui-apps/components/types.ts
index 26bda540fa53..65c83972a41a 100644
--- a/services/mcp/src/ui-apps/components/types.ts
+++ b/services/mcp/src/ui-apps/components/types.ts
@@ -154,6 +154,7 @@ export type RetentionPeriod = 'Hour' | 'Day' | 'Week' | 'Month'
export interface RetentionFilter {
aggregationType?: RetentionAggregationType | null
+ display?: ChartDisplayType | null
period?: RetentionPeriod | null
retentionReference?: RetentionReference | null
showTrendLines?: boolean | null
diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/insight-create.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/insight-create.json
index d3497dc3714f..c93bc553f1a1 100644
--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/insight-create.json
+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/insight-create.json
@@ -169,6 +169,44 @@
},
"type": "object"
},
+ "legendPosition": {
+ "description": "Where the legend sits. Defaults to right for pie and donut, top for other charts.",
+ "enum": ["top", "bottom", "left", "right"],
+ "type": "string"
+ },
+ "metric": {
+ "description": "Settings for `Metric`. `summary` defaults to `latest`.",
+ "properties": {
+ "showChange": {
+ "type": "boolean"
+ },
+ "summary": {
+ "enum": ["total", "average", "latest"],
+ "type": "string"
+ }
+ },
+ "type": "object"
+ },
+ "pie": {
+ "description": "Settings for `ActionsPie` and `ActionsDonut`.",
+ "properties": {
+ "showTotal": {
+ "description": "Whether to show the aggregation total. Defaults to on only when slices show values.",
+ "type": "boolean"
+ },
+ "sliceContent": {
+ "description": "What to render on each slice. Defaults to values.",
+ "enum": ["labels", "values", "none"],
+ "type": "string"
+ },
+ "valueDisplay": {
+ "description": "Whether slice values show as absolute amounts or shares of the total. Only applies when `sliceContent` is `values`.",
+ "enum": ["absolute", "percentage"],
+ "type": "string"
+ }
+ },
+ "type": "object"
+ },
"rightYAxisSettings": {
"description": "Settings for the right Y axis. Only applies when a Y series uses `settings.display.yAxisPosition: \"right\"`.",
"properties": {
@@ -374,13 +412,16 @@
"type": "object"
},
"display": {
- "description": "Visualization type. Defaults to `ActionsTable` when omitted.\n\nGuidance:\n- Single-value result (one numeric column, one row) → `BoldNumber`.\n- Time series → `ActionsLineGraph` or `ActionsAreaGraph`.\n- Categorical proportions → `ActionsPie`.\n- Categorical comparison → `ActionsBar` or `ActionsStackedBar`.\n- Two-dimensional aggregation → `TwoDimensionalHeatmap`.\n- Relationship between two numeric measures, one point per row → `ScatterPlot`.\n- Distribution summaries from pre-aggregated SQL rows → `BoxPlot` with `chartSettings.boxPlot`.\n- Otherwise → `ActionsTable`.",
+ "description": "Visualization type. Defaults to `ActionsTable` when omitted.\n\nGuidance:\n- Single-value result (one numeric column, one row) → `BoldNumber`.\n- Headline number with its change over time (KPI, scorecard) → `Metric`.\n- Time series → `ActionsLineGraph` or `ActionsAreaGraph`.\n- Categorical proportions → `ActionsPie` or `ActionsDonut`.\n- Categorical comparison → `ActionsBar` or `ActionsStackedBar`.\n- Ranking of categories by one value (top N, horizontal bars) → `ActionsBarValue`.\n- Two-dimensional aggregation → `TwoDimensionalHeatmap`.\n- Relationship between two numeric measures, one point per row → `ScatterPlot`.\n- Distribution summaries from pre-aggregated SQL rows → `BoxPlot` with `chartSettings.boxPlot`.\n- Otherwise → `ActionsTable`.",
"enum": [
"ActionsTable",
"BoldNumber",
+ "Metric",
"ActionsLineGraph",
"ActionsBar",
+ "ActionsBarValue",
"ActionsPie",
+ "ActionsDonut",
"ActionsStackedBar",
"ActionsAreaGraph",
"TwoDimensionalHeatmap",
diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/insight-update.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/insight-update.json
index 3f8127c96408..4e350dbc8c2b 100644
--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/insight-update.json
+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/insight-update.json
@@ -180,6 +180,44 @@
},
"type": "object"
},
+ "legendPosition": {
+ "description": "Where the legend sits. Defaults to right for pie and donut, top for other charts.",
+ "enum": ["top", "bottom", "left", "right"],
+ "type": "string"
+ },
+ "metric": {
+ "description": "Settings for `Metric`. `summary` defaults to `latest`.",
+ "properties": {
+ "showChange": {
+ "type": "boolean"
+ },
+ "summary": {
+ "enum": ["total", "average", "latest"],
+ "type": "string"
+ }
+ },
+ "type": "object"
+ },
+ "pie": {
+ "description": "Settings for `ActionsPie` and `ActionsDonut`.",
+ "properties": {
+ "showTotal": {
+ "description": "Whether to show the aggregation total. Defaults to on only when slices show values.",
+ "type": "boolean"
+ },
+ "sliceContent": {
+ "description": "What to render on each slice. Defaults to values.",
+ "enum": ["labels", "values", "none"],
+ "type": "string"
+ },
+ "valueDisplay": {
+ "description": "Whether slice values show as absolute amounts or shares of the total. Only applies when `sliceContent` is `values`.",
+ "enum": ["absolute", "percentage"],
+ "type": "string"
+ }
+ },
+ "type": "object"
+ },
"rightYAxisSettings": {
"description": "Settings for the right Y axis. Only applies when a Y series uses `settings.display.yAxisPosition: \"right\"`.",
"properties": {
@@ -385,13 +423,16 @@
"type": "object"
},
"display": {
- "description": "Visualization type. Defaults to `ActionsTable` when omitted.\n\nGuidance:\n- Single-value result (one numeric column, one row) → `BoldNumber`.\n- Time series → `ActionsLineGraph` or `ActionsAreaGraph`.\n- Categorical proportions → `ActionsPie`.\n- Categorical comparison → `ActionsBar` or `ActionsStackedBar`.\n- Two-dimensional aggregation → `TwoDimensionalHeatmap`.\n- Relationship between two numeric measures, one point per row → `ScatterPlot`.\n- Distribution summaries from pre-aggregated SQL rows → `BoxPlot` with `chartSettings.boxPlot`.\n- Otherwise → `ActionsTable`.",
+ "description": "Visualization type. Defaults to `ActionsTable` when omitted.\n\nGuidance:\n- Single-value result (one numeric column, one row) → `BoldNumber`.\n- Headline number with its change over time (KPI, scorecard) → `Metric`.\n- Time series → `ActionsLineGraph` or `ActionsAreaGraph`.\n- Categorical proportions → `ActionsPie` or `ActionsDonut`.\n- Categorical comparison → `ActionsBar` or `ActionsStackedBar`.\n- Ranking of categories by one value (top N, horizontal bars) → `ActionsBarValue`.\n- Two-dimensional aggregation → `TwoDimensionalHeatmap`.\n- Relationship between two numeric measures, one point per row → `ScatterPlot`.\n- Distribution summaries from pre-aggregated SQL rows → `BoxPlot` with `chartSettings.boxPlot`.\n- Otherwise → `ActionsTable`.",
"enum": [
"ActionsTable",
"BoldNumber",
+ "Metric",
"ActionsLineGraph",
"ActionsBar",
+ "ActionsBarValue",
"ActionsPie",
+ "ActionsDonut",
"ActionsStackedBar",
"ActionsAreaGraph",
"TwoDimensionalHeatmap",
diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/query-retention-actors.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/query-retention-actors.json
index 60158a9c478c..0e5515137cd8 100644
--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/query-retention-actors.json
+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/query-retention-actors.json
@@ -1130,6 +1130,11 @@
"description": "Whether retention should be rolling (aka unbounded, cumulative). Rolling retention means that a user coming back in period 5 makes them count towards all the previous periods.",
"type": "boolean"
},
+ "display": {
+ "description": "`ActionsLineGraph` (default) draws lines. `ActionsBar` draws bars.",
+ "enum": ["ActionsLineGraph", "ActionsBar"],
+ "type": "string"
+ },
"meanRetentionCalculation": {
"description": "Whether an additional series should be shown, showing the mean conversion for each period across cohorts.",
"enum": ["simple", "weighted", "none"],
diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/query-retention.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/query-retention.json
index 3523aa6f183f..5f049c21fcc1 100644
--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/query-retention.json
+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/query-retention.json
@@ -1101,6 +1101,11 @@
"description": "Whether retention should be rolling (aka unbounded, cumulative). Rolling retention means that a user coming back in period 5 makes them count towards all the previous periods.",
"type": "boolean"
},
+ "display": {
+ "description": "`ActionsLineGraph` (default) draws lines. `ActionsBar` draws bars.",
+ "enum": ["ActionsLineGraph", "ActionsBar"],
+ "type": "string"
+ },
"meanRetentionCalculation": {
"description": "Whether an additional series should be shown, showing the mean conversion for each period across cohorts.",
"enum": ["simple", "weighted", "none"],
diff --git a/services/mcp/tests/unit/insight-query-shapes.test.ts b/services/mcp/tests/unit/insight-query-shapes.test.ts
index 0f7fe8ad570b..2e116ceedebb 100644
--- a/services/mcp/tests/unit/insight-query-shapes.test.ts
+++ b/services/mcp/tests/unit/insight-query-shapes.test.ts
@@ -1,4 +1,5 @@
import { describe, expect, it } from 'vitest'
+import { z } from 'zod'
import { GENERATED_TOOLS } from '@/tools/generated/product_analytics'
@@ -60,4 +61,31 @@ describe('insight query shapes', () => {
expect(schema.safeParse({ ...base, query }).success).toBe(false)
})
+
+ it.each(tools)('$tool names every SQL display type in the display guidance', ({ tool }) => {
+ const schema = z.toJSONSchema(GENERATED_TOOLS[tool]!().schema, { io: 'input', reused: 'inline' })
+ const display = findSqlDisplay(schema)!
+
+ for (const value of display.enum) {
+ expect(display.description).toContain(`\`${value}\``)
+ }
+ })
})
+
+function findSqlDisplay(node: unknown): { enum: string[]; description: string } | undefined {
+ if (!node || typeof node !== 'object') {
+ return undefined
+ }
+ const display = (node as { properties?: { display?: { enum?: string[]; description: string } } }).properties
+ ?.display
+ if (display?.enum?.includes('ActionsTable')) {
+ return display as { enum: string[]; description: string }
+ }
+ for (const child of Object.values(node)) {
+ const found = findSqlDisplay(child)
+ if (found) {
+ return found
+ }
+ }
+ return undefined
+}