Supabase MCP
Supabase MCP Server connects Supabase projects to AI assistants for managing data, querying, and performing tasks securely. It supports project scoping, read-only mode, and customizable tool access.
How to Install and Use Supabase MCP
Supabase MCP is a tool that lets you connect your Supabase projects to AI assistants like Cursor and Claude. These assistants can help you manage tables, run queries, and more. Here’s a simple guide on how to install and use Supabase MCP.
Step 1: Follow Security Best Practices
Before setting up Supabase MCP, it’s important to know about security risks. Connecting your database to AI tools has risks, like prompt injection attacks, where harmful commands trick the AI into running unwanted actions. Always read Supabase’s security best practices to understand how to keep your data safe.
Step 2: Configure Your MCP Client
Now, you can set up Supabase MCP on your client. To do this, open your MCP client or AI tool and add the MCP server’s details. The server URL usually looks like this:
{
"mcpServers": {
"supabase": {
"type": "http",
"url": "https://mcp.supabase.com/mcp"
}
}
}
If you want to use your own project, you can generate a custom URL with your project ID by visiting the MCP connection tab in your Supabase dashboard.
When configuring your client, it will ask you to sign in to Supabase. Make sure you select the organization that holds the project you want to work on.
Step 3: Use the MCP Server Locally or Self-Hosted
If you use the Supabase CLI, you can access MCP locally at:
http://localhost:54321/mcp
Keep in mind that the local MCP server has limited tools and does not support OAuth 2.1.
If you run Supabase on your own servers (self-hosted), check the documentation to enable MCP. This also has a limited set of tools without OAuth support.
Step 4: Customize MCP Using URL Options
Supabase MCP lets you change settings with URL query parameters. These can restrict or expand what your AI assistant can do.
- Read-only mode: To prevent any changes to your databases, add
?read_only=trueto the URL:
https://mcp.supabase.com/mcp?read_only=true
This makes sure the AI can only run queries that do not change anything.
- Project scoped mode: To restrict the assistant to one project only, add your project reference ID:
https://mcp.supabase.com/mcp?project_ref=<your-project-id>
Replace <your-project-id> with your actual project ID found in your Supabase dashboard.
- Feature groups: You can select which tool groups the AI can use by adding a list in the
featuresparameter:
https://mcp.supabase.com/mcp?features=database,docs
This example only allows database and documentation tools.
Step 5: Using Supabase MCP Tools
Supabase MCP offers many tools depending on your settings. Some examples include:
- Database tools: List tables or run SQL queries.
- Account tools: Manage your projects and organizations.
- Knowledge base: Search Supabase documentation.
- Edge functions: Deploy and list serverless functions.
If you choose read-only mode, any tools that change data will be disabled for safety.
Quick Recap of Setup Code Example
Here’s the basic JSON you need in your MCP client to connect to Supabase MCP:
{
"mcpServers": {
"supabase": {
"type": "http",
"url": "https://mcp.supabase.com/mcp?read_only=true&project_ref=<your-project-id>"
}
}
}
Replace <your-project-id> with your actual project ID to scope access and enable read-only mode for security.
By following these steps, you will have Supabase MCP running securely and ready to connect your Supabase projects to AI assistants. This helps you manage your data and projects using AI tools in a safe and controlled way.