Back to Blog

Setting Up Supabase MCP — Control Supabase Directly from Claude Code

(edited: March 18, 2026)

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.

  1. Go to the Supabase Access Tokens page.
  2. Click Generate new token.
  3. Enter a token name (e.g., claude-code-mcp).
  4. 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

  1. Go to the Supabase Dashboard and select your project.
  2. Navigate to Settings > General.
  3. Copy the Reference ID (e.g., abcdefghijklmnop).

Step 3: Register the MCP Server in Claude Code

Run the following command in your terminal:

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

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:

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

TEXT
https://mcp.supabase.com/mcp?project_ref=<YOUR_PROJECT_REF>&read_only=true

This allows read access only and blocks any data modifications.

Summary

StepDescription
Generate Access TokenDashboard > Account > Access Tokens
Find Project RefDashboard > Settings > General
Register MCPclaude mcp add command or settings.json
Verify ConnectionQuery 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:

Comments