Labsco
abushadab logo

Self-Hosted Supabase MCP Server

โ˜… 1

from abushadab

Interact with self-hosted Supabase instances for database management and introspection.

๐Ÿ”ฅ๐Ÿ”ฅ๐Ÿ”ฅโœ“ VerifiedFreeAdvanced setup

Self-Hosted Supabase MCP Server

smithery badge

Overview

This project provides a Model Context Protocol (MCP) server designed specifically for interacting with self-hosted Supabase instances. It bridges the gap between MCP clients (like IDE extensions) and your local or privately hosted Supabase projects, enabling database introspection, management, and interaction directly from your development environment.

This server was built from scratch, drawing lessons from adapting the official Supabase cloud MCP server, to provide a minimal, focused implementation tailored for the self-hosted use case.

Purpose

The primary goal of this server is to enable developers using self-hosted Supabase installations to leverage MCP-based tools for tasks such as:

  • Querying database schemas and data.
  • Managing database migrations.
  • Inspecting database statistics and connections.
  • Managing authentication users.
  • Interacting with Supabase Storage.
  • Generating type definitions.

It avoids the complexities of the official cloud server related to multi-project management and cloud-specific APIs, offering a streamlined experience for single-project, self-hosted environments.

Features (Implemented Tools)

The server exposes the following tools to MCP clients:

  • Schema & Migrations
    • list_tables: Lists tables in the database schemas.
    • list_extensions: Lists installed PostgreSQL extensions.
    • list_migrations: Lists applied Supabase migrations.
    • apply_migration: Applies a SQL migration script.
  • Database Operations & Stats
    • execute_sql: Executes an arbitrary SQL query (via RPC or direct connection).
    • get_database_connections: Shows active database connections (pg_stat_activity).
    • get_database_stats: Retrieves database statistics (pg_stat_*).
  • Project Configuration & Keys
    • get_project_url: Returns the configured Supabase URL.
    • get_anon_key: Returns the configured Supabase anon key.
    • get_service_key: Returns the configured Supabase service role key (if provided).
    • verify_jwt_secret: Checks if the JWT secret is configured and returns a preview.
  • Development & Extension Tools
    • generate_typescript_types: Generates TypeScript types from the database schema.
    • rebuild_hooks: Attempts to restart the pg_net worker (if used).
  • Auth User Management
    • list_auth_users: Lists users from auth.users.
    • get_auth_user: Retrieves details for a specific user.
    • create_auth_user: Creates a new user (Requires direct DB access, insecure password handling).
    • delete_auth_user: Deletes a user (Requires direct DB access).
    • update_auth_user: Updates user details (Requires direct DB access, insecure password handling).
  • Storage Insights
    • list_storage_buckets: Lists all storage buckets.
    • list_storage_objects: Lists objects within a specific bucket.
  • Realtime Inspection
    • list_realtime_publications: Lists PostgreSQL publications (often supabase_realtime).

(Note: get_logs was initially planned but skipped due to implementation complexities in a self-hosted environment).

Development

  • Language: TypeScript
  • Build: tsc (TypeScript Compiler)
  • Dependencies: Managed via npm (package.json)
  • Core Libraries: @supabase/supabase-js, pg (node-postgres), zod (validation), commander (CLI args), @modelcontextprotocol/sdk (MCP server framework).