Setting Up Supabase MCP Server with Cursor (With Debugging)

Table of contents

I Had a hell of a time getting my Supabase MCP Server working. I figured that, because I went through the ringer on figuring out how to fix it, that I would share with you all that are probably googling how to get it fixed a guide to do just that.
If you're unaware, the current official MCP server for Supabase seems to not be working very well at the moment: https://github.com/supabase-community/supabase-mcp/issues/28
Setting Up Supabase MCP Server with Cursor
This guide walks through setting up the Supabase Model Context Protocol (MCP) server with Cursor, allowing you to interact with your Supabase database directly through Cursor's AI assistant.
Prerequisites
- A Supabase account with a project
- Cursor IDE installed
- Node.js installed (v18+ recommended)
- A Supabase Personal Access Token (PAT)
Step 1: Generate a Supabase Personal Access Token
- Log in to your Supabase account at https://supabase.com/dashboard
- Click on your profile icon in the top right corner
- Select "Access Tokens" from the dropdown menu
- Click "Generate new token"
- Give your token a name (e.g., "Cursor MCP")
- Copy the generated token (it starts with
sbp_
)
Step 2: Install Required Packages
The Supabase MCP server requires specific packages to work properly. Install them locally in a dedicated directory:
Mac
# Create a directory for MCP packages
mkdir -p ~/.cursor/mcp-packages
# Navigate to the directory
cd ~/.cursor/mcp-packages
# Initialize a package.json
npm init -y
# Install required packages
npm install @supabase/mcp-server-supabase @modelcontextprotocol/sdk
Windows
# Create a directory for MCP packages
mkdir -p %APPDATA%\Cursor\mcp-packages
# Navigate to the directory
cd %APPDATA%\Cursor\mcp-packages
# Initialize a package.json
npm init -y
# Install required packages
npm install @supabase/mcp-server-supabase @modelcontextprotocol/sdk
Step 3: Configure Cursor's MCP Server
Mac Setup
- Create or edit your Cursor MCP configuration file:
mkdir -p ~/.cursor
touch ~/.cursor/mcp.json
- Add the Supabase MCP server configuration:
{
"mcpServers": {
"supabase": {
"command": "node",
"args": [
"/Users/YOUR_USERNAME/.cursor/mcp-packages/node_modules/@supabase/mcp-server-supabase/dist/stdio.js",
"--access-token",
"YOUR_SUPABASE_PAT_HERE"
]
}
}
}
- Replace:
YOUR_USERNAME
with your Mac usernameYOUR_SUPABASE_PAT_HERE
with your Supabase Personal Access Token
Windows Setup
Create or edit your Cursor MCP configuration file at
%APPDATA%\Cursor\mcp.json
Add the Supabase MCP server configuration:
Option 1: Using npx (simpler but might have dependency issues)
{
"mcpServers": {
"supabase": {
"command": "cmd",
"args": [
"/c",
"npx",
"-y",
"@supabase/mcp-server-supabase",
"--access-token",
"YOUR_SUPABASE_PAT_HERE"
]
}
}
}
Note: We're intentionally omitting @latest
to avoid potential dependency conflicts.
Option 2: Using locally installed packages (more reliable)
{
"mcpServers": {
"supabase": {
"command": "cmd",
"args": [
"/c",
"node",
"%APPDATA%\\Cursor\\mcp-packages\\node_modules\\@supabase\\mcp-server-supabase\\dist\\stdio.js",
"--access-token",
"YOUR_SUPABASE_PAT_HERE"
]
}
}
}
- Replace
YOUR_SUPABASE_PAT_HERE
with your Supabase Personal Access Token
Step 4: Verify the MCP Server Path
Mac
- Make sure the path to the stdio.js file is correct:
ls -la ~/.cursor/mcp-packages/node_modules/@supabase/mcp-server-supabase/dist/
- Confirm that
stdio.js
exists in this directory and is executable.
Windows
- Make sure the path to the stdio.js file is correct:
dir %APPDATA%\Cursor\mcp-packages\node_modules\@supabase\mcp-server-supabase\dist\
- Confirm that
stdio.js
exists in this directory.
Step 5: Restart Cursor
- Completely close Cursor
- Reopen Cursor
- The Supabase MCP server should now be available
Security Considerations and Docker Alternative
The setup described above runs the MCP server directly on your system, which has some security implications:
Potential Vulnerabilities
- Access Token Exposure: Your Supabase PAT is stored in a plaintext file on your system
- Dependency Security: The MCP server and its dependencies run with your user permissions
- Network Access: The server has direct network access to Supabase from your machine
Docker-Based Alternative (More Secure)
Using Docker provides better isolation and security. Here's how to set it up:
1. Create a Dockerfile
Create a file named Dockerfile
in a directory of your choice:
FROM node:18-slim
RUN npm install -g @supabase/mcp-server-supabase @modelcontextprotocol/sdk
ENTRYPOINT ["supabase-mcp", "--access-token"]
CMD ["YOUR_SUPABASE_PAT_HERE"]
Replace YOUR_SUPABASE_PAT_HERE
with your Supabase PAT.
2. Build the Docker image
docker build -t supabase-mcp .
3. Update your Cursor MCP configuration
Mac/Linux
{
"mcpServers": {
"supabase": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"supabase-mcp"
]
}
}
}
Windows
{
"mcpServers": {
"supabase": {
"command": "cmd",
"args": [
"/c",
"docker",
"run",
"-i",
"--rm",
"supabase-mcp"
]
}
}
}
Security Best Practices
Regardless of which approach you choose:
- Limit Token Permissions: Create a Supabase PAT with the minimum necessary permissions
- Regular Updates: Keep the MCP server and dependencies updated
- Monitor Access: Regularly audit your Supabase logs for unusual activity
- Token Rotation: Periodically rotate your PAT for enhanced security
- Local Network: Consider running the MCP server on a trusted local network only
Troubleshooting
Error: Cannot find module
If you see an error message like:
Error [ERR_MODULE_NOT_FOUND]: Cannot find module '@modelcontextprotocol/sdk/dist/esm/server/stdio.js'
Try the following solutions (in order of simplicity):
Remove
@latest
from npx command:- If you're using the npx approach with
@latest
suffix, remove it:{ "mcpServers": { "supabase": { "command": "npx", "args": [ "-y", "@supabase/mcp-server-supabase", "--access-token", "YOUR_SUPABASE_PAT_HERE" ] } } }
- This simple change often resolves dependency conflicts
- If you're using the npx approach with
Use a direct local installation:
- Make sure you've installed the packages in the correct directory
- Check that you're using the absolute path in your configuration
- Point directly to the stdio.js file
Try global installation:
npm install -g @supabase/mcp-server-supabase @modelcontextprotocol/sdk
For Windows users:
- Check that you're using the correct path with double backslashes in your configuration
- If using the npx method, try switching to the local installation method
Configuration not working
- Check your JSON syntax in
mcp.json
(no trailing commas, proper nesting) - Verify that your PAT is valid and not expired
- Ensure you're pointing to the correct file (
stdio.js
, notcli.js
) - On Windows, make sure paths use double backslashes (
\\
) in the JSON configuration
Using the Supabase MCP Server
Once configured, you can interact with your Supabase database through Cursor's AI assistant:
- Ask for information about your Supabase projects
- Query your database tables
- Insert, update, or delete data
- Work with Supabase storage, authentication, and functions
Example prompts:
- "Show me the schema of my Supabase database"
- "List all users in my Supabase project"
- "Create a new table in my Supabase database"
- "Query all documents created in the last week"
Resources
Subscribe to my newsletter
Read articles from Patrick Skinner directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by

Patrick Skinner
Patrick Skinner
As a former Paratrooper Medic and Mass Casualty Coordinator, I made the leap into software engineering. Through my journey, I've continued to grow and learn, and I'm eager to share my knowledge with others. As a self-taught software engineer, I'm passionate about empowering others to pursue their dreams and learn new skills. Active Member of Developer DAO.