Deploys and runs the MCP server on Cloudflare Workers platform for remote database access
Provides OAuth-based user authentication and authorization for secure database access
Supports connections to Google Cloud SQL PostgreSQL databases through standard PostgreSQL tools
Provides comprehensive database tools for PostgreSQL databases including table listing, migration management, SQL execution, and extension management
Alternative deployment platform for hosting the MCP server with automatic git-based deployments
Offers specialized support for Supabase PostgreSQL databases with migration tracking and database operations
Database MCP Server
A remote web-based Model Context Protocol (MCP) server that provides comprehensive database tools for both Supabase and general PostgreSQL databases. This server allows AI assistants like Claude and Cursor to interact with PostgreSQL databases through natural language.
🚀 Features
🔐 User-Provided Database Credentials
Secure Web Form - Users provide their own database credentials through a beautiful, responsive web interface
Multi-Database Support - Works with any PostgreSQL database including Supabase, AWS RDS, Google Cloud SQL, etc.
No Shared Databases - Each user connects to their own database with their own credentials
Real-time Validation - Instant validation of connection parameters and database connectivity
Encrypted Storage - Database credentials are encrypted and only used for the user's session
Core Database Tools
list_tables
- List all tables in specified schemaslist_extensions
- List all PostgreSQL extensions installed in the databaselist_migrations
- List all migrations applied to the database (supports common migration patterns)apply_migration
- Apply SQL migrations (DDL operations with tracking)execute_sql
- Execute any raw SQL statement for data queries or updatesquery
- Run read-only SQL queries (legacy tool)
Additional Tools
Steampipe Integration - Table and plugin management tools
GitHub Authentication - OAuth-based user authentication
Connection Testing - Automatic database connection validation
🏗️ Architecture
This MCP server is built on Cloudflare Workers and features:
Authentication Flow
User Authorization - Users access the MCP server through their AI assistant (Claude, Cursor, etc.)
Database Credentials Form - Users fill out a secure web form with their database connection details
GitHub OAuth - Users authenticate via GitHub for identity verification
Secure Connection - Individual database pools are created per user with their provided credentials
Key Features
Remote deployment on Cloudflare Workers or Railway
No shared databases - Each user connects to their own database
Per-user database pools with connection management
Both Supabase and general PostgreSQL database support
Secure credential handling with encryption and validation
📋 Prerequisites
Node.js 18+
A Cloudflare account (for Cloudflare Workers deployment)
A GitHub account (for OAuth setup)
A PostgreSQL or Supabase database
🛠️ Setup
1. Clone and Install
2. GitHub OAuth Application Setup
Create a GitHub OAuth App for authentication:
Go to GitHub → Settings → Developer Settings → OAuth Apps
Click "New OAuth App"
Fill in the details:
Application name:
Database MCP Server
Homepage URL:
https://your-worker-name.your-account.workers.dev
Authorization callback URL:
https://your-worker-name.your-account.workers.dev/callback
3. Environment Variables
Set up the following environment variables in your Cloudflare Worker:
Variable Name | Type | Description | Example |
| Secret | PostgreSQL connection string |
|
| Secret | GitHub OAuth App Client ID |
|
| Secret | GitHub OAuth App Client Secret |
|
| Secret | Random key for cookie encryption |
|
| Secret | Comma-separated GitHub usernames |
|
Setting Secrets via Wrangler CLI:
4. Deploy to Cloudflare Workers
🔧 Usage
Connecting to AI Clients
Claude Desktop
Install the mcp-remote proxy
Update your Claude Desktop configuration:
Cursor AI
Add to your MCP configuration:
Cloudflare AI Playground
Enter your MCP server URL:
https://your-worker-name.your-account.workers.dev/sse
Authenticate with GitHub
Start using the database tools!
Database Connection
The server supports both Supabase and general PostgreSQL databases. Users provide their own database credentials through the DATABASE_URL
environment variable.
Supabase Connection String Format:
General PostgreSQL Connection String Format:
🔍 Available Tools
Core Database Operations
list_tables
Lists all tables in specified schemas.
list_extensions
Lists all PostgreSQL extensions installed in the database.
list_migrations
Lists all migrations applied to the database. Supports common migration table patterns:
supabase_migrations.schema_migrations
public.schema_migrations
public.migrations
And more...
apply_migration
Applies a SQL migration with automatic tracking.
execute_sql
Executes any raw SQL statement.
query
Runs read-only SQL queries (legacy tool).
🚀 Deployment Options
Cloudflare Workers (Recommended)
Deploy:
npm run deploy
Set secrets: Use
wrangler secret put
commandsConfigure OAuth: Update GitHub OAuth app URLs
Test: Visit your worker URL
Railway (Alternative)
Connect your GitHub repository to Railway
Set environment variables in Railway dashboard
Deploy automatically on git push
🔒 Security
OAuth Authentication: Only authorized GitHub users can access the tools
User Allowlist: Configure specific GitHub usernames in
ALLOWED_USERNAMES
Connection Security: All database connections use secure connection strings
Read-only Options: Tools support read-only execution modes
Transaction Safety: Automatic rollback on errors
🛠️ Development
Local Development
Type Checking
Generate Types
📚 Examples
List all tables in public schema
Execute a data query
Apply a migration
🤝 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.
🆘 Troubleshooting
Common Issues
"Database pool not initialized"
Check your
DATABASE_URL
environment variableEnsure the connection string is valid
"OAuth authentication failed"
Verify GitHub OAuth app configuration
Check
GITHUB_CLIENT_ID
andGITHUB_CLIENT_SECRET
"User not authorized"
Add your GitHub username to
ALLOWED_USERNAMES
Ensure the username is spelled correctly
Connection timeout
Check database server accessibility
Verify firewall settings
Ensure SSL/TLS configuration is correct
Getting Help
Check the Cloudflare Workers documentation
Review the Model Context Protocol specification
Open an issue in this repository
Built with ❤️ for the AI community. This MCP server bridges the gap between AI assistants and database management, making database operations accessible through natural language.
This server cannot be installed
remote-capable server
The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.
Enables AI assistants to interact with PostgreSQL and Supabase databases through natural language. Supports secure database operations including queries, migrations, and schema management with user-provided credentials.
Related MCP Servers
- AsecurityAlicenseAqualityAllows AI assistants to list tables, read data, and execute SQL queries through a controlled interface, making database exploration and analysis safer and more structured.Last updated -898MIT License
- -securityFlicense-qualityA bridge between AI assistants like GitHub Copilot and Supabase databases, allowing AI to understand schema, assist with query writing, and provide context-aware suggestions related to your data model.Last updated -
- AsecurityAlicenseAqualityEnables AI models to interact with PostgreSQL databases through a standardized interface, supporting operations like queries, table manipulation, and schema inspection.Last updated -61917MIT License
- AsecurityFlicenseAqualityEnables AI assistants to interact with PostgreSQL databases using natural language queries, providing secure read-only access to database schemas and SQL translation capabilities.Last updated -62