Supabase Platform Development
When to use
- Manage Supabase projects (create, pause, restore, list)
- Query or modify the PostgreSQL database via Supabase
- Configure Supabase Auth (email, phone, OAuth, SSO)
- Work with Supabase Storage (buckets, policies, CDN)
- Set up Realtime channels (presence, broadcast, postgres changes)
- Deploy or debug Edge Functions
- Generate TypeScript types from the database schema
- Use Supabase MCP tools for any of the above
- Integrate Supabase with Flutter/Dart or JavaScript/TypeScript clients
MCP Tool Reference
Discovery & Configuration
search_docs — GraphQL search against live Supabase docs. Always query docs first even if you think you know the answer; docs update frequently.
list_projects — List all projects to find project IDs.
get_project — Get project details (status, region, tier).
get_project_url — Get the API URL for the connected project.
get_publishable_keys — Get anon/publishable keys. Prefer sb_publishable_* format keys.
Database
list_tables — List tables in schemas. Use verbose: true for columns, PKs, FKs.
execute_sql — Run read queries (SELECT) or DML (INSERT/UPDATE/DELETE). Not for DDL.
apply_migration — Run DDL (CREATE TABLE, ALTER, etc.). Use snake_case names.
list_migrations — See applied migrations.
list_extensions — Check installed Postgres extensions.
generate_typescript_types — Generate TypeScript types from schema.
Edge Functions
list_edge_functions — List all deployed functions.
get_edge_function — Read function source code.
deploy_edge_function — Deploy or update a function. Include deno.json if present.
Branching
create_branch — Create a dev branch (runs all migrations on fresh DB).
list_branches — Check branch status.
merge_branch / rebase_branch / reset_branch / delete_branch — Branch lifecycle.
Observability
get_logs — Fetch 24h logs by service: api, postgres, edge-function, auth, storage, realtime, branch-action.
get_advisors — Security and performance advisories. Run after DDL changes to catch missing RLS policies.
Key Patterns
Flutter/Dart Client
// Initialize
final supabase = Supabase.instance.client;
// Query
final data = await supabase.from('farts').select().eq('user_id', uid);
// Insert
await supabase.from('farts').insert({'content': 'hello', 'user_id': uid});
// RPC (call database function)
final result = await supabase.rpc('get_nearby_farts', params: {'lat': 37.7, 'lng': -122.4});
// Realtime
supabase.channel('room1')
.onPostgresChanges(event: PostgresChangeEvent.all, schema: 'public', table: 'messages',
callback: (payload) => print(payload))
.subscribe();
// Auth
await supabase.auth.signInWithOtp(phone: '+1234567890');
final session = supabase.auth.currentSession;
Edge Function Pattern (Deno)
import "jsr:@supabase/functions-js/edge-runtime.d.ts";
import { createClient } from "jsr:@supabase/supabase-js@2";
Deno.serve(async (req: Request) => {
const supabase = createClient(
Deno.env.get("SUPABASE_URL")!,
Deno.env.get("SUPABASE_SERVICE_ROLE_KEY")!
);
const { data, error } = await supabase.from("table").select();
return new Response(JSON.stringify({ data, error }), {
headers: { "Content-Type": "application/json" },
});
});
Cost Optimization Checklist
- Use database triggers instead of Edge Functions for counters/aggregations
- Batch notifications (pg_cron every 5 min) instead of individual sends
- Use materialized views for leaderboards/aggregations (refresh on schedule)
- Enforce RLS at database level to reduce Edge Function calls by 50%
- Use PostGIS for spatial queries (10-50x faster than geohash approximation)
- Use pg_cron for scheduled maintenance instead of external schedulers
Security Defaults
- Always enable JWT verification on Edge Functions unless custom auth is implemented
- Run
get_advisors(type: "security") after any DDL change
- Enable RLS on every public table — no exceptions
- Use
auth.uid() in RLS policies, never trust client-provided user IDs
- Service role key stays server-side only (Edge Functions, backend)
1---2name: supabase3description: Use for Supabase platform development including project management, database queries, auth configuration, storage, realtime channels, Edge Functions deployment, branching, and MCP tool usage. Covers Flutter/Dart client, JavaScript client, PostgREST, and Supabase CLI patterns.4---56# Supabase Platform Development78## When to use9- Manage Supabase projects (create, pause, restore, list)10- Query or modify the PostgreSQL database via Supabase11- Configure Supabase Auth (email, phone, OAuth, SSO)12- Work with Supabase Storage (buckets, policies, CDN)13- Set up Realtime channels (presence, broadcast, postgres changes)14- Deploy or debug Edge Functions15- Generate TypeScript types from the database schema16- Use Supabase MCP tools for any of the above17- Integrate Supabase with Flutter/Dart or JavaScript/TypeScript clients1819## MCP Tool Reference2021### Discovery & Configuration22- `search_docs` — GraphQL search against live Supabase docs. **Always query docs first** even if you think you know the answer; docs update frequently.23- `list_projects` — List all projects to find project IDs.24- `get_project` — Get project details (status, region, tier).25- `get_project_url` — Get the API URL for the connected project.26- `get_publishable_keys` — Get anon/publishable keys. Prefer `sb_publishable_*` format keys.2728### Database29- `list_tables` — List tables in schemas. Use `verbose: true` for columns, PKs, FKs.30- `execute_sql` — Run read queries (SELECT) or DML (INSERT/UPDATE/DELETE). **Not for DDL.**31- `apply_migration` — Run DDL (CREATE TABLE, ALTER, etc.). Use snake_case names.32- `list_migrations` — See applied migrations.33- `list_extensions` — Check installed Postgres extensions.34- `generate_typescript_types` — Generate TypeScript types from schema.3536### Edge Functions37- `list_edge_functions` — List all deployed functions.38- `get_edge_function` — Read function source code.39- `deploy_edge_function` — Deploy or update a function. Include `deno.json` if present.4041### Branching42- `create_branch` — Create a dev branch (runs all migrations on fresh DB).43- `list_branches` — Check branch status.44- `merge_branch` / `rebase_branch` / `reset_branch` / `delete_branch` — Branch lifecycle.4546### Observability47- `get_logs` — Fetch 24h logs by service: `api`, `postgres`, `edge-function`, `auth`, `storage`, `realtime`, `branch-action`.48- `get_advisors` — Security and performance advisories. **Run after DDL changes** to catch missing RLS policies.4950## Key Patterns5152### Flutter/Dart Client53```dart54// Initialize55final supabase = Supabase.instance.client;5657// Query58final data = await supabase.from('farts').select().eq('user_id', uid);5960// Insert61await supabase.from('farts').insert({'content': 'hello', 'user_id': uid});6263// RPC (call database function)64final result = await supabase.rpc('get_nearby_farts', params: {'lat': 37.7, 'lng': -122.4});6566// Realtime67supabase.channel('room1')68 .onPostgresChanges(event: PostgresChangeEvent.all, schema: 'public', table: 'messages',69 callback: (payload) => print(payload))70 .subscribe();7172// Auth73await supabase.auth.signInWithOtp(phone: '+1234567890');74final session = supabase.auth.currentSession;75```7677### Edge Function Pattern (Deno)78```typescript79import "jsr:@supabase/functions-js/edge-runtime.d.ts";80import { createClient } from "jsr:@supabase/supabase-js@2";8182Deno.serve(async (req: Request) => {83 const supabase = createClient(84 Deno.env.get("SUPABASE_URL")!,85 Deno.env.get("SUPABASE_SERVICE_ROLE_KEY")!86 );8788 const { data, error } = await supabase.from("table").select();89 return new Response(JSON.stringify({ data, error }), {90 headers: { "Content-Type": "application/json" },91 });92});93```9495### Cost Optimization Checklist961. Use database triggers instead of Edge Functions for counters/aggregations972. Batch notifications (pg_cron every 5 min) instead of individual sends983. Use materialized views for leaderboards/aggregations (refresh on schedule)994. Enforce RLS at database level to reduce Edge Function calls by 50%1005. Use PostGIS for spatial queries (10-50x faster than geohash approximation)1016. Use pg_cron for scheduled maintenance instead of external schedulers102103### Security Defaults104- **Always enable JWT verification** on Edge Functions unless custom auth is implemented105- Run `get_advisors(type: "security")` after any DDL change106- Enable RLS on every public table — no exceptions107- Use `auth.uid()` in RLS policies, never trust client-provided user IDs108- Service role key stays server-side only (Edge Functions, backend)