Setting Up Supabase MCP — Control Supabase Directly from Claude Code
Once Supabase MCP is connected, you can create tables, set RLS policies, and query data from Claude Code through conversation.
What is MCP?
MCP (Model Context Protocol) is a standard protocol that lets LLMs talk to external services. With Supabase MCP connected, Claude Code can access your Supabase project to manage the database, run queries, and more.
Prerequisites
- A Supabase account and project (create one at supabase.com if needed)
- Claude Code installed
Step 1: Find Your Project Reference
- Select your project in the Supabase Dashboard.
- Go to Settings > General.
- Copy the Reference ID (e.g.,
abcdefghijklmnop).
Adding project_ref to the URL limits the MCP server to that one project.
Step 2: Register the MCP Server in Claude Code
Option A: OAuth login (the default in the Supabase docs)
claude mcp add --scope project --transport http supabase \
"https://mcp.supabase.com/mcp?project_ref=<YOUR_PROJECT_REF>"
--scope project saves the server to .mcp.json in your project root. Then open /mcp in Claude Code, pick the supabase server, and authenticate: a browser window opens, you sign in to Supabase and grant access. No token needed.
Option B: Personal Access Token header (CI and other environments without a browser login)
- On the Supabase Access Tokens page, click Generate new token.
- Name it for its purpose (e.g.,
claude-code-mcp), scope it to the project you'll connect, and grant only the permissions you need. - Copy the token right away and store it somewhere safe. You won't see it again.
claude mcp add --transport http supabase \
"https://mcp.supabase.com/mcp?project_ref=<YOUR_PROJECT_REF>" \
--header "Authorization: Bearer <YOUR_ACCESS_TOKEN>"
To use a config file instead, add it to .mcp.json in your project root. Pass the token through an environment variable rather than writing it into the file:
{
"mcpServers": {
"supabase": {
"type": "http",
"url": "https://mcp.supabase.com/mcp?project_ref=${SUPABASE_PROJECT_REF}",
"headers": {
"Authorization": "Bearer ${SUPABASE_ACCESS_TOKEN}"
}
}
}
}
Warning: Never expose your token.
.mcp.jsonis committed to your repository, so a token written into it is published along with it.
Step 3: Verify the Connection
Launch Claude Code and ask:
What tables are in my database?
If you get your project's table list, you're connected. You can also check with claude mcp get supabase.
Read-Only Mode
The Supabase docs recommend narrowing the scope when connecting to a production project. Adding read_only=true runs every query as a read-only Postgres user:
https://mcp.supabase.com/mcp?project_ref=<YOUR_PROJECT_REF>&read_only=true
You can also limit the tool groups, e.g. features=database,docs.
Summary
| Step | Details |
|---|---|
| Find Project Ref | Dashboard > Settings > General |
| Register MCP | claude mcp add --transport http supabase <URL> |
| Authenticate | OAuth login via /mcp by default; PAT header for CI |
| Verify | Query tables from Claude Code |
You can now ask Claude Code things like "create a table" or "set up an RLS policy".
References: