# Cursor + Supabase MCP: the service_role risk most setup guides skip

> Most Cursor + Supabase MCP guides stop at pasting an access token into .cursor/mcp.json. The documented risk: the default setup can run with service_role, which bypasses row level security entirely. What to check, and the governed alternative.

Source: https://scribase.com/cursor-supabase-mcp

Connecting Cursor to Supabase over MCP is a few lines in .cursor/mcp.json — an access token, or the hosted mcp.supabase.com endpoint with OAuth. Most setup guides stop there. A real, publicly discussed risk does not: the agent can end up operating the database with service_role access, which bypasses row level security entirely, so a prompt-injection payload hidden in ordinary data can make Cursor leak rows a correctly written policy would have blocked.

## The usual setup

Add the hosted Supabase MCP server (mcp.supabase.com) with OAuth sign-in, or run the npx server locally with an access token in .cursor/mcp.json. Either way, Cursor's Composer/Agent mode can then call tools for listing tables, running queries, creating migrations and generating TypeScript types against the connected project.

## The part guides skip: what role the connection actually runs as

A discussion on Hacker News on exactly this setup flagged it plainly: the assistant can operate the Supabase database "with elevated access via the service_role, which bypasses all row-level security (RLS) protections." That matters specifically for an agent, because an agent reads untrusted content as part of its job — a support ticket, a scraped page, a file in the repo — and a prompt-injection payload hidden in that content can instruct the agent to run a query that, under service_role, returns rows a normal, policy-protected connection never would.

## Sources

- [HN: "Supabase MCP can leak your entire SQL database"](https://news.ycombinator.com/item?id=44502318)

## What to check before trusting a Postgres MCP setup with Cursor

- Which role the MCP server actually connects as — ask for the exact grant, not "it works."
- Whether the server can be restricted to read-only, and whether that restriction is enforced server-side or just a client-side flag the agent could be talked out of.
- Whether every table the agent can reach has row level security on and a real policy, independent of the MCP connection — RLS is the backstop even if the connection role is wrong.
- Whether a destructive call (migration, drop, delete) against production needs anything beyond the agent deciding to send it.

[Check your tables for missing RLS](https://scribase.com/tools/rls-checker)

## The governed alternative

Scribase's MCP server never hands an agent the secret-key-equivalent role by default: agent tokens are scoped (project:<id>:write, sql:read or sql:write, migrations:write), SQL on a connection that is a superuser drops to the project's postgres role for the transaction, and reading the secret key at all needs the separate keys:secret scope. RLS is required at migration time, not optional. Destructive production calls wait for a named approver.

## Sources

- [Scribase docs: Tokens and safety](https://docs.scribase.com/docs/agents/safety)

## FAQ

**Does the Supabase MCP server for Cursor use the service_role key?**

It depends on how it is configured and which access token or API key is supplied — a real, publicly discussed concern is that a common setup gives the assistant elevated database access via service_role, which bypasses row level security entirely. Check the exact role your specific connection runs as rather than assuming the safe default.

**Why does bypassing RLS matter if I trust my own prompts?**

An agent in Composer/Agent mode reads untrusted content as part of normal work — a support ticket, a web page, a file from a repo — and a prompt-injection payload hidden in that content can direct the agent to run a query. Under service_role that query returns everything; under a normal, RLS-protected role it only returns what a real policy allows.

**How is a Postgres MCP connection on Scribase different?**

Scribase agent tokens are scoped by default (no secret-key-equivalent access unless keys:secret is explicitly granted), SQL never runs as a superuser even with an agent token, and every table is required to have RLS and a real policy before a migration ships — independent of which role the MCP connection itself uses.

**Can I just restrict the MCP server to read-only instead?**

That helps for the specific risk of the agent writing bad data, and several Postgres MCP servers support a read-only flag. It does not address an RLS gap (a read-only connection still returns every row of an unprotected table) or a destructive action taken through the agent's separate deploy credentials rather than the MCP connection itself.

## Related

- [MCP server for Postgres](https://scribase.com/mcp-server-postgres)
- [RLS for AI coding agents](https://scribase.com/rls-for-ai-coding-agents)
- [AI agent database permissions](https://scribase.com/ai-agent-database-permissions)
- [Migrate from Supabase](https://scribase.com/migrate/supabase)