Supabase Mcp
When to Use
Trigger phrases:
- "supabase mcp"
- "Help me with supabase mcp"
Use cases:
- When the task matches this skill's domain expertise
When NOT to use:
- For tasks outside this skill's scope
When NOT to Use
- When a simpler HTTP client would suffice
- For internal tools that do not need cross-platform compatibility
- When the tool is used by a single agent in a single context
Overview
Supabase is an open-source Firebase alternative that provides a full suite of backend services built on PostgreSQL, including authentication, real-time subscriptions, object storage, and serverless Edge Functions. The Supabase MCP server bridges these capabilities into AI agent workflows, enabling agents to query databases, manage auth users, upload and retrieve storage objects, and invoke Edge Functions through standardized Model Context Protocol tools.
The platform's foundation is PostgreSQL with automatic Row Level Security (RLS) — every database operation can be scoped to the authenticated user through policies written in plain SQL. Supabase manages database migrations through a version-controlled SQL migration system, provides a RESTful API layer (PostgREST) generated automatically from your schema, and exposes GraphQL through pg_graphql.
Beyond the database, Supabase handles user authentication via email/password, magic links, OAuth providers (Google, GitHub, Discord, and others), and multi-factor authentication. The Realtime engine broadcasts database changes over WebSocket connections, Storage manages files in S3-compatible buckets with RLS integration, and Edge Functions execute TypeScript/Deno code at the edge with cold starts under 50ms.
Architecture
- PostgreSQL Database — Managed Postgres with pgvector, full-text search, automatic backups, and point-in-time recovery
- PostgREST API — Auto-generated RESTful API from your database schema with row-level security enforcement
- GoTrue Auth — Built-in authentication with email/password, OAuth, magic links, and MFA support
- Realtime Engine — WebSocket-based real-time subscriptions using PostgreSQL replication slots
- Storage — S3-compatible object storage with RLS policy integration for file access control
- Edge Functions — Deno-based serverless functions with global deployment and low-latency execution
- MCP Server — Model Context Protocol layer exposing query, auth, storage, and function invocation tools to AI agents
Setup
Install the Supabase client SDK:
# Python
pip install supabase
# Node.js
npm install @supabase/supabase-js
Add the Supabase MCP server to your client configuration (e.g., Claude Desktop):
{
"mcpServers": {
"supabase": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-supabase"],
"env": {
"SUPABASE_URL": "https://your-project.supabase.co",
"SUPABASE_SERVICE_ROLE_KEY": "your-service-role-key"
}
}
}
}
Initialize the client in your application:
from supabase import create_client, Client
url = "https://your-project.supabase.co"
key = "your-supabase-anon-key" # or service_role key for admin
supabase: Client = create_client(url, key)
import { createClient } from '@supabase/supabase-js'
const supabase = createClient(
'https://your-project.supabase.co',
'your-supabase-anon-key'
)
Configuration
SUPABASE_URL — Project URL from Dashboard Settings (e.g., https://abc123.supabase.co)
SUPABASE_ANON_KEY — Client-safe anon/public key for browser and mobile SDKs
SUPABASE_SERVICE_ROLE_KEY — Server-only key that bypasses RLS; never expose in client code
SUPABASE_DB_PASSWORD — Direct database connection password for schema migrations and admin tasks
- Connection pooling — Use Supavisor on port
6543 (transaction mode) or 6543?mode=session for production workloads
- Custom SMTP — Configure in Auth → Settings for branded auth emails and password resets
Integration
The Supabase MCP server integrates with Claude Desktop, Cursor, and any MCP-compatible client. Exposed tools and resources include:
- Tools:
query_database, execute_sql, manage_auth_user, storage_upload, storage_list, invoke_edge_function
- Resource URIs:
supabase://{project}/tables, supabase://{project}/table/{name}/rows
- Real-time:
supabase://{project}/realtime/{table} for live data subscriptions
- Transport: stdio for local clients, HTTP for remote access over SSE
Workflow
- Project initialization — Create a new Supabase project via Dashboard or CLI (
supabase init), select database region and pricing tier.
- Schema design — Define tables, primary keys, foreign keys, and indexes using the SQL Editor or local migration files in
supabase/migrations/.
- Row Level Security — Write
CREATE POLICY statements for each table operation. Test with auth.uid() simulation in the SQL Editor.
- Client SDK setup — Install
supabase-py or @supabase/supabase-js, create a client with project URL and anon key, wrap authenticated routes.
- Realtime configuration — Enable replication on target tables via Dashboard → Database → Replication, subscribe with
channel.on('postgres_changes', ...).
- Storage and Edge Functions — Create buckets with policy-protected access, deploy Deno functions with
supabase functions deploy, wire to database triggers.
- Production hardening — Enable point-in-time recovery, configure custom SMTP, set up Supavisor connection pooling, monitor with Dashboard analytics.
Anti-Rationalization Table
| Rationalization |
Reality |
| "I will just use curl" |
MCP handles auth, retries, streaming, and type safety. Use the SDK. |
| "One mega-server is simpler" |
Single-responsibility servers are easier to debug and maintain. |
| "MCP is just a wrapper" |
MCP enables cross-platform tool sharing. It is infrastructure, not overhead. |
| "Postgres.js is enough, I don't need Supabase" |
Supabase provides auth, real-time, storage, and edge functions — months of work if built on raw Postgres. |
| "RLS policies are optional for my MVP" |
RLS is the security foundation. Skipping it creates data leakage that requires a full rewrite to add later. |
| "I can poll the database instead of real-time" |
Supabase Realtime uses WebSocket subscriptions — lower latency, lower bandwidth, no polling interval to tune. |
Code Examples
Python (supabase-py)
from supabase import create_client, Client
# Initialize client
url: str = "https://your-project.supabase.co"
key: str = "your-supabase-anon-key"
supabase: Client = create_client(url, key)
# Query rows with filters
response = supabase.table("profiles").select("*").eq("role", "admin").execute()
for row in response.data:
print(row["full_name"])
# Insert a new row
data = {"full_name": "Alice", "role": "admin", "email": "alice@example.com"}
result = supabase.table("profiles").insert(data).execute()
print(f"Created: {result.data}")
# Auth — sign up a new user
auth_response = supabase.auth.sign_up(
{"email": "alice@example.com", "password": "secure-password"}
)
print(f"User ID: {auth_response.user.id}")
# Storage — upload a file
with open("photo.jpg", "rb") as f:
storage_resp = supabase.storage.from_("avatars").upload(
"public/alice.jpg", f.read()
)
JavaScript (supabase-js)
import { createClient } from '@supabase/supabase-js'
const supabase = createClient(
'https://your-project.supabase.co',
'your-supabase-anon-key'
)
// Query rows with filters
const { data, error } = await supabase
.from('profiles')
.select('*')
.eq('role', 'admin')
if (error) throw error
console.log(data)
// Insert a new row
const { data: newProfile, error: insertError } = await supabase
.from('profiles')
.insert({ full_name: 'Alice', role: 'admin', email: 'alice@example.com' })
.select()
// Real-time subscription
const channel = supabase
.channel('profile-changes')
.on('postgres_changes',
{ event: 'INSERT', schema: 'public', table: 'profiles' },
(payload) => console.log('New profile:', payload.new)
)
.subscribe()
// Storage download
const { data: fileData, error: dlError } = await supabase
.storage
.from('avatars')
.download('public/alice.jpg')
Common Issues & Troubleshooting
| Problem |
Solution |
| Row Level Security blocks all queries |
Ensure the anon key JWT has the correct role claim. Use service_role key for server-side admin operations. |
| Real-time subscription receives no events |
Enable Replication on the table via Dashboard → Database → Replication. Only tables with replication enabled broadcast changes. |
| Storage upload fails with 403 |
Check the bucket's RLS policy — a common pattern is bucket_id = 'your-bucket' AND auth.role() = 'authenticated'. |
| supabase-py returns empty data |
Add .execute() to the query chain. Supabase queries in Python are lazily evaluated until .execute() is called. |
| Edge Function times out connecting to DB |
Set SUPABASE_URL and SUPABASE_SERVICE_ROLE_KEY as environment variables in the function config; never hardcode credentials. |
| TypeScript type errors on Supabase types |
Use @supabase/supabase-js v2+ with generated types: run supabase gen types typescript --linked > database.types.ts and pass as generic. |
Monetization
- Supabase consulting — Offer Supabase migration, schema design, and RLS policy auditing at $150–300/hr. Many teams migrating from Firebase or raw Postgres need expert guidance on RLS and real-time.
- MCP server as a product — Package and sell a hosted Supabase MCP gateway with team access controls, usage dashboards, and SLA guarantees for enterprises.
- Template marketplace — Create and sell full-stack starter kits (Next.js + Supabase, React Native + Supabase) with pre-configured RLS policies, auth flows, and MCP tooling.
- Performance optimization — Offer Supabase query tuning, indexing strategy, connection pooling configuration, and query plan analysis as a flat-fee or retainer service.
- Custom RLS and Edge Function development — Build and maintain custom RLS policies, database triggers, and Supabase Edge Functions for clients on monthly retainer.
- Supabase course/platform — Create a video course or written guide on building production apps with Supabase + MCP, monetized via one-time purchase or subscription.
Process
- Project design — Define tables, relationships, RLS policies, and storage buckets in the Supabase Dashboard before writing any client code.
- SQL schema migration — Use Supabase migrations (local SQL files) or the Dashboard SQL editor for version-controlled schema changes with rollback plans.
- Client integration — Install supabase-js or supabase-py, initialize the client with anon key, and verify basic CRUD against each table.
- Security hardening — Write RLS policies for every table, enable MFA for production, set up email confirmation, and audit service_role key usage.
- Production deployment — Enable point-in-time recovery, configure Supavisor connection pooling, deploy Edge Functions, set up custom SMTP, and monitor via Dashboard analytics.
Verification
1---2name: supabase-mcp3description: Use when mCP server for Supabase databases. Query tables, manage auth, and handle storage through standardized protocol. Use when working with supabase mcp.4license: Apache-2.05---678# Supabase Mcp910## When to Use1112**Trigger phrases:**13- "supabase mcp"14- "Help me with supabase mcp"1516**Use cases:**17- When the task matches this skill's domain expertise1819**When NOT to use:**20- For tasks outside this skill's scope212223## When NOT to Use2425- When a simpler HTTP client would suffice26- For internal tools that do not need cross-platform compatibility27- When the tool is used by a single agent in a single context282930## Overview3132Supabase is an open-source Firebase alternative that provides a full suite of backend services built on PostgreSQL, including authentication, real-time subscriptions, object storage, and serverless Edge Functions. The Supabase MCP server bridges these capabilities into AI agent workflows, enabling agents to query databases, manage auth users, upload and retrieve storage objects, and invoke Edge Functions through standardized Model Context Protocol tools.3334The platform's foundation is PostgreSQL with automatic Row Level Security (RLS) — every database operation can be scoped to the authenticated user through policies written in plain SQL. Supabase manages database migrations through a version-controlled SQL migration system, provides a RESTful API layer (PostgREST) generated automatically from your schema, and exposes GraphQL through pg_graphql.3536Beyond the database, Supabase handles user authentication via email/password, magic links, OAuth providers (Google, GitHub, Discord, and others), and multi-factor authentication. The Realtime engine broadcasts database changes over WebSocket connections, Storage manages files in S3-compatible buckets with RLS integration, and Edge Functions execute TypeScript/Deno code at the edge with cold starts under 50ms.373839## Architecture4041- **PostgreSQL Database** — Managed Postgres with pgvector, full-text search, automatic backups, and point-in-time recovery42- **PostgREST API** — Auto-generated RESTful API from your database schema with row-level security enforcement43- **GoTrue Auth** — Built-in authentication with email/password, OAuth, magic links, and MFA support44- **Realtime Engine** — WebSocket-based real-time subscriptions using PostgreSQL replication slots45- **Storage** — S3-compatible object storage with RLS policy integration for file access control46- **Edge Functions** — Deno-based serverless functions with global deployment and low-latency execution47- **MCP Server** — Model Context Protocol layer exposing query, auth, storage, and function invocation tools to AI agents484950## Setup5152Install the Supabase client SDK:5354```bash55# Python56pip install supabase5758# Node.js59npm install @supabase/supabase-js60```6162Add the Supabase MCP server to your client configuration (e.g., Claude Desktop):6364```json65{66 "mcpServers": {67 "supabase": {68 "command": "npx",69 "args": ["-y", "@modelcontextprotocol/server-supabase"],70 "env": {71 "SUPABASE_URL": "https://your-project.supabase.co",72 "SUPABASE_SERVICE_ROLE_KEY": "your-service-role-key"73 }74 }75 }76}77```7879Initialize the client in your application:8081```python82from supabase import create_client, Client8384url = "https://your-project.supabase.co"85key = "your-supabase-anon-key" # or service_role key for admin86supabase: Client = create_client(url, key)87```8889```javascript90import { createClient } from '@supabase/supabase-js'9192const supabase = createClient(93 'https://your-project.supabase.co',94 'your-supabase-anon-key'95)96```979899## Configuration100101- `SUPABASE_URL` — Project URL from Dashboard Settings (e.g., `https://abc123.supabase.co`)102- `SUPABASE_ANON_KEY` — Client-safe anon/public key for browser and mobile SDKs103- `SUPABASE_SERVICE_ROLE_KEY` — Server-only key that bypasses RLS; never expose in client code104- `SUPABASE_DB_PASSWORD` — Direct database connection password for schema migrations and admin tasks105- **Connection pooling** — Use Supavisor on port `6543` (transaction mode) or `6543?mode=session` for production workloads106- **Custom SMTP** — Configure in Auth → Settings for branded auth emails and password resets107108109## Integration110111The Supabase MCP server integrates with Claude Desktop, Cursor, and any MCP-compatible client. Exposed tools and resources include:112113- **Tools:** `query_database`, `execute_sql`, `manage_auth_user`, `storage_upload`, `storage_list`, `invoke_edge_function`114- **Resource URIs:** `supabase://{project}/tables`, `supabase://{project}/table/{name}/rows`115- **Real-time:** `supabase://{project}/realtime/{table}` for live data subscriptions116- **Transport:** stdio for local clients, HTTP for remote access over SSE117118119## Workflow1201211. **Project initialization** — Create a new Supabase project via Dashboard or CLI (`supabase init`), select database region and pricing tier.1222. **Schema design** — Define tables, primary keys, foreign keys, and indexes using the SQL Editor or local migration files in `supabase/migrations/`.1233. **Row Level Security** — Write `CREATE POLICY` statements for each table operation. Test with `auth.uid()` simulation in the SQL Editor.1244. **Client SDK setup** — Install `supabase-py` or `@supabase/supabase-js`, create a client with project URL and anon key, wrap authenticated routes.1255. **Realtime configuration** — Enable replication on target tables via Dashboard → Database → Replication, subscribe with `channel.on('postgres_changes', ...)`.1266. **Storage and Edge Functions** — Create buckets with policy-protected access, deploy Deno functions with `supabase functions deploy`, wire to database triggers.1277. **Production hardening** — Enable point-in-time recovery, configure custom SMTP, set up Supavisor connection pooling, monitor with Dashboard analytics.128129130## Anti-Rationalization Table131132| Rationalization | Reality |133|---|---|134| "I will just use curl" | MCP handles auth, retries, streaming, and type safety. Use the SDK. |135| "One mega-server is simpler" | Single-responsibility servers are easier to debug and maintain. |136| "MCP is just a wrapper" | MCP enables cross-platform tool sharing. It is infrastructure, not overhead. |137| "Postgres.js is enough, I don't need Supabase" | Supabase provides auth, real-time, storage, and edge functions — months of work if built on raw Postgres. |138| "RLS policies are optional for my MVP" | RLS is the security foundation. Skipping it creates data leakage that requires a full rewrite to add later. |139| "I can poll the database instead of real-time" | Supabase Realtime uses WebSocket subscriptions — lower latency, lower bandwidth, no polling interval to tune. |140141142## Code Examples143144### Python (supabase-py)145146```python147from supabase import create_client, Client148149# Initialize client150url: str = "https://your-project.supabase.co"151key: str = "your-supabase-anon-key"152supabase: Client = create_client(url, key)153154# Query rows with filters155response = supabase.table("profiles").select("*").eq("role", "admin").execute()156for row in response.data:157 print(row["full_name"])158159# Insert a new row160data = {"full_name": "Alice", "role": "admin", "email": "alice@example.com"}161result = supabase.table("profiles").insert(data).execute()162print(f"Created: {result.data}")163164# Auth — sign up a new user165auth_response = supabase.auth.sign_up(166 {"email": "alice@example.com", "password": "secure-password"}167)168print(f"User ID: {auth_response.user.id}")169170# Storage — upload a file171with open("photo.jpg", "rb") as f:172 storage_resp = supabase.storage.from_("avatars").upload(173 "public/alice.jpg", f.read()174 )175```176177### JavaScript (supabase-js)178179```javascript180import { createClient } from '@supabase/supabase-js'181182const supabase = createClient(183 'https://your-project.supabase.co',184 'your-supabase-anon-key'185)186187// Query rows with filters188const { data, error } = await supabase189 .from('profiles')190 .select('*')191 .eq('role', 'admin')192193if (error) throw error194console.log(data)195196// Insert a new row197const { data: newProfile, error: insertError } = await supabase198 .from('profiles')199 .insert({ full_name: 'Alice', role: 'admin', email: 'alice@example.com' })200 .select()201202// Real-time subscription203const channel = supabase204 .channel('profile-changes')205 .on('postgres_changes',206 { event: 'INSERT', schema: 'public', table: 'profiles' },207 (payload) => console.log('New profile:', payload.new)208 )209 .subscribe()210211// Storage download212const { data: fileData, error: dlError } = await supabase213 .storage214 .from('avatars')215 .download('public/alice.jpg')216```217218219## Common Issues & Troubleshooting220221| Problem | Solution |222|---|---|223| Row Level Security blocks all queries | Ensure the anon key JWT has the correct `role` claim. Use `service_role` key for server-side admin operations. |224| Real-time subscription receives no events | Enable Replication on the table via Dashboard → Database → Replication. Only tables with replication enabled broadcast changes. |225| Storage upload fails with 403 | Check the bucket's RLS policy — a common pattern is `bucket_id = 'your-bucket' AND auth.role() = 'authenticated'`. |226| supabase-py returns empty data | Add `.execute()` to the query chain. Supabase queries in Python are lazily evaluated until `.execute()` is called. |227| Edge Function times out connecting to DB | Set `SUPABASE_URL` and `SUPABASE_SERVICE_ROLE_KEY` as environment variables in the function config; never hardcode credentials. |228| TypeScript type errors on Supabase types | Use `@supabase/supabase-js` v2+ with generated types: run `supabase gen types typescript --linked > database.types.ts` and pass as generic. |229230231## Monetization232233- **Supabase consulting** — Offer Supabase migration, schema design, and RLS policy auditing at $150–300/hr. Many teams migrating from Firebase or raw Postgres need expert guidance on RLS and real-time.234- **MCP server as a product** — Package and sell a hosted Supabase MCP gateway with team access controls, usage dashboards, and SLA guarantees for enterprises.235- **Template marketplace** — Create and sell full-stack starter kits (Next.js + Supabase, React Native + Supabase) with pre-configured RLS policies, auth flows, and MCP tooling.236- **Performance optimization** — Offer Supabase query tuning, indexing strategy, connection pooling configuration, and query plan analysis as a flat-fee or retainer service.237- **Custom RLS and Edge Function development** — Build and maintain custom RLS policies, database triggers, and Supabase Edge Functions for clients on monthly retainer.238- **Supabase course/platform** — Create a video course or written guide on building production apps with Supabase + MCP, monetized via one-time purchase or subscription.239240241## Process2422431. **Project design** — Define tables, relationships, RLS policies, and storage buckets in the Supabase Dashboard before writing any client code.2442. **SQL schema migration** — Use Supabase migrations (local SQL files) or the Dashboard SQL editor for version-controlled schema changes with rollback plans.2453. **Client integration** — Install supabase-js or supabase-py, initialize the client with anon key, and verify basic CRUD against each table.2464. **Security hardening** — Write RLS policies for every table, enable MFA for production, set up email confirmation, and audit service_role key usage.2475. **Production deployment** — Enable point-in-time recovery, configure Supavisor connection pooling, deploy Edge Functions, set up custom SMTP, and monitor via Dashboard analytics.248249250## Verification251252- [ ] Supabase project created and `service_role` key stored securely (never in client-side code)253- [ ] Client SDK (supabase-py or supabase-js) connects and authenticates successfully254- [ ] All table CRUD operations work with proper RLS enforcement for both authenticated and anonymous users255- [ ] Auth flows verified end-to-end: signup, login, password reset, and OAuth provider integration256- [ ] Storage upload and download succeed with correct bucket-level RLS policies257- [ ] Real-time subscriptions fire correctly on INSERT, UPDATE, and DELETE events258- [ ] Edge Functions deploy without errors and return expected responses259- [ ] Database backups enabled and point-in-time recovery time window confirmed