How to Give an AI Agent Safe Access to Your Supabase Database with Claix
Do not hand an agent a Supabase service role key. Retrieve answers from a read-only connection, and Guard checks every write before your own code runs it.
Claix · November 2026. Related guides: MySQL read-only user for an AI agent, text-to-SQL vs predefined queries, and Slack approvals. Products: Claix Retrieve and Claix Guard.
Claix and Supabase at a glance
| What the agent needs to do | How Claix handles it | Endpoint or interface |
|---|---|---|
| Read live data from Supabase | Retrieve answers questions from your database through a read-only connection | POST /retrieve/{agent}, MCP tool claix.retrieve.ask, A2A |
| Get answers it can use in code or a workflow | Typed results: string, int, boolean, date, json, arrays | Same |
| Change data | The agent proposes, Guard returns allow or deny with a reason, your code executes | POST /check-sql |
| Ask a person first | Guard returns Needs approval and posts to Slack with Approve and Reject buttons | Guard alerts |
| Stay in control | Per-agent call limits, a pause switch and a trace of every query | Dashboard and API |
The usual ways agents reach Supabase, and where each falls short
| Approach | What it gives the agent | Main concern |
|---|---|---|
| The service role key | Unrestricted access to the project | It bypasses row-level security, so one bad prompt or leaked key exposes everything |
| A database MCP server with an execute-SQL tool | Flexible access for development | Supabase's own guidance for its MCP server is to use it with development and test data rather than production, and prompt injection remains a concern even in read-only mode |
| A custom connection with raw SQL generated by the model | Any query the schema supports | The model decides the SQL, and the credentials decide the blast radius |
| One Edge Function per question | Exact, reviewed queries | Every new question needs new code, and the agent has to choose among many tools |
None of these is wrong for every case. A Supabase MCP server is excellent for building and debugging, and Edge Functions are a solid choice when your questions are few and stable. The gap appears when an agent that is part of your product needs live production data and open-ended questions, without being trusted with the keys.
How Claix sits between your agent and Supabase
READS
Agent -> asks in plain language -> Claix Retrieve -> read-only connection -> Supabase
<- typed answer <-----------
WRITES
Agent -> proposes a change -> your code -> POST /check-sql (Claix Guard)
|- allowed -> your code runs it on Supabase
|- denied -> reason returned to the agent
|- needs approval -> Slack -> your approve or reject endpointThe two halves follow one principle: Claix decides, and your code executes. Retrieve reads through a read-only connection, and Guard only returns a verdict. Your data stays in Supabase. Claix does not copy it into a vector store or keep a second version of it.
What Claix Retrieve adds
- Limits you define, not the agent. You connect Supabase and Claix drafts a Data Map of your tables and relationships for you to review. You then create routes, which describe the tables and columns an agent may use and the vocabulary of your business, and agents, each with its own endpoint, prompt and routes.
- No schema in the prompt. The agent asks questions in plain language. It does not need to know your table names or write SQL, which also saves tokens.
- Typed answers. A boolean for an IF node, an integer for a counter, an array for a list. Your code receives data it can use directly instead of text to parse.
- Two kinds of routes. In fixed routes, the model only selects an approved, parameterised query and fills validated values, and it never writes SQL. In open routes, the model writes one read-only SELECT inside the route's allowlist, and a deterministic check rejects anything else before it runs.
- Operational control. Cap how many calls an agent can make per day, week or month, pause an agent instantly, and review a trace of what each agent asked and what ran.
- Your own model key. With BYOK (OpenAI, Google, Anthropic or xAI) you pay your provider for tokens and Claix charges the lower rate.
What Claix Guard adds
Claix Guard is a rules checker for the changes your agent proposes. You describe the rules in plain English, Claix turns them into exact rules with test cases, and you review, accept or edit them. Examples for a Supabase-backed product:
- Agents can change the status of an order but never delete an order.
- Every UPDATE and DELETE must include a condition.
- Refunds above 100 euros need approval.
When your agent proposes a statement, your code sends it to Guard and receives allow or deny with a reason. No AI model decides at check time, so the same statement gets the same answer every time. A verdict can also be Needs approval, which posts the change to Slack with Approve and Reject buttons that call the endpoints you configured. The endpoint is what runs the statement after a person decides.
Set it up in four steps
- Connect Supabase in the Claix dashboard using a read-only connection (the Claix documentation walks through it). Review the Data Map Claix drafts.
- Create a route and an agent. Choose the tables and columns the agent may use, add a short guide in your own vocabulary, and pick fixed or open routes.
- Call the agent from your product, n8n, LangChain or any MCP client.
- Check writes with Guard before your code runs them, and route alerts and approvals to Slack or to your own endpoints.
curl -X POST https://claix.dev/retrieve/support-assistant \
-H 'x-api-key: YOUR_API_KEY' \
-H 'Content-Type: application/json' \
-d '{"questions": [{"question": "How many orders did customer 42 place this month?", "format": "int"}]}'The response has this shape:
{
"user_ask": [{ "question": "How many orders did customer 42 place this month?", "format": "int" }],
"ia_response": [3],
"log_id": "<uuid>"
}curl -X POST https://claix.dev/check-sql \
-H 'x-api-key: YOUR_API_KEY' \
-H 'Content-Type: application/json' \
-d '{"sql": "UPDATE orders SET status = $1 WHERE id = $2", "params": ["shipped", 4812]}'Example: a support agent in a Supabase-backed SaaS
| What the user asks the agent | What happens | Result |
|---|---|---|
| Where is my order 4812? | Retrieve answers from the orders table inside the agent's route | A typed status the product can show |
| Is my plan active? | Retrieve returns a boolean | true or false, ready for the UI |
| Mark this order as shipped | The agent proposes an UPDATE and Guard checks it | Allowed, then your code runs it |
| Refund 250 euros | Guard returns Needs approval | A person approves in Slack, then your endpoint runs the change |
| Delete all my old orders | Guard denies it with a reason | Nothing runs |
How Claix fits with what you already use in Supabase
Claix does not replace the rest of your Supabase setup. Keep row-level security for your application's end users, and keep using the Supabase MCP server in development. Claix is the path for agents in production: it adds per-agent limits, typed answers, write checks, approvals and traces on top of what the database already enforces.
Pricing
Every account has 30 successful calls per month free. Retrieve costs €0.10 per question with Claix Managed AI, or €0.02 with your own LLM key (you pay your provider for tokens). Guard costs €0.01 per check. You pay only for successful calls; authentication errors, invalid requests and server errors are free.
When Claix is not the right tool
- You are building and debugging, and want your assistant to explore the schema or run migrations. Use a development MCP server for that.
- You need open-ended analytical SQL over very large tables. Use a read replica and an analytics tool.
- You need semantic search over documents. A vector store is a better fit.
- Your data is not in a SQL database.
Frequently asked questions
- How do I give an AI agent safe access to Supabase?
- Place a controlled layer between the agent and the database. With Claix, the agent asks questions through Retrieve, which reads through a read-only connection and returns typed answers limited to the tables and columns you allow, and every proposed write goes through Guard before your own code executes it.
- Should an AI agent use the Supabase service role key?
- No. The service role key bypasses row-level security and gives unrestricted access, so a single manipulated prompt or leaked key exposes the whole project. Keep it out of agents.
- Is the Supabase MCP server safe for production?
- Supabase positions its MCP server for development and testing, and recommends caution with production data. It offers safeguards such as read-only mode and project scoping, but prompt injection remains a concern. For agents that serve real users, a controlled layer such as Claix is a better fit.
- Does Claix copy my Supabase data?
- No. Retrieve queries your database where it lives, inside the tables and columns you allow, and does not move your data into a vector store.
- Does Claix write to my Supabase database?
- No. Retrieve uses a read-only connection, and Guard only returns allow, deny or needs approval. Your own code or workflow runs the statement.
- Do I still need row-level security?
- Yes, for your application's end users. Claix adds controls at the agent level on top of it, so the two work together.
- Does Claix work with n8n and LangChain?
- Yes. Retrieve is available over REST, MCP and A2A, and Guard is a REST call, so both work from n8n, LangChain, custom backends and any MCP client.
- What happens when an agent proposes a delete?
- Guard checks the statement against your rules and returns a verdict with a reason. If it is denied, your code does not run it, and you can send the alert to Slack or an endpoint of your choice.
- Can I use it with plain PostgreSQL, MySQL or MariaDB?
- Yes. Claix works with PostgreSQL, MySQL, MariaDB and Supabase.
- Is there a free tier?
- Yes. Every account has 30 successful calls per month free, enough to test the full flow.
Conclusion
An agent that works with production data should not hold the keys to it. Claix gives agents a controlled path to Supabase: Retrieve for scoped, typed reads, Guard for checked writes, approvals in Slack when a person should decide, and a trace of everything. Your data stays in Supabase, and your code stays in charge of executing changes. Try Claix free: 30 successful calls per month.
You might also like…
Guides · MySQL
MySQL Read-Only User for an AI Agent: Setup and the Gaps to Close
Guides · Retrieval
Text-to-SQL vs Predefined Queries: Which Should Your AI Agent Use?
Product · Guard
Claix Guard Now Sends Alerts and Approval Requests to Slack
Comparison · Security
Best Ways to Give AI Agents Safe Database Access in 2026 (Compared)