- Published on
How to Connect Cursor IDE with Supabase Using Model Context Protocol (MCP)
- Authors
- Name
- Jeevan Wijerathna
- @iamjeevanvj
The Model Context Protocol (MCP) allows Cursor IDE to directly connect with Supabase, giving the AI assistant context about your database schema, tables, relationships, and data. By establishing this connection, you can leverage AI-powered database interactions without leaving your IDE.
Prerequisites
Before setting up the connection, ensure you have:
- Supabase Account and Project: Sign up at supabase.com and create a project
- Cursor IDE Installed: Download from cursor.so
- Node.js and npm: Version 16 or higher
- Personal Access Token (PAT): Generated from your Supabase dashboard
# Verify Node.js and npm installationnode -v # Should be v16.0.0 or highernpm -v
Creating the MCP Configuration
- Create a
.cursor
folder in your project's root directory - Inside this folder, create an
mcp.json
file with the following configuration:
{ "mcpServers": { "supabase": { "command": "npx", "args": [ "-y", "@supabase/mcp-server-supabase@latest", "--access-token", "<your-personal-access-token>" ] } }}
Replace <your-personal-access-token>
with the PAT you generated from Supabase's dashboard under Settings > Access Tokens. Name your token something descriptive like "Cursor MCP Server".
Verifying the Connection
Once the configuration is in place:
- Open or restart Cursor IDE
- Navigate to Settings > MCP
- You should see the Supabase MCP server listed with a green "active" status
# If you're having connection issues, you can manually test the MCP servernpx @supabase/mcp-server-supabase@latest --access-token <your-token> --debug
Practical Usage Examples
With the MCP server connected, you can interact with your database in natural language:
# Example prompts you can now use in Cursor IDE"Show me the users table schema""Generate a query to find all orders placed in the last week""Create a new table to store product reviews with appropriate fields"
Result
When properly configured:
- Cursor IDE will understand your database schema
- You can generate SQL queries using natural language
- Create or modify tables and schemas directly from the IDE
- Get context-aware code completions for database operations
For enhanced security, consider storing your access token as an environment variable and referencing it in your configuration instead of hardcoding it.
Happy Coding :)