MCP HubMCP Hub
supabase-community

mcp-supabase

by: supabase-community

A collection of MCP servers that connect LLMs to Supabase

1193created 20/12/2024
Visit
Supabase
LLMs

📌Overview

Purpose: To provide a standardized interface that connects Large Language Models (LLMs) with external services, specifically Supabase.

Overview: The Model Context Protocol (MCP) serves as a bridge between LLMs and external data services, allowing for enhanced interaction and functionality. This repository features a collection of MCP servers designed to integrate seamlessly with Supabase, enabling LLMs to leverage external resources effectively.

Key Features:

  • PostgREST Server: This MCP server allows users to connect their Supabase projects, or any PostgREST-compatible database, directly to an LLM. It facilitates querying the database through the LLM's chat interface, enhancing user experience and data accessibility.

  • Management API (Coming Soon): This upcoming feature will enable users to manage their Supabase projects, schema, and DDL directly through an LLM, streamlining project management tasks and improving efficiency.


Supabase MCP Server

Connect your Supabase projects to Cursor, Claude, Windsurf, and other AI assistants.

The Model Context Protocol (MCP) standardizes how Large Language Models (LLMs) talk to external services like Supabase. It connects AI assistants directly with your Supabase project and allows them to perform tasks like managing tables, fetching config, and querying data.

Prerequisites

You will need Node.js installed on your machine. You can check this by running:

node -v

If you don't have Node.js installed, you can download it from nodejs.org.

Setup

1. Personal access token (PAT)

Go to your Supabase settings and create a personal access token. Give it a descriptive name like "Cursor MCP Server". This token authenticates the MCP server with your Supabase account. Make sure to copy the token, as you won't see it again.

2. Configure MCP client

Configure your MCP client (such as Cursor) to use this server. Most MCP clients store the configuration as JSON:

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

Replace <personal-access-token> with your token. Alternatively, omit --access-token and set the SUPABASE_ACCESS_TOKEN environment variable instead. Restart the MCP client after setting it.

If your MCP client doesn't accept JSON, the direct CLI command is:

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

Note: Do not run this command directly; it is meant to be executed by your MCP client to start the server.

Windows

On Windows, prefix the command with cmd /c:

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

Or use wsl if running Node.js inside WSL:

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

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

  1. Get the path to npm:

    npm config get prefix
    
  2. Add the directory to your PATH:

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

Read-only mode

To restrict the Supabase MCP server to read-only queries, add the --read-only flag:

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

This prevents write operations by executing SQL as a read-only Postgres user. The flag applies only to database tools (execute_sql and apply_migration), not to others like create_project.

Tools

Note: This server is pre-1.0; expect some breaking changes between versions.

The Supabase MCP server provides the following tools:

Project Management

  • list_projects: Lists all Supabase projects for the user.
  • get_project: Gets details for a project.
  • create_project: Creates a new Supabase project.
  • pause_project: Pauses a project.
  • restore_project: Restores a project.
  • list_organizations: Lists all organizations the user belongs to.
  • get_organization: Gets organization details.

Database Operations

  • list_tables: Lists tables within specified schemas.
  • list_extensions: Lists database extensions.
  • list_migrations: Lists migrations in the database.
  • apply_migration: Applies a SQL migration (DDL changes).
  • execute_sql: Executes raw SQL queries.
  • get_logs: Retrieves logs for a project by service type (e.g., api, postgres, edge functions).

Project Configuration

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

Branching (Experimental, requires a paid plan)

  • create_branch: Creates a development branch with migrations.
  • list_branches: Lists development branches.
  • delete_branch: Deletes a development branch.
  • merge_branch: Merges changes from a development branch to production.
  • reset_branch: Resets migrations of a development branch.
  • rebase_branch: Rebases a development branch on production.

Development Tools

  • generate_typescript_types: Generates TypeScript types from the database schema.

Cost Confirmation

  • get_cost: Retrieves the cost of a new project or branch.
  • confirm_cost: Confirms the user's acknowledgment of costs.

Other MCP servers

@supabase/mcp-server-postgrest

The PostgREST MCP server connects your users to your app via REST API. See details in the project README.

Resources

License

This project is licensed under Apache 2.0. See the LICENSE file for details.