How to Configure Mastra Supabase Approval

Published
Length
3 min read

Luis Felipe Dias

All posts

You set up a mastra supabase approval step by pausing agent workflows before database writes. Your app waits for a human check before the agent runs the query. Teams often start by giving AI agents direct database keys to speed up testing. When those roles are too broad, a bad prompt can alter or delete production tables. Putting a human check in front of risky actions stops bad writes before they run. It also forces teams to separate read tasks from write tasks. How mastra supabase approval

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 a mastra supabase approval step by pausing agent workflows before database writes. Your app waits for a human check before the agent runs the query.

Teams often start by giving AI agents direct database keys to speed up testing. When those roles are too broad, a bad prompt can alter or delete production tables. Putting a human check in front of risky actions stops bad writes before they run. It also forces teams to separate read tasks from write tasks.

How mastra supabase approval works in practice

In a standard setup, the agent framework handles the pause and resume logic. When an agent picks a database tool, the workflow stops and saves its current state. The app sends a message to a reviewer with the planned action and details. The workflow stays paused until a team member marks the task as approved or denied.

On the database side, every project starts with a default postgres role. This default role has admin rights, though the platform does not grant full superuser status. The platform blocks superuser access because it lets users run destructive commands on the database. Even so, the default postgres role has extra rights for many admin tasks.

The password you set when creating a project belongs to this default postgres role. Official docs state you should never share this password with an external service. Instead, you should create a new database user for every service or agent you run. Each project also comes with built-in roles like anon for public requests. When you run queries in the project dashboard, they run as the default postgres role.

What native roles solve and what they miss

Creating a separate database user for your agent limits what the agent can touch. You can grant that user read rights on one table and write rights on another. This setup controls who can log in and which tables they can reach. Combining dedicated database users with workflow pauses handles basic team checks well.

Still, database roles only check permissions when a session starts or a table is accessed. A role cannot tell if a valid delete query will wipe one row or thousands. App-level pauses also depend on developers wrapping every single database tool call in code. If a developer forgets to add the pause step to a new tool, queries run unchecked.

Approval Chains & Escalation + End-to-End Encryption: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Static database credentials also sit in your app settings so the agent can use them. Anyone who can read those app settings can use the database key directly. Also, native roles do not mask sensitive fields in query results. If a table holds emails, phone numbers, card numbers, or national IDs, queries return them raw. Masking rules are needed to rewrite matched fields in results before the agent processes them.

Separating read queries from write queries

A clean setup splits agent tools into safe read actions and gated write actions. You can map read tools to a database user that only has select rights. The agent can then fetch context and answer user questions without pausing for human checks. This keeps daily read tasks fast while protecting the database from changes.

For write tools, you use a separate database role with insert or update rights. Every tool that uses this write role triggers a pause in the agent workflow. A reviewer checks the exact inputs before the app runs the query against the database. Still, keeping track of these separate keys across many agents takes ongoing work from your team.

Add query and result controls beside Postgres

Grants and pools govern who logs into PostgreSQL. Yet every query in an open session still runs with that role's full scope. In practice, hoop.dev runs beside your database as a sidecar for your Postgres. It reads plain and prepared queries on the wire with no change to your users or drivers.

When a tool or agent sends SQL, hoop.dev Postgres controls check each statement against your deny rules. An AI Analyzer you configure can also score intent or hold a risky query for human review. Matched sensitive columns in result rows are masked in memory before they reach the caller. Each query and decision is logged per listener, which generates evidence for SOC 2, HIPAA, and GDPR audits. View the binary on GitHub.

Frequently asked questions

Should I give my AI agent the default postgres role password?

No, you should keep the default postgres password strictly for admin tasks. The platform advises creating a dedicated database user with limited rights for each external service.

Does an app-level workflow pause protect against raw SQL queries?

An app pause only stops the workflow until a human clicks approve. It does not parse the SQL statement or restrict what the database role can do once approved.

How can I protect sensitive data when my agent reads from tables?

Database roles grant table or column access, so permitted queries return raw values. To protect emails, phone numbers, or card numbers, you need masking that rewrites matched fields in results.

The query runs. The emails stay hidden.