How do I give an AI read-only access to data?
Recipe verified on
Ran on the public demo (read-only)
Short answer
Give it an API key with the Read role. In mcpdata, a Read key can list, describe and query tables and run saved views, and every tool that writes (tables, views, reports, exports) refuses it. Make a separate key per assistant so each can be revoked on its own.
Steps
- 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.
- Make a Read key. In the accounts portal, open your instance, API keys, choose the Read role (optionally an expiry and the addresses it may be used from), and give that key to the assistant.
- Ask your question. Give your AI this prompt:
Using mcpdata, add a row to agent.notes, then tell me what happened.
What your AI does: the tool calls it makes for this prompt, and what came back
query(table_name="Demo.Products", columns=["product_id", "category"], limit=3) → 3 rows (more available)
append_rows(table="agent.notes", rows=[{"note": "hello"}]) → refused: Error calling tool 'append_rows': not authorised: writing tables needs the ReadWrite role -- this agent's API key is read
| product_id | category |
|---|---|
| 1 | Monitors |
| 2 | Cameras |
| 3 | Accessories |
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
Read-only is enforced by the database for the key, not by asking the AI to behave. The public demo runs on exactly such a key: the query works, and the write below is refused with a message saying why.