Supabase PostgreSQL MCP server

Provides a bridge to Supabase PostgreSQL databases for managing tables, storage, users, and realtime features through natural language interaction without manual SQL queries.
Back to servers
Provider
Quegenx
Release date
Feb 18, 2025
Language
TypeScript
Stats
11 stars

The Supabase MCP Server is a powerful tool that provides administrative control over your Supabase PostgreSQL database through Cursor's Composer and Codeium's Cascade. It enables seamless database management with features for table operations, record management, schema modifications, and more - all through natural language commands.

Installation

Prerequisites

  • Node.js >= 16.x
  • npm >= 8.x
  • A Supabase project with:
    • Project ID
    • Database password
    • PostgreSQL connection string
  • Cursor IDE or Codeium's Cascade (for paying users)

Setup Instructions

  1. Clone the repository and install dependencies:

    git clone https://github.com/Quegenx/supabase-mcp-server.git
    cd supabase-mcp-server
    npm install
    npm run build
    
  2. Find your Node.js path:

    # On Mac/Linux
    which node
    # On Windows
    where node
    

Configuration

Cursor MCP Integration

  1. Open Cursor Settings > Features > MCP
  2. Click the "+ Add New MCP Server" button
  3. Fill in the form:
    • Name: "Supabase MCP" (or any name you prefer)
    • Type: command (stdio transport)
    • Command: Use the following format, replacing the placeholders:
      /path/to/node /path/to/dist/index.js postgresql://postgres.[PROJECT-ID]:[PASSWORD]@aws-0-eu-central-1.pooler.supabase.com:5432/postgres
      
  4. Click "Add Server" and then click the refresh button

Windsurf/Cascade Integration

  1. Create or edit ~/.codeium/windsurf/mcp_config.json:

    {
      "mcpServers": {
        "supabase-mcp": {
          "command": "/path/to/node",
          "args": [
            "/path/to/dist/index.js",
            "postgresql://postgres.[PROJECT-ID]:[PASSWORD]@aws-0-eu-central-1.pooler.supabase.com:5432/postgres"
          ]
        }
      }
    }
    
  2. In Cascade:

    • Click the hammer icon in the toolbar
    • Click "Configure" to verify your setup
    • Click "Refresh" to load the MCP server

Available Features

Table Management

  • List, create, drop, and rename tables
  • Add, drop, and alter columns
  • Fetch, create, update, and delete records

Indexes & Constraints

  • Manage database indexes and constraints

Database Functions & Triggers

  • Create and manage database functions and triggers

Security & Access Control

  • Manage policies and roles for database access

Storage Management

  • Manage buckets, files, and folders

Realtime Features

  • Control realtime policies, channels, and messaging

User Management

  • Manage user authentication

Direct SQL Access

  • Execute custom SQL queries

Usage Examples

Once configured, you can manage your database through natural language commands:

  • "Show me all tables in my database"
  • "Create a new users table with id, name, and email columns"
  • "Add an index on the email column of the users table"
  • "Fetch the first 10 records from the products table"
  • "Create a new function to calculate total sales"

Troubleshooting

Common Connection Issues

  1. Node.js Path Issues

    • Ensure you're using the correct Node.js path from which node or where node
  2. File Path Issues

    • Use absolute paths instead of relative paths
    • Example: /Users/username/projects/supabase-mcp-server/dist/index.js
  3. MCP Not Detecting Tools

    • Click the refresh button in Cursor's MCP settings
    • Verify your Supabase credentials and connection string

Debug Mode

For detailed logs, add DEBUG=true to your command:

DEBUG=true /usr/local/bin/node /path/to/dist/index.js [connection-string]

Platform-Specific Notes

Windows Users

"C:\\Program Files\\nodejs\\node.exe" "C:\\path\\to\\dist\\index.js" "postgresql://..."

Linux Users

chmod +x /path/to/dist/index.js

Security Notes

  • Keep your database connection string secure
  • Never commit sensitive credentials to version control
  • Use appropriate access controls and permissions
  • Validate and sanitize all inputs to prevent SQL injection

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