Supabase Playbook
How to Query Your Supabase Database With AI Agents
Every product question ends at the database — how many signups this week, which plan converts, what changed after the release. The teams that answer fastest don't queue those questions behind a developer with a psql session; they let an agent run the query. Here's how to wire Supabase into your stack safely.
What top teams do
The habits behind teams that treat their Supabase data as something the whole team can ask, not just the person with the connection string.
Ask the database, not a developer
Let an agent translate a plain-language question into SQL and run it against the project through a scoped connection.
Why it works: Most 'quick data questions' are one SELECT away. Removing the human relay turns a day's wait into a minute.
Give agents OAuth, never a connection string
Authorize access through the Management API OAuth flow instead of pasting service-role keys or connection strings into prompts and scripts.
Why it works: OAuth tokens are scoped to one organization, encrypted at rest and revocable in one click — a leaked connection string is none of those things.
Point experiments at staging
Connect a staging project for exploratory agent work, and keep production reads deliberate.
Why it works: The SQL tool executes what it's given, including writes. A staging boundary makes 'let the agent explore' a safe default.
How this plays out in practice
Generalized examples of the kinds of teams running this play.
Routed 'how many / which / since when' questions to an MCP-connected agent that queries Supabase directly, freeing the backend developer from ad-hoc SQL requests.
Had an agent check project health, row counts and new signups each morning and post a one-line digest, replacing a dashboard-checking ritual.
The examples above are generalized, illustrative descriptions of common approaches across the industry. They are not based on, attributed to, or affiliated with any specific company or individual, and are provided for educational purposes only.
Steal these templates
Copy-paste starting points. Swap the brackets for your own topic and ship.
ON QUESTION: list tables → inspect relevant schema → write SELECT → run via database_query_run DAILY: run signup/revenue counts → post digest to the team channel WEEKLY: check project health + edge function list → flag anything that changed
Do it with Modiva
Here’s how to run this play for real — connect once, then publish, schedule and automate across every platform from one place.
- 1
Connect Supabase to Modiva
Sign in at modiva.ai, open Connections → New connection and pick Supabase. You authorize on Supabase's own screen — Modiva stores only a scoped, encrypted token, never your password. The free tier connects your first three accounts at no cost.
💡 Connecting once makes Supabase available to every REST API call and MCP key in your workspace — you never wire up OAuth again.
- 2
Explore the schema, then query
Use Modiva's Supabase tools to list your projects, list tables in a schema and run SQL through the Management API. An agent that inspects the schema first writes far better queries than one guessing at column names.
💡 The SQL tool executes arbitrary statements — including writes. Review what an agent runs against production, or point it at a staging project.
- 3
Manage projects and functions
Read project status, deploy and update edge functions, manage secrets and branches, and update service config through the same connection — so operational work lives next to the data questions instead of in a separate dashboard habit.
- 4
Let an AI agent run the busywork
Create an MCP key and point your AI assistant (Claude, Cursor, or any MCP client) at Modiva. The agent can draft variations, schedule posts, pull engagement and reply to comments through typed tools — across every connected platform at once.
💡 Describe the playbook to your agent in plain language ('repurpose this video into 5 platform-native posts and queue them') and let it call the tools.
FAQ
Can Modiva write to my Supabase database?
The SQL query tool executes the statements it's given, including INSERT, UPDATE, DELETE and DDL — so yes, if you or your agent send a write (it also has a read-only mode that rejects writes). The rest of the connection is read & write too: projects, edge functions, branches, secrets, domains and service config can all be created and managed through typed tools.
How does Supabase authentication work?
Through the Supabase Management API OAuth flow (Authorization Code with PKCE). You authorize once on Supabase's consent screen and pick the organization to share; Modiva stores a scoped, encrypted token and refreshes it automatically.
Which projects can an agent touch?
Only projects in the organization you authorized, and every tool takes an explicit project ref — so an agent has to name the project it's querying. Connect a staging organization if you want a hard safety boundary.