Kshitijijari09/supabase-mcp-server
If you are the rightful owner of supabase-mcp-server and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.
A Model Context Protocol (MCP) server for integrating Supabase databases with AI assistants like Claude, optimized for use with Cursor IDE.
Supabase MCP Server
A Model Context Protocol (MCP) server for integrating Supabase databases with AI assistants like Claude. Built for use with Cursor IDE.
🚀 Features
- Database Queries: Query any table with filtering and sorting
- CRUD Operations: Create, read, update, and delete records
- Resource Access: Tables exposed as MCP resources
- Type Safety: Full TypeScript-style schemas for tools
- Error Handling: Comprehensive error handling and logging
- Cursor Integration: Optimized for Cursor IDE workflow
📋 Prerequisites
- Python 3.8+
- Supabase account and project
- Cursor IDE
- Basic knowledge of MCP (Model Context Protocol)
🛠️ Setup Instructions for Cursor IDE
1. Install Dependencies
Open terminal in Cursor (Terminal → New Terminal) and run:
# Create virtual environment (recommended)
python -m venv venv
# Activate virtual environment
# On Windows:
venv\Scripts\activate
# On macOS/Linux:
source venv/bin/activate
# Install required packages
pip install -r requirements.txt
2. Configure Environment Variables
- Copy your Supabase credentials from Supabase Dashboard
- Edit the
.envfile with your actual values:
SUPABASE_URL=https://your-project-id.supabase.co
SUPABASE_KEY=your-anon-or-service-key-here
3. Update Table Configuration
Edit config.py and update the KNOWN_TABLES list with your actual table names:
KNOWN_TABLES: List[str] = [
"your_table_1",
"your_table_2",
"your_table_3",
# Add all your table names here
]
4. Test the Connection
Run this in Cursor's terminal to test your setup:
python -c "from config import get_supabase_client; print('✅ Connection successful!' if get_supabase_client() else '❌ Connection failed!')"
5. Run the MCP Server
python main.py
You should see:
INFO:__main__:✅ Successfully connected to Supabase
INFO:__main__:🚀 MCP Server running...
🔧 Available Tools
| Tool | Description | Parameters |
|---|---|---|
query_table | Query table with filters | table_name, columns, filter_column, filter_value, limit, order_by |
insert_data | Insert new records | table_name, data |
update_data | Update existing records | table_name, filter_column, filter_value, update_data |
delete_data | Delete records | table_name, filter_column, filter_value |
count_rows | Count table rows | table_name |
get_table_info | Get table information | None |
📖 Usage Examples
Query a table:
{
"tool": "query_table",
"arguments": {
"table_name": "users",
"columns": "id, email, created_at",
"filter_column": "status",
"filter_value": "active",
"limit": 10,
"order_by": "created_at",
"ascending": false
}
}
Insert data:
{
"tool": "insert_data",
"arguments": {
"table_name": "users",
"data": {
"email": "user@example.com",
"name": "John Doe"
}
}
}
🔗 Integrating with Cursor IDE
Using with Claude in Cursor:
- Start the MCP server:
python main.py - Configure Cursor: Add MCP server to your Cursor configuration
- Use with AI: The AI can now query your database directly
Cursor-Specific Tips:
- Use Ctrl+Shift+P → "Python: Select Interpreter" to ensure Cursor uses your virtual environment
- Install the Python extension for better IntelliSense
- Use Cursor's AI chat to help debug database queries
- Set up debugging with F5 for easy troubleshooting
🐛 Troubleshooting
Common Issues:
Connection Failed:
- ✅ Check your
.envfile has correct Supabase URL and key - ✅ Ensure your Supabase project is active
- ✅ Verify your key has the right permissions
Table Not Found:
- ✅ Update
KNOWN_TABLESinconfig.py - ✅ Check table names are exact (case-sensitive)
- ✅ Ensure tables exist in your Supabase project
Import Errors:
- ✅ Activate your virtual environment
- ✅ Run
pip install -r requirements.txt - ✅ Check Python version is 3.8+
Debugging in Cursor:
- Set breakpoints in your code
- Press F5 to start debugging
- Use Debug Console to inspect variables
- Check Terminal for error logs
📁 Project Structure
supabase-mcp-server/
├── main.py # Main MCP server implementation
├── config.py # Configuration and Supabase client
├── requirements.txt # Python dependencies
├── .env # Environment variables (your secrets)
├── .gitignore # Git ignore rules
└── README.md # This file
🚦 Next Steps
- Add more tables to
KNOWN_TABLES - Implement table schema discovery for dynamic table listing
- Add authentication for production use
- Create custom tools for your specific use cases
- Set up RLS policies in Supabase for security
🤝 Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
📝 License
MIT License - see LICENSE file for details
🆘 Support
- Check the MCP Documentation
- Visit Supabase Docs
- Open an issue for bugs or feature requests
Happy coding with Cursor IDE! 🎯