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 proportion bar for sql insights (#114315)

Sam Penningtone9daec220531
diff --git a/frontend/src/queries/schema.json b/frontend/src/queries/schema.json
index 6f4428bb8d2a..55c8344bda93 100644
--- a/frontend/src/queries/schema.json
+++ b/frontend/src/queries/schema.json
@@ -2573,7 +2573,7 @@
"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- `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.",
+ "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- `ActionsProportionBar` — one flat bar that shows the parts of one whole, one segment per label. 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",
@@ -2583,6 +2583,7 @@
"ActionsBarValue",
"ActionsPie",
"ActionsDonut",
+ "ActionsProportionBar",
"ActionsStackedBar",
"ActionsAreaGraph",
"TwoDimensionalHeatmap",
@@ -2629,7 +2630,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- 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`."
+ "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- Parts of one whole → `ActionsPie`, `ActionsDonut` or `ActionsProportionBar`.\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",
diff --git a/frontend/src/queries/schema/schema-assistant-queries.ts b/frontend/src/queries/schema/schema-assistant-queries.ts
index 18a1c0758016..10f0b6dc42b3 100644
--- a/frontend/src/queries/schema/schema-assistant-queries.ts
+++ b/frontend/src/queries/schema/schema-assistant-queries.ts
@@ -1837,6 +1837,7 @@ export interface AssistantInsightVizNode {
* - `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`.
+ * - `ActionsProportionBar` — one flat bar that shows the parts of one whole, one segment per label. 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.
@@ -1852,6 +1853,7 @@ export type AssistantDataVisualizationDisplayType =
| ChartDisplayType.ActionsBarValue
| ChartDisplayType.ActionsPie
| ChartDisplayType.ActionsDonut
+ | ChartDisplayType.ActionsProportionBar
| ChartDisplayType.ActionsStackedBar
| ChartDisplayType.ActionsAreaGraph
| ChartDisplayType.TwoDimensionalHeatmap
@@ -2022,7 +2024,7 @@ export interface AssistantDataVisualizationNode {
* - 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` or `ActionsDonut`.
+ * - Parts of one whole → `ActionsPie`, `ActionsDonut` or `ActionsProportionBar`.
* - Categorical comparison → `ActionsBar` or `ActionsStackedBar`.
* - Ranking of categories by one value (top N, horizontal bars) → `ActionsBarValue`.
* - Two-dimensional aggregation → `TwoDimensionalHeatmap`.
diff --git a/posthog/schema.py b/posthog/schema.py
index 33aceef04f9a..f84cbaebd265 100644
--- a/posthog/schema.py
+++ b/posthog/schema.py
@@ -10198,8 +10198,8 @@ class AssistantDataVisualizationNode(BaseModel):
" 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"
+ " `ActionsAreaGraph`.\n- Parts of one whole → `ActionsPie`, `ActionsDonut`"
+ " or `ActionsProportionBar`.\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,"
diff --git a/posthog/schema_enums.py b/posthog/schema_enums.py
index 976b7ea20661..2ba97bb05acc 100644
--- a/posthog/schema_enums.py
+++ b/posthog/schema_enums.py
@@ -262,6 +262,7 @@ class AssistantDataVisualizationDisplayType(StrEnum):
ACTIONS_BAR_VALUE = "ActionsBarValue"
ACTIONS_PIE = "ActionsPie"
ACTIONS_DONUT = "ActionsDonut"
+ ACTIONS_PROPORTION_BAR = "ActionsProportionBar"
ACTIONS_STACKED_BAR = "ActionsStackedBar"
ACTIONS_AREA_GRAPH = "ActionsAreaGraph"
TWO_DIMENSIONAL_HEATMAP = "TwoDimensionalHeatmap"
diff --git a/services/mcp/src/tools/generated/product_analytics.ts b/services/mcp/src/tools/generated/product_analytics.ts
index 79544054c4f1..c95f83125550 100644
--- a/services/mcp/src/tools/generated/product_analytics.ts
+++ b/services/mcp/src/tools/generated/product_analytics.ts
@@ -198,6 +198,7 @@ const AssistantDataVisualizationDisplayType = z.enum([
'ActionsBarValue',
'ActionsPie',
'ActionsDonut',
+ 'ActionsProportionBar',
'ActionsStackedBar',
'ActionsAreaGraph',
'TwoDimensionalHeatmap',
@@ -219,7 +220,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- 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`.'
+ '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- Parts of one whole → `ActionsPie`, `ActionsDonut` or `ActionsProportionBar`.\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.'),
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 c93bc553f1a1..c1a636cf32c9 100644
--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/insight-create.json
+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/insight-create.json
@@ -412,7 +412,7 @@
"type": "object"
},
"display": {
- "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`.",
+ "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- Parts of one whole → `ActionsPie`, `ActionsDonut` or `ActionsProportionBar`.\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",
@@ -422,6 +422,7 @@
"ActionsBarValue",
"ActionsPie",
"ActionsDonut",
+ "ActionsProportionBar",
"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 4e350dbc8c2b..9e8a7f1291b0 100644
--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/insight-update.json
+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/insight-update.json
@@ -423,7 +423,7 @@
"type": "object"
},
"display": {
- "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`.",
+ "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- Parts of one whole → `ActionsPie`, `ActionsDonut` or `ActionsProportionBar`.\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",
@@ -433,6 +433,7 @@
"ActionsBarValue",
"ActionsPie",
"ActionsDonut",
+ "ActionsProportionBar",
"ActionsStackedBar",
"ActionsAreaGraph",
"TwoDimensionalHeatmap",