Answers / Get data into your AI
How do I turn a folder of CSV files into tables my AI can query?
Recipe verified on
Ran on a private test instance
Short answer
Point cdb-localdata at the folder: every CSV becomes a table named after the file, under a namespace you choose (shop.orders, shop.customers, ...). Your AI lists them with list_tables and queries each one; new and changed files arrive on the next sync.
Steps
- 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. - Install the client and sign it in.
pip install https://[you].mcpdata.org/help/download/cdb-0.3.4-py3-none-any.whl cdb-localdata login --to https://[you].mcpdata.org
- Add the folder and sync it. The sample folder
shopholds orders.csv, customers.csv and products.csv:cdb-localdata add ./samples/shop --to https://[you].mcpdata.org --namespace shop cdb-localdata sync
- Ask your question. Give your AI this prompt:
Using mcpdata, list the tables under shop, then total the quantity per category in shop.orders.
What your AI does: the tool calls it makes for this prompt, and what came back
list_tables() → 10 tables: mycsv.orders_mixed_dates, shop.orders, shop.customers, shop.products
query(table_name="shop.orders", group_by=["category"], agg=[{"func": "sum", "column": "quantity", "alias": "units"}], sort=[{"column": "units", "desc": true}]) → 12 rows
| category | units |
|---|---|
| Storage | 1,508 |
| Monitors | 1,484 |
| Audio | 1,470 |
| Cameras | 1,396 |
| Tablets | 1,373 |
| Networking | 1,372 |
| Phones | 1,348 |
| Smart Home | 1,334 |
| Laptops | 1,288 |
| Accessories | 1,191 |
| Software | 1,156 |
| Gaming | 1,132 |
The assistant needs mcpdata connected (step 1) to run the query.
Why this works
One table per file keeps the structure you already have, so the AI can find things by name. Subfolders become part of the name (shop.2025.orders), and a file that's deleted locally can be dropped from the server too.