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.

chore(llma): render real MCP visualizers in storybook snapshots (#63576)

Sam Penningtonf249809eccc0
diff --git a/common/storybook/.storybook/main.ts b/common/storybook/.storybook/main.ts
index 2ded002a4d21..0c7995db6167 100644
--- a/common/storybook/.storybook/main.ts
+++ b/common/storybook/.storybook/main.ts
@@ -15,6 +15,7 @@ const config: StorybookConfig = {
'../../../products/**/frontend/**/*.stories.@(js|jsx|ts|tsx)',
'../../../products/**/mcp/**/*.mdx',
'../../../products/**/mcp/**/*.stories.@(js|jsx|ts|tsx)',
+ '../../../services/mcp/src/ui-apps/**/*.stories.@(js|jsx|ts|tsx)',
'../../../packages/quill/packages/charts/src/**/*.mdx',
'../../../packages/quill/packages/charts/src/**/*.stories.@(js|jsx|ts|tsx)',
],
diff --git a/frontend/snapshots.yml b/frontend/snapshots.yml
index 29095629144d..285df19d6886 100644
--- a/frontend/snapshots.yml
+++ b/frontend/snapshots.yml
@@ -3953,13 +3953,13 @@ snapshots:
mcp-apps-feature-flags--testing-no-match--light:
hash: v1.k794b7964.b5eec4d4100dc834d4c7c891e4962c9effa643ff190f3b0957d816d82ebb7269.9Hg0pCpNp895WlYr8k2m97K0fvniLuzPcRSAIWUCtg8
mcp-apps-funnels--steep-dropoff--light:
- hash: v1.k794b7964.923aafaf8e1bce9f1caa2410cd58f7378ff97f8e9fb569e0ce18b45dfb885ff8.osZQjoZOyTIkZuiFFYz_vt8LWPp7oKhCd1an1UQjLwM
+ hash: v1.k794b7964.cc26937830dc95deb164b13bda7327a6a7bed094f2670332b6ea0885ffb15733.j8pxbf3h92E8pkD9KCSQrlBeFY3UUEmF7E_6XJg47kQ
mcp-apps-funnels--three-step--light:
- hash: v1.k794b7964.f19f626d5aff4b6ca134f18575cc7f0427aa30320a4c180c48350fef19e49de5.4R95Zy0oSa_HwNB7qItvpvI6lWU2o78sUz8s86Edgao
+ hash: v1.k794b7964.a4cf6cff88ffb74e40e2dbe91cc266054f699eeae2d39d40019f3ed184ba030e.g12F2_uMZw3-VDO3TX1BqQu01X5UDRFTag0fO0WcrTc
mcp-apps-lifecycle--grouped--light:
- hash: v1.k794b7964.fd7ea8e18d9ce39a5f3285f10164895250c2be53767f73f7ea0ce773db91ebdb.6zCk5Rp1GyfhWuNTJmlel2BI0JCMDdG3_SBdCs_DC1k
+ hash: v1.k794b7964.fa32f317c7015ae73b5b5c38e11209e6a51967de4e0457ae29f7eedb8ea8fce8._OUjY62EdIDs4LQbOyr1ORBmTYMn9AZ5BHWC9e4Bx5c
mcp-apps-lifecycle--stacked--light:
- hash: v1.k794b7964.e2a2db105f8ab13b4135a14656bd4882bee8ff014a5e1d03c457664795aa2727.dh6W8kx-RdFESmR8NhgdNMyjlBMEv1Fup6xuv9CwMWQ
+ hash: v1.k794b7964.9ae65eadce145d0cbade09760b4d774eab2861bf0bf9bd0bdf36f1dd1389a620.qYdACXQ2q-w43FAjwS-g7JDwiZiGs6-Mc5lsUs79byA
mcp-apps-surveys--active-popover--light:
hash: v1.k794b7964.c47633461e9a437f0761e09f795eb793b02ed0bac4489ce757a5837dbaa3f847.wclUgXFjBkoHXJLNP2R3ncawfRArgVyVEUWbIiQve0o
mcp-apps-surveys--completed--light:
@@ -3971,17 +3971,17 @@ snapshots:
mcp-apps-surveys--stats--light:
hash: v1.k794b7964.da67b48f277665016d143ea09d4471ca6f01f3b8a6d22e7fe0f3dc51b075e92a.l81wzNlVna0bTrWF2HHg1RkJaB7vXRpAIdMbNylhzCw
mcp-apps-trends--area-chart--light:
- hash: v1.k794b7964.6cf42e74cc7686abba8123717fd06198df9cec15b137857ebeff6a41d882f588.bIEusW4n6ate8V8Ujn33aEEEuqxdLQFibt6BcBUnK1g
+ hash: v1.k794b7964.a999deccedf5244f57f6566d676aacadc4ef4c94722473c68df6c554bd87ad3e.ZHF5IaBqQ0FqN3hgvVZVeLUVvbFI4-7lpT-kWfJFcow
mcp-apps-trends--bar-value-few-series--light:
- hash: v1.k794b7964.0306912db87cc31480193197f8836a77bdb605eddff02f4f3a49513ea0607ffa.7eggN7eGBfu9J82WduiVyY_KMUPBFlus190tJfCKdnc
+ hash: v1.k794b7964.17235de255bc7d04240957e537b7bc76027c19471525218a28582af1298cd0b3.aA5Dz0x9KR6knEKP4CvKEtRoVS7z6TeKEtTY4_qoML0
mcp-apps-trends--bar-value-many-breakdowns--light:
- hash: v1.k794b7964.55d92ceb29c5fedf37ed82999dcb4d0a1122cead487ed73a8e8891cc4ce89ea2.zCQNhUwqzZqBkFs-rbqKBENtndciu2imsafQHGtsrsA
+ hash: v1.k794b7964.407f0a6b71b45525e4d45d20e1e6af8f0b7a4345748af552b53df223fbcf576a.GnlWLZvvw78tfb9YT0og22-n8GDKTQs3487BrZiQi_8
mcp-apps-trends--multi-series--light:
- hash: v1.k794b7964.2622c6a6026ee9a0afdee272a93207428b6b162319c26f749f720301e95295b3.ud_GEZpQP8zR9kgPkMECKr09f544GEqMjVQzKPe-Zec
+ hash: v1.k794b7964.b3592fc2ce95288f8ca5aeccf3333734383d51c13e4bd495cac91285b6d894d1.26ymJ354sVR0hF1sQR3_Py4lPCNLBQI-d5qUWoBinvc
mcp-apps-trends--single-series--light:
- hash: v1.k794b7964.6a6c47fecbb703e86c25c3fe051fd016603be281e123505f65056572c419c097.R1RwU-Cl_QiDuRrQnQCkUIgUo-rYmTLyhct9aBLwxV0
+ hash: v1.k794b7964.0237d655cb884729a1b01cd8d4bcbc2300e3bb42a6c6bc3f89c70cd206cc91ba.1vqtb4aI3CDKE_XTPD4SOrHfS57ty28sbg1OwXiLcX8
mcp-apps-trends--time-series-bar--light:
- hash: v1.k794b7964.e1e30210da96cd145f00b28d397e041d7128d7c1710981f2b88d217e99c23548.JkBseKZcpx1MlLiHgkFgcFCobn6ZL0U7U9BoDuNJemg
+ hash: v1.k794b7964.36adcc571f4e889579cad4209857a6f63b5cb350adf7d0ccfeba9510360a689c.Ftkx3aKLXu_zFVXyG3nXcz5Syk9oU3OkOXrDSy2QujE
mcp-apps-workflows--active--light:
hash: v1.k794b7964.ad71858e2dc5a45e3d81bb38d46ad3bbe2dea9c152b625fbbf93117a27e624ca.Z4AVu3aic8bdKuv98SD1V1ZqQXsxPwGX2mZl3cL31bs
mcp-apps-workflows--archived--light:
diff --git a/products/product_analytics/mcp/apps/Funnels.stories.tsx b/products/product_analytics/mcp/apps/Funnels.stories.tsx
deleted file mode 100644
index c163c2aea95f..000000000000
--- a/products/product_analytics/mcp/apps/Funnels.stories.tsx
+++ /dev/null
@@ -1,94 +0,0 @@
-import type { Meta, StoryObj } from '@storybook/react'
-import type { ReactElement } from 'react'
-
-import { CHART_THEME, FUNNEL_COLOR } from '@posthog/mcp-ui'
-import { McpThemeDecorator } from '@posthog/mcp-ui/storybook/decorator'
-import { BarChart, type TooltipContext, TooltipSurface } from '@posthog/quill-charts'
-
-import {
- buildFunnelStepsBarConfig,
- buildFunnelStepsBars,
- type FunnelStepsBarRow,
-} from '../../frontend/insights/funnels/shared/funnelStepsBarShared'
-
-const NOOP = (): void => {}
-
-const CHART_CONFIG = buildFunnelStepsBarConfig({ maxCategoryLabelWidth: 120, tooltipPlacement: 'cursor' })
-
-function renderTooltip(rows: FunnelStepsBarRow[]) {
- return function FunnelTooltip(ctx: TooltipContext): ReactElement | null {
- const row = rows[ctx.dataIndex]
- if (!row) {
- return null
- }
- return (
- <TooltipSurface>
- <div className="font-semibold mb-1">
- {row.stepIndex + 1}. {row.name}
- </div>
- <div>
- {row.count.toLocaleString()} ({Math.round(row.fractionOfBasis * 100)}% of first step)
- </div>
- </TooltipSurface>
- )
- }
-}
-
-const meta: Meta = {
- title: 'MCP Apps/Funnels',
- decorators: [McpThemeDecorator],
- parameters: {
- testOptions: {
- skipDarkMode: true,
- },
- },
-}
-export default meta
-
-type Story = StoryObj<{}>
-
-// Fixed pixel size, not width:100% — the chart sizes its canvas off a ResizeObserver, which measures
-// 0 for a percentage width at mount in the headless snapshot runner and draws nothing.
-function FunnelDemo({ steps }: { steps: { name: string; count: number }[] }): ReactElement {
- const { series, labels, rows } = buildFunnelStepsBars(steps, { color: FUNNEL_COLOR })
- return (
- // eslint-disable-next-line react/forbid-dom-props
- <div style={{ width: 640, height: 320, display: 'flex', flexDirection: 'column' }}>
- <BarChart
- series={series}
- labels={labels}
- theme={CHART_THEME}
- config={CHART_CONFIG}
- tooltip={renderTooltip(rows)}
- onError={NOOP}
- />
- </div>
- )
-}
-
-export const ThreeStep: Story = {
- render: () => (
- <FunnelDemo
- steps={[
- { name: 'Pageview', count: 1000 },
- { name: 'Signed up', count: 420 },
- { name: 'Activated', count: 180 },
- ]}
- />
- ),
- name: 'Three-step funnel',
-}
-
-export const SteepDropoff: Story = {
- render: () => (
- <FunnelDemo
- steps={[
- { name: 'Visited', count: 5000 },
- { name: 'Added to cart', count: 800 },
- { name: 'Checkout started', count: 240 },
- { name: 'Purchased', count: 96 },
- ]}
- />
- ),
- name: 'Steep drop-off',
-}
diff --git a/products/product_analytics/mcp/apps/Lifecycle.stories.tsx b/products/product_analytics/mcp/apps/Lifecycle.stories.tsx
deleted file mode 100644
index bec2c53d86d6..000000000000
--- a/products/product_analytics/mcp/apps/Lifecycle.stories.tsx
+++ /dev/null
@@ -1,68 +0,0 @@
-import type { Meta, StoryObj } from '@storybook/react'
-import type { ReactElement } from 'react'
-
-import { CHART_THEME, lifecycleColor } from '@posthog/mcp-ui'
-import { McpThemeDecorator } from '@posthog/mcp-ui/storybook/decorator'
-import { Legend, TimeSeriesBarChart, legendItemsFromSeries } from '@posthog/quill-charts'
-
-import {
- buildTrendsLifecycleConfig,
- buildTrendsLifecycleSeries,
- type TrendsLifecycleResultLike,
-} from '../../frontend/insights/trends/TrendsLifecycleChart/trendsLifecycleChartTransforms'
-
-const LABELS = ['Jun 1', 'Jun 2', 'Jun 3', 'Jun 4', 'Jun 5', 'Jun 6', 'Jun 7']
-
-// `dormant` values come back negated from the backend so a diverging stack lays them below zero.
-const RESULTS: TrendsLifecycleResultLike[] = [
- { id: 'new', status: 'new', label: 'Pageview - new', data: [40, 35, 50, 45, 60, 55, 70] },
- { id: 'returning', status: 'returning', label: 'Pageview - returning', data: [20, 30, 35, 40, 45, 50, 55] },
- { id: 'resurrecting', status: 'resurrecting', label: 'Pageview - resurrecting', data: [10, 8, 12, 9, 14, 11, 16] },
- { id: 'dormant', status: 'dormant', label: 'Pageview - dormant', data: [-15, -20, -18, -25, -22, -30, -28] },
-]
-
-const meta: Meta = {
- title: 'MCP Apps/Lifecycle',
- decorators: [McpThemeDecorator],
- parameters: {
- testOptions: {
- skipDarkMode: true,
- },
- },
-}
-export default meta
-
-type Story = StoryObj<{}>
-
-function LifecycleChartDemo({
- results,
- isStacked,
-}: {
- results: TrendsLifecycleResultLike[]
- isStacked: boolean
-}): ReactElement {
- const series = buildTrendsLifecycleSeries(results, { getColor: lifecycleColor })
- const config = buildTrendsLifecycleConfig({ isStacked })
- const legendItems = legendItemsFromSeries(series, CHART_THEME)
- return (
- <div className="flex flex-col gap-2">
- <Legend items={legendItems} orientation="horizontal" align="center" />
- {/* Fixed pixel size, not width:100% — the chart sizes its canvas off a ResizeObserver, which
- measures 0 for a percentage width at mount in the headless snapshot runner and draws nothing. */}
- {/* eslint-disable-next-line react/forbid-dom-props */}
- <div style={{ display: 'flex', flexDirection: 'column', width: 640, height: 320 }}>
- <TimeSeriesBarChart series={series} labels={LABELS} theme={CHART_THEME} config={config} />
- </div>
- </div>
- )
-}
-
-export const Stacked: Story = {
- render: () => <LifecycleChartDemo results={RESULTS} isStacked />,
- name: 'Stacked',
-}
-
-export const Grouped: Story = {
- render: () => <LifecycleChartDemo results={RESULTS} isStacked={false} />,
- name: 'Grouped',
-}
diff --git a/products/product_analytics/mcp/apps/Trends.stories.tsx b/products/product_analytics/mcp/apps/Trends.stories.tsx
deleted file mode 100644
index 21463b4e5964..000000000000
--- a/products/product_analytics/mcp/apps/Trends.stories.tsx
+++ /dev/null
@@ -1,166 +0,0 @@
-import type { Meta, StoryObj } from '@storybook/react'
-import type { ReactElement } from 'react'
-
-import { CHART_THEME, colorAt } from '@posthog/mcp-ui'
-import { McpThemeDecorator } from '@posthog/mcp-ui/storybook/decorator'
-import { BarChart, TimeSeriesBarChart, TimeSeriesLineChart } from '@posthog/quill-charts'
-
-import { buildTrendsBarChartModel } from '../../frontend/insights/trends/TrendsBarChart/trendsBarChartTransforms'
-import {
- buildTrendsBarValueConfig,
- buildTrendsBarValueSeries,
- type TrendsBarValueItem,
-} from '../../frontend/insights/trends/TrendsBarValueChart/trendsBarValueChartTransforms'
-import {
- buildTrendsLineTimeSeriesConfig,
- buildTrendsSeries,
- type TrendsResultLike,
-} from '../../frontend/insights/trends/TrendsLineChart/trendsChartTransforms'
-
-const getColor = (_r: TrendsResultLike, i: number): string => colorAt(i)
-
-const DAYS = ['2025-05-26', '2025-05-27', '2025-05-28', '2025-05-29', '2025-05-30', '2025-05-31', '2025-06-01']
-
-const meta: Meta = {
- title: 'MCP Apps/Trends',
- decorators: [McpThemeDecorator],
- parameters: {
- testOptions: {
- skipDarkMode: true,
- },
- },
-}
-export default meta
-
-type Story = StoryObj<{}>
-
-// Renders the chart the same way the MCP app does: assemble series + config from results, then hand
-// them to quill's TimeSeriesLineChart. Fixed pixel size, not width:100% — the chart sizes its canvas
-// off a ResizeObserver, which measures 0 for a percentage width at mount in the headless snapshot
-// runner and draws nothing.
-function TrendsLineChartDemo({ results, isArea }: { results: TrendsResultLike[]; isArea?: boolean }): ReactElement {
- const series = buildTrendsSeries(results, { isArea, getColor })
- const config = buildTrendsLineTimeSeriesConfig({ results, isPercentStackView: false })
- return (
- // eslint-disable-next-line react/forbid-dom-props
- <div style={{ display: 'flex', flexDirection: 'column', width: 640, height: 300 }}>
- <TimeSeriesLineChart series={series} labels={DAYS} theme={CHART_THEME} config={config} />
- </div>
- )
-}
-
-export const SingleSeries: Story = {
- render: () => (
- <TrendsLineChartDemo
- results={[{ id: 1, label: 'Pageviews', data: [420, 380, 510, 490, 630, 580, 720], days: DAYS }]}
- />
- ),
- name: 'Single series',
-}
-
-export const MultiSeries: Story = {
- render: () => (
- <TrendsLineChartDemo
- results={[
- { id: 1, label: 'Pageviews', data: [420, 380, 510, 490, 630, 580, 720], days: DAYS },
- { id: 2, label: 'Signups', data: [42, 38, 51, 49, 63, 58, 72], days: DAYS },
- { id: 3, label: 'Purchases', data: [8, 12, 9, 15, 11, 18, 14], days: DAYS },
- ]}
- />
- ),
- name: 'Multi-series',
-}
-
-export const AreaChart: Story = {
- render: () => (
- <TrendsLineChartDemo
- results={[
- { id: 1, label: 'Pageviews', data: [420, 380, 510, 490, 630, 580, 720], days: DAYS },
- { id: 2, label: 'Signups', data: [42, 38, 51, 49, 63, 58, 72], days: DAYS },
- ]}
- isArea
- />
- ),
- name: 'Area chart',
-}
-
-// Renders the line/bar toggle's bar mode the same way the MCP app does: time-series results through
-// buildTrendsBarChartModel, then quill's TimeSeriesBarChart.
-function TrendsBarChartDemo({ results }: { results: TrendsResultLike[] }): ReactElement {
- const { series, config } = buildTrendsBarChartModel(results, {
- getColor: (_r, i) => colorAt(i),
- labels: DAYS,
- isPercentStackView: false,
- isGrouped: false,
- })
- return (
- // eslint-disable-next-line react/forbid-dom-props
- <div style={{ display: 'flex', flexDirection: 'column', width: 640, height: 300 }}>
- <TimeSeriesBarChart series={series} labels={DAYS} theme={CHART_THEME} config={config} />
- </div>
- )
-}
-
-export const TimeSeriesBar: Story = {
- render: () => (
- <TrendsBarChartDemo
- results={[
- { id: 1, label: 'Pageviews', data: [420, 380, 510, 490, 630, 580, 720], days: DAYS },
- { id: 2, label: 'Signups', data: [42, 38, 51, 49, 63, 58, 72], days: DAYS },
- ]}
- />
- ),
- name: 'Time-series bar',
-}
-
-// Renders ActionsBarValue the same way the MCP app does: aggregated totals through
-// buildTrendsBarValueSeries, then quill's BarChart. Fixed pixel size for the same
-// headless-snapshot reason as the line demo above.
-function TrendsBarValueChartDemo({
- items,
- height = 300,
-}: {
- items: TrendsBarValueItem[]
- height?: number
-}): ReactElement {
- const series = buildTrendsBarValueSeries(items, { getColor: colorAt })
- const config = buildTrendsBarValueConfig()
- return (
- // eslint-disable-next-line react/forbid-dom-props
- <div style={{ display: 'flex', flexDirection: 'column', width: 640, height }}>
- <BarChart series={series} labels={items.map((item) => item.label)} theme={CHART_THEME} config={config} />
- </div>
- )
-}
-
-export const BarValueFewSeries: Story = {
- render: () => (
- <TrendsBarValueChartDemo
- items={[
- { label: 'Chrome', value: 8421 },
- { label: 'Firefox', value: 3204 },
- { label: 'Safari', value: 2817 },
- ]}
- />
- ),
- name: 'Bar value — few series',
-}
-
-export const BarValueManyBreakdowns: Story = {
- render: () => (
- <TrendsBarValueChartDemo
- items={[
- { label: 'United States', value: 14320 },
- { label: 'United Kingdom', value: 6210 },
- { label: 'Germany', value: 4890 },
- { label: 'France', value: 3720 },
- { label: 'Canada', value: 2940 },
- { label: 'Australia', value: 2310 },
- { label: 'Netherlands', value: 1870 },
- { label: 'India', value: 1640 },
- ]}
- height={400}
- />
- ),
- name: 'Bar value — many breakdowns',
-}
diff --git a/services/mcp/src/ui-apps/components/Funnels.stories.tsx b/services/mcp/src/ui-apps/components/Funnels.stories.tsx
new file mode 100644
index 000000000000..3e4be1924381
--- /dev/null
+++ b/services/mcp/src/ui-apps/components/Funnels.stories.tsx
@@ -0,0 +1,53 @@
+import type { Meta, StoryFn, StoryObj } from '@storybook/react'
+import type { ReactElement } from 'react'
+
+import { McpThemeDecorator } from '@posthog/mcp-ui/storybook/decorator'
+
+import { FunnelVisualizer } from './FunnelVisualizer'
+import type { FunnelResult, FunnelsQuery } from './types'
+
+const FUNNELS_QUERY: FunnelsQuery = { kind: 'FunnelsQuery' }
+
+// The visualizer sizes its canvas off a ResizeObserver, so give it a definite width — a `w-full` box
+// can measure 0 at mount in the headless snapshot runner and paint nothing.
+const FixedWidth = (Story: StoryFn): ReactElement => (
+ <div className="w-[680px]">
+ <Story />
+ </div>
+)
+
+const meta: Meta = {
+ title: 'MCP Apps/Funnels',
+ decorators: [McpThemeDecorator, FixedWidth],
+ parameters: {
+ testOptions: {
+ skipDarkMode: true,
+ },
+ },
+}
+export default meta
+
+type Story = StoryObj<{}>
+
+const renderFunnel = (results: FunnelResult): ReactElement => <FunnelVisualizer query={FUNNELS_QUERY} results={results} />
+
+export const ThreeStep: Story = {
+ render: () =>
+ renderFunnel([
+ { name: 'Pageview', count: 1000, order: 0 },
+ { name: 'Signed up', count: 420, order: 1 },
+ { name: 'Activated', count: 180, order: 2 },
+ ]),
+ name: 'Three-step funnel',
+}
+
+export const SteepDropoff: Story = {
+ render: () =>
+ renderFunnel([
+ { name: 'Visited', count: 5000, order: 0 },
+ { name: 'Added to cart', count: 800, order: 1 },
+ { name: 'Checkout started', count: 240, order: 2 },
+ { name: 'Purchased', count: 96, order: 3 },
+ ]),
+ name: 'Steep drop-off',
+}
diff --git a/services/mcp/src/ui-apps/components/Lifecycle.stories.tsx b/services/mcp/src/ui-apps/components/Lifecycle.stories.tsx
new file mode 100644
index 000000000000..d613dc79a4e1
--- /dev/null
+++ b/services/mcp/src/ui-apps/components/Lifecycle.stories.tsx
@@ -0,0 +1,53 @@
+import type { Meta, StoryFn, StoryObj } from '@storybook/react'
+import type { ReactElement } from 'react'
+
+import { McpThemeDecorator } from '@posthog/mcp-ui/storybook/decorator'
+
+import { LifecycleVisualizer } from './LifecycleVisualizer'
+import type { LifecycleQuery, LifecycleResult } from './types'
+
+const DAYS = ['2025-06-01', '2025-06-02', '2025-06-03', '2025-06-04', '2025-06-05', '2025-06-06', '2025-06-07']
+
+// `dormant` values come back negated from the backend so a diverging stack lays them below zero.
+const RESULTS: LifecycleResult = [
+ { status: 'new', label: 'Pageview - new', data: [40, 35, 50, 45, 60, 55, 70], days: DAYS },
+ { status: 'returning', label: 'Pageview - returning', data: [20, 30, 35, 40, 45, 50, 55], days: DAYS },
+ { status: 'resurrecting', label: 'Pageview - resurrecting', data: [10, 8, 12, 9, 14, 11, 16], days: DAYS },
+ { status: 'dormant', label: 'Pageview - dormant', data: [-15, -20, -18, -25, -22, -30, -28], days: DAYS },
+]
+
+const lifecycleQuery = (stacked: boolean): LifecycleQuery => ({
+ kind: 'LifecycleQuery',
+ lifecycleFilter: { stacked },
+})
+
+// The visualizer sizes its canvas off a ResizeObserver, so give it a definite width — a `w-full` box
+// can measure 0 at mount in the headless snapshot runner and paint nothing.
+const FixedWidth = (Story: StoryFn): ReactElement => (
+ <div className="w-[680px]">
+ <Story />
+ </div>
+)
+
+const meta: Meta = {
+ title: 'MCP Apps/Lifecycle',
+ decorators: [McpThemeDecorator, FixedWidth],
+ parameters: {
+ testOptions: {
+ skipDarkMode: true,
+ },
+ },
+}
+export default meta
+
+type Story = StoryObj<{}>
+
+export const Stacked: Story = {
+ render: () => <LifecycleVisualizer query={lifecycleQuery(true)} results={RESULTS} />,
+ name: 'Stacked',
+}
+
+export const Grouped: Story = {
+ render: () => <LifecycleVisualizer query={lifecycleQuery(false)} results={RESULTS} />,
+ name: 'Grouped',
+}
diff --git a/services/mcp/src/ui-apps/components/Trends.stories.tsx b/services/mcp/src/ui-apps/components/Trends.stories.tsx
new file mode 100644
index 000000000000..27101a5b752c
--- /dev/null
+++ b/services/mcp/src/ui-apps/components/Trends.stories.tsx
@@ -0,0 +1,97 @@
+import type { Meta, StoryFn, StoryObj } from '@storybook/react'
+import type { ReactElement } from 'react'
+
+import { McpThemeDecorator } from '@posthog/mcp-ui/storybook/decorator'
+
+import { TrendsVisualizer } from './TrendsVisualizer'
+import type { ChartDisplayType, TrendsQuery, TrendsResult } from './types'
+
+const DAYS = ['2025-05-26', '2025-05-27', '2025-05-28', '2025-05-29', '2025-05-30', '2025-05-31', '2025-06-01']
+
+const trendsQuery = (display: ChartDisplayType): TrendsQuery => ({ kind: 'TrendsQuery', trendsFilter: { display } })
+
+// The visualizer sizes its canvas off a ResizeObserver, so give it a definite width — a `w-full` box
+// can measure 0 at mount in the headless snapshot runner and paint nothing.
+const FixedWidth = (Story: StoryFn): ReactElement => (
+ <div className="w-[680px]">
+ <Story />
+ </div>
+)
+
+const meta: Meta = {
+ title: 'MCP Apps/Trends',
+ decorators: [McpThemeDecorator, FixedWidth],
+ parameters: {
+ testOptions: {
+ skipDarkMode: true,
+ },
+ },
+}
+export default meta
+
+type Story = StoryObj<{}>
+
+const renderTrends = (query: TrendsQuery, results: TrendsResult): ReactElement => (
+ <TrendsVisualizer query={query} results={results} />
+)
+
+export const SingleSeries: Story = {
+ render: () =>
+ renderTrends(trendsQuery('ActionsLineGraph'), [
+ { label: 'Pageviews', data: [420, 380, 510, 490, 630, 580, 720], days: DAYS },
+ ]),
+ name: 'Single series',
+}
+
+export const MultiSeries: Story = {
+ render: () =>
+ renderTrends(trendsQuery('ActionsLineGraph'), [
+ { label: 'Pageviews', data: [420, 380, 510, 490, 630, 580, 720], days: DAYS },
+ { label: 'Signups', data: [42, 38, 51, 49, 63, 58, 72], days: DAYS },
+ { label: 'Purchases', data: [8, 12, 9, 15, 11, 18, 14], days: DAYS },
+ ]),
+ name: 'Multi-series',
+}
+
+export const AreaChart: Story = {
+ render: () =>
+ renderTrends(trendsQuery('ActionsAreaGraph'), [
+ { label: 'Pageviews', data: [420, 380, 510, 490, 630, 580, 720], days: DAYS },
+ { label: 'Signups', data: [42, 38, 51, 49, 63, 58, 72], days: DAYS },
+ ]),
+ name: 'Area chart',
+}
+
+export const TimeSeriesBar: Story = {
+ render: () =>
+ renderTrends(trendsQuery('ActionsBar'), [
+ { label: 'Pageviews', data: [420, 380, 510, 490, 630, 580, 720], days: DAYS },
+ { label: 'Signups', data: [42, 38, 51, 49, 63, 58, 72], days: DAYS },
+ ]),
+ name: 'Time-series bar',
+}
+
+export const BarValueFewSeries: Story = {
+ render: () =>
+ renderTrends(trendsQuery('ActionsBarValue'), [
+ { label: 'Chrome', aggregated_value: 8421 },
+ { label: 'Firefox', aggregated_value: 3204 },
+ { label: 'Safari', aggregated_value: 2817 },
+ ]),
+ name: 'Bar value — few series',
+}
+
+export const BarValueManyBreakdowns: Story = {
+ render: () =>
+ renderTrends(trendsQuery('ActionsBarValue'), [
+ { label: 'United States', aggregated_value: 14320 },
+ { label: 'United Kingdom', aggregated_value: 6210 },
+ { label: 'Germany', aggregated_value: 4890 },
+ { label: 'France', aggregated_value: 3720 },
+ { label: 'Canada', aggregated_value: 2940 },
+ { label: 'Australia', aggregated_value: 2310 },
+ { label: 'Netherlands', aggregated_value: 1870 },
+ { label: 'India', aggregated_value: 1640 },
+ ]),
+ name: 'Bar value — many breakdowns',
+}
diff --git a/services/mcp/tsconfig.json b/services/mcp/tsconfig.json
index f5fdba414aff..9cb1fd569dff 100644
--- a/services/mcp/tsconfig.json
+++ b/services/mcp/tsconfig.json
@@ -31,5 +31,5 @@
}
},
"include": ["src/**/*.ts", "src/**/*.tsx", "scripts/**/*.ts", "tests/**/*.ts", "worker-configuration.d.ts"],
- "exclude": ["node_modules", "dist", "src/ui-apps/lib/storybook/**"]
+ "exclude": ["node_modules", "dist", "src/ui-apps/lib/storybook/**", "src/**/*.stories.tsx"]
}