This server implements the Model Context Protocol (MCP) to allow natural language querying of your Supabase PostgreSQL database on macOS. With this setup, you can interact with your database using conversational language rather than writing SQL queries directly.
Install Docker Desktop
Download and install Docker Desktop for macOS from the official website.
Create Docker Configuration
Create a new file named docker-compose.yml
and add the following content:
version: '3.8'
services:
db:
image: supabase/postgres:15.8.1.049
container_name: supabase-db
restart: unless-stopped
environment:
POSTGRES_PASSWORD: your_postgres_password
POSTGRES_DB: your_database_name
ports:
- "5432:5432"
volumes:
- db-data:/var/lib/postgresql/data
mcp:
image: node:18
container_name: mcp-supabase
working_dir: /app
command: >
sh -c "npx -y @modelcontextprotocol/server-postgres 'postgres://postgres:your_postgres_password@db:5432/your_database_name'"
depends_on:
- db
ports:
- "3000:3000"
environment:
NODE_ENV: production
volumes:
db-data:
Configure Connection Details
In the docker-compose.yml
file, replace:
your_postgres_password
with your actual PostgreSQL passwordyour_database_name
with your actual database nameStart the Docker Containers
Open Terminal, navigate to the directory containing your docker-compose.yml
file, and run:
docker-compose up -d
Verify Your Installation
Check that the services are running properly:
docker-compose ps
You should see both "supabase-db" and "mcp-supabase" containers with a status of "Up".
To view the logs for troubleshooting:
docker-compose logs -f
Once the MCP server is running, you can access it at:
http://localhost:3000
With the server running, you can send natural language queries to interact with your Supabase database. This endpoint can be integrated with any MCP-compatible AI tool to perform SQL operations.
You can use tools like curl
to send requests to your MCP server:
curl -X POST http://localhost:3000/query \
-H "Content-Type: application/json" \
-d '{"query": "Show me all users who signed up last month"}'
If you encounter issues:
To stop the MCP server and database:
docker-compose down
To stop and remove all data volumes:
docker-compose down -v
There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json
file so that it is available in all of your projects.
If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json
file.
To add a global MCP server go to Cursor Settings > MCP and click "Add new global MCP server".
When you click that button the ~/.cursor/mcp.json
file will be opened and you can add your server like this:
{
"mcpServers": {
"cursor-rules-mcp": {
"command": "npx",
"args": [
"-y",
"cursor-rules-mcp"
]
}
}
}
To add an MCP server to a project you can create a new .cursor/mcp.json
file or add it to the existing one. This will look exactly the same as the global MCP server example above.
Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.
The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.
You can also explictly ask the agent to use the tool by mentioning the tool name and describing what the function does.