mcpdata Request an invite

Answers / Report with AI

How do I get an AI to make a chart from my data?

Recipe verified on Ran on a private test instance
Short answer

Ask it to summarise the data into a view and create a report with a chart on top: create_report with chart = {"chart": "bar", "x": ..., "y": ...}. Bar, line, area, scatter, pie and histogram charts are drawn over the view's rows, with the table underneath.

Steps

  1. Connect your assistant to your instance (this writes, so it needs your own instance with a ReadWrite key from the accounts portal; the public demo is read-only). In Claude Code:
    claude mcp add --transport http mcpdata https://[you].mcpdata.org/mcp --header "Authorization: Bearer $CDB_API_KEY"

    Replace [you] with your instance's name. Other apps: Connect your AI.

  2. Ask your question. Give your AI this prompt:
    Using mcpdata, make a bar chart of total revenue by product category from Demo.Orders.
What your AI does: the tool calls it makes for this prompt, and what came back
create_view(name="sales.by_category", select_sql="SELECT category, SUM(revenue) AS revenue FROM Demo.Orders GROUP BY category ORDER BY revenue DESC") → created true, view sales.by_category
create_report(name="Revenue by category", view="sales.by_category", chart={"chart": "bar", "x": "category", "y": "revenue"}) → report_id 3438d0ae76a748dfb7195921eea8410b
run_report(report_id="3438d0ae76a748dfb7195921eea8410b") → status ok, rows 12

The assistant needs mcpdata connected (step 1) to run the query.

Why this works

A chart drawn from a query is drawn from every row, and it stays right when the data changes because the report re-runs the view. The report's HTML file is self-contained, so it opens anywhere, offline too.

Related questions