Fire in da houseTop Tip:Paying $100+ per month for Perplexity, MidJourney, Runway, ChatGPT and other tools is crazy - get all your AI tools in one site starting at $15 per month with Galaxy AI Fire in da houseCheck it out free

Supabase-MCP

MCP.Pizza Chef: NightTrek

Supabase-MCP is a Model Context Protocol (MCP) server designed to integrate large language models with Supabase databases. It allows LLMs to perform complex database queries including schema selection, column filtering, and pagination, while also supporting error handling. Additionally, it can generate TypeScript types for any Supabase schema, facilitating type-safe development. Compatible with both local and remote Supabase projects, this server streamlines database interaction and type generation through a standardized MCP interface, enhancing AI-driven workflows and developer productivity.

Use This MCP server To

Execute complex Supabase database queries via LLMs Generate TypeScript types from Supabase schemas automatically Filter and paginate Supabase table data programmatically Integrate Supabase data querying into AI-powered applications Support multi-schema Supabase projects with type generation Enable error-handled database interactions through MCP

README

Supabase MCP Server

A Model Context Protocol (MCP) server for interacting with Supabase databases. This server provides tools for querying tables and generating TypeScript types through the MCP interface.

Features

  • Query Tables: Execute queries on any table with support for:

    • Schema selection
    • Column filtering
    • Where clauses with multiple operators
    • Pagination
    • Error handling
  • Type Generation: Generate TypeScript types for your database:

    • Support for any schema (public, auth, api, etc.)
    • Works with both local and remote Supabase projects
    • Direct output to console
    • Automatic project reference detection

Prerequisites

  1. Node.js (v16 or higher)
  2. A Supabase project (either local or hosted)
  3. Supabase CLI (for type generation)

Installation

  1. Clone the repository:
git clone https://github.com/yourusername/supabase-mcp-server.git
cd supabase-mcp-server
  1. Install dependencies:
npm install
  1. Install the Supabase CLI (required for type generation):
# Using npm
npm install -g supabase

# Or using Homebrew on macOS
brew install supabase/tap/supabase

Configuration

  1. Get your Supabase credentials:

    • For hosted projects:

      1. Go to your Supabase project dashboard
      2. Navigate to Project Settings > API
      3. Copy the Project URL and service_role key (NOT the anon key)
    • For local projects:

      1. Start your local Supabase instance
      2. Use the local URL (typically http://localhost:54321)
      3. Use your local service_role key
  2. Configure environment variables:

# Create a .env file (this will be ignored by git)
echo "SUPABASE_URL=your_project_url
SUPABASE_KEY=your_service_role_key" > .env
  1. Build the server:
npm run build

Integration with Claude Desktop

  1. Open Claude Desktop settings:

    • 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 the server configuration:

{
  "mcpServers": {
    "supabase": {
      "command": "node",
      "args": ["/absolute/path/to/supabase-mcp-server/build/index.js"],
      "env": {
        "SUPABASE_URL": "your_project_url",
        "SUPABASE_KEY": "your_service_role_key"
      }
    }
  }
}

Integration with VSCode Extension

  1. Open VSCode settings:

    • macOS: ~/Library/Application Support/Code/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json
    • Windows: %APPDATA%\Code\User\globalStorage\saoudrizwan.claude-dev\settings\cline_mcp_settings.json
    • Linux: ~/.config/Code/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json
  2. Add the server configuration (same format as Claude Desktop).

Usage Examples

Querying Tables

// Query with schema selection and where clause
<use_mcp_tool>
<server_name>supabase</server_name>
<tool_name>query_table</tool_name>
<arguments>
{
  "schema": "public",
  "table": "users",
  "select": "id,name,email",
  "where": [
    {
      "column": "is_active",
      "operator": "eq",
      "value": true
    }
  ]
}
</arguments>
</use_mcp_tool>

Generating Types

// Generate types for public schema
<use_mcp_tool>
<server_name>supabase</server_name>
<tool_name>generate_types</tool_name>
<arguments>
{
  "schema": "public"
}
</arguments>
</use_mcp_tool>

Available Tools

query_table

Query a specific table with schema selection and where clause support.

Parameters:

  • schema (optional): Database schema (defaults to public)
  • table (required): Name of the table to query
  • select (optional): Comma-separated list of columns
  • where (optional): Array of conditions with:
    • column: Column name
    • operator: One of: eq, neq, gt, gte, lt, lte, like, ilike, is
    • value: Value to compare against

generate_types

Generate TypeScript types for your Supabase database schema.

Parameters:

  • schema (optional): Database schema (defaults to public)

Troubleshooting

Type Generation Issues

  1. Ensure Supabase CLI is installed:
supabase --version
  1. For local projects:

    • Make sure your local Supabase instance is running
    • Verify your service_role key is correct
  2. For hosted projects:

    • Confirm your project ref is correct (extracted from URL)
    • Verify you're using the service_role key, not the anon key

Query Issues

  1. Check your schema and table names
  2. Verify column names in select and where clauses
  3. Ensure your service_role key has necessary permissions

Contributing

  1. Fork the repository
  2. Create your feature branch: git checkout -b feature/my-feature
  3. Commit your changes: git commit -am 'Add my feature'
  4. Push to the branch: git push origin feature/my-feature
  5. Submit a pull request

License

MIT License - see LICENSE file for details

Supabase-MCP FAQ

How do I install Supabase-MCP server?
Clone the repository, install dependencies with npm, and ensure Node.js v16+ and Supabase CLI are installed.
Can Supabase-MCP handle multiple schemas?
Yes, it supports querying and type generation for any Supabase schema including public, auth, and api.
Does Supabase-MCP support remote Supabase projects?
Yes, it works with both local and remote Supabase instances seamlessly.
How does Supabase-MCP generate TypeScript types?
It uses the Supabase CLI to generate types and can output them directly to the console with automatic project reference detection.
What kind of query operations are supported?
Supabase-MCP supports column filtering, where clauses with multiple operators, pagination, and error handling.
Is Supabase-MCP compatible with different LLM providers?
Yes, it is designed to work with models like OpenAI, Anthropic Claude, and Google Gemini via the MCP interface.
What are the prerequisites for running Supabase-MCP?
You need Node.js v16 or higher, a Supabase project, and the Supabase CLI installed.
How does Supabase-MCP handle errors during queries?
It includes built-in error handling to manage and report query issues effectively.