Supabase MCP server

Connects directly to Supabase projects for managing databases, executing SQL queries, applying migrations, and handling configurations through natural language commands.
Back to servers
Provider
Supabase
Release date
Apr 01, 2025
Language
TypeScript
Package
Stats
129.5K downloads
1.5K stars

Supabase MCP Server enables your Supabase projects to connect with AI assistants like Cursor, Claude, and Windsurf through the Model Context Protocol (MCP). This standardized interface allows AI assistants to directly interact with your Supabase projects, performing tasks such as managing tables, executing queries, and handling database operations.

Prerequisites

You will need Node.js installed on your machine. Verify your installation by running:

node -v

If Node.js isn't installed, download it from nodejs.org.

Installation and Setup

Creating a Personal Access Token

  1. Go to your Supabase settings
  2. Create a personal access token with a descriptive name (e.g., "Cursor MCP Server")
  3. Copy the token immediately as you won't be able to view it again

Configuring Your MCP Client

Configure your MCP client (such as Cursor) with the following JSON configuration:

{
  "mcpServers": {
    "supabase": {
      "command": "npx",
      "args": [
        "-y",
        "@supabase/mcp-server-supabase@latest",
        "--access-token",
        "<personal-access-token>"
      ]
    }
  }
}

Replace <personal-access-token> with your token from step 1. Alternatively, you can omit the --access-token parameter and set the SUPABASE_ACCESS_TOKEN environment variable instead.

Windows-Specific Configuration

For Windows users, prefix the command with cmd /c:

{
  "mcpServers": {
    "supabase": {
      "command": "cmd",
      "args": [
        "/c",
        "npx",
        "-y",
        "@supabase/mcp-server-supabase@latest",
        "--access-token",
        "<personal-access-token>"
      ]
    }
  }
}

If running Node.js inside WSL, use:

{
  "mcpServers": {
    "supabase": {
      "command": "wsl",
      "args": [
        "npx",
        "-y",
        "@supabase/mcp-server-supabase@latest",
        "--access-token",
        "<personal-access-token>"
      ]
    }
  }
}

Ensure Node.js is in your PATH environment variable. If running natively on Windows:

  1. Find your npm path:

    npm config get prefix
    
  2. Add to PATH:

    setx PATH "%PATH%;<path-to-dir>"
    
  3. Restart your MCP client

Usage Options

Project Scoped Mode

To restrict server access to a specific project:

npx -y @supabase/mcp-server-supabase@latest --access-token=<personal-access-token> --project-ref=<project-ref>

Find your Project ID in your Supabase project settings.

When using project scoped mode, account-level tools like list_projects will be unavailable.

Read-only Mode

To limit the server to read-only operations:

npx -y @supabase/mcp-server-supabase@latest --access-token=<personal-access-token> --read-only

This prevents write operations on databases by executing SQL as a read-only Postgres user.

Available Tools

Project Management

These tools are unavailable in project scoped mode:

  • list_projects: Lists all Supabase projects
  • get_project: Gets details for a specific project
  • create_project: Creates a new project
  • pause_project: Pauses a project
  • restore_project: Restores a paused project
  • list_organizations: Lists all your organizations
  • get_organization: Gets details for an organization

Database Operations

  • list_tables: Lists all tables within specified schemas
  • list_extensions: Lists all database extensions
  • list_migrations: Lists all database migrations
  • apply_migration: Applies a SQL migration (tracked within the database)
  • execute_sql: Executes raw SQL queries
  • get_logs: Gets logs by service type (api, postgres, edge functions, etc.)

Edge Function Management

  • list_edge_functions: Lists all Edge Functions
  • deploy_edge_function: Deploys a new Edge Function

Project Configuration

  • get_project_url: Gets the API URL for a project
  • get_anon_key: Gets the anonymous API key

Branching (Requires paid plan)

  • create_branch: Creates a development branch
  • list_branches: Lists all branches
  • delete_branch: Deletes a branch
  • merge_branch: Merges migrations and functions to production
  • reset_branch: Resets migrations to a prior version
  • rebase_branch: Rebases development branch on production

Development Tools

  • generate_typescript_types: Generates TypeScript types from database schema

Cost Management

  • get_cost: Gets the cost for a new project or branch
  • confirm_cost: Confirms understanding of costs (required for creation)

How to add this MCP server to 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 > MCP and click "Add new global MCP server".

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

{
    "mcpServers": {
        "cursor-rules-mcp": {
            "command": "npx",
            "args": [
                "-y",
                "cursor-rules-mcp"
            ]
        }
    }
}

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 explictly ask the agent to use the tool by mentioning the tool name and describing what the function does.

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