Query | MCP server for Supabase
以下摘录自该仓库的 README(片段) · 在 GitHub 读完整 README →
> 🌅 More than 17k installs via pypi and close to 30k downloads on Smithery.ai — in short, this was fun! 🥳
> Thanks to everyone who has been using this server for the past few months, and I hope it was useful for you.
> Since Supabase has released their own official MCP server,
> I've decided to no longer actively maintain this one. The official MCP server is as feature-rich, and many more
> features will be added in the future. Check it out!
Query MCP is an open-source MCP server that lets your IDE safely run SQL, manage schema changes, call the Supabase Management API, and use Auth Admin SDK — all with built-in safety controls.
Table of contents
Getting started •
Feature overview •
Troubleshooting •
Changelog
✨ Key features
- 💻 Compatible with Cursor, Windsurf, Cline and other MCP clients supporting stdio protocol
- 🔐 Control read-only and read-write modes of SQL query execution
- 🔍 Runtime SQL query validation with risk level assessment
- 🛡️ Three-tier safety system for SQL operations: safe, write, and destructive
- 🔄 Robust transaction handling for both direct and pooled database connections
- 📝 Automatic versioning of database schema changes
- 💻 Manage your Supabase projects with Supabase Management API
- 🧑💻 Manage users with Supabase Auth Admin methods via Python SDK
- 🔨 Pre-built tools to help Cursor & Windsurf work with MCP more effectively
- 📦 Dead-simple install & setup via package manager (uv, pipx, etc.)
Getting Started
Prerequisites
Installing the server requires the following on your system:
- Python 3.12+
If you plan to install via uv, ensure it's installed.
PostgreSQL Installation
PostgreSQL installation is no longer required for the MCP server itself, as it now uses asyncpg which doesn't depend on PostgreSQL development libraries.
However, you'll still need PostgreSQL if you're running a local Supabase instance:
**MacOS**
**Windows**
- Download and install PostgreSQL 16+ from https://www.postgresql.org/download/windows/
- Ensure "PostgreSQL Server" and "Command Line Tools" are selected during installation
Step 1. Installation
Since v0.2.0 I introduced support for package installation. You can use your favorite Python package manager to install the server via:
pipx is recommended because it creates isolated environments for each package.
You can also install the server manually by cloning the repository and running pipx install -e . from the root directory.
Installing from source
If you would like to install from source, for example for local development:
Installing via Smithery.ai
You can find the full instructions on how to use Smithery.ai to connect to this MCP server here.
Step 2. Configuration
The Supabase MCP server requires configuration to connect to your Supabase database, access the Management API, and use the Auth Admin SDK. This section explains all available configuration options and how to set them up.
> 🔑 **Important**: Since v0.4 MCP server requires an API key which you can get for free at thequery.dev to use this MCP server.
Environment Variables
The server uses the following environment variables:
| Variable | Required | Default | Description |
|----------|----------|---------|-------------|
| SUPABASE_PROJECT_REF | Yes | 127.0.0.1:54322 | Your Supabase project reference ID (or local host:port) |
| SUPABASE_DB_PASSWORD | Yes | postgres | Your database password |
| SUPABASE_REGION | Yes* | us-east-1 | AWS region where your Supabase project is hosted |
| SUPABASE_ACCESS_TOKEN | No | None | Personal access token for Supabase Management API |
| SUPABASE_SERVICE_ROLE_KEY | No | None | Service role key for Auth Admin SDK |
| QUERY_API_KEY | Yes | None | API key from thequery.dev (required for all operations) |
> **Note**: The default values are configured for local Supabase development. For remote Supabase projects, you must provide your own values for SUPABASE_PROJECT_REF and SUPABASE_DB_PASSWORD.
> 🚨 **CRITICAL CONFIGURATION NOTE**: For remote Supabase projects, you MUST specify the correct region where your project is hosted using SUPABASE_REGION. If you encounter a "Tenant or user not found" error, this is almost certainly because your region setting doesn't match your project's actual region. You can find your project's region in the Supabase dashboard under Project Settings.
Connection Types
Database Connection
- The server connects to your Supabase PostgreSQL database using the transaction pooler endpoint
- Local development uses a direct connection to 127.0.0.1:54322