How to Configure Copilot Studio Supabase Read Only Access

Published
Length
3 min read

Luis Felipe Dias

All posts

You set up copilot studio supabase read only access by creating a dedicated Postgres role with select rights. Then you connect your agent to the database using that restricted user account. Many teams start by pasting their default project password into an agent tool. That default role carries admin privileges across the entire database. If an AI agent uses an admin role, one bad query can alter or drop production tables. How to set up copilot studio supabase read only access Every Supabase p

Your coding agents run with your access.

Claude Code reaches prod with a developer's credentials, and approval prompts get clicked through. hoop.dev checks every query, masks sensitive data, and holds risky changes for a human.

You set up copilot studio supabase read only access by creating a dedicated Postgres role with select rights. Then you connect your agent to the database using that restricted user account. Many teams start by pasting their default project password into an agent tool. That default role carries admin privileges across the entire database. If an AI agent uses an admin role, one bad query can alter or drop production tables.

How to set up copilot studio supabase read only access

Every Supabase project starts with a default postgres role. This default role has admin privileges rather than full superuser rights. Supabase blocks superuser access because it allows destructive actions on the database. Even so, the vendor warns against giving the default postgres password to any third-party service. You should create a new database user for each external service instead.

To build a safe setup, you first log in to the database dashboard. Queries that run in the dashboard execute as the default admin role. From there, you create a dedicated role for your AI agent. You grant this new role usage rights on your target schema. Next, you grant select privileges on the specific tables the agent needs to read. You also set default privileges so future tables stay readable or locked down by choice.

Supabase also includes built-in roles like the anon role for API requests. If your agent reaches the database through the REST API, row level security rules apply. You must write select policies that restrict which rows the agent role can read. If your agent uses a direct Postgres connection string, database table grants control the session. Storing that read-only string in your agent action settings finishes the basic setup.

What native database roles solve and what they leave open

A dedicated read-only Postgres role stops the agent from running write or delete statements. The database engine rejects any attempt to modify rows or drop tables. Separating users per service also helps when you need to rotate a leaked password. You can revoke the agent role without breaking other apps that use the database.

Still, native database roles only check who logs in and which tables they can read. Once the session starts, a select grant allows reading every column in those permitted tables by default. Customer tables often hold sensitive fields like emails, phone numbers, card numbers, and national IDs. A read-only user can still pull thousands of these raw records into an agent prompt.

Auditor Read-Only Access + Customer Support Access to Production: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Static connection strings stored in third-party agent tools also create credential management work. The external tool holds a long-lived password that works until someone rotates it by hand. Also, standard role grants do not tie individual AI queries back to the specific person asking the agent. Database logs only show the shared service account name, not the human user behind the request.

Managing sensitive data and query visibility for AI agents

When teams connect AI agents to production data, table-level read grants are only the first step. Security teams also need a way to inspect queries while they run. Data masking rewrites matched fields like emails or card numbers in query results. This step prevents raw personal data from entering the model context during a support chat.

Teams also benefit from setting row limits and query timeouts on agent sessions. An AI agent might write a broad join that scans millions of rows by mistake. Controlling the session at runtime stops heavy queries from hurting database performance for real users. Clear audit logs that record every statement give compliance teams full visibility into agent behavior.

Check every Postgres query on the wire

Database roles and network rules decide who can open a session. They do not read what each SQL statement does after login. With hoop.dev, you run an open-source proxy, a sidecar for your Postgres. It runs beside your database and reads the Postgres wire protocol. Your apps and agents keep their login details and change only the host and port in the connection string their tool uses.

Before a query runs, hoop.dev guardrails check the statement by its effect, table, or pattern. They refuse bad deletes or drops with a real Postgres error. On the way back, hoop.dev data masking rewrites sensitive values in returned rows based on your rules. Every query and verdict goes to the audit trail. Furthermore, hoop.dev holds SOC 2 Type II, is MIT licensed, and generates evidence for HIPAA, GDPR, and PCI DSS. See the code on GitHub.

Frequently asked questions

Should I use the default postgres role for my AI agent?

No, the default postgres role has admin privileges across your project. Supabase advises creating a separate user for every external service you connect. A custom role lets you limit the agent to select queries on approved tables.

Does a read-only Postgres role hide sensitive columns from the agent?

A standard table select grant lets the user read every column on that table by default. Unless you maintain column-level grants or views, the agent can read emails and card numbers. Adding runtime data masking rewrites those sensitive fields in the query results by default.

How do I stop an AI agent from modifying rows in Supabase?

Grant only schema usage and table select rights to the database user your agent uses. Do not grant insert, update, delete, or truncate rights to that role. If you use the Supabase API, create row level security policies for select actions only.

The query runs. The emails stay hidden.