Supabase is great, but there’s a problem. If you’re using Cursor to help build your databases, you’ll run into a big issue: Cursor forgets what’s in the database. It doesn’t retain the structure, the data, or how everything connects, leading to constant errors, and that’s frustrating. You have to keep reminding it what’s inside, which slows everything down.
Now, for those who don’t know, Supabase is an open-source alternative to Firebase that lets you manage databases visually without needing to set them up locally. It’s powerful, flexible, and integrates well with AI tools like Cursor. But if Cursor keeps forgetting your database structure, what’s the solution? I’ve got a really cool fix. Let me show you.
The Database Setup
This is the database in Supabase, with its tables and schemas. For this demonstration, I have a folder schema and a notes schema, which are part of an Apple Notes clone I made for this article.
The UI looks really nice. I built the whole thing in Cursor, and everything is working perfectly. The database updates correctly as well. For example, if I delete a note and go back to refresh, the note is deleted. So, everything is set up properly. I just use this as a simple example to demonstrate how the tool works and how I used it.
Now, let me show you what it is.
The Solution: MCP Server for Supabase
Here in Cursor, I have my MCP servers. This is the Supabase server, which enables context transfer between database tables and the Cursor agent. If you want to learn more about them, you can check out our dedicated article, but don’t worry about how to install it; I’ll show you that later in this article.
This is the tool you can use. In the composer window, the query tool is being used by Cursor. What Cursor does is generate SQL files that you inject into the SQL editor in Supabase, where you can run your commands. However, from my experience working with Supabase, Cursor tends to forget what tables have been written. It doesn’t retain the context of what’s been done. Since it lacks context for the data, it struggles to manage the database correctly, which is why this tool is really helpful.
How It Works
To give you a better idea of what it was actually doing, here is a description of the process.
After running the first command, the tool verified that the tables were correct. Now, some errors can arise, but because of this verification step, it was able to get the context and proceed accordingly.
It’s constantly verifying. When I was debugging something, it even told me that the tables were empty based on the context and then inserted some placeholder data to test out the front end. It repeats the same process, verifying over and over. This makes managing databases in large projects so much easier and more efficient. If you’re using Supabase, you definitely need to try this.
Setting Up the MCP Server
These are the docs provided by Supabase for the Modern Context Protocol. You can connect to both local and hosted instances, depending on what setup you have.
- For the local version: You can find the connection string by using the
superbase statuscommand. - For the hosted version (which I used): I’ll show you the process.
In general, this is the command we need to use:
mcp-server-supabase --connection-string <connection-string>
It requires the connection string. Other than that, you just paste the command with the connection string into Cursor, and it’ll start working. For other tools like Claude, desktop clients, or Wind-Surf, they’ve provided separate configurations that you can use.
Where do you get the connection string?
- In your Supabase project, navigate to Project Settings, then Database.
- The first thing I want to point out is that you’ll find your password here. The reason I’m mentioning this is that you’ll need it in your connection string. If you don’t remember your password, just reset it from here.
- After that, go into the Connect tab.
- Scroll down, and you’ll find the Session Pooler section. This is your connection string.
Just copy it, paste your password into it, and then use it in the command.
After that’s done, your command will look something like this when combined:
mcp-server-supabase --connection-string "postgresql://postgres:[YOUR-PASSWORD]@db.your-project.supabase.co:5432/postgres"
Note: You’ll notice that I haven’t included the angle brackets (< >) that were around the connection string parameter, so make sure you don’t include them either. Also, when entering the password, remove the square brackets ([ ]) as well, because you’re supposed to enter the password without them.
Once that’s done, you can just go ahead and paste the entire command with your password into Cursor.
Adding the MCP Service to Cursor
Here in Cursor, you can just add the full command. Let me actually show you how to add the MCP service.
- Add the server name.
- Set the type, which is just going to be
Command. - Paste the command down below.
- After that, you add it, and it’ll start working.
You’ll notice that I haven’t used the command I mentioned earlier. That’s because I’ve put it in a script and am running it through bash. You can do it either way; I just prefer this method.
If you’re wondering what I mean, let me show you.
- Here in the terminal, first, using
touch, create a script and make sure its name ends with.sh.touch run_supabase_mcp.sh - Once that’s done, open it with any text editor, paste in your command, and save it.
- After that, use
realpath. For example, I named my scriptrun_supabase_mcp.sh, and what this does is give me the path of the script.realpath run_supabase_mcp.sh - Then I go back into Cursor, add
bashin front of it, and paste the rest of the path. This is how I prefer to run the MCP service. You can see that I’ve done the same with the GitHub MCP as well.
And that’s pretty much it. Setting up the MCP server in Cursor keeps your database structure in check, so you’re not constantly reminding it what’s inside. It just works, making the whole process way smoother. If you’re using Supabase with Cursor, definitely give this a shot. It’ll save you a ton of headaches. Let me know how it goes.