Best Way to Let Claude or Cursor Query Your Production Data Safely
Point Claude or Cursor at claix.retrieve.ask, not at a production role. Reads stay inside the agent’s routes. Writes go through a hook that calls Guard.
Claix · November 2026. Related guides: stop a destructive write before it runs, MCP, and read replica vs production. Product: Claix Retrieve and Claix Guard.
Claude and Cursor are great at writing code. They are also increasingly good at working with data. If you give them direct access to a production database, they can query anything the underlying role allows. That can include customer records, payment details, internal notes or data from another tenant.
The question is not “Can Claude or Cursor query my database?” They can. The question is whether they can query only the data they need, in a form their workflow can use, without exposing the rest of the database.
Why direct database access is risky
A generic database MCP connection is quick to wire up. The access model depends on the server and the role you attach. A broad role is inherited by the assistant. It may be able to query every table, retrieve sensitive columns, access records from another tenant, return large result sets, execute writes if the role allows it, and leave actions difficult to audit. A database role is the foundation. It is not a complete permission model.
The two halves of the problem
| Problem | What it controls | What Claix provides |
|---|---|---|
| What can the agent read? | Tables, columns, rules and answer format | Claix Retrieve |
| What can the agent change? | Inserts, updates and deletes | Claix Guard |
Claix Retrieve controls what the assistant can read. Claix Guard checks what it proposes to change. Your hook or executor is what allows, blocks or pauses the statement.
What Claix Retrieve does
Claix Retrieve connects to a relational database and lets each agent retrieve only the tables and columns you allow, within the rules and limits you define. It does not copy your data into a vector store. The assistant queries the database where the data lives, inside that perimeter. A smaller retrieval surface means less exposure.
Routes define what an agent can read
A route specifies which tables an agent can access, which columns it can retrieve, and a guide with your rules and vocabulary. You create a route once and attach it to as many agents as you need. A support agent might see orders and customers. An operations agent might see inventory and shifts. An internal analytics agent can have a wider route. The route is the boundary.
Agents define who can access what
An agent is the identity that uses one or more routes. Each agent has its own endpoint, business prompt, attached routes and response mode. A support bot and an internal assistant can share the same database while seeing different data. Claude and Cursor can be pointed at the agent that matches the task.
How Claix works with MCP
Claix Retrieve is an MCP server. The tool is claix.retrieve.ask. You expose a Claix agent as an MCP tool for Cursor and compatible clients, including Claude. You do not give the assistant a raw database connection. You give it a scoped retrieval tool. Docs: MCP.
{
"mcpServers": {
"claix": {
"url": "https://claix.dev/mcp",
"headers": { "x-api-key": "<YOUR_API_KEY>" }
}
}
}The tool takes an agent_name and a questions array. Each question can include a format such as string, int or boolean. The response mode, raw or reasoned, is set on the agent in the dashboard.
What the MCP tool returns
| Mode | What you get |
|---|---|
| Raw | JSON rows returned by the database |
| Reasoned | A single typed value per question |
Typed answers are booleans, numbers, lists and JSON objects. A workflow can branch on the value instead of parsing free text. Typical questions are whether an item is in stock, how many orders are pending, which customers need follow-up, and the status of a reservation.
Why this is better than raw execute_sql
| Approach | What it gives the assistant | What it risks |
|---|---|---|
| Raw execute_sql | Full SQL access within the role | Broad data exposure, expensive queries, unsafe writes |
| Claix Retrieve | Scoped tables and columns, typed answers, validation and traces | Less flexibility for ad hoc exploration |
| Claix Guard | A check before writes | Does not execute SQL. Your code does |
A raw MCP server is still the better choice for development, exploration and ad hoc analysis. For production agents acting on data that matters, Retrieve is the better fit when you want scoped tables and columns, typed answers and no SQL written by a model.
How to control writes
If the workflow needs to write, Guard checks the proposed INSERT, UPDATE or DELETE against rules you approved. Allowed means your code can execute the statement. Denied means it should not, and the assistant receives the reason. Claix does not execute the statement and does not block Cursor or Claude Code on its own. Give the assistant a guarded function that sends the statement to /check-sql, returns the reason on deny, and calls execute_sql only on an explicit allow. Do not expose the raw write tool. If the check fails, times out, or returns anything other than allow, do not run the statement. A denial is still HTTP 200. Read allowed.
The step-by-step hook is in stop Cursor or Claude Code from running destructive SQL.
What Guard can enforce
| Control | What it prevents |
|---|---|
| Operation type | Unwanted inserts, updates or deletes |
| Target table | Changes to tables outside the agent’s scope |
| Target columns | Changes to sensitive or protected fields |
| Record selection | Updates or deletes that affect too many records |
| Value limits | Discounts, quantities, amounts or statuses outside allowed ranges |
| State transitions | Invalid changes from one status to another |
| Rate limits | Too many changes in a short period |
| Human review | High-risk actions that require approval |
| Audit trail | Missing evidence of what was proposed and decided |
- Agents can create and update orders, but never delete them.
- Agents can update an order status, but never its price.
- Discounts cannot exceed 20 percent.
- Refunds above a threshold require human review.
- An update or delete must target a specific record.
- Certain status transitions are not allowed.
- The number of refunds per hour is limited.
How to get started
Claix supports any SQL database, including Postgres, MySQL and MariaDB, plus Postgres-compatible setups such as Supabase. Connect with a read-only role. Define routes and agents, then point Claude or Cursor at claix.retrieve.ask. For writes, Guard supports PostgreSQL, MySQL and MariaDB. Keep write credentials in the executor, not in the assistant.
Conclusion
Claude and Cursor are powerful tools. When they connect to production data, they need a control layer. Retrieve limits and structures what they can read. Guard checks proposed writes before they run. Traces make requests and decisions reviewable. Do not give them unrestricted database access.
You might also like…
Guides · Guard
Stop Cursor or Claude Code From Running Destructive SQL: Use a Pre-Execution Check
Guides · Retrieval
Read Replica vs Production for AI Agents: When a Replica Is Enough and When It Is Not
Comparison · Security
Best Ways to Give AI Agents Safe Database Access in 2026 (Compared)
Guides · Security
AI Agent Database Permissions Checklist: 12 Controls Before You Connect an Agent