How to connect a Supabase database to Claude, ChatGPT and Cursor, read-only
Updated
Create a login in Supabase that can only read, add a policy so row level security lets it see the rows, and paste its Session pooler connection string into Kaiva Bridge. Bridge turns your tables into tools on one MCP address for Claude, ChatGPT and Cursor, and every call runs in a read-only transaction. Each person signs in with their own Kaiva account, so nobody needs your Supabase password.
Step by step
- Create a read-only loginIn Supabase's SQL Editor, run the SQL below. It makes a login called ai_reader that can read the tables in the public schema and nothing else.
- Let row level security show it the rowsTables made in Supabase's Table Editor have row level security on, and a new login sees no rows in them until a policy lets it. Add a SELECT policy for ai_reader on each table it should read.
- Copy the Session pooler connection stringClick Connect at the top of your project, choose Session pooler and copy the string. Its user is postgres followed by a dot and your project's ref: change postgres to ai_reader, keep the dot and the ref, and put ai_reader's password in.
- Create the server in Kaiva BridgeSign up free at app.kaiv.ai, choose New server, then Database, then PostgreSQL, and paste the string. If Bridge says it couldn't verify the certificate, download your project's CA certificate in Supabase's database settings, under SSL configuration, and add it.
- Choose tools and connectBridge makes two tools per table: get_<table> reads rows and summarize_<table> counts and totals them. Switch on the ones your AI needs, click Deploy server, and add the address from the Connect tab to Claude, ChatGPT or Cursor.
From a terminal, with the connection string read from a variable so it never lands in your shell history:
npx @kaiva/cli login
printf %s "$SUPABASE_AI_URL" | npx @kaiva/cli bridge push supabase-db --postgres --secret-stdin
npx @kaiva/cli bridge install supabase-db --client cursorThe SQL for Supabase
Run it in the SQL Editor. Add one policy line for each table with row level security on. Put a condition in place of true to share only some rows.
CREATE ROLE ai_reader LOGIN PASSWORD 'choose-a-long-random-password';
GRANT CONNECT ON DATABASE postgres TO ai_reader;
GRANT USAGE ON SCHEMA public TO ai_reader;
GRANT SELECT ON ALL TABLES IN SCHEMA public TO ai_reader;
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO ai_reader;
ALTER ROLE ai_reader SET default_transaction_read_only = on;
-- one line per table with row level security on
CREATE POLICY ai_reader_read ON public.orders FOR SELECT TO ai_reader USING (true);Why the Session pooler
Supabase's direct connection uses IPv6 unless your project has the IPv4 add-on. The Session pooler works over IPv4 as well.
What your AI can do with it
Ask "how many orders shipped late this week?" and your AI calls summarize_orders with a filter. Ask for the late orders and it calls get_orders. It never writes SQL, and only the tables and columns ai_reader can read become tools.
A Supabase project and a free Kaiva account are all you need. Free includes 10 MCP servers, 200,000 tool calls a month and 200 pages of documents, with no card.
Other ways to do it
- Supabase's own MCP serverBest when you want your AI to manage the project: run SQL, change the schema, deploy functions. Each person signs in to Supabase. In read-only mode it uses a role that can read every table, so row level security doesn't narrow what it sees.
- Kaiva Postgres MCP, on your machineFor Claude Code, Cursor or Claude Desktop on your own machine: free, open source, read-only, no account. Use the same ai_reader string, and if the connection fails on the certificate, add sslrootcert= and the path to your project's CA file to the URL.
- A database client with AI built inSome SQL editors let an AI write queries for you. Fine for one person at a desk; it doesn't give Claude, ChatGPT or your team an address to use.
Questions
- Why does the AI see no rows?
- Row level security is on and no policy lets ai_reader read that table. Add a SELECT policy for it.
- Can the AI change my Supabase data?
- Not through Bridge. Its database tools only read, every call runs in a read-only transaction, and ai_reader has no write grants.
- Do my teammates need a Supabase account?
- No. They join your Kaiva workspace and sign in to Kaiva Bridge from Claude, ChatGPT or Cursor. The database password stays with Bridge, encrypted, and is never sent to the AI client.
- Which connection string should I use?
- The Session pooler string, with ai_reader, a dot and your project's ref as the user.
- Does it work with a Lovable or Bolt app's database?
- Yes, if the app uses a Supabase project you can open in Supabase's dashboard: the steps are the same.
- Is it free?
- Free includes 10 MCP servers, 200,000 tool calls a month and 200 pages of documents, with no card.