Answers / Get data into your AI
How do I let Claude query a CSV file on my computer?
Recipe verified on
Ran on a private test instance
Short answer
Sync the folder with the CSV to an mcpdata instance with cdb-localdata, and connect Claude to that instance. Claude then queries the file as a table. The file is only read, and it stays in step: run the sync again (or install it to run every minute) and changes arrive as a new version.
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. Here a folder
mixedwith the sample orders_mixed_dates.csv:cdb-localdata add ./samples/mixed --to https://[you].mcpdata.org --namespace mycsv cdb-localdata sync
- Keep it in step (optional). Sync every minute in the background, started with your computer (Task Scheduler, launchd or cron):
cdb-localdata install
- Ask your question. Give your AI this prompt:
Using mcpdata, how many orders per channel are in mycsv.orders_mixed_dates?
What your AI does: the tool call it makes for this prompt, and what came back
query(table_name="mycsv.orders_mixed_dates", group_by=["channel"], agg=[{"func": "count", "column": "order_id", "alias": "orders"}], sort=[{"column": "orders", "desc": true}]) → 3 rows
| channel | orders |
|---|---|
| Online | 5,507 |
| Store | 3,224 |
| Partner | 1,269 |
The assistant needs mcpdata connected (step 1) to run the query.
Why this works
Claude can't open files on your disk by itself, and pasting a CSV into the chat runs into the context limit. Syncing the folder makes the file a table Claude can query with exact results, and your other tools (Python, JDBC, the workbench) see the same table.