drafty
Postgres logo

Query your Postgres database and build a dashboard with Claude

Connect your Postgres database to Claude over MCP, ask it to query your tables and turn the result into a dashboard, 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 metrics dashboard — signups, active users, revenue by plan, a daily trend, and a recent-activity table — generated by Claude straight from a query against your own Postgres database, 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 Postgres MCP server gives Claude read access to your database — schemas, tables, and the result of any SELECT you ask for — through a controlled set of tools. You point it at a connection string and run it in restricted (read-only) mode, so it can query but never write.
  2. Claude runs the query, reads the rows, and writes 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 Postgres MCP server

Use Postgres MCP Pro (crystaldba/postgres-mcp), a maintained server that connects to any Postgres database and runs in restricted (read-only) mode by default with --access-mode=restricted. It's a local stdio server — it runs on your machine and talks to your database directly, so nothing about your data leaves your network.

In Claude Code (via Docker — pass your connection string as DATABASE_URI):

claude
claude mcp add postgres -e DATABASE_URI=postgresql://readonly_user:password@localhost:5432/yourdb -- docker run -i --rm -e DATABASE_URI crystaldba/postgres-mcp --access-mode=restricted

Prefer not to use Docker? Install with pipx install postgres-mcp and point Claude at the binary instead:

claude
claude mcp add postgres -e DATABASE_URI=postgresql://readonly_user:password@localhost:5432/yourdb -- postgres-mcp --access-mode=restricted

In Claude Desktop: open Settings → Developer → Edit Config and add a postgres entry under mcpServers with the same command, args (--access-mode=restricted), and a DATABASE_URI env var.

Safety first
Create a dedicated read-only Postgres role and connect with that — GRANT CONNECT, GRANT USAGE ON SCHEMA public, and GRANT SELECT ON ALL TABLES, nothing more — and keep the server in --access-mode=restricted. A reporting dashboard only reads; it has no reason to hold write permissions. Never commit the connection string; pass it through an env var.

Step 2 — Pull the numbers

Ask Claude in plain language. It uses the server's read tools (list_schemas, list_objects, execute_sql) to inspect your tables and run the query:

claude
Using the Postgres MCP server, look at my schema and pull everything we need for a metrics dashboard: total users and new signups in the last 30 days, weekly active users, revenue this month broken down by plan, the daily signup count for the last 14 days, and the 10 most recent signups with their plan. Show me the SQL you ran and summarize the figures before you build anything.

Claude inspects the schema, runs the queries, returns the figures, and you sanity-check them against a query you trust before going further. This is the moment to catch a wrong assumption — a join that double-counts, a soft-delete column you forgot to filter, a timezone in the date math — 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. Active users as the hero number with the trend, then tiles for new signups, revenue this month, and total users. A daily-signups bar chart and a recent-signups 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 high, are we counting internal accounts?" The comment is anchored to that element, not floating in a Slack thread. Claude reads the comments through the CLI, reruns the relevant 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 — exclude internal accounts from the active-user count." 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 Postgres 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 Postgres dashboard into a live canvas: every morning, re-run the queries against the database 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

Postgres dashboard with Claude — FAQ

Do I need to expose my database credentials anywhere risky?
No. The Postgres MCP server runs locally on your machine and connects straight to your database — your data never leaves your network. Pass the connection string through a DATABASE_URI env var, never committed to a repo, and connect with a dedicated read-only role rather than your admin user.
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 Postgres 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 Postgres 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 the database needs access to it.
Is it safe to give Claude access to my database?
Connect with a read-only role (SELECT only) and run the server in --access-mode=restricted, and a metrics dashboard never needs more than that. 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 Metabase, Grafana, or a BI tool?
BI tools query live data against a model and dashboards you maintain — the right choice for governed reporting at scale. 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.