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

  1. Select your project in the Supabase Dashboard.
  2. Go to Settings > General.
  3. 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)

Bash
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)

  1. On the Supabase Access Tokens page, click Generate new token.
  2. 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.
  3. Copy the token right away and store it somewhere safe. You won't see it again.
Bash
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:

JSON
{
  "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.json is 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:

TEXT
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:

TEXT
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

StepDetails
Find Project RefDashboard > Settings > General
Register MCPclaude mcp add --transport http supabase <URL>
AuthenticateOAuth login via /mcp by default; PAT header for CI
VerifyQuery tables from Claude Code

You can now ask Claude Code things like "create a table" or "set up an RLS policy".


References: