Supabase MCP server

Integrates with Supabase to enable database operations, file storage, and user authentication for scalable, real-time applications.
Back to servers
Provider
Dynamic Endpoints
Release date
Dec 20, 2024
Language
TypeScript
Stats
40 stars

The Supabase MCP server provides a bridge between MCP clients and Supabase services, offering database operations, storage management, edge function invocation, and user management capabilities. This server enables you to seamlessly integrate Supabase functionality into any MCP-compatible application.

Installation

Installing via Smithery

To install Supabase Server automatically via Smithery:

npx -y @smithery/cli install supabase-server --client claude

Manual Installation

  1. Clone the repository:
git clone https://github.com/DynamicEndpoints/supabase-mcp.git
cd supabase-mcp
  1. Install dependencies:
npm install
  1. Create environment configuration:
cp .env.example .env
  1. Configure environment variables:
SUPABASE_URL=your_project_url_here
SUPABASE_KEY=your_service_role_key_here
SUPABASE_ACCESS_TOKEN=your_access_token_here  # Required for management operations
  1. Create server configuration:
cp config.json.example config.json
  1. Build the server:
npm run build

Configuration

The server can be configured through environment variables and a config.json file.

Server Configuration

{
  "server": {
    "name": "supabase-server",    // Server name
    "version": "0.1.0",           // Server version
    "port": 3000,                 // Port number (if running standalone)
    "host": "localhost"           // Host address (if running standalone)
  }
}

Supabase Configuration

{
  "supabase": {
    "project": {
      "url": "your_project_url",
      "key": "your_service_role_key",
      "accessToken": "your_access_token"
    },
    "storage": {
      "defaultBucket": "public",           // Default storage bucket
      "maxFileSize": 52428800,            // Max file size in bytes (50MB)
      "allowedMimeTypes": [               // Allowed file types
        "image/*",
        "application/pdf",
        "text/*"
      ]
    },
    "database": {
      "maxConnections": 10,               // Max DB connections
      "timeout": 30000,                   // Query timeout in ms
      "ssl": true                         // SSL connection
    },
    "auth": {
      "autoConfirmUsers": false,          // Auto-confirm new users
      "disableSignup": false,             // Disable public signups
      "jwt": {
        "expiresIn": "1h",               // Token expiration
        "algorithm": "HS256"              // JWT algorithm
      }
    }
  }
}

Logging and Security Configuration

{
  "logging": {
    "level": "info",                      // Log level
    "format": "json",                     // Log format
    "outputs": ["console", "file"],       // Output destinations
    "file": {
      "path": "logs/server.log",          // Log file path
      "maxSize": "10m",                   // Max file size
      "maxFiles": 5                       // Max number of files
    }
  },
  "security": {
    "cors": {
      "enabled": true,
      "origins": ["*"],
      "methods": ["GET", "POST", "PUT", "DELETE", "OPTIONS"],
      "allowedHeaders": ["Content-Type", "Authorization"]
    },
    "rateLimit": {
      "enabled": true,
      "windowMs": 900000,                 // 15 minutes
      "max": 100                          // Max requests per window
    }
  }
}

MCP Integration

Add the server to your MCP settings (cline_mcp_settings.json):

{
  "mcpServers": {
    "supabase": {
      "command": "node",
      "args": ["path/to/supabase-server/build/index.js"],
      "env": {
        "SUPABASE_URL": "your_project_url",
        "SUPABASE_KEY": "your_service_role_key",
        "SUPABASE_ACCESS_TOKEN": "your_access_token"
      },
      "config": "path/to/config.json"  // Optional: path to configuration file
    }
  }
}

Available Tools

Database Operations

create_record

Create a new record in a table:

{
  table: "users",
  data: {
    name: "John Doe",
    email: "[email protected]"
  },
  returning: ["id", "created_at"]
}

read_records

Read records with filtering and joins:

{
  table: "posts",
  select: ["id", "title", "user.name"],
  filter: { published: true },
  joins: [{
    type: "left",
    table: "users",
    on: "posts.user_id=users.id"
  }]
}

update_record

Update existing records:

{
  table: "users",
  data: { status: "active" },
  filter: { email: "[email protected]" },
  returning: ["id", "status", "updated_at"]
}

delete_record

Delete records from a table:

{
  table: "posts",
  filter: { status: "draft" },
  returning: ["id", "title"]
}

Storage Operations

upload_file

Upload files to Supabase Storage:

{
  bucket: "avatars",
  path: "users/123/profile.jpg",
  file: imageBlob,
  options: {
    contentType: "image/jpeg",
    upsert: true
  }
}

download_file

Download files from Supabase Storage:

{
  bucket: "documents",
  path: "reports/annual-2023.pdf"
}

Edge Functions

invoke_function

Invoke Supabase Edge Functions:

{
  function: "process-image",
  params: {
    url: "https://example.com/image.jpg",
    width: 800
  },
  options: {
    responseType: "json"
  }
}

User Management

list_users

List users with pagination:

{
  page: 1,
  per_page: 20
}

create_user

Create a new user:

{
  email: "[email protected]",
  password: "securePassword123",
  data: {
    firstName: "Jane",
    lastName: "Smith"
  }
}

update_user

Update user details:

{
  user_id: "123e4567-e89b-12d3-a456-426614174000",
  email: "[email protected]",
  data: {
    status: "premium"
  }
}

delete_user

Delete a user:

{
  user_id: "123e4567-e89b-12d3-a456-426614174000"
}

assign_user_role

Assign a role to a user:

{
  user_id: "123e4567-e89b-12d3-a456-426614174000",
  role: "admin"
}

Error Handling

The server provides standardized error messages in this format:

{
  code: ErrorCode;
  message: string;
  details?: any;
}

Common error scenarios include invalid parameters, authentication failures, permission issues, and network errors.

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