supabase.com
supabase.com logo

Supabase

Bridges Supabase databases with natural language commands for querying tables, generating TypeScript types, and explorin...

Created byApr 23, 2025

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)
  1. A Supabase project (either local or hosted)
  1. Supabase CLI (for type generation)

Installation

  1. Clone the repository:
  1. Install dependencies:
  1. Install the Supabase CLI (required for type generation):

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
  1. Configure environment variables:
  1. Build the server:

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`
  1. Add the server configuration:

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`
  1. Add the server configuration (same format as Claude Desktop).

Usage Examples

Querying Tables

Generating Types

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:
  1. For local projects: - Make sure your local Supabase instance is running - Verify your service_role key is correct
  1. 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
  1. Verify column names in select and where clauses
  1. Ensure your service_role key has necessary permissions

Contributing

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

License

MIT License - see LICENSE file for details