Setting Up Supabase MCP — Control Supabase Directly from Claude Code
Connect Supabase MCP to create tables, set RLS policies, and query data through conversation in Claude Code.
What is MCP?
MCP (Model Context Protocol) is a standard protocol for LLMs to communicate with external services. By connecting Supabase MCP, Claude Code can directly access your Supabase project to manage databases, run queries, and more.
Prerequisites
- A Supabase account and project (create one at supabase.com if you don't have one)
- Claude Code installed
Step 1: Generate an Access Token
A Supabase Personal Access Token is required for the MCP server to access your project with your account privileges.
- Go to the Supabase Access Tokens page.
- Click Generate new token.
- Enter a token name (e.g.,
claude-code-mcp). - Copy the generated token immediately and store it somewhere safe. You won't be able to see it again.
Warning: A Personal Access Token has the same privileges as your account. Never expose it publicly.
Step 2: Find Your Project Reference
- Go to the Supabase Dashboard and select your project.
- Navigate to Settings > General.
- Copy the Reference ID (e.g.,
abcdefghijklmnop).
Step 3: Register the MCP Server in Claude Code
Run the following command in your terminal:
claude mcp add supabase \
--transport http \
--url "https://mcp.supabase.com/mcp?project_ref=<YOUR_PROJECT_REF>" \
--header "Authorization: Bearer <YOUR_ACCESS_TOKEN>"
Replace <YOUR_PROJECT_REF> and <YOUR_ACCESS_TOKEN> with your actual values.
Alternatively, add it directly to .claude/settings.json:
{
"mcpServers": {
"supabase": {
"type": "http",
"url": "https://mcp.supabase.com/mcp?project_ref=<YOUR_PROJECT_REF>",
"headers": {
"Authorization": "Bearer <YOUR_ACCESS_TOKEN>"
}
}
}
}
Step 4: Verify the Connection
Launch Claude Code and ask:
What tables are in the database?
If it returns your Supabase project's table list, the connection is working.
Read-Only Mode
When connecting to production data, it's recommended to add read_only=true to the URL:
https://mcp.supabase.com/mcp?project_ref=<YOUR_PROJECT_REF>&read_only=true
This allows read access only and blocks any data modifications.
Summary
| Step | Description |
|---|---|
| Generate Access Token | Dashboard > Account > Access Tokens |
| Find Project Ref | Dashboard > Settings > General |
| Register MCP | claude mcp add command or settings.json |
| Verify Connection | Query tables in Claude Code |
Now you can make natural language requests like "create a table" or "set up RLS policies" directly in Claude Code.
References: