This guide explains how to set up the Supabase MCP server to connect your AI assistants (Cursor, Claude, etc.) to your Supabase database.
Model Context Protocol (MCP) standardizes how Large Language Models (LLMs) talk to external services like Supabase. Once connected, your AI assistants can interact with and query your Supabase projects on your behalf.
- Supabase Personal Access Token:
- Go to Supabase Settings
- Click "Generate new token"
- Give it a descriptive name like "MCP Server"
- Copy the token - you'll need it for configuration
Two configuration options are provided:
File: .mcp.json
{
"mcpServers": {
"supabase": {
"command": "npx",
"args": [
"-y",
"@supabase/mcp-server-supabase@latest",
"--read-only",
"--project-ref=rfakvkihqdhfueclbkhm"
],
"env": {
"SUPABASE_ACCESS_TOKEN": "YOUR_PERSONAL_ACCESS_TOKEN_HERE"
}
}
}
}Setup Steps:
- Replace
YOUR_PERSONAL_ACCESS_TOKEN_HEREwith your Supabase personal access token - Your project reference is already configured:
rfakvkihqdhfueclbkhm
File: .mcp-postgrest.json
This option uses your existing anon key and doesn't require a personal access token. It's already configured with your project details.
{
"mcpServers": {
"supabase": {
"command": "npx",
"args": [
"-y",
"@supabase/mcp-server-postgrest",
"--apiUrl",
"https://rfakvkihqdhfueclbkhm.supabase.co/rest/v1",
"--apiKey",
"YOUR_ANON_KEY",
"--schema",
"public"
]
}
}
}- Copy
.mcp.jsonto.cursor/mcp.jsonin your project root - Restart Cursor
- The MCP server will be available for AI interactions
- Copy the configuration to
.vscode/mcp.json - Restart VS Code
- Use the main
.mcp.jsonconfiguration - Follow Claude's MCP setup instructions
- Read-only by default: The configuration uses
--read-onlyflag to prevent accidental data modifications - Project-scoped: Limited to your specific project (
rfakvkihqdhfueclbkhm) - Development use: Recommended for development/staging, not production databases
- Token security: Personal access tokens are sensitive - keep them secure
Once configured, the MCP server provides 20+ tools including:
- Database schema inspection
- Table data querying
- Storage bucket management
- Authentication user management
- Real-time subscription management
- Edge function management
- Permission denied: Ensure your personal access token has the correct permissions
- Connection failed: Verify your project reference is correct
- Windows users: Prefix commands with
cmd /cif needed
You can test if MCP is working by asking your AI assistant:
- "Show me the database schema"
- "What tables exist in this Supabase project?"
- "List the users in the auth.users table"
- The
.mcp.jsonfile is added to.gitignoreto prevent committing sensitive tokens - Use environment variables or secure token management in production
- Consider using the PostgREST option for simpler setup without personal tokens
- Create your Supabase personal access token
- Update the
.mcp.jsonfile with your token - Copy the configuration to your AI tool's config directory
- Restart your AI tool
- Test the integration by asking database-related questions
The MCP integration will significantly enhance your AI assistant's ability to help with database operations, schema management, and data analysis tasks.