Supabase MCP server

Enables AI to perform database operations with Supabase including reading, creating, updating, and deleting records with filtering, pagination, and sorting capabilities.
Back to servers
Setup instructions
Provider
gevans3000
Release date
Apr 05, 2025
Language
Python

The Supabase MCP server implements the Model Context Protocol to provide database operation tools that enable large language models to interact with Supabase databases. It offers a standardized way to perform common database operations like reading, creating, updating, and deleting records directly from AI assistants.

Prerequisites

  • Python 3.8 or higher
  • A Supabase project with tables already set up
  • Supabase service role key for authentication

Installation

Clone and Setup

Clone this repository:

git clone https://github.com/gevans3000/supabase-mcp.git
cd supabase-mcp

Set Up a Virtual Environment

# Create a virtual environment
python -m venv venv

# Activate the virtual environment
# On Windows:
venv\Scripts\activate
# On macOS/Linux:
source venv/bin/activate

Install Dependencies

pip install -r requirements.txt

Configure Environment Variables

Copy the example environment file:

cp .env.example .env
# On Windows, use:
# copy .env.example .env

Edit the .env file and add your Supabase credentials:

SUPABASE_URL=your_supabase_project_url
SUPABASE_SERVICE_ROLE_KEY=your_supabase_service_role_key

Usage

Starting the Server

With your virtual environment activated, run:

python server.py

The server uses Stdio transport, listening for MCP requests on standard input and responding on standard output.

Integrating with MCP Clients

Adding to Windsurf/Cursor MCP Configuration

  1. Locate your mcp_config.json file:

    • Windows: C:\Users\<username>\.codeium\windsurf\mcp_config.json
    • macOS: ~/.codeium/windsurf/mcp_config.json
    • Linux: ~/.codeium/windsurf/mcp_config.json
  2. Add the Supabase MCP server to the configuration:

{
  "mcpServers": {
    "supabase": {
      "command": "python",
      "args": [
        "/path/to/your/supabase-mcp/server.py"
      ],
      "env": {
        "SUPABASE_URL": "your_supabase_url",
        "SUPABASE_SERVICE_ROLE_KEY": "your_supabase_key"
      }
    }
  }
}

For better isolation, you can use the Python executable from your virtual environment:

{
  "mcpServers": {
    "supabase": {
      "command": "/path/to/your/venv/bin/python",
      "args": [
        "/path/to/your/supabase-mcp/server.py"
      ]
    }
  }
}
  1. Restart your Windsurf/Cursor application to apply the changes.

Available Tools

read_records

Reads records from a Supabase database table with flexible querying options.

Parameters:

  • table (string, required): Name of the table to read from
  • columns (string, optional, default: "*"): Columns to select (comma-separated or * for all)
  • filters (object, optional): Filtering conditions as key-value pairs
  • limit (integer, optional): Maximum number of records to return
  • offset (integer, optional): Number of records to skip for pagination
  • order_by (object, optional): Sorting options as column:direction pairs

Example:

{
  "table": "users",
  "columns": "id,name,email",
  "filters": {"is_active": true},
  "limit": 10,
  "offset": 0,
  "order_by": {"created_at": "desc"}
}

create_records

Creates one or more records in a Supabase database table.

Parameters:

  • table (string, required): Name of the table to create records in
  • records (object or array, required): A single record object or array of record objects to create

Example (single record):

{
  "table": "users",
  "records": {
    "name": "John Doe",
    "email": "[email protected]",
    "role": "user"
  }
}

Example (multiple records):

{
  "table": "users",
  "records": [
    {
      "name": "John Doe",
      "email": "[email protected]",
      "role": "user"
    },
    {
      "name": "Jane Smith",
      "email": "[email protected]",
      "role": "admin"
    }
  ]
}

update_records

Updates existing records in a Supabase database table based on filter conditions.

Parameters:

  • table (string, required): Name of the table to update records in
  • updates (object, required): Fields to update as key-value pairs
  • filters (object, required): Filtering conditions to identify records to update

delete_records

Deletes records from a Supabase database table based on filter conditions.

Parameters:

  • table (string, required): Name of the table to delete records from
  • filters (object, required): Filtering conditions to identify records to delete

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":"python","args":["/path/to/your/supabase-mcp/server.py"],"env":{"SUPABASE_URL":"your_supabase_url","SUPABASE_SERVICE_ROLE_KEY":"your_supabase_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": "python",
            "args": [
                "/path/to/your/supabase-mcp/server.py"
            ],
            "env": {
                "SUPABASE_URL": "your_supabase_url",
                "SUPABASE_SERVICE_ROLE_KEY": "your_supabase_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": "python",
            "args": [
                "/path/to/your/supabase-mcp/server.py"
            ],
            "env": {
                "SUPABASE_URL": "your_supabase_url",
                "SUPABASE_SERVICE_ROLE_KEY": "your_supabase_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