Supabase MCP server

Integrates with Supabase to enable natural language-driven database schema exploration, management, and read-only SQL query execution.
Back to servers
Setup instructions
Provider
Alexander Zuev
Release date
Feb 15, 2025
Language
Python
Stats
765 stars

Query MCP is an open-source MCP server that lets your IDE safely run SQL, manage schema changes, call the Supabase Management API, and use Auth Admin SDK for Supabase projects. With built-in safety controls, it provides a secure interface between your development environment and Supabase services.

Prerequisites

  • Python 3.12 or higher
  • A Supabase project (local or hosted)
  • An API key from thequery.dev

Installation

You can install the server using your preferred Python package manager:

# Recommended: install with pipx for isolated environments
pipx install supabase-mcp-server

# Alternative: install with uv
uv pip install supabase-mcp-server

Configuration

The server requires configuration to connect to your Supabase database and related services.

Required Environment Variables

Variable Description
QUERY_API_KEY API key from thequery.dev (required)
SUPABASE_PROJECT_REF Your Supabase project reference ID
SUPABASE_DB_PASSWORD Your database password
SUPABASE_REGION AWS region where your Supabase project is hosted

Optional Environment Variables

Variable Description
SUPABASE_ACCESS_TOKEN Personal access token for Supabase Management API
SUPABASE_SERVICE_ROLE_KEY Service role key for Auth Admin SDK

Configuration Methods

The server looks for configuration in this order (highest to lowest priority):

  1. Environment variables set directly in your environment
  2. Global config file:
    • Windows: %APPDATA%\supabase-mcp\.env
    • macOS/Linux: ~/.config/supabase-mcp/.env
  3. Default settings (local development defaults)

Creating a Global Configuration File

# On macOS/Linux
mkdir -p ~/.config/supabase-mcp
nano ~/.config/supabase-mcp/.env

# On Windows (PowerShell)
mkdir -Force "$env:APPDATA\supabase-mcp"
notepad "$env:APPDATA\supabase-mcp\.env"

Add your configuration values to the file:

QUERY_API_KEY=your-api-key
SUPABASE_PROJECT_REF=your-project-ref
SUPABASE_DB_PASSWORD=your-db-password
SUPABASE_REGION=us-east-1
SUPABASE_ACCESS_TOKEN=your-access-token
SUPABASE_SERVICE_ROLE_KEY=your-service-role-key

Client Configuration

Cursor

  1. Go to Settings → Features → MCP Servers
  2. Add a new server with this configuration:
    name: supabase
    type: command
    command: /full/path/to/supabase-mcp-server
    

Windsurf

  1. Go to Cascade → Click the hammer icon → Configure
  2. Fill in the configuration:
    {
        "mcpServers": {
          "supabase": {
            "command": "/full/path/to/supabase-mcp-server",
            "env": {
              "QUERY_API_KEY": "your-api-key",
              "SUPABASE_PROJECT_REF": "your-project-ref",
              "SUPABASE_DB_PASSWORD": "your-db-password",
              "SUPABASE_REGION": "us-east-1",
              "SUPABASE_ACCESS_TOKEN": "your-access-token",
              "SUPABASE_SERVICE_ROLE_KEY": "your-service-role-key"
            }
          }
        }
    }
    

Claude Desktop

  1. Find the full path to the executable:

    # On macOS/Linux
    which supabase-mcp-server
    # On Windows
    where supabase-mcp-server
    
  2. Go to Settings → Developer → Edit Config MCP Servers

  3. Add a new configuration:

    {
      "mcpServers": {
        "supabase": {
          "command": "/full/path/to/supabase-mcp-server",
          "env": {
            "QUERY_API_KEY": "your-api-key",
            "SUPABASE_PROJECT_REF": "your-project-ref",
            "SUPABASE_DB_PASSWORD": "your-db-password",
            "SUPABASE_REGION": "us-east-1",
            "SUPABASE_ACCESS_TOKEN": "your-access-token",
            "SUPABASE_SERVICE_ROLE_KEY": "your-service-role-key"
          }
        }
      }
    }
    

Cline

  1. Find the full path to the executable
  2. Click on the "MCP Servers" tab in the Cline sidebar
  3. Click "Configure MCP Servers"
  4. Add the configuration similar to Claude Desktop

Features and Usage

Database Query Tools

  • SQL Query Execution: Execute PostgreSQL queries with risk assessment
    • execute_postgresql: Executes SQL statements against your database
    • get_schemas: Lists schemas with sizes and table counts
    • get_tables: Lists tables, foreign tables, and views with metadata
    • get_table_schema: Gets detailed table structure
    • retrieve_migrations: Gets migrations with filtering and pagination options
    • live_dangerously: Toggles between safe and unsafe modes

Management API Tools

  • send_management_api_request: Sends arbitrary requests to Supabase Management API
  • get_management_api_spec: Gets the enriched API specification with safety information
  • get_management_api_safety_rules: Gets all safety rules with explanations

Auth Admin Tools

  • call_auth_admin_method: Invoke Auth Admin methods with proper parameter handling
  • get_auth_admin_methods_spec: Retrieve documentation for Auth Admin methods

Available methods include:

  • get_user_by_id, list_users, create_user, delete_user
  • invite_user_by_email, generate_link, update_user_by_id

Logs & Analytics Access

  • retrieve_logs: Access logs from any Supabase service (postgres, auth, storage, etc.)

Troubleshooting

  • Debug installation: Run supabase-mcp-server directly from the terminal
  • Find executable path: Use which supabase-mcp-server (macOS/Linux) or where supabase-mcp-server (Windows)
  • Access logs: Check log files at:
    • macOS/Linux: ~/.local/share/supabase-mcp/mcp_server.log
    • Windows: %USERPROFILE%\.local\share\supabase-mcp\mcp_server.log
  • Verify region: Ensure you've specified the correct region for your Supabase project
  • MCP Inspector: Run supabase-mcp-inspector for debugging (source installation only)

Safety Controls

The server implements a three-tier safety system for all operations:

  • Low risk (read-only): Always allowed
  • Medium risk (write operations): Require unsafe mode
  • High risk (destructive operations): Require unsafe mode AND explicit confirmation
  • Extreme risk operations: Never allowed

How to install this MCP server

For Claude Code

To add this MCP server to Claude Code, run this command in your terminal:

claude mcp add-json "supabase" '{"command":"supabase-mcp-server","env":{"QUERY_API_KEY":"your-api-key","SUPABASE_PROJECT_REF":"your-project-ref","SUPABASE_DB_PASSWORD":"your-db-password","SUPABASE_REGION":"us-east-1","SUPABASE_ACCESS_TOKEN":"your-access-token","SUPABASE_SERVICE_ROLE_KEY":"your-service-role-key"}}'

See the official Claude Code MCP documentation for more details.

For Cursor

There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.

If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.

Adding an MCP server to Cursor globally

To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

{
    "mcpServers": {
        "supabase": {
            "command": "supabase-mcp-server",
            "env": {
                "QUERY_API_KEY": "your-api-key",
                "SUPABASE_PROJECT_REF": "your-project-ref",
                "SUPABASE_DB_PASSWORD": "your-db-password",
                "SUPABASE_REGION": "us-east-1",
                "SUPABASE_ACCESS_TOKEN": "your-access-token",
                "SUPABASE_SERVICE_ROLE_KEY": "your-service-role-key"
            }
        }
    }
}

Adding an MCP server to a project

To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.

How to use the MCP server

Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.

The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.

You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.

For Claude Desktop

To add this MCP server to Claude Desktop:

1. Find your configuration file:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json
  • Linux: ~/.config/Claude/claude_desktop_config.json

2. Add this to your configuration file:

{
    "mcpServers": {
        "supabase": {
            "command": "supabase-mcp-server",
            "env": {
                "QUERY_API_KEY": "your-api-key",
                "SUPABASE_PROJECT_REF": "your-project-ref",
                "SUPABASE_DB_PASSWORD": "your-db-password",
                "SUPABASE_REGION": "us-east-1",
                "SUPABASE_ACCESS_TOKEN": "your-access-token",
                "SUPABASE_SERVICE_ROLE_KEY": "your-service-role-key"
            }
        }
    }
}

3. Restart Claude Desktop for the changes to take effect

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later