Integrations
Uses .env files to securely store and manage configuration variables like API keys and database credentials
Enables SQL execution, schema inspection, and database migration management for PostgreSQL databases
Designed for integration with React Native PaveApp, providing database access capabilities
Yazdani-Supabase-MCP-Server
An MCP server that integrates with Supabase PostgreSQL and uses Claude 3.7 for natural language query processing, designed for integration with React Native PaveApp.
Features
- Schema Inspection: View database schemas, tables, columns, and relationships
- SQL Execution: Run SQL queries with safety controls
- Migration Management: View and manage database migrations
- Natural Language Processing: Convert natural language to SQL using Claude 3.7
- Safety Controls: Protection against destructive operations
- Mock Database Mode: Support for development and testing without a live database connection
- Auto-Fallback Mechanism: Gracefully falls back to mock data when database connection fails
- Session Pooler Support: Uses Supabase Session pooler for stable connections
Installation
Prerequisites
- Python 3.8 or higher
- Access to a Supabase PostgreSQL database (optional with mock mode)
- Anthropic API key (for Claude integration)
Setup
- Clone the repository:Copy
- Install dependencies:Copy
- Create a
.env
file with your credentials:Copy
Usage
Running the Server with Live Database
For normal operation with a Supabase database connection:
Running the Server with Mock Database
For development or testing without a live database connection:
Testing Connection
To test the connection with both real and mock database:
Natural Language Testing
We've added a powerful natural language testing environment that allows you to test the MCP server with natural language queries:
The natural language test client provides:
- Interactive command-line interface for testing
- Natural language to SQL conversion using Claude
- SQL execution against the Supabase database
- Formatted result display
- Command history and result saving capabilities
Sample natural language queries to try:
- "Show me all tables in the public schema"
- "Get all users who signed up in the last month"
- "What is the total number of users in the database?"
Installing as a Package
Integration with React Native PaveApp
Setting Up MCP Server for React Native
- Run the server:
- For development: Use mock mode with
improved_mock_server.bat
- For production: Ensure database credentials are correct and run
run_server.py
- For development: Use mock mode with
- Make the server accessible:
- For local development: Ensure React Native can access your local network
- For production: Host the server where it can be accessed by your app
- Connect from React Native:
- Use the MCP client libraries to connect to the server
- Configure the client with the server's address and port
API Endpoints
The MCP server exposes the following tools that can be accessed through the MCP protocol:
get_schemas
: List all database schemasget_tables
: List tables in a schemaget_table_schema
: Get detailed table structureexecute_postgresql
: Execute SQL statementsretrieve_migrations
: List database migrationsgenerate_sql
: Generate SQL from natural language
Troubleshooting
Connection Details
The server uses the Supabase Session pooler for database connections:
This connection format is recommended by Supabase for applications that maintain persistent connections, especially on IPv4 networks.
Connection Issues
If you're experiencing connection issues with Supabase:
- Verify your Supabase project is active
- Check that your database credentials are correct in the
.env
file - Ensure your IP address is allowed in Supabase database settings
- Verify you're using the correct pooler host for your region
- Try using the mock database mode:
USE_MOCK_DB=true
- Run
python test_pooler_connection.py
to test the pooler connection specifically - Run
python connection_test.py
to run a comprehensive connection test
Mock Database Mode
The server now includes improved mock database support:
- Auto-fallback to mock data when connection fails
- Consistent interface between real and mock data
- Clear indication when mock data is being used
- Improved logging for troubleshooting
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
This project is licensed under the MIT License - see the LICENSE file for details.
This server cannot be installed
An MCP server that enables natural language querying of Supabase PostgreSQL databases using Claude 3.7, allowing users to inspect schemas, execute SQL, manage migrations, and convert natural language to SQL queries.