mcpdata Request an invite

Answers / Report with AI

How do I make an HTML report from a query?

Recipe verified on Ran on a private test instance
Short answer

Save the query as a view, then create_report with format = "html" (the default). Running it renders a self-contained HTML page: a title, an optional chart, and the table of results.

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 an HTML report of the top 20 products by units sold 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.top_products", select_sql="SELECT TOP 20 product_id, SUM(quantity) AS units FROM Demo.Orders GROUP BY product_id ORDER BY units DESC") → created true, view sales.top_products
create_report(name="Top 20 products", view="sales.top_products", format="html") → report_id 64890e2994054019becef8d8aaeac4ce
run_report(report_id="64890e2994054019becef8d8aaeac4ce") → status ok, rows 20

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

Why this works

The view holds the query, the report holds how it looks. Change either one and the next run picks it up, and because the HTML file carries everything it needs, it opens offline or as an attachment.

Related questions