: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
feat(mcp): expose chart display + formatting settings on insight tools (#60868)
Sam Pennington490a9ad79a02
diff --git a/frontend/src/queries/schema.json b/frontend/src/queries/schema.jsonindex 84bb115b1e1a..88082f27d122 100644--- a/frontend/src/queries/schema.json+++ b/frontend/src/queries/schema.json@@ -1296,6 +1296,23 @@"AssistantDataVisualizationAxisDisplaySettings": {"additionalProperties": false,"properties": {+ "color": {+ "description": "Custom color for this series as a hex string (e.g. `#1d4aff`).",+ "type": "string"+ },+ "displayType": {+ "description": "Override how this individual series is rendered, independent of the chart-level `display` type. Use this to mix series types — e.g. plot one series as `bar` and overlay another as `line`. `auto` follows the chart-level display type.",+ "enum": ["auto", "line", "bar", "area"],+ "type": "string"+ },+ "label": {+ "description": "Custom label for this series, shown in the legend and tooltips instead of the column name.",+ "type": "string"+ },+ "trendLine": {+ "description": "Draw a linear trend line for this series. Only meaningful for line, bar, and area charts.",+ "type": "boolean"+ },"yAxisPosition": {"description": "Which Y axis this numeric series should use. Use `right` for a secondary Y axis.","enum": ["left", "right"],@@ -1304,12 +1321,39 @@},"type": "object"},+ "AssistantDataVisualizationAxisFormatting": {+ "additionalProperties": false,+ "properties": {+ "decimalPlaces": {+ "description": "Number of decimal places to display.",+ "type": "number"+ },+ "prefix": {+ "description": "Text prepended to each value (e.g. `$`).",+ "type": "string"+ },+ "style": {+ "description": "Number formatting style.\n- `none` — no formatting.\n- `number` — thousands separators (e.g. `1,234`).\n- `short` — abbreviated large numbers (e.g. `1.2k`, `3.4M`).\n- `percent` — render the value as a percentage.",+ "enum": ["none", "number", "short", "percent"],+ "type": "string"+ },+ "suffix": {+ "description": "Text appended to each value (e.g. `%` or ` ms`).",+ "type": "string"+ }+ },+ "type": "object"+ },"AssistantDataVisualizationAxisSettings": {"additionalProperties": false,"properties": {"display": {"$ref": "#/definitions/AssistantDataVisualizationAxisDisplaySettings","description": "Display settings for a plotted Y series."+ },+ "formatting": {+ "$ref": "#/definitions/AssistantDataVisualizationAxisFormatting",+ "description": "Number-formatting settings for the values on this axis or series."}},"type": "object"@@ -1344,6 +1388,10 @@"description": "Replace null aggregation results with zero.","type": "boolean"},+ "showValuesOnSeries": {+ "description": "Render each data point's value as a label directly on the series.",+ "type": "boolean"+ },"stackBars100": {"description": "Stack bars to 100% of the total. Only meaningful with `ActionsStackedBar`.","type": "boolean"diff --git a/frontend/src/queries/schema/schema-assistant-queries.ts b/frontend/src/queries/schema/schema-assistant-queries.tsindex 4ba1f2862c20..0d06fdef5419 100644--- a/frontend/src/queries/schema/schema-assistant-queries.ts+++ b/frontend/src/queries/schema/schema-assistant-queries.ts@@ -1491,11 +1491,42 @@ export type AssistantDataVisualizationDisplayType =export interface AssistantDataVisualizationAxisDisplaySettings {/** Which Y axis this numeric series should use. Use `right` for a secondary Y axis. */yAxisPosition?: 'left' | 'right'+ /**+ * Override how this individual series is rendered, independent of the chart-level `display` type.+ * Use this to mix series types — e.g. plot one series as `bar` and overlay another as `line`.+ * `auto` follows the chart-level display type.+ */+ displayType?: 'auto' | 'line' | 'bar' | 'area'+ /** Draw a linear trend line for this series. Only meaningful for line, bar, and area charts. */+ trendLine?: boolean+ /** Custom label for this series, shown in the legend and tooltips instead of the column name. */+ label?: string+ /** Custom color for this series as a hex string (e.g. `#1d4aff`). */+ color?: string+}++export interface AssistantDataVisualizationAxisFormatting {+ /** Text prepended to each value (e.g. `$`). */+ prefix?: string+ /** Text appended to each value (e.g. `%` or ` ms`). */+ suffix?: string+ /**+ * Number formatting style.+ * - `none` — no formatting.+ * - `number` — thousands separators (e.g. `1,234`).+ * - `short` — abbreviated large numbers (e.g. `1.2k`, `3.4M`).+ * - `percent` — render the value as a percentage.+ */+ style?: 'none' | 'number' | 'short' | 'percent'+ /** Number of decimal places to display. */+ decimalPlaces?: number}export interface AssistantDataVisualizationAxisSettings {/** Display settings for a plotted Y series. */display?: AssistantDataVisualizationAxisDisplaySettings+ /** Number-formatting settings for the values on this axis or series. */+ formatting?: AssistantDataVisualizationAxisFormatting}export interface AssistantDataVisualizationAxis {@@ -1547,6 +1578,8 @@ export interface AssistantDataVisualizationChartSettings {stackBars100?: boolean/** Show the chart legend. */showLegend?: boolean+ /** Render each data point's value as a label directly on the series. */+ showValuesOnSeries?: boolean/** Replace null aggregation results with zero. */showNullsAsZero?: boolean}diff --git a/posthog/schema.py b/posthog/schema.pyindex d5b73fa41069..8163bb4608ed 100644--- a/posthog/schema.py+++ b/posthog/schema.py@@ -142,6 +142,13 @@ class Operator(StrEnum):NOT_IN = "not_in"+class DisplayType(StrEnum):+ AUTO = "auto"+ LINE = "line"+ BAR = "bar"+ AREA = "area"++class YAxisPosition(StrEnum):LEFT = "left"RIGHT = "right"@@ -151,12 +158,58 @@ class AssistantDataVisualizationAxisDisplaySettings(BaseModel):model_config = ConfigDict(extra="forbid",)+ color: str | None = Field(+ default=None,+ description="Custom color for this series as a hex string (e.g. `#1d4aff`).",+ )+ displayType: DisplayType | None = Field(+ default=None,+ description=(+ "Override how this individual series is rendered, independent of the"+ " chart-level `display` type. Use this to mix series types — e.g. plot one"+ " series as `bar` and overlay another as `line`. `auto` follows the"+ " chart-level display type."+ ),+ )+ label: str | None = Field(+ default=None,+ description=("Custom label for this series, shown in the legend and tooltips instead of the column name."),+ )+ trendLine: bool | None = Field(+ default=None,+ description=("Draw a linear trend line for this series. Only meaningful for line, bar, and area charts."),+ )yAxisPosition: YAxisPosition | None = Field(default=None,description=("Which Y axis this numeric series should use. Use `right` for a secondary Y axis."),)+class Style(StrEnum):+ NONE = "none"+ NUMBER = "number"+ SHORT = "short"+ PERCENT = "percent"+++class AssistantDataVisualizationAxisFormatting(BaseModel):+ model_config = ConfigDict(+ extra="forbid",+ )+ decimalPlaces: float | None = Field(default=None, description="Number of decimal places to display.")+ prefix: str | None = Field(default=None, description="Text prepended to each value (e.g. `$`).")+ style: Style | None = Field(+ default=None,+ description=(+ "Number formatting style.\n- `none` — no formatting.\n- `number` —"+ " thousands separators (e.g. `1,234`).\n- `short` — abbreviated large"+ " numbers (e.g. `1.2k`, `3.4M`).\n- `percent` — render the value as a"+ " percentage."+ ),+ )+ suffix: str | None = Field(default=None, description="Text appended to each value (e.g. `%` or ` ms`).")++class AssistantDataVisualizationAxisSettings(BaseModel):model_config = ConfigDict(extra="forbid",@@ -164,6 +217,10 @@ class AssistantDataVisualizationAxisSettings(BaseModel):display: AssistantDataVisualizationAxisDisplaySettings | None = Field(default=None, description="Display settings for a plotted Y series.")+ formatting: AssistantDataVisualizationAxisFormatting | None = Field(+ default=None,+ description="Number-formatting settings for the values on this axis or series.",+ )class AssistantDataVisualizationDisplayType(StrEnum):@@ -1014,13 +1071,6 @@ class ChartDisplayType(StrEnum):BOX_PLOT = "BoxPlot"-class DisplayType(StrEnum):- AUTO = "auto"- LINE = "line"- BAR = "bar"- AREA = "area"--class ChartSettingsDisplay(BaseModel):model_config = ConfigDict(extra="forbid",@@ -1032,13 +1082,6 @@ class ChartSettingsDisplay(BaseModel):yAxisPosition: YAxisPosition | None = None-class Style(StrEnum):- NONE = "none"- NUMBER = "number"- SHORT = "short"- PERCENT = "percent"--class ChartSettingsFormatting(BaseModel):model_config = ConfigDict(extra="forbid",@@ -5627,6 +5670,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.")+ showValuesOnSeries: bool | None = Field(+ default=None,+ description="Render each data point's value as a label directly on the series.",+ )stackBars100: bool | None = Field(default=None,description=("Stack bars to 100% of the total. Only meaningful with `ActionsStackedBar`."),diff --git a/services/mcp/src/tools/generated/product_analytics.ts b/services/mcp/src/tools/generated/product_analytics.tsindex 934eecc596fd..08028df5a4c9 100644--- a/services/mcp/src/tools/generated/product_analytics.ts+++ b/services/mcp/src/tools/generated/product_analytics.ts@@ -42,16 +42,46 @@ const AssistantDataVisualizationYAxisSettings = z.object({})const AssistantDataVisualizationAxisDisplaySettings = z.object({+ color: z.string().describe('Custom color for this series as a hex string (e.g. `#1d4aff`).').optional(),+ displayType: z+ .enum(['auto', 'line', 'bar', 'area'])+ .describe(+ 'Override how this individual series is rendered, independent of the chart-level `display` type. Use this to mix series types — e.g. plot one series as `bar` and overlay another as `line`. `auto` follows the chart-level display type.'+ )+ .optional(),+ label: z+ .string()+ .describe('Custom label for this series, shown in the legend and tooltips instead of the column name.')+ .optional(),+ trendLine: z.coerce+ .boolean()+ .describe('Draw a linear trend line for this series. Only meaningful for line, bar, and area charts.')+ .optional(),yAxisPosition: z.enum(['left', 'right']).describe('Which Y axis this numeric series should use. Use `right` for a secondary Y axis.').optional(),})+const AssistantDataVisualizationAxisFormatting = z.object({+ decimalPlaces: z.coerce.number().describe('Number of decimal places to display.').optional(),+ prefix: z.string().describe('Text prepended to each value (e.g. `$`).').optional(),+ style: z+ .enum(['none', 'number', 'short', 'percent'])+ .describe(+ 'Number formatting style.\n- `none` — no formatting.\n- `number` — thousands separators (e.g. `1,234`).\n- `short` — abbreviated large numbers (e.g. `1.2k`, `3.4M`).\n- `percent` — render the value as a percentage.'+ )+ .optional(),+ suffix: z.string().describe('Text appended to each value (e.g. `%` or ` ms`).').optional(),+})+const AssistantDataVisualizationAxisSettings = z.object({display: AssistantDataVisualizationAxisDisplaySettings.describe('Display settings for a plotted Y series.').optional(),+ formatting: AssistantDataVisualizationAxisFormatting.describe(+ 'Number-formatting settings for the values on this axis or series.'+ ).optional(),})const AssistantDataVisualizationAxis = z.object({@@ -79,6 +109,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(),+ showValuesOnSeries: z.coerce+ .boolean()+ .describe("Render each data point's value as a label directly on the series.")+ .optional(),stackBars100: z.coerce.boolean().describe('Stack bars to 100% of the total. Only meaningful with `ActionsStackedBar`.')diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/insight-create.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/insight-create.jsonindex 8a7a67b296d2..c1712a93f0ca 100644--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/insight-create.json+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/insight-create.json@@ -150,6 +150,10 @@"description": "Replace null aggregation results with zero.","type": "boolean"},+ "showValuesOnSeries": {+ "description": "Render each data point's value as a label directly on the series.",+ "type": "boolean"+ },"stackBars100": {"description": "Stack bars to 100% of the total. Only meaningful with `ActionsStackedBar`.","type": "boolean"@@ -167,6 +171,23 @@"display": {"description": "Display settings for a plotted Y series.","properties": {+ "color": {+ "description": "Custom color for this series as a hex string (e.g. `#1d4aff`).",+ "type": "string"+ },+ "displayType": {+ "description": "Override how this individual series is rendered, independent of the chart-level `display` type. Use this to mix series types — e.g. plot one series as `bar` and overlay another as `line`. `auto` follows the chart-level display type.",+ "enum": ["auto", "line", "bar", "area"],+ "type": "string"+ },+ "label": {+ "description": "Custom label for this series, shown in the legend and tooltips instead of the column name.",+ "type": "string"+ },+ "trendLine": {+ "description": "Draw a linear trend line for this series. Only meaningful for line, bar, and area charts.",+ "type": "boolean"+ },"yAxisPosition": {"description": "Which Y axis this numeric series should use. Use `right` for a secondary Y axis.","enum": ["left", "right"],@@ -174,6 +195,29 @@}},"type": "object"+ },+ "formatting": {+ "description": "Number-formatting settings for the values on this axis or series.",+ "properties": {+ "decimalPlaces": {+ "description": "Number of decimal places to display.",+ "type": "number"+ },+ "prefix": {+ "description": "Text prepended to each value (e.g. `$`).",+ "type": "string"+ },+ "style": {+ "description": "Number formatting style.\n- `none` — no formatting.\n- `number` — thousands separators (e.g. `1,234`).\n- `short` — abbreviated large numbers (e.g. `1.2k`, `3.4M`).\n- `percent` — render the value as a percentage.",+ "enum": ["none", "number", "short", "percent"],+ "type": "string"+ },+ "suffix": {+ "description": "Text appended to each value (e.g. `%` or ` ms`).",+ "type": "string"+ }+ },+ "type": "object"}},"type": "object"@@ -200,6 +244,23 @@"display": {"description": "Display settings for a plotted Y series.","properties": {+ "color": {+ "description": "Custom color for this series as a hex string (e.g. `#1d4aff`).",+ "type": "string"+ },+ "displayType": {+ "description": "Override how this individual series is rendered, independent of the chart-level `display` type. Use this to mix series types — e.g. plot one series as `bar` and overlay another as `line`. `auto` follows the chart-level display type.",+ "enum": ["auto", "line", "bar", "area"],+ "type": "string"+ },+ "label": {+ "description": "Custom label for this series, shown in the legend and tooltips instead of the column name.",+ "type": "string"+ },+ "trendLine": {+ "description": "Draw a linear trend line for this series. Only meaningful for line, bar, and area charts.",+ "type": "boolean"+ },"yAxisPosition": {"description": "Which Y axis this numeric series should use. Use `right` for a secondary Y axis.","enum": ["left", "right"],@@ -207,6 +268,29 @@}},"type": "object"+ },+ "formatting": {+ "description": "Number-formatting settings for the values on this axis or series.",+ "properties": {+ "decimalPlaces": {+ "description": "Number of decimal places to display.",+ "type": "number"+ },+ "prefix": {+ "description": "Text prepended to each value (e.g. `$`).",+ "type": "string"+ },+ "style": {+ "description": "Number formatting style.\n- `none` — no formatting.\n- `number` — thousands separators (e.g. `1,234`).\n- `short` — abbreviated large numbers (e.g. `1.2k`, `3.4M`).\n- `percent` — render the value as a percentage.",+ "enum": ["none", "number", "short", "percent"],+ "type": "string"+ },+ "suffix": {+ "description": "Text appended to each value (e.g. `%` or ` ms`).",+ "type": "string"+ }+ },+ "type": "object"}},"type": "object"@@ -263,6 +347,23 @@"display": {"description": "Display settings for a plotted Y series.","properties": {+ "color": {+ "description": "Custom color for this series as a hex string (e.g. `#1d4aff`).",+ "type": "string"+ },+ "displayType": {+ "description": "Override how this individual series is rendered, independent of the chart-level `display` type. Use this to mix series types — e.g. plot one series as `bar` and overlay another as `line`. `auto` follows the chart-level display type.",+ "enum": ["auto", "line", "bar", "area"],+ "type": "string"+ },+ "label": {+ "description": "Custom label for this series, shown in the legend and tooltips instead of the column name.",+ "type": "string"+ },+ "trendLine": {+ "description": "Draw a linear trend line for this series. Only meaningful for line, bar, and area charts.",+ "type": "boolean"+ },"yAxisPosition": {"description": "Which Y axis this numeric series should use. Use `right` for a secondary Y axis.","enum": ["left", "right"],@@ -270,6 +371,29 @@}},"type": "object"+ },+ "formatting": {+ "description": "Number-formatting settings for the values on this axis or series.",+ "properties": {+ "decimalPlaces": {+ "description": "Number of decimal places to display.",+ "type": "number"+ },+ "prefix": {+ "description": "Text prepended to each value (e.g. `$`).",+ "type": "string"+ },+ "style": {+ "description": "Number formatting style.\n- `none` — no formatting.\n- `number` — thousands separators (e.g. `1,234`).\n- `short` — abbreviated large numbers (e.g. `1.2k`, `3.4M`).\n- `percent` — render the value as a percentage.",+ "enum": ["none", "number", "short", "percent"],+ "type": "string"+ },+ "suffix": {+ "description": "Text appended to each value (e.g. `%` or ` ms`).",+ "type": "string"+ }+ },+ "type": "object"}},"type": "object"diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/insight-update.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/insight-update.jsonindex 03ba4bf77d8e..0c772f033b77 100644--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/insight-update.json+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/insight-update.json@@ -161,6 +161,10 @@"description": "Replace null aggregation results with zero.","type": "boolean"},+ "showValuesOnSeries": {+ "description": "Render each data point's value as a label directly on the series.",+ "type": "boolean"+ },"stackBars100": {"description": "Stack bars to 100% of the total. Only meaningful with `ActionsStackedBar`.","type": "boolean"@@ -178,6 +182,23 @@"display": {"description": "Display settings for a plotted Y series.","properties": {+ "color": {+ "description": "Custom color for this series as a hex string (e.g. `#1d4aff`).",+ "type": "string"+ },+ "displayType": {+ "description": "Override how this individual series is rendered, independent of the chart-level `display` type. Use this to mix series types — e.g. plot one series as `bar` and overlay another as `line`. `auto` follows the chart-level display type.",+ "enum": ["auto", "line", "bar", "area"],+ "type": "string"+ },+ "label": {+ "description": "Custom label for this series, shown in the legend and tooltips instead of the column name.",+ "type": "string"+ },+ "trendLine": {+ "description": "Draw a linear trend line for this series. Only meaningful for line, bar, and area charts.",+ "type": "boolean"+ },"yAxisPosition": {"description": "Which Y axis this numeric series should use. Use `right` for a secondary Y axis.","enum": ["left", "right"],@@ -185,6 +206,29 @@}},"type": "object"+ },+ "formatting": {+ "description": "Number-formatting settings for the values on this axis or series.",+ "properties": {+ "decimalPlaces": {+ "description": "Number of decimal places to display.",+ "type": "number"+ },+ "prefix": {+ "description": "Text prepended to each value (e.g. `$`).",+ "type": "string"+ },+ "style": {+ "description": "Number formatting style.\n- `none` — no formatting.\n- `number` — thousands separators (e.g. `1,234`).\n- `short` — abbreviated large numbers (e.g. `1.2k`, `3.4M`).\n- `percent` — render the value as a percentage.",+ "enum": ["none", "number", "short", "percent"],+ "type": "string"+ },+ "suffix": {+ "description": "Text appended to each value (e.g. `%` or ` ms`).",+ "type": "string"+ }+ },+ "type": "object"}},"type": "object"@@ -211,6 +255,23 @@"display": {"description": "Display settings for a plotted Y series.","properties": {+ "color": {+ "description": "Custom color for this series as a hex string (e.g. `#1d4aff`).",+ "type": "string"+ },+ "displayType": {+ "description": "Override how this individual series is rendered, independent of the chart-level `display` type. Use this to mix series types — e.g. plot one series as `bar` and overlay another as `line`. `auto` follows the chart-level display type.",+ "enum": ["auto", "line", "bar", "area"],+ "type": "string"+ },+ "label": {+ "description": "Custom label for this series, shown in the legend and tooltips instead of the column name.",+ "type": "string"+ },+ "trendLine": {+ "description": "Draw a linear trend line for this series. Only meaningful for line, bar, and area charts.",+ "type": "boolean"+ },"yAxisPosition": {"description": "Which Y axis this numeric series should use. Use `right` for a secondary Y axis.","enum": ["left", "right"],@@ -218,6 +279,29 @@}},"type": "object"+ },+ "formatting": {+ "description": "Number-formatting settings for the values on this axis or series.",+ "properties": {+ "decimalPlaces": {+ "description": "Number of decimal places to display.",+ "type": "number"+ },+ "prefix": {+ "description": "Text prepended to each value (e.g. `$`).",+ "type": "string"+ },+ "style": {+ "description": "Number formatting style.\n- `none` — no formatting.\n- `number` — thousands separators (e.g. `1,234`).\n- `short` — abbreviated large numbers (e.g. `1.2k`, `3.4M`).\n- `percent` — render the value as a percentage.",+ "enum": ["none", "number", "short", "percent"],+ "type": "string"+ },+ "suffix": {+ "description": "Text appended to each value (e.g. `%` or ` ms`).",+ "type": "string"+ }+ },+ "type": "object"}},"type": "object"@@ -274,6 +358,23 @@"display": {"description": "Display settings for a plotted Y series.","properties": {+ "color": {+ "description": "Custom color for this series as a hex string (e.g. `#1d4aff`).",+ "type": "string"+ },+ "displayType": {+ "description": "Override how this individual series is rendered, independent of the chart-level `display` type. Use this to mix series types — e.g. plot one series as `bar` and overlay another as `line`. `auto` follows the chart-level display type.",+ "enum": ["auto", "line", "bar", "area"],+ "type": "string"+ },+ "label": {+ "description": "Custom label for this series, shown in the legend and tooltips instead of the column name.",+ "type": "string"+ },+ "trendLine": {+ "description": "Draw a linear trend line for this series. Only meaningful for line, bar, and area charts.",+ "type": "boolean"+ },"yAxisPosition": {"description": "Which Y axis this numeric series should use. Use `right` for a secondary Y axis.","enum": ["left", "right"],@@ -281,6 +382,29 @@}},"type": "object"+ },+ "formatting": {+ "description": "Number-formatting settings for the values on this axis or series.",+ "properties": {+ "decimalPlaces": {+ "description": "Number of decimal places to display.",+ "type": "number"+ },+ "prefix": {+ "description": "Text prepended to each value (e.g. `$`).",+ "type": "string"+ },+ "style": {+ "description": "Number formatting style.\n- `none` — no formatting.\n- `number` — thousands separators (e.g. `1,234`).\n- `short` — abbreviated large numbers (e.g. `1.2k`, `3.4M`).\n- `percent` — render the value as a percentage.",+ "enum": ["none", "number", "short", "percent"],+ "type": "string"+ },+ "suffix": {+ "description": "Text appended to each value (e.g. `%` or ` ms`).",+ "type": "string"+ }+ },+ "type": "object"}},"type": "object"