Skip to main content
Mobile Launcher
Advanced AIAvailable Servers

Supabase MCP Server

Connect your AI to your PostgreSQL database

Supabase MCP Server

The Supabase MCP server allows your AI assistant to interact directly with your PostgreSQL database. This is enhancing for building features that require complex queries or RLS policies.

Features

  • Schema Inspection: The AI can read your entire database structure (tables, columns, types, relationships).
  • SQL Generation: It generates highly accurate SQL queries because it knows your exact schema.
  • Data Querying: It can fetch sample data to understand the content (e.g., "Show me 5 recent users").
  • RLS Policy Assistant: It can help write and debug Row Level Security policies by understanding your auth setup.

Installation & Configuration

Prerequisites

  • Supabase Project Created
  • SUPABASE_URL and SUPABASE_SERVICE_ROLE_KEY available.

Security Warning: You must use the Service Role Key (found in Project Settings > API) for the MCP server to function correctly (it needs admin access to read system schemas). NEVER commit this key to git. Add it to your .env or secure storage.

Setup for Cursor

  1. Open Cursor Settings > Features > MCP.
  2. Click + Add New MCP Server.
  3. Fill in the details:
FieldValue
Namesupabase
Typecommand
Commandnpx -y @modelcontextprotocol/server-supabase
  1. Add Environment Variables:
VariableValue
SUPABASE_URLhttps://your-project-ref.supabase.co
SUPABASE_SERVICE_ROLE_KEYyour-service-role-key

Setup for Claude Code

Add the following to your claude_config.json (or equivalent configuration):

Json
{
  "mcpServers": {
    "supabase": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-supabase"],
      "env": {
        "SUPABASE_URL": "your-project-url",
        "SUPABASE_SERVICE_ROLE_KEY": "your-service-role-key"
      }
    }
  }
}

Usage Examples

Once connected, try these prompts with your AI:

1. Understand your data:

"Analyze my database schema and tell me how the users and subscriptions tables are related."

2. Write complex queries:

"Write a SQL function to calculate the monthly recurring revenue (MRR) for the last 12 months based on the payments table."

3. specific constraints:

"I need to add a constraint to user_profiles ensuring username is alphanumeric. Write the migration SQL."