Blog

Claude Code Supabase MCP Integration Guide

How to connect Claude Code to Supabase via MCP, covering setup, schema exploration, query building, RLS policy review, data seeding, and migration generation.

Phos Team ·
claude code

What Supabase MCP Exposes to Claude

Supabase is a backend platform built on Postgres, with additional layers for authentication, storage, edge functions, and real-time subscriptions. The Supabase MCP server gives Claude Code structured access to most of those layers through the Supabase Management API.

Once configured, Claude can see and interact with:

  • Database: table schemas, column definitions, foreign key relationships, row counts, and query execution
  • Authentication: user records, auth configuration, and provider settings
  • Storage: bucket listings and file metadata
  • Edge functions: deployed function names and their configurations
  • Row-level security: existing RLS policies on tables

This is especially useful for developers building on Supabase who want Claude to understand the full shape of their backend, not just the files in their local codebase. The Claude Code course covers how to work with MCP servers and backend integrations like this as part of a structured workflow.

When Claude knows your Supabase schema, it generates code that fits your actual data model instead of requiring you to explain it every time.


Installation

The Supabase MCP server is published by the Supabase team.

npm install -g @supabase/mcp-server-supabase

Configuration

You need two values from your Supabase project:

  • Project URL: found in your Supabase dashboard under Project Settings > API
  • Service role key: found in the same location (use the service role key, not the anon key, to enable full schema access)

The service role key bypasses row-level security. Treat it as a privileged credential and never expose it in client-side code or commit it to version control.

Add the server to your project’s .mcp.json:

{
  "mcpServers": {
    "supabase": {
      "command": "npx",
      "args": ["-y", "@supabase/mcp-server-supabase"],
      "env": {
        "SUPABASE_URL": "https://your-project-ref.supabase.co",
        "SUPABASE_SERVICE_ROLE_KEY": "eyJhbGci..."
      }
    }
  }
}

Restart Claude Code after saving. Verify the connection:

What tables exist in my Supabase database?

Claude should return a list of your tables with their column definitions.


5 Workflows the Supabase MCP Server Enables

Workflow 1: Schema Exploration

When starting work on a new feature, ask Claude to map your schema and identify the relevant tables before writing any code.

List all tables in my Supabase database. For each one, show the columns, 
data types, and any foreign key relationships. Then identify which tables 
are most relevant for building a user notification preferences feature.

Claude reads the schema through the MCP server and reasons across the relationships to identify relevant tables. This replaces the manual process of opening the Supabase dashboard and reading table definitions before writing code.


Workflow 2: Query Building

Ask Claude to write and validate SQL queries against your actual schema.

Write a query that returns all users who have placed an order in the last 30 days 
but have not logged in since then. Use the actual column names from my schema.

Because Claude has access to the real table names and column definitions, it generates SQL that runs correctly on the first try instead of producing placeholder names you have to substitute.


Workflow 3: RLS Policy Review

Row-level security policies are critical for Supabase applications but difficult to audit manually. Claude can read all existing policies and reason about gaps.

List all RLS policies on every table in my database. 
For each table, tell me: is RLS enabled? What operations are covered? 
Are there any tables where authenticated users could access other users' data?

Claude fetches the policies through the MCP server and performs a structured audit. This surfaces security gaps that are easy to miss when reviewing policies one table at a time.


Workflow 4: Data Seeding

During development, generating realistic seed data that respects foreign key constraints is tedious. Claude can read your schema and generate seed SQL that inserts valid records.

Write a SQL seed script that creates 10 realistic test users, 
3 organizations, and assigns each user to one organization. 
Use the actual foreign key structure from my schema.

Claude reads the schema, identifies the constraints, and generates valid SQL that can be run directly in the Supabase SQL editor or via a migration file.


Workflow 5: Migration Generation

When you need to modify your schema, Claude can read the current state and generate the migration SQL.

I need to add a subscription_tier column to the users table 
(values: 'free', 'pro', 'enterprise', default 'free') and create 
a new subscription_events table that references users. 
Write the migration SQL.

With the current schema visible, Claude generates migration SQL that accounts for existing data, uses the right column types, and sets up foreign keys correctly.


Limits of the Supabase MCP Server

The server provides significant access, but some operations remain outside its scope.

CapabilitySupabase MCP serverAlternative
Read table schemasSupported
Execute SQL queriesSupported
Read RLS policiesSupported
Create or modify RLS policiesLimitedSupabase dashboard or migration SQL
Deploy edge functionsNot supportedSupabase CLI
Manage auth providersRead-onlySupabase dashboard
Real-time subscriptionsNot supportedApplication code
Storage file contentsMetadata onlySupabase dashboard or SDK

For operations not covered by the MCP server, use the Supabase CLI through Claude Code’s built-in Bash tool or access the Supabase dashboard directly.


Frequently Asked Questions

Is it safe to use the service role key in the MCP config?

The service role key has full access to your database, bypassing RLS. In your local development config (.mcp.json in your project root), it is acceptable if you keep the file out of version control. Add .mcp.json to your .gitignore. For production data access, consider creating a read-only Postgres role with a direct connection and using the PostgreSQL MCP server instead.

Can I connect to multiple Supabase projects at the same time?

Yes. Define each project as a separate server with a distinct key in mcpServers. Use descriptive names like supabase-production and supabase-staging to keep them distinct. Direct Claude to the right one by naming it in your prompt.

Will Claude modify my production data when I ask it to run queries?

Claude will only execute queries if you ask it to. However, the service role key grants write access. For safety during schema exploration, ask Claude to run SELECT queries only, or create a read-only database role and use that key instead.

Does the Supabase MCP server work with self-hosted Supabase?

The standard server is designed for Supabase Cloud. Self-hosted setups have different API endpoints and may require configuration changes. Check the server’s GitHub repository for self-hosted configuration options.


Ready to connect Claude Code to your Supabase backend?

Follow the installation and configuration steps above, start with schema exploration to confirm the connection, then move into query building and RLS review as your workflow matures.

Path one: set it up yourself. The setup takes about ten minutes once you have your service role key. The Claude Code course covers how to structure backend-aware workflows that get the most out of MCP integrations like this one.

Path two: work with Phos AI Labs. If you want Supabase MCP integrated as part of a full Claude Code setup for your development team, including workflow design, security considerations, and connecting the database layer to broader development operations, we handle that implementation. Phos AI Labs is a CCA-F certified Claude implementation partner. Thirty minutes, no deck. Start here.

Related articles

The fastest way to know whether we're the right fit, is a conversation.

STEP 1/2 · ABOUT YOU