Supabase with MCP Server
Learn how to connect your AI tools to Supabase using the Model Context Protocol (MCP) for enhanced development workflow.
What is the Model Context Protocol (MCP)?
The Model Context Protocol is a powerful standard that enables Large Language Models (LLMs) to interact with platforms like Supabase. This protocol creates a bridge between AI tools and your Supabase projects, allowing AI assistants to query and manage your database directly.
Benefits of Using MCP
- Seamless integration with AI tools
- Enhanced development workflow with AI assistance
Setting Up MCP with Supabase
Step 1: Create a Personal Access Token
First, you'll need to create a personal access token in your Supabase settings:
- Navigate to your Supabase dashboard
- Go to Settings
- Create a new personal access token
- Give it a descriptive name (e.g. "Cursor MCP Server")
Step 2: Configure Your AI Tool
The configuration process varies slightly depending on your chosen AI tool. Here's an example configuration for Cursor:
{ "mcpServers": { "supabase": { "command": "npx", "args": [ "-y", "@supabase/mcp-server-supabase@latest", "--access-token", "<personal-access-token>" ] } } }
Tools
The following tools are available to the MCP server. You can use them to manage your Supabase projects and database.
Category | Command | Description |
---|---|---|
Project Management | list_projects | Lists all Supabase projects for the user. |
get_project | Gets details for a project. | |
create_project | Creates a new Supabase project. | |
pause_project | Pauses a project. | |
restore_project | Restores a project. | |
list_organizations | Lists all organizations that the user is a member of. | |
get_organization | Gets details for an organization. | |
Database Operations | list_tables | Lists all tables within the specified schemas. |
list_extensions | Lists all extensions in the database. | |
list_migrations | Lists all migrations in the database. | |
apply_migration | Applies a SQL migration to the database. SQL passed to this tool will be tracked within the database, so LLMs should use this for DDL operations (schema changes). | |
execute_sql | Executes raw SQL in the database. LLMs should use this for regular queries that don't change the schema. | |
get_logs | Gets logs for a Supabase project by service type (api, postgres, edge functions, auth, storage, realtime). LLMs can use this to help with debugging and monitoring service performance. | |
Edge Functions | list_edge_functions | Lists all Edge Functions in a Supabase project. |
deploy_edge_function | Deploys a new Edge Function to a Supabase project. LLMs can use this to deploy new functions or update existing ones. | |
Project Configuration | get_project_url | Gets the API URL for a project. |
get_anon_key | Gets the anonymous API key for a project. | |
Branching | create_branch | Creates a development branch with migrations from production branch. |
list_branches | Lists all development branches. | |
delete_branch | Deletes a development branch. | |
merge_branch | Merges migrations and edge functions from a development branch to production. | |
reset_branch | Resets migrations of a development branch to a prior version. | |
rebase_branch | Rebases development branch on production to handle migration drift. | |
Development | generate_typescript_types | Generates TypeScript types based on the database schema. LLMs can save this to a file and use it in their code. |
Cost | get_cost | Gets the cost of a new project or branch for an organization. |
confirm_cost | Confirms the user's understanding of new project or branch costs. This is required to create a new project or branch. |