mcpdata Request an invite

Answers / Analyse data

How do I find the top 10 customers by revenue with AI?

Recipe verified on Ran on the public demo (read-only)
Short answer

Have your AI group the orders by customer, sum the revenue, sort it descending and keep ten rows. With a database behind it that's one query over every order, so the ranking is exact even with millions of rows.

Steps

  1. Connect your assistant to the public demo. It's a read-only instance with 10 million synthetic orders, so you can try this before you have your own. In Claude Code:
    claude mcp add --transport http mcpdata-demo https://demo.mcpdata.org/mcp --header "Authorization: Bearer cdb_live_PkVoldus8qcE-hqffjajNZzQwiA7rTHMoR4RLSAxsCE"

    The key is public on purpose: it can only read the demo's sample data. For Claude Desktop, Cursor and other apps, see Connect your AI.

  2. Ask your question. Give your AI this prompt:
    Using mcpdata, who are the top 10 customers by total revenue in Demo.Orders?
What your AI does: the tool call it makes for this prompt, and what came back
query(table_name="Demo.Orders", group_by=["customer_id"], agg=[{"func": "sum", "column": "revenue", "alias": "revenue"}, {"func": "count", "column": "order_id", "alias": "orders"}], sort=[{"column": "revenue", "desc": true}], limit=10) → 10 rows (more available)
What you should get · the recipe's real result from its last run
customer_idrevenueorders
11943860,657.0473
15109657,983.6665
18671757,948.1869
2589956,686.1358
19872656,061.8671
6271555,974.6468
5663255,786.9864
14188755,581.9162
2837455,460.2961
2986355,275.8682

Synthetic data: the demo's orders are generated, not real customers.

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

Why this works

A top-N needs every row: a customer whose orders sit at the end of a file the AI only partly read would be missed. The database sorts the totals and returns ten rows, so the conversation holds the answer, not the data.

Related questions