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(mcp): add quill-charts plumbing for ui-apps (#61807)

Sam Pennington63a864b232e3
diff --git a/packages/quill/packages/charts/package.json b/packages/quill/packages/charts/package.json
index 32007f576daa..9351657374c4 100644
--- a/packages/quill/packages/charts/package.json
+++ b/packages/quill/packages/charts/package.json
@@ -19,9 +19,11 @@
"./story-helpers": "./src/story-helpers.tsx",
"./package.json": "./package.json"
},
+ "scripts": {
+ "build": "tsc -p tsconfig.build.json"
+ },
"dependencies": {
"@floating-ui/react": "^0.27.19",
- "@testing-library/dom": ">=9.3.4",
"d3-array": "^3.2.4",
"d3-color": "^3.1.0",
"d3-scale": "^4.0.2",
@@ -32,6 +34,7 @@
"devDependencies": {
"@posthog/quill-tokens": "workspace:*",
"@storybook/react": "catalog:",
+ "@testing-library/dom": ">=9.3.4",
"@testing-library/react": "^14.3.1",
"@types/d3-array": "^3.2.1",
"@types/d3-color": "^3.1.3",
@@ -40,7 +43,8 @@
"@types/jest": "catalog:",
"@types/react": "^18.3.27",
"@types/react-dom": "^18.3.7",
- "jest": "^29.7.0"
+ "jest": "^29.7.0",
+ "typescript": "catalog:"
},
"peerDependencies": {
"react": "^18.3.1 || ^19.0.0",
diff --git a/packages/quill/packages/charts/tsconfig.build.json b/packages/quill/packages/charts/tsconfig.build.json
new file mode 100644
index 000000000000..930c84d610fd
--- /dev/null
+++ b/packages/quill/packages/charts/tsconfig.build.json
@@ -0,0 +1,12 @@
+{
+ "extends": "./tsconfig.json",
+ "compilerOptions": {
+ "noEmit": false,
+ "declaration": true,
+ "emitDeclarationOnly": true,
+ "rootDir": "src",
+ "outDir": "dist"
+ },
+ "include": ["src/index.ts"],
+ "exclude": ["src/**/*.test.ts", "src/**/*.test.tsx", "src/testing", "src/story-helpers.tsx"]
+}
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 23a9f9030f26..e6f000573eab 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -343,7 +343,7 @@ importers:
version: 0.25.12
jest:
specifier: ^29.7.0
puppeteer:
specifier: 19.0.0
version: 19.0.0([email protected])
@@ -1899,9 +1899,6 @@ importers:
'@floating-ui/react':
specifier: ^0.27.19
- '@testing-library/dom':
- specifier: '>=9.3.4'
- version: 9.3.4
d3-array:
specifier: ^3.2.4
version: 3.2.4
@@ -1933,6 +1930,9 @@ importers:
'@storybook/react':
specifier: 'catalog:'
+ '@testing-library/dom':
+ specifier: '>=9.3.4'
+ version: 9.3.4
'@testing-library/react':
specifier: ^14.3.1
@@ -1960,6 +1960,9 @@ importers:
jest:
specifier: ^29.7.0
+ typescript:
+ specifier: 6.0.3
+ version: 6.0.3
packages/quill/packages/components:
dependencies:
@@ -3775,6 +3778,9 @@ importers:
'@posthog/quill':
specifier: workspace:*
version: link:../../packages/quill/packages/quill
+ '@posthog/quill-charts':
+ specifier: workspace:*
+ version: link:../../packages/quill/packages/charts
'@toon-format/toon':
specifier: ^2.1.0
version: 2.1.0
@@ -31962,7 +31968,7 @@ snapshots:
'@swc/core': 1.15.18
'@swc/jest': 0.2.37(@swc/[email protected])
expect-playwright: 0.8.0
+ jest: 29.7.0
jest-circus: 29.7.0
jest-environment-node: 29.7.0
jest-junit: 16.0.0
@@ -39033,6 +39039,25 @@ snapshots:
- ts-node
- utf-8-validate
+ dependencies:
+ '@jest/test-result': 29.7.0
+ '@jest/types': 29.6.3
+ chalk: 4.1.2
+ exit: 0.1.2
+ import-local: 3.2.0
+ jest-util: 29.7.0
+ jest-validate: 29.7.0
+ yargs: 17.7.2
+ transitivePeerDependencies:
+ - '@types/node'
+ - babel-plugin-macros
+ - supports-color
+ - ts-node
+
dependencies:
@@ -39675,7 +39700,7 @@ snapshots:
dependencies:
expect-playwright: 0.8.0
+ jest: 29.7.0
jest-circus: 29.7.0
jest-environment-node: 29.7.0
jest-process-manager: 0.4.0
@@ -40110,7 +40135,7 @@ snapshots:
dependencies:
ansi-escapes: 6.0.0
chalk: 5.6.2
+ jest: 29.7.0
jest-regex-util: 29.6.3
jest-watcher: 29.7.0
slash: 5.1.0
@@ -40182,6 +40207,18 @@ snapshots:
- ts-node
- utf-8-validate
+ dependencies:
+ '@jest/types': 29.6.3
+ import-local: 3.2.0
+ jest-cli: 29.7.0
+ transitivePeerDependencies:
+ - '@types/node'
+ - babel-plugin-macros
+ - supports-color
+ - ts-node
+
dependencies:
diff --git a/services/mcp/package.json b/services/mcp/package.json
index 5215266a32df..8a6a6d71d2dc 100644
--- a/services/mcp/package.json
+++ b/services/mcp/package.json
@@ -45,6 +45,7 @@
"@modelcontextprotocol/sdk": "^1.29.0",
"@posthog/mcp-analytics": "npm:@posthog/[email protected]",
"@posthog/quill": "workspace:*",
+ "@posthog/quill-charts": "workspace:*",
"@toon-format/toon": "^2.1.0",
"agents": "0.10.2",
"ai": "^6.0.0",
diff --git a/services/mcp/src/ui-apps/components/charts/theme.ts b/services/mcp/src/ui-apps/components/charts/theme.ts
new file mode 100644
index 000000000000..43ab92e4a6de
--- /dev/null
+++ b/services/mcp/src/ui-apps/components/charts/theme.ts
@@ -0,0 +1,26 @@
+import { type ChartTheme } from '@posthog/quill-charts'
+
+// PostHog brand palette. Canvas can't read CSS custom properties, so we hand the
+// chart concrete hexes. The chart picks one per series by index; legends use the
+// same array to stay in sync.
+export const CHART_COLORS = [
+ '#1d4aff', // PostHog blue
+ '#621da6', // PostHog purple
+ '#00d683', // PostHog green
+ '#f54e00', // PostHog orange
+ '#f7a501', // PostHog yellow
+ '#dc2626', // red
+]
+
+// Single mid-gray for axis labels — readable on both light and dark hosts. Claude
+// Desktop's iframe doesn't set `prefers-color-scheme`, so we can't detect the host
+// theme and adapt at runtime.
+export const CHART_THEME: ChartTheme = {
+ colors: CHART_COLORS,
+ backgroundColor: '#ffffff',
+ axisColor: '#9ca3af',
+ gridColor: 'rgba(128, 128, 128, 0.2)',
+ crosshairColor: 'rgba(128, 128, 128, 0.5)',
+ tooltipBackground: '#ffffff',
+ tooltipColor: '#111827',
+}
diff --git a/services/mcp/tsconfig.json b/services/mcp/tsconfig.json
index ec4138e5764c..d06077c06c3d 100644
--- a/services/mcp/tsconfig.json
+++ b/services/mcp/tsconfig.json
@@ -16,7 +16,6 @@
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"noUncheckedIndexedAccess": true,
- "exactOptionalPropertyTypes": true,
"skipLibCheck": true,
"types": ["node", "./worker-configuration.d.ts", "./types.d.ts", "@cloudflare/vitest-pool-workers"],
"paths": {
@@ -26,6 +25,7 @@
"@posthog/mcp-ui": ["./src/ui-apps/lib/index.ts"],
"@posthog/mcp-ui/*": ["./src/ui-apps/lib/*"],
"@posthog/quill": ["../../packages/quill/packages/quill/dist/index.d.ts"],
+ "@posthog/quill-charts": ["../../packages/quill/packages/charts/dist/index.d.ts"],
"lucide-react": ["./node_modules/lucide-react"],
"@common/*": ["../../common/*"]
}
diff --git a/services/mcp/vite.ui-apps.config.ts b/services/mcp/vite.ui-apps.config.ts
index cf49663c675a..0921abcd3b3b 100644
--- a/services/mcp/vite.ui-apps.config.ts
+++ b/services/mcp/vite.ui-apps.config.ts
@@ -51,6 +51,13 @@ export default defineConfig({
find: /^@posthog\/quill$/,
replacement: resolve(__dirname, '../../packages/quill/packages/quill/dist/index.js'),
},
+ // quill-charts is consumed as source (its package main is src/index.ts); resolve it
+ // explicitly so files reached via the `products` alias — and the local chart wrappers —
+ // can find it without a node_modules symlink.
+ {
+ find: /^@posthog\/quill-charts$/,
+ replacement: resolve(__dirname, '../../packages/quill/packages/charts/src/index.ts'),
+ },
// lucide-react isn't a workspace dep at the products/ level, so files
// resolved via the `products` alias can't find it. Pin to this
// package's installed copy (matches the version Quill expects).