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.

fix(mcp): move showTotalRow to chart settings in insight schema (#70462)

posthog[bot]bf790736c5ae
diff --git a/frontend/src/queries/schema.json b/frontend/src/queries/schema.json
index fac31e4343f5..20619ce45c7a 100644
--- a/frontend/src/queries/schema.json
+++ b/frontend/src/queries/schema.json
@@ -1555,6 +1555,10 @@
"description": "Replace null aggregation results with zero.",
"type": "boolean"
},
+ "showTotalRow": {
+ "description": "Show a total summing all Y series. Applies to line, bar, and area charts.",
+ "type": "boolean"
+ },
"showValuesOnSeries": {
"description": "Render each data point's value as a label directly on the series.",
"type": "boolean"
@@ -1655,10 +1659,6 @@
},
"type": "array"
},
- "showTotalRow": {
- "description": "Show a total row at the bottom of the table.",
- "type": "boolean"
- },
"transpose": {
"description": "Transpose rows and columns.",
"type": "boolean"
diff --git a/frontend/src/queries/schema/schema-assistant-queries.ts b/frontend/src/queries/schema/schema-assistant-queries.ts
index f368be43e703..25a6228baafb 100644
--- a/frontend/src/queries/schema/schema-assistant-queries.ts
+++ b/frontend/src/queries/schema/schema-assistant-queries.ts
@@ -1816,6 +1816,8 @@ export interface AssistantDataVisualizationChartSettings {
showValuesOnSeries?: boolean
/** Replace null aggregation results with zero. */
showNullsAsZero?: boolean
+ /** Show a total summing all Y series. Applies to line, bar, and area charts. */
+ showTotalRow?: boolean
}
export interface AssistantDataVisualizationTableSettings {
@@ -1823,8 +1825,6 @@ export interface AssistantDataVisualizationTableSettings {
columns?: AssistantDataVisualizationAxis[]
/** Column names to pin to the left of the table. */
pinnedColumns?: string[]
- /** Show a total row at the bottom of the table. */
- showTotalRow?: boolean
/** Transpose rows and columns. */
transpose?: boolean
}
diff --git a/posthog/schema.py b/posthog/schema.py
index ed93f0f9562e..babc8ee847f5 100644
--- a/posthog/schema.py
+++ b/posthog/schema.py
@@ -3032,6 +3032,10 @@ class AssistantDataVisualizationChartSettings(BaseModel):
)
showLegend: bool | None = Field(default=None, description="Show the chart legend.")
showNullsAsZero: bool | None = Field(default=None, description="Replace null aggregation results with zero.")
+ showTotalRow: bool | None = Field(
+ default=None,
+ description=("Show a total summing all Y series. Applies to line, bar, and area charts."),
+ )
showValuesOnSeries: bool | None = Field(
default=None,
description="Render each data point's value as a label directly on the series.",
@@ -3059,7 +3063,6 @@ class AssistantDataVisualizationTableSettings(BaseModel):
description=("Columns to display and their order. Omit to show every column returned by the query."),
)
pinnedColumns: list[str] | None = Field(default=None, description="Column names to pin to the left of the table.")
- showTotalRow: bool | None = Field(default=None, description="Show a total row at the bottom of the table.")
transpose: bool | None = Field(default=None, description="Transpose rows and columns.")
diff --git a/posthog/test/test_assistant_dataviz_schema_contract.py b/posthog/test/test_assistant_dataviz_schema_contract.py
new file mode 100644
index 000000000000..7480906785f2
--- /dev/null
+++ b/posthog/test/test_assistant_dataviz_schema_contract.py
@@ -0,0 +1,32 @@
+from django.test.testcases import SimpleTestCase
+
+from posthog.schema import (
+ AssistantDataVisualizationChartSettings,
+ AssistantDataVisualizationTableSettings,
+ ChartSettings,
+ TableSettings,
+)
+
+# The assistant-facing DataVisualizationNode (produced by Max and the insight MCP tools) is
+# validated on save against the real DataVisualizationNode, whose ChartSettings/TableSettings
+# are `extra="forbid"`. Any assistant field not present on its real counterpart is rejected as
+# an extra property, so a schema-following caller hits a validation error. These tests keep the
+# advertised assistant fields a strict subset of what the API actually accepts.
+
+
+class TestAssistantDataVizSchemaContract(SimpleTestCase):
+ def test_assistant_chart_settings_are_accepted_by_real_chart_settings(self) -> None:
+ extra = set(AssistantDataVisualizationChartSettings.model_fields) - set(ChartSettings.model_fields)
+ self.assertEqual(
+ extra,
+ set(),
+ f"AssistantDataVisualizationChartSettings advertises fields ChartSettings rejects: {sorted(extra)}",
+ )
+
+ def test_assistant_table_settings_are_accepted_by_real_table_settings(self) -> None:
+ extra = set(AssistantDataVisualizationTableSettings.model_fields) - set(TableSettings.model_fields)
+ self.assertEqual(
+ extra,
+ set(),
+ f"AssistantDataVisualizationTableSettings advertises fields TableSettings rejects: {sorted(extra)}",
+ )
diff --git a/services/mcp/src/tools/generated/product_analytics.ts b/services/mcp/src/tools/generated/product_analytics.ts
index f7837f37c25c..cbe8697936ef 100644
--- a/services/mcp/src/tools/generated/product_analytics.ts
+++ b/services/mcp/src/tools/generated/product_analytics.ts
@@ -110,6 +110,10 @@ const AssistantDataVisualizationChartSettings = z.object({
.optional(),
showLegend: z.coerce.boolean().describe('Show the chart legend.').optional(),
showNullsAsZero: z.coerce.boolean().describe('Replace null aggregation results with zero.').optional(),
+ showTotalRow: z.coerce
+ .boolean()
+ .describe('Show a total summing all Y series. Applies to line, bar, and area charts.')
+ .optional(),
showValuesOnSeries: z.coerce
.boolean()
.describe("Render each data point's value as a label directly on the series.")
@@ -145,7 +149,6 @@ const AssistantDataVisualizationTableSettings = z.object({
.describe('Columns to display and their order. Omit to show every column returned by the query.')
.optional(),
pinnedColumns: z.array(z.string()).describe('Column names to pin to the left of the table.').optional(),
- showTotalRow: z.coerce.boolean().describe('Show a total row at the bottom of the table.').optional(),
transpose: z.coerce.boolean().describe('Transpose rows and columns.').optional(),
})
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 d6da833dfd6a..f9e8d8de6d8a 100644
--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/insight-create.json
+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/insight-create.json
@@ -151,6 +151,10 @@
"description": "Replace null aggregation results with zero.",
"type": "boolean"
},
+ "showTotalRow": {
+ "description": "Show a total summing all Y series. Applies to line, bar, and area charts.",
+ "type": "boolean"
+ },
"showValuesOnSeries": {
"description": "Render each data point's value as a label directly on the series.",
"type": "boolean"
@@ -413,10 +417,6 @@
},
"type": "array"
},
- "showTotalRow": {
- "description": "Show a total row at the bottom of the table.",
- "type": "boolean"
- },
"transpose": {
"description": "Transpose rows and columns.",
"type": "boolean"
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 4b257e9f6697..1000c5a4f11d 100644
--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/insight-update.json
+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/insight-update.json
@@ -162,6 +162,10 @@
"description": "Replace null aggregation results with zero.",
"type": "boolean"
},
+ "showTotalRow": {
+ "description": "Show a total summing all Y series. Applies to line, bar, and area charts.",
+ "type": "boolean"
+ },
"showValuesOnSeries": {
"description": "Render each data point's value as a label directly on the series.",
"type": "boolean"
@@ -424,10 +428,6 @@
},
"type": "array"
},
- "showTotalRow": {
- "description": "Show a total row at the bottom of the table.",
- "type": "boolean"
- },
"transpose": {
"description": "Transpose rows and columns.",
"type": "boolean"