Navigation
Yazdani-Supabase-MCP-Server: Natural-to-SQL Translation & Data Bridge - MCP Implementation

Yazdani-Supabase-MCP-Server: Natural-to-SQL Translation & Data Bridge

Yazdani-Supabase-MCP-Server bridges human language and data with effortless natural-to-SQL translation, powered by Supabase PostgreSQL and Claude 3.7 Sonnet’s precision.

Developer Tools
4.2(28 reviews)
42 saves
19 comments

44% of users reported increased productivity after just one week

About Yazdani-Supabase-MCP-Server

What is Yazdani-Supabase-MCP-Server: Natural-to-SQL Translation & Data Bridge?

This middleware server bridges natural language queries to PostgreSQL operations via Claude 3.7 integration, offering a robust interface for React Native apps. It combines schema introspection, secure SQL execution, and Supabase session pooling into a developer-friendly package. The auto-fallback mock database and granular safety controls make it ideal for rapid prototyping while maintaining production-grade safeguards.

How to Use Yazdani-Supabase-MCP-Server

Begin by cloning the repository and configuring your .env with Supabase credentials. For development, activate mock mode to bypass live databases. Production deployments require proper network configuration to ensure stable Supabase pooler connections. Use the provided test harness to validate natural language queries like "List users created this quarter" which auto-translates to optimized SQL.

Yazdani-Supabase-MCP-Server Features

Key Features of Yazdani-Supabase-MCP-Server

  • Schema Intelligence: Visualizes database structures with relationship mappings
  • Contextual SQL Generation: Claude 3.7 powered natural language parsing
  • Fail-Safe Architecture: Mock data auto-activation during connection drops
  • Migration Governance: Auditable migration tracking and rollbacks
  • Session Resilience: Supabase pooler ensures stable IPv4 connections

Use Cases of Yazdani-Supabase-MCP-Server

Developers leverage this tool for:

  • Building chat-based query interfaces for non-technical users
  • Automating schema documentation through introspection APIs
  • Testing app logic against dynamic mock datasets
  • Securing production databases with operation whitelists
  • Managing multi-environment migrations across staging/production

Yazdani-Supabase-MCP-Server FAQ

FAQ from Yazdani-Supabase-MCP-Server

Q: How does the mock database differ from live mode?
A: Mock mode uses in-memory datasets with identical schema structures, providing identical API responses while isolating real data.

Q: What safeguards prevent malicious SQL?
A: The safety layer blocks DDL operations by default, and Claude's contextual understanding avoids destructive queries through intent analysis.

Q: Can I customize natural language parsing?
A: Yes, the NL processing pipeline allows injecting custom pre/post processors via middleware hooks.

Q: How is Supabase session pooling configured?
A: The connection string uses the recommended postgres.{project_ref}@pooler_host format for persistent IPv4 connections.

Content

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

  1. Clone the repository:

    git clone

cd Yazdani-supabase-mcp-server
  1. Install dependencies:

    pip install -r requirements.txt

  2. Create a .env file with your credentials:

    Supabase credentials

SUPABASE_PROJECT_REF=your_project_ref
SUPABASE_URL=https://your_project_ref.supabase.co
SUPABASE_DB_PASSWORD=your_db_password
SUPABASE_REGION=your_region
SUPABASE_ACCESS_TOKEN=your_access_token
SUPABASE_SERVICE_ROLE_KEY=your_service_role_key

# Database connection
POSTGRES_HOST=db.your_project_ref.supabase.co
POSTGRES_PORT=5432
POSTGRES_DB=postgres
POSTGRES_USER=postgres
SUPABASE_POOLER_HOST=aws-0-ca-central-1.pooler.supabase.com

# Claude API
ANTHROPIC_API_KEY=your_anthropic_api_key

# Optional: for mock database mode
# USE_MOCK_DB=true

Usage

Running the Server with Live Database

For normal operation with a Supabase database connection:

python run_server.py

Running the Server with Mock Database

For development or testing without a live database connection:

# Windows
improved_mock_server.bat

# Unix/macOS
USE_MOCK_DB=true python run_server.py

Testing Connection

To test the connection with both real and mock database:

python connection_test.py

Natural Language Testing

We've added a powerful natural language testing environment that allows you to test the MCP server with natural language queries:

# Windows - Run the full test environment (HTTP server + NL client)
run_nl_test.bat

# Manual setup
python http_server.py --port 8000   # Terminal 1
python nl_test_client.py            # Terminal 2

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

pip install -e .
yazdani-supabase-mcp-server

Integration with React Native PaveApp

Setting Up MCP Server for React Native

  1. 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`
  1. 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
  1. 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 schemas
  • get_tables: List tables in a schema
  • get_table_schema: Get detailed table structure
  • execute_postgresql: Execute SQL statements
  • retrieve_migrations: List database migrations
  • generate_sql: Generate SQL from natural language

Troubleshooting

Connection Details

The server uses the Supabase Session pooler for database connections:

postgresql://postgres.{project_ref}:{password}@{pooler_host}:5432/postgres

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:

  1. Verify your Supabase project is active
  2. Check that your database credentials are correct in the .env file
  3. Ensure your IP address is allowed in Supabase database settings
  4. Verify you're using the correct pooler host for your region
  5. Try using the mock database mode: USE_MOCK_DB=true
  6. Run python test_pooler_connection.py to test the pooler connection specifically
  7. 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.

Related MCP Servers & Clients