Guide · Supabase MCP
Supabase MCP Server: Setup, Read-Only Mode and Safe Scoping
How to connect Claude Code, Cursor, Codex and other AI tools to Supabase's MCP server, which tools it exposes, and how to scope it so an agent never gets more than it needs.
Last checked against its sources on . Part of MCP and Headless Analytics.
The Supabase MCP server is Supabase’s official Model Context Protocol server. Once an AI tool is connected to it, the assistant can list your tables, run SQL, apply migrations, read logs and advisors, generate TypeScript types and search the Supabase docs on your behalf. It is a developer tool: it acts with your permissions, on whatever projects you let it see. Most of setting it up well is deciding how little it should see. For a Postgres database hosted anywhere else, see our Postgres MCP server guide; on Neon, our Neon MCP guide.
The short answer
Supabase hosts the server at https://mcp.supabase.com/mcp. You add that URL to your MCP client, sign in to Supabase in the browser window it opens, and pick the organization that holds your project. No personal access token is needed for interactive use. For almost every team, the URL worth starting from is the scoped, read-only one:
https://mcp.supabase.com/mcp?project_ref=<your-project-ref>&read_only=true&features=database,docsThat limits the agent to one project, runs every query as a read-only Postgres user, and only exposes the database and docs tools. Widen it when a task needs more, not before. If you develop locally with the Supabase CLI, the same server runs at http://localhost:54321/mcp.
Connecting your AI tool
Each client stores MCP servers in its own place. These are the setups Supabase documents for the tools people search for most; for any other client, add the hosted URL wherever it registers HTTP MCP servers.
Claude Code
Add the server to the project from your terminal:
claude mcp add --scope project --transport http supabase "https://mcp.supabase.com/mcp"Or put it in the project’s .mcp.json:
{
"mcpServers": {
"supabase": {
"type": "http",
"url": "https://mcp.supabase.com/mcp"
}
}
}Then authenticate from a regular terminal (not the IDE extension) with claude /mcp, choose the supabase server and select Authenticate.
Cursor
Add this to .cursor/mcp.json in the project, or to ~/.cursor/mcp.json to make it available in every project:
{
"mcpServers": {
"supabase": {
"url": "https://mcp.supabase.com/mcp"
}
}
}Cursor prompts you to sign in. Check the connection under Settings, Cursor Settings, Tools & MCP. The Cursor CLI reads the same file: agent mcp enable supabase, then agent mcp login supabase.
Codex
codex mcp add supabase --url "https://mcp.supabase.com/mcp"
codex mcp login supabaseThe same entry can live in ~/.codex/config.toml under [mcp_servers.supabase]. Run /mcp inside Codex to confirm it authenticated.
VS Code
Add this to .vscode/mcp.json:
{
"servers": {
"supabase": {
"type": "http",
"url": "https://mcp.supabase.com/mcp"
}
}
}Claude.ai and ChatGPT list Supabase as a connector in their own directories, and Supabase’s docs also cover Gemini CLI, the GitHub Copilot CLI, Goose, Kiro, Warp and others. Client commands change often, so check the Supabase MCP docs for your client’s current syntax.
To check it works, ask the assistant something it can only answer through the server: “What tables are in the database? Use MCP tools.”
The options that decide what an agent can do
Every restriction is a query parameter on the server URL, and they combine with &.
| Parameter | What it does |
|---|---|
project_ref=<id> | Limits the server to one project and turns off the account tools (listing, creating and pausing projects, organizations, costs). |
read_only=true | Runs every SQL query as a read-only Postgres user, so the agent can look but not write. |
features=<groups> | Exposes only the tool groups you list, comma-separated, such as database,docs. |
skip_elicitations=<tools> | Skips the confirmation forms some tools show before costly or destructive actions. It does not bypass permissions or read-only mode; leave it unset unless you have a reason. |
Your project ref is the ID in your project’s dashboard URL and in its API URL (<ref>.supabase.co).
What the server exposes
The tools come in groups. Every group your connection supports is on by default except Storage, which is why features is worth setting.
- Database:
list_tables,list_extensions,list_migrations,apply_migrationandexecute_sql. - Debugging:
query_logs(read-only SQL over project logs) andget_advisors(security and performance advisors). - Development:
get_project_url,get_publishable_keysandgenerate_typescript_types. - Edge Functions: list, read and deploy functions.
- Account management: projects, organizations and costs. Off when the server is scoped to a project.
- Docs:
search_docs. - Branching (experimental, paid plans): create, merge, reset and delete development branches.
- Storage (off by default) and, on hosted connections, Notebooks.
For day-to-day schema work, database,docs covers most of it; add debugging when you want the agent reading logs and advisors.
The two risks to plan for
Prompt injection through your own data
Supabase’s own example: a customer files a support ticket whose text tells the model to select everything from a sensitive table and post it as a reply. Later a developer asks their assistant to read that ticket through MCP, and the assistant tries to follow the instructions it found in the data. Supabase wraps SQL results with extra instructions that discourage the model from obeying what is in them, and says plainly that this is not foolproof. The defences that hold are the ones above: read-only mode, one project, few tools, and approving each tool call yourself. We go further into this in prompt injection risks when agents access live databases.
It acts as you
The server runs with your developer permissions. Supabase’s advice is not to hand it to customers or end users, and to connect a production project only when a task needs production evidence, scoped and read-only. Its confirmation dialogs for destructive SQL and paid actions are a guardrail, not a review: some clients can answer them automatically.
A safe setup, in order
- Point it at a development project or a branch, not production.
- Add
project_refso it sees one project and none of your account. - Add
read_only=trueunless the task is writing migrations. - Set
featuresto the groups the task needs. - Keep manual approval of tool calls on in your client.
- Read what the agent got back before letting it act on it, especially when the rows hold text your users wrote.
Using it in CI
Browser sign-in doesn’t work in a pipeline. There, Supabase documents creating a personal access token, scoping it to the one project and the permissions your enabled tools need, and passing it as a header:
{
"mcpServers": {
"supabase": {
"type": "http",
"url": "https://mcp.supabase.com/mcp?project_ref=${SUPABASE_PROJECT_REF}&read_only=true",
"headers": {
"Authorization": "Bearer ${SUPABASE_ACCESS_TOKEN}"
}
}
}
}Keep the token in your CI secrets, never in the repository, and check that your client supports custom headers. An unattended job can’t ask for approval, so give it only read-only, project-scoped tools and have it report a recommendation instead of writing.
When the Supabase MCP server is the wrong interface
The Supabase MCP server is built for the person writing the app. It is not how the agents inside your product, or the ones your teammates run against business numbers, should reach your data: they would be querying live tables with a developer’s reach, and each one would work out its own definition of “active user” or “revenue” from raw rows.
For those agents, the pattern this site keeps returning to is a governed read surface: metrics defined once, pre-aggregated into views or datasets, and served through an MCP server that exposes those and nothing else. Start with why AI agents must not query production Postgres and exposing metrics via MCP without exposing the database.
Sources
Supabase changes the server’s tools and client setup often; its docs are the reference for what is current.


