DB Bridge▌
by lucassiqueirasurreco
DB Bridge enables secure SQL queries on MySQL, PostgreSQL, and SQLite with granular permissions and production-safe writ
Provides secure SQL query execution across MySQL, PostgreSQL, and SQLite databases with granular permission controls, transaction-based operations, and configurable write access for production environments.
Both formats append explainx.ai attribution and the canonical URL for this MCP server listing.
best for
- / Backend developers working with multiple database types
- / Database administrators managing cloud databases
- / Applications requiring secure multi-database access
- / Development teams needing transaction-safe database operations
capabilities
- / Execute SQL queries on MySQL, PostgreSQL, and SQLite
- / Manage database transactions with automatic commit/rollback
- / Connect to cloud databases via SSL/TLS
- / Control access with read-only mode and schema permissions
- / Access multiple databases simultaneously
- / Run as HTTP server for remote access
what it does
Executes SQL queries across MySQL, PostgreSQL, and SQLite databases with security controls and transaction support. Supports cloud databases and simultaneous multi-database access.
about
DB Bridge is a community-built MCP server published by lucassiqueirasurreco that provides AI assistants with tools and capabilities via the Model Context Protocol. DB Bridge enables secure SQL queries on MySQL, PostgreSQL, and SQLite with granular permissions and production-safe writ It is categorized under databases, cloud infrastructure.
how to install
You can install DB Bridge in your AI client of choice. Use the install panel on this page to get one-click setup for Cursor, Claude Desktop, VS Code, and other MCP-compatible clients. This server runs locally on your machine via the stdio transport.
license
MIT
DB Bridge is released under the MIT license. This is a permissive open-source license, meaning you can freely use, modify, and distribute the software.
readme
mcp-db-bridge
English
MCP (Model Context Protocol) server for MySQL, PostgreSQL & SQLite with granular permissions, multi-DB support, and cloud-ready SSL/TLS. Built with adapter pattern for extensibility.
Features
- 🔌 Multi-Database: MySQL, PostgreSQL, SQLite
- 🏗️ Adapter Pattern: Clean and extensible architecture
- ☁️ Cloud-Ready: SSL/TLS for AWS RDS, Google Cloud SQL, Azure Database
- 🔒 Security First: Read-only mode + granular schema permissions
- 🌐 Multi-DB Mode: Simultaneous access to multiple schemas/databases
- 🔄 Transactions: Automatic BEGIN/COMMIT/ROLLBACK
- 🚀 HTTP Mode: Optional remote HTTP server (Express)
Installation
npm install mcp-db-bridge
# or
pnpm add mcp-db-bridge
Quick Start
MySQL (Local)
# .env
DB_TYPE=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_USER=root
DB_PASS=password
DB_NAME=mydb
PostgreSQL (Local)
# .env
DB_TYPE=postgresql
DB_HOST=127.0.0.1
DB_PORT=5432
DB_USER=postgres
DB_PASS=password
DB_NAME=mydb
SQLite (In-Memory)
# .env
DB_TYPE=sqlite
SQLITE_DB=:memory:
Run
pnpm build
pnpm start
# or
node dist/index.js
Configuration
Database Types
DB_TYPE=mysql # MySQL
DB_TYPE=postgresql # PostgreSQL
DB_TYPE=sqlite # SQLite
Connection Settings
Generic (All Databases)
DB_HOST=127.0.0.1
DB_PORT=3306 # MySQL: 3306, PostgreSQL: 5432
DB_USER=root
DB_PASS=password
DB_NAME=mydb # Leave empty for multi-DB mode
DB_CONNECTION_LIMIT=10
MySQL-Specific (Backward Compatibility)
MYSQL_HOST=127.0.0.1
MYSQL_PORT=3306
MYSQL_USER=root
MYSQL_PASS=password
MYSQL_DB=mydb
MYSQL_SOCKET_PATH=/tmp/mysql.sock # Unix socket (priority over host/port)
PostgreSQL-Specific
POSTGRESQL_HOST=127.0.0.1
POSTGRESQL_PORT=5432
POSTGRESQL_DB=mydb
SQLite-Specific
SQLITE_DB=:memory: # In-memory database
SQLITE_DB=/var/lib/app/data.db # File-based database
Security & Permissions
Read-Only Mode
Blocks all write operations at application level:
DB_READ_ONLY_MODE=true
Global Write Permissions
Fine-grained operation control by type (applied globally):
ALLOW_INSERT_OPERATION=true # Allow INSERT
ALLOW_UPDATE_OPERATION=true # Allow UPDATE
ALLOW_DELETE_OPERATION=false # Block DELETE
ALLOW_DDL_OPERATION=false # Block CREATE/ALTER/DROP/TRUNCATE
Schema-Specific Permissions
Override global permissions for specific schemas:
# Format: "schema1:true,schema2:false,schema3:true"
SCHEMA_INSERT_PERMISSIONS=prod_db:false,test_db:true,staging_db:true
SCHEMA_UPDATE_PERMISSIONS=prod_db:false,test_db:true,staging_db:true
SCHEMA_DELETE_PERMISSIONS=prod_db:false,test_db:false,staging_db:false
SCHEMA_DDL_PERMISSIONS=prod_db:false,test_db:true,staging_db:false
How it works:
- If schema has specific permission → use it
- Otherwise → use global flag
Example:
# Global: INSERT blocked
ALLOW_INSERT_OPERATION=false
# test_db can insert, prod_db cannot
SCHEMA_INSERT_PERMISSIONS=test_db:true,prod_db:false
# Result:
# - INSERT on test_db: ✅ allowed (schema permission)
# - INSERT on prod_db: ❌ blocked (schema permission)
# - INSERT on other_db: ❌ blocked (global permission)
Multi-DB Mode
Access multiple databases/schemas through a single connection.
Activation
Leave DB_NAME empty (MySQL/PostgreSQL only):
DB_TYPE=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_USER=root
DB_PASS=password
DB_NAME= # Empty = multi-DB mode
Write Protection
By default, multi-DB mode is read-only for security. To allow writes:
MULTI_DB_WRITE_MODE=true # ⚠️ Use with caution!
Recommendation: Use SCHEMA_*_PERMISSIONS for granular control instead of MULTI_DB_WRITE_MODE=true.
Complete Example
# Multi-DB with granular permissions
DB_TYPE=mysql
DB_NAME= # Multi-DB mode
ALLOW_INSERT_OPERATION=false # Global: blocked
SCHEMA_INSERT_PERMISSIONS=test_db:true # Exception: test_db can insert
SCHEMA_UPDATE_PERMISSIONS=test_db:true # Exception: test_db can update
SCHEMA_DELETE_PERMISSIONS=test_db:false # test_db: DELETE blocked
SCHEMA_DDL_PERMISSIONS=test_db:true # test_db: DDL allowed
SSL/TLS for Cloud Databases
AWS RDS (MySQL/PostgreSQL)
DB_TYPE=mysql
DB_HOST=myinstance.123456789012.us-east-1.rds.amazonaws.com
DB_PORT=3306
DB_SSL=true
DB_SSL_REJECT_UNAUTHORIZED=true
# Optional: DB_SSL_CA=/path/to/aws-rds-ca-cert.pem
Google Cloud SQL (PostgreSQL)
DB_TYPE=postgresql
DB_HOST=34.123.45.67
DB_PORT=5432
DB_SSL=true
DB_SSL_CA=/path/to/server-ca.pem
DB_SSL_CERT=/path/to/client-cert.pem
DB_SSL_KEY=/path/to/client-key.pem
Azure Database for MySQL
DB_TYPE=mysql
DB_HOST=myserver.mysql.database.azure.com
DB_PORT=3306
DB_SSL=true
DB_SSL_REJECT_UNAUTHORIZED=true
Remote MCP (HTTP Server)
Run MCP server via HTTP with authentication:
# .env
IS_REMOTE_MCP=true
REMOTE_SECRET_KEY=your-secret-key-here
PORT=3000
Endpoint: POST http://localhost:3000/mcp
Header: Authorization: Bearer your-secret-key-here
Architecture
src/
├── db/
│ ├── adapters/
│ │ ├── types.ts # Interfaces and types
│ │ ├── factory.ts # Factory pattern
│ │ ├── mysql.adapter.ts # MySQL via mysql2
│ │ ├── postgresql.adapter.ts # PostgreSQL via pg
│ │ └── sqlite.adapter.ts # SQLite via better-sqlite3
│ ├── index.ts # Core query handlers
│ ├── utils.ts # SQL parsing (node-sql-parser)
│ └── permissions.ts # Schema permission checks
├── config/
│ └── index.ts # Environment configuration
├── utils/
│ └── index.ts # Logging & utilities
└── types/
└── index.ts # Type definitions
Adapter Pattern
Each adapter implements the DatabaseAdapter interface:
export interface DatabaseAdapter {
readonly type: DatabaseType;
createPool(config: ConnectionConfig): Promise<DatabasePool>;
executeQuery<T>(pool: DatabasePool, sql: string, params?: any[]): Promise<T>;
setReadOnly(connection: DatabaseConnection): Promise<void>;
unsetReadOnly(connection: DatabaseConnection): Promise<void>;
normalizeResult(result: any): NormalizedResult;
supportsReadOnlyMode(): boolean;
}
Transaction Flows
Read Operations:
BEGIN → SET TRANSACTION READ ONLY → QUERY → ROLLBACK → RESET TO READ WRITE
Write Operations:
BEGIN → QUERY → COMMIT (or ROLLBACK on error)
Examples
MySQL with Unix Socket
DB_TYPE=mysql
MYSQL_SOCKET_PATH=/tmp/mysql.sock
DB_USER=root
DB_PASS=password
DB_NAME=mydb
PostgreSQL Multi-DB with Permissions
DB_TYPE=postgresql
DB_HOST=localhost
DB_PORT=5432
DB_USER=postgres
DB_PASS=password
DB_NAME= # Multi-DB mode
SCHEMA_INSERT_PERMISSIONS=app_db:true # app_db can insert
SCHEMA_UPDATE_PERMISSIONS=app_db:true # app_db can update
SCHEMA_DELETE_PERMISSIONS=app_db:false # app_db: DELETE blocked
SQLite Read-Only
DB_TYPE=sqlite
SQLITE_DB=/var/lib/data/production.db
DB_READ_ONLY_MODE=true
AWS RDS MySQL with SSL
DB_TYPE=mysql
DB_HOST=prod.abc123.us-east-1.rds.amazonaws.com
DB_PORT=3306
DB_USER=admin
DB_PASS=secure_password
DB_NAME=production
DB_SSL=true
DB_SSL_REJECT_UNAUTHORIZED=true
ALLOW_INSERT_OPERATION=false
ALLOW_UPDATE_OPERATION=false
ALLOW_DELETE_OPERATION=false
ALLOW_DDL_OPERATION=false
Development
pnpm dev # Run in dev mode (tsx)
pnpm build # Compile TypeScript
pnpm watch # Watch mode
pnpm exec # Build + run with .env
Testing
pnpm test # Run all tests (setup + vitest run)
pnpm test:watch # Watch mode
pnpm test:unit # Unit tests only
pnpm test:integration # Integration tests (MySQL, socket, permissions)
pnpm test:e2e # End-to-end tests
pnpm test:coverage # Coverage report
Test Structure:
tests/
├── unit/ # Isolated functions (query parsing, utils)
├── integration/ # Real database operations
└── e2e/ # Complete MCP server workflows
Performance Tuning
Connection Pool
DB_CONNECTION_LIMIT=20 # Default: 10
Disable Read-Only Transactions (MySQL)
⚠️ Not recommended - reduces security:
MYSQL_DISABLE_READ_ONLY_TRANSACTIONS=true
Environment Variables Reference
Core Database Settings
| Variable | Description | Default | Example |
|---|---|---|---|
DB_TYPE | Database type | mysql | mysql, postgresql, sqlite |
DB_HOST | Database host | 127.0.0.1 | localhost, db.example.com |
DB_PORT | Database port | 3306 | 3306 (MySQL), 5432 (PostgreSQL) |
DB_USER | Database user | root | admin, postgres |
DB_PASS | Database password | "" | secure_password |
DB_NAME | Database name | undefined | mydb, "" (multi-DB) |
DB_CONNECTION_LIMIT | Pool size | 10 | 20 |
Security Settings
| Variable | Description | Default | Values |
|---|---|---|---|
DB_READ_ONLY_MODE | Global read-only mode | false | true, false |
ALLOW_INSERT_OPERATION | Global INSERT permission | false | true, false |
ALLOW_UPDATE_OPERATION | Global UPDATE permission | false | true, false |
ALLOW_DELETE_OPERATION | Global DELETE permission | false | true, false |
ALLOW_DDL_OPERATION | Global DDL permission | ` |
FAQ
- What is the DB Bridge MCP server?
- DB Bridge is a Model Context Protocol (MCP) server profile on explainx.ai. MCP lets AI hosts (e.g. Claude Desktop, Cursor) call tools and resources through a standard interface; this page summarizes categories, install hints, and community ratings.
- How do MCP servers relate to agent skills?
- Skills are reusable instruction packages (often SKILL.md); MCP servers expose live capabilities. Teams frequently combine both—skills for workflows, MCP for APIs and data. See explainx.ai/skills and explainx.ai/mcp-servers for parallel directories.
- How are reviews shown for DB Bridge?
- This profile displays 63 aggregated ratings (sample rows for discoverability plus signed-in user reviews). Average score is about 4.4 out of 5—verify behavior in your own environment before production use.
Use Cases▌
Direct Database Queries from AI
Enable Claude to query your database directly using natural language
Example
Ask 'Show me top 10 customers by revenue this month' and get SQL results instantly
Eliminate manual SQL writing for ad-hoc queries, get insights 10x faster
Data Analysis & Reporting
Generate complex reports and analytics without leaving conversation
Example
Analyze sales trends, cohort retention, user behavior patterns conversationally
Democratize data access—non-technical team members can query databases
Schema Exploration
Understand database structure, relationships, and data models
Example
'Explain the user_orders table schema and its relationships'
Onboard engineers faster, explore unfamiliar databases efficiently
Data Validation & Quality Checks
Run data quality queries to catch anomalies and inconsistencies
Example
Find duplicate records, missing values, orphaned foreign keys automatically
Maintain data integrity with less manual SQL work
Implementation Guide▌
Prerequisites
- ›Claude Desktop 0.7.0+ or Cursor with MCP support
- ›Database credentials (read-only recommended for safety)
- ›Network access from Claude client to database
- ›Understanding of database security and access control
Time Estimate
15-30 minutes including configuration and testing
Installation Steps
- 1.Install MCP server: npm install -g @modelcontextprotocol/server-[name]
- 2.Configure database connection in Claude Desktop config (~/.claude/mcp.json)
- 3.Provide connection string: host, port, database, username, password
- 4.Restart Claude Desktop to load MCP server
- 5.Test connection: 'List all tables in database'
- 6.Run simple query: 'Show me 5 rows from users table'
- 7.Verify results and permissions are correct
- 8.Document query patterns for team use
Troubleshooting
- ⚠Connection refused: Check database is running and network accessible
- ⚠Authentication failed: Verify credentials, check user permissions
- ⚠Claude can't see tables: Grant appropriate read permissions to database user
- ⚠Slow queries: Add indexes, limit result set size, use read replicas
- ⚠MCP server not loading: Check config syntax, restart Claude Desktop
Best Practices▌
✓ Do
- +Use read-only database credentials to prevent accidental writes
- +Connect to read replica, not production primary database
- +Set query timeout limits to prevent long-running queries
- +Document database schema and common queries for AI context
- +Monitor query performance and optimize slow queries
- +Use connection pooling for better performance
- +Test with non-production data first
✗ Don't
- −Don't use production write credentials—risk of data corruption
- −Don't query production database during peak traffic hours
- −Don't expose sensitive PII without proper access controls
- −Don't skip query result validation—AI can misinterpret schema
- −Don't allow unlimited result set sizes—set LIMIT clauses
- −Don't share database credentials in plain text config files
💡 Pro Tips
- ★Create database views for common queries to simplify AI access
- ★Add schema comments/descriptions so AI understands column meanings
- ★Use semantic table/column names ('customer_lifetime_value' not 'clv')
- ★Set up query logging to audit what Claude is querying
- ★Create saved query templates for recurring analysis
- ★Combine with data visualization tools for better insights
Technical Details▌
Architecture
MCP server acts as bridge between Claude and database, translating natural language to SQL queries and returning results in structured format.
Protocols
- Model Context Protocol (MCP)
- Database-specific protocols (PostgreSQL, MySQL, MongoDB)
Compatibility
- PostgreSQL
- MySQL
- SQLite
- MongoDB
- Redis
When to Use This▌
✓ Use When
Use for ad-hoc data queries, exploratory analysis, report generation, schema exploration, and democratizing data access. Best for read-heavy analytics workloads.
✗ Avoid When
Avoid for production write operations, mission-critical transactions, real-time OLTP workloads, or when database contains sensitive PII without proper access controls. Use read replicas, not primary.
Integration▌
- →Read replica connection for analytics queries
- →Database view layer to abstract complex joins
- →Query result caching for repeated questions
- →Audit logging of all AI-generated queries
Discussion
Product Hunt–style comments (not star reviews)- No comments yet — start the thread.
List & Promote Your MCP Server
Share your MCP server with the developer community
Ratings
4.4★★★★★63 reviews- ★★★★★Chaitanya Patil· Dec 24, 2024
Useful MCP listing: DB Bridge is the kind of server we cite when onboarding engineers to host + tool permissions.
- ★★★★★Luis Huang· Dec 24, 2024
According to our notes, DB Bridge benefits from clear Model Context Protocol framing — fewer ambiguous “AI plugin” claims.
- ★★★★★Camila Reddy· Dec 20, 2024
Useful MCP listing: DB Bridge is the kind of server we cite when onboarding engineers to host + tool permissions.
- ★★★★★Naina Sethi· Dec 16, 2024
We evaluated DB Bridge against two servers with overlapping tools; this profile had the clearer scope statement.
- ★★★★★Omar Martin· Nov 27, 2024
We evaluated DB Bridge against two servers with overlapping tools; this profile had the clearer scope statement.
- ★★★★★Piyush G· Nov 15, 2024
DB Bridge reduced integration guesswork — categories and install configs on the listing matched the upstream repo.
- ★★★★★Camila Sethi· Nov 15, 2024
DB Bridge has been reliable for tool-calling workflows; the MCP profile page is a good permalink for internal docs.
- ★★★★★Naina Malhotra· Nov 15, 2024
DB Bridge is a well-scoped MCP server in the explainx.ai directory — install snippets and categories matched our Claude Code setup.
- ★★★★★Camila Garcia· Nov 11, 2024
DB Bridge reduced integration guesswork — categories and install configs on the listing matched the upstream repo.
- ★★★★★Meera Thomas· Nov 7, 2024
I recommend DB Bridge for teams standardizing on MCP; the explainx.ai page compares cleanly with sibling servers.
showing 1-10 of 63