drafty
ClickHouse logo

Build a ClickHouse event-analytics dashboard with Claude

Connect the ClickHouse MCP server to Claude, ask for an event-analytics dashboard straight from your tables, and publish it to a link your team comments on directly — no BI tool, no screenshots pasted into Slack.

What you'll build
A self-contained event-analytics dashboard — events per day, active users, top events, p50/p95/p99 query latency, and the busiest tables — generated by Claude from your real ClickHouse data, then published to a drafty.im/canvas/… link. Your team clicks the exact chart or number they want changed and leaves a note. Claude reads the comments and ships a revised version to the same URL.

This is an end-to-end example: connect a data source over MCP, generate a dashboard from live numbers, and close the review loop on one link. Total time, start to shared link, is under fifteen minutes. The same shape works for any of the other examples — only the connection step changes.

Here's the finished dashboard, published to a canvas — click any tile or number to leave a comment, exactly as your team would:

Live canvas — comment on any elementOpen ↗

The three moving parts

  1. The ClickHouse MCP server gives Claude read access to your ClickHouse cluster — it can list databases and tables and run SELECT queries over your event data. It runs in read-only mode by default, so Claude can analyze but never mutate.
  2. Claude writes the SQL, pulls the aggregates, and builds a single self-contained HTML dashboard. You iterate on it in the artifact panel until it's right.
  3. Drafty turns that HTML into a stable link your team reviews. Comments pin to the exact element; Claude ships the fix to the same URL.

The generation step is fast now. The part this example is really about is the third one — getting the dashboard in front of people without losing their feedback to a screenshot circled in Preview.

Step 1 — Connect the ClickHouse MCP server

ClickHouse ships an official MCP server, mcp-clickhouse, run through uv. It connects to your cluster with the credentials you pass as environment variables and runs read-only by default (CLICKHOUSE_ALLOW_WRITE_ACCESS is off unless you set it). You'll need uv installed first.

In Claude Code:

claude
claude mcp add clickhouse --env CLICKHOUSE_HOST=your-host.clickhouse.cloud --env CLICKHOUSE_PORT=8443 --env CLICKHOUSE_USER=readonly_user --env CLICKHOUSE_PASSWORD=your-password --env CLICKHOUSE_SECURE=true -- uv run --with mcp-clickhouse --python 3.10 mcp-clickhouse

Then run /mcp inside Claude Code to confirm the clickhouse server is listed and connected.

In Claude Desktop: open Settings → Developer → Edit config, and add an mcpServers entry with "command": "uv", "args": ["run", "--with", "mcp-clickhouse", "--python", "3.10", "mcp-clickhouse"], and the same CLICKHOUSE_HOST / CLICKHOUSE_PORT / CLICKHOUSE_USER / CLICKHOUSE_PASSWORD / CLICKHOUSE_SECURE environment variables.

Safety first
Connect with a read-only ClickHouse user — create one with a row policy or a READONLY profile and grant it SELECT on only the databases this dashboard needs. Leave CLICKHOUSE_ALLOW_WRITE_ACCESS unset (the server defaults to read-only) and never set CLICKHOUSE_ALLOW_DROP. Never commit the password into a config file or a repo — pass it through the environment. The dashboard only reads; it has no reason to hold write permissions.

Step 2 — Pull the numbers

Ask Claude in plain language. It uses the MCP server's read tools (list_databases, list_tables, run_query) to explore your schema and run the aggregations:

claude
Using the ClickHouse MCP server, pull everything we need for an event-analytics dashboard from our events table: total events in the last 30 days with day-over-day trend, distinct active users per day, the top 10 event names by volume, p50/p95/p99 latency for our main query workload, and the busiest tables by row count. Show me the SQL you ran and summarize the figures before you build anything.

Claude lists your tables, writes the SELECT queries, returns the figures, and you sanity-check them against your own ClickHouse queries or your existing dashboards before going further. This is the moment to catch a wrong assumption — the wrong events table, a timezone offset on the day bucketing, a uniqExact vs. uniq choice that shifts the active-user count — while it's cheap.

Step 3 — Build the dashboard

Once the numbers look right, ask for the artifact:

claude
Build a single self-contained HTML dashboard from those figures. Events-per-day as the hero with a trend line, then tiles for active users, top events, and query latency percentiles. A busiest-tables table at the bottom. Clean, no external dependencies — inline the CSS and any chart code.

Claude renders it live in the artifact panel. Iterate in place — you're not regenerating from scratch:

Step 4 — Publish to Drafty for review

A Claude artifact link is a preview, not a stable URL — iterate the artifact and the link you already sent now shows the old version. Ask Claude to publish it to a Drafty canvas instead, so the link you share always stays current:

claude
Publish this dashboard to Drafty as a canvas and give me the shareable link.

Claude pushes the dashboard and hands back a drafty.im/canvas/… link that renders on any device. Send it — your team opens it in a browser, no login and no Claude account needed.

Step 5 — The review loop

This is the part that's not obvious until you've done it once.

A reviewer clicks the specific tile, chart, or number they want changed and leaves a pinned comment — "this active-user count looks low, are we deduping by user or by session?" The comment is anchored to that element, not floating in a Slack thread. Claude reads the comments through the CLI, reruns the relevant ClickHouse query if needed, and pushes a revised dashboard to the same URL. The reviewer refreshes and sees the change; the thread stays attached to the element.

The mechanic matters because of what it removes. A Slack message about a chart produces "the number on the left looks wrong." A pinned comment on the actual tile produces "this — dedupe active users by user_id, not session." One of those produces a correct revision; the other produces a guess.

Keeping it fresh

An MCP-generated dashboard is a snapshot — it holds the numbers Claude pulled when it built it; it doesn't re-query ClickHouse when someone opens the link. For a weekly review or a board-ready snapshot, that's fine.

To make it a live canvas that always shows today's figures, copy this prompt — Claude sets up the refresh for you and schedules it to run on its own:

claude
Turn this ClickHouse dashboard into a live canvas: every morning, re-run the queries against ClickHouse via the MCP server, rebuild the dashboard, and push a new version to the same canvas URL so the link always shows today's figures. Schedule it to run daily on its own.

The link stays stable while the content updates underneath it — see keeping a canvas updated automatically.

What to watch for

ClickHouse dashboard with Claude — FAQ

Do I need to put my ClickHouse password in a config file?
The mcp-clickhouse server reads the password from a CLICKHOUSE_PASSWORD environment variable, so pass it through the environment rather than hard-coding it. Use a dedicated read-only ClickHouse user, and never commit the credentials into a repo. The server runs read-only by default, so it can SELECT but never write or drop.
Is the dashboard live or a snapshot?
A snapshot. It contains the numbers Claude pulled when it built the file; it does not re-query ClickHouse when someone opens the link. To refresh it, ask Claude to re-run the queries and re-push to the same URL — or put that on a daily schedule so the stable link always shows current numbers.
Can my team comment without a ClickHouse or Claude account?
Yes. The dashboard is published to a Drafty canvas link that renders in any browser. Reviewers click the exact element they want changed and leave a pinned comment with no login required. Only the person connecting ClickHouse needs access to the cluster.
Is it safe to give Claude access to my ClickHouse cluster?
Connect with a read-only user scoped to only the databases this dashboard needs, and leave CLICKHOUSE_ALLOW_WRITE_ACCESS and CLICKHOUSE_ALLOW_DROP unset — the server defaults to read-only. Every query is mediated by the MCP server, and in Claude you approve actions. Don't grant write access for a read-only reporting task.
How is this different from a ClickHouse BI tool like Grafana or Superset?
Grafana, Superset, and ClickHouse's own dashboards query live data against panels and models you maintain — the right choice for governed, always-on reporting. This approach is for a fast, shareable snapshot you can spin up in minutes and iterate by talking to Claude, then collect feedback on inline. Different jobs: one is a standing system, the other is a quick reviewable deliverable.