mcpdata Request an invite

Answers / Report with AI

How do I make a line chart of monthly totals with Claude?

Recipe verified on Ran on a private test instance
Short answer

Ask Claude to save a monthly-totals view and create a report with a line chart over it (chart = {"chart": "line", "x": "order_month", "y": "revenue"}). Running the report draws the chart from every month's exact total.

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 line chart of total revenue per month from Demo.Orders, and run it.
What your AI does: the tool calls it makes for this prompt, and what came back
create_view(name="sales.monthly", select_sql="SELECT order_month, SUM(revenue) AS revenue FROM Demo.Orders GROUP BY order_month ORDER BY order_month") → created true, view sales.monthly
create_report(name="Monthly revenue", view="sales.monthly", chart={"chart": "line", "x": "order_month", "y": "revenue", "title": "Revenue per month"}) → report_id a109db8e3ac9436ab795b850c562e39c
run_report(report_id="a109db8e3ac9436ab795b850c562e39c") → status ok, rows 36

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

Why this works

The months come from a GROUP BY over all the rows, so the line is right, and because the report re-runs its view, the chart extends itself as new months arrive.

Related questions