feat(mcp): expose chart display + formatting settings on insight tools#60868
Merged
Conversation
The agent-facing `AssistantDataVisualization*` schema that the MCP `insight-create` / `insight-update` tools validate against only exposed `yAxisPosition` under a series' display settings, even though the backend `DataVisualizationNode` accepts the full `ChartSettingsDisplay`. Agents could not toggle a trend line (or set most display options) on a SQL insight without the strict Zod layer rejecting the field before it reached Django. Enrich the agent schema to match what the backend already supports: - per-series display: `trendLine`, `displayType` (mix line/bar/area), `label`, `color` (in addition to `yAxisPosition`) - per-series/axis number `formatting`: `prefix`, `suffix`, `style`, `decimalPlaces` - chart-level `showValuesOnSeries` Each field carries a docstring so the generated MCP tool schema documents valid options for agents. Regenerated schema.json, schema.py, the MCP tool Zod, and the tool-schema snapshots. Generated-By: PostHog Code Task-Id: 563610e9-d6a9-45ef-962e-8b92a573cca6
Contributor
|
Size Change: +4.78 kB (+0.01%) Total Size: 80.9 MB 📦 View Changed
ℹ️ View Unchanged
|
Contributor
|
Reviews (1): Last reviewed commit: "feat(llma): expose chart display + forma..." | Re-trigger Greptile |
…t-display-settings
Contributor
There was a problem hiding this comment.
Purely additive, optional schema fields for the LLM analytics assistant. The DisplayType and Style enum moves in schema.py are a clean consolidation (moved up to be shared), all new fields default to None, and all six files (Python schema, TS types, JSON schema, MCP Zod tool, and two test snapshots) are kept consistent with each other.
Contributor
|
🎭 Playwright report · View test results →
These issues are not necessarily caused by your changes. |
inkeep Bot
added a commit
to PostHog/posthog.com
that referenced
this pull request
Jun 1, 2026
Document the per-series display settings (displayType, trendLine, label, color, yAxisPosition), number formatting (prefix, suffix, style, decimalPlaces), and chart-level showValuesOnSeries that are now available on the insight-create and insight-update MCP tools for SQL-backed insights. Ref: PostHog/posthog#60868
MattPua
pushed a commit
that referenced
this pull request
Jun 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Updating the display settings of a SQL-backed (DataVisualization) insight through the PostHog MCP was unnecessarily hard. The agent-facing
AssistantDataVisualization*schema — which theinsight-createandinsight-updatetools validate against — only exposedyAxisPositionunder a series' display settings, even though the backendDataVisualizationNodealready accepts the fullChartSettingsDisplay(trendLine,displayType,label,color, …) plus per-series number formatting.Because the strict Zod layer used
additionalProperties: false, an agent trying to turn on a trend line had every reason to expect the field to be stripped or rejected before the request reached Django. The change happened to pass, but only by sending an undocumented field — agents had to hedge and verify rather than trust the schema.Changes
Enriched the agent-facing DataVisualization insight schema (
schema-assistant-queries.ts) to surface the display settings the backend already supports, so they flow throughinsight-create/insight-updatewith documented, validated fields:trendLine,displayType(auto/line/bar/area, to mix series types),label,color— alongside the existingyAxisPosition.formattingblock withprefix,suffix,style(none/number/short/percent), anddecimalPlaces.showValuesOnSeries.Every field carries a docstring, which flows into the generated MCP tool schema so agents see exactly what's valid.
Regenerated all downstream artifacts from the source type:
schema.json,schema.py, the MCP tool Zod (services/mcp/src/tools/generated/product_analytics.ts), and the tool-schema snapshots.How did you test this code?
I'm an agent. I ran the following automated checks — no manual UI testing:
pnpm --filter=@posthog/mcp run vitest run tests/unit/tool-schema-snapshots.test.ts tests/unit/json-schema-to-zod.test.ts— pass (snapshots regenerated to include the new fields).tsc --noEmiton the MCP package — no errors in the regenerated tool file (only pre-existing, unrelated@posthog/quillmodule-resolution errors in this environment).python3 -m py_compile posthog/schema.py— pass.schema.json,schema.py, the generated Zod, and both insight tool snapshots.🤖 Agent context
Authored by PostHog Code (Claude). The task came from a session where adding a trend line to a SQL insight via MCP took longer than it should have, largely because the curated
insight-updateschema appeared to forbidtrendLine.Approach: traced the codegen chain (
schema-assistant-queries.ts→schema.json→schema.py+ generated MCP Zod) and confirmed the gap was only in the agent-facingAssistant*subset, not the backend. Rather than add onlytrendLine, I brought the agent schema in line with the backend'sChartSettingsDisplayand added per-series formatting +showValuesOnSeries, since the same friction applied to every display option. The generatedproduct_analytics.tswas updated by reproducing the deterministic codegen output (the OpenAPI step that normally regenerates it needs a full Django+DB stack) and re-running the project formatter; CI'sbuild:openapiwill reconcile it if anything drifts.Created with PostHog Code