# Supabase MCP Server
Full-featured MCP (Model Context Protocol) server for Supabase with CRUD operations, SQL queries, RPC functions, and storage management.
## š Features
- ā
**CRUD Operations**: Query, Insert, Update, Delete, Upsert
- ā
**Raw SQL Queries**: Execute custom SQL
- ā
**RPC Functions**: Call stored procedures
- ā
**Storage Management**: Upload and list files
- ā
**Claude Desktop Compatible**: Full MCP protocol support
- ā
**n8n Compatible**: REST API endpoints
- ā
**Universal**: Works with any Supabase project
## š¦ Installation
### Local Development
```bash
pip install -r requirements.txt
python server.py
```
### Railway Deployment
1. Create new project on Railway
2. Connect your GitHub repository or deploy directly
3. Railway will auto-detect and deploy using the Procfile
## š§ Usage
### MCP Protocol (Claude Desktop)
**List Tools:**
```bash
POST /mcp/tools/list
```
**Call Tool:**
```json
POST /mcp/tools/call
{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "supabase_query",
"arguments": {
"credentials": {
"url": "https://your-project.supabase.co",
"anon_key": "your-anon-key",
"service_key": "your-service-key"
},
"table": "users",
"select": "*",
"filters": {"status": "active"},
"limit": 10
}
}
}
```
### REST API (n8n, Postman, etc.)
**Query:**
```json
POST /api/query
{
"credentials": {
"url": "https://your-project.supabase.co",
"service_key": "your-service-key"
},
"table": "users",
"select": "*",
"limit": 10
}
```
## š ļø Available Tools
### 1. supabase_query
Query data with filters, pagination, and ordering.
### 2. supabase_insert
Insert single or multiple rows.
### 3. supabase_update
Update rows matching filters.
### 4. supabase_delete
Delete rows matching filters.
### 5. supabase_upsert
Insert new or update existing rows.
### 6. supabase_sql
Execute raw SQL queries (requires service_key).
### 7. supabase_rpc
Call Supabase RPC functions.
### 8. supabase_storage_upload
Upload files to Supabase Storage.
### 9. supabase_storage_list
List files in storage bucket.
## š Authentication
You can provide either:
- `anon_key`: For public/authenticated access
- `service_key`: For admin access (bypasses RLS)
## š Examples
### Filter Examples
```json
// Simple equality
{"filters": {"id": "1"}}
// Greater than
{"filters": {"age": {"gt": "18"}}}
// Like pattern
{"filters": {"name": {"like": "*John*"}}}
// In list
{"filters": {"status": {"in": "(active,pending)"}}}
// Multiple filters
{"filters": {
"age": {"gte": "18"},
"status": "active"
}}
```
### Ordering
```json
{"order": "created_at.desc"}
{"order": "name.asc,age.desc"}
```
### RPC Call
```json
{
"credentials": {...},
"function_name": "get_user_stats",
"params": {"user_id": "123"}
}
```
## š Endpoints
- `GET /` - Server info
- `GET /health` - Health check
- `POST /mcp/tools/list` - List MCP tools
- `POST /mcp/tools/call` - Execute MCP tool
- `POST /api/query` - REST query
- `POST /api/insert` - REST insert
- `POST /api/update` - REST update
- `POST /api/delete` - REST delete
- `POST /api/rpc` - REST RPC call
## š License
MIT