by lucassiqueirasurreco
DB Bridge enables secure SQL queries on MySQL, PostgreSQL, and SQLite with granular permissions and production-safe writ
Executes SQL queries across MySQL, PostgreSQL, and SQLite databases with security controls and transaction support. Supports cloud databases and simultaneous multi-database access.
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.
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.
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.
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
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
Understand database structure, relationships, and data models
Example
'Explain the user_orders table schema and its relationships'
Onboard engineers faster, explore unfamiliar databases efficiently
Share your MCP server with the developer community
Useful MCP listing: DB Bridge is the kind of server we cite when onboarding engineers to host + tool permissions.
According to our notes, DB Bridge benefits from clear Model Context Protocol framing — fewer ambiguous “AI plugin” claims.
Useful MCP listing: DB Bridge is the kind of server we cite when onboarding engineers to host + tool permissions.
We evaluated DB Bridge against two servers with overlapping tools; this profile had the clearer scope statement.
We evaluated DB Bridge against two servers with overlapping tools; this profile had the clearer scope statement.
DB Bridge reduced integration guesswork — categories and install configs on the listing matched the upstream repo.
DB Bridge has been reliable for tool-calling workflows; the MCP profile page is a good permalink for internal docs.
DB Bridge is a well-scoped MCP server in the explainx.ai directory — install snippets and categories matched our Claude Code setup.
DB Bridge reduced integration guesswork — categories and install configs on the listing matched the upstream repo.
I recommend DB Bridge for teams standardizing on MCP; the explainx.ai page compares cleanly with sibling servers.
showing 1-10 of 63
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.
npm install mcp-db-bridge
# or
pnpm add mcp-db-bridge
# .env
DB_TYPE=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_USER=root
DB_PASS=password
DB_NAME=mydb
# .env
DB_TYPE=postgresql
DB_HOST=127.0.0.1
DB_PORT=5432
DB_USER=postgres
DB_PASS=password
DB_NAME=mydb
# .env
DB_TYPE=sqlite
SQLITE_DB=:memory:
pnpm build
pnpm start
# or
node dist/index.js
DB_TYPE=mysql # MySQL
DB_TYPE=postgresql # PostgreSQL
DB_TYPE=sqlite # SQLite
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
Blocks all write operations at application level:
DB_READ_ONLY_MODE=true
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
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:
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)
Access multiple databases/schemas through a single connection.
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
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.
# 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
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
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
DB_TYPE=mysql
DB_HOST=myserver.mysql.database.azure.com
DB_PORT=3306
DB_SSL=true
DB_SSL_REJECT_UNAUTHORIZED=true
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
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
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;
}
Read Operations:
BEGIN → SET TRANSACTION READ ONLY → QUERY → ROLLBACK → RESET TO READ WRITE
Write Operations:
BEGIN → QUERY → COMMIT (or ROLLBACK on error)
DB_TYPE=mysql
MYSQL_SOCKET_PATH=/tmp/mysql.sock
DB_USER=root
DB_PASS=password
DB_NAME=mydb
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
DB_TYPE=sqlite
SQLITE_DB=/var/lib/data/production.db
DB_READ_ONLY_MODE=true
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
pnpm dev # Run in dev mode (tsx)
pnpm build # Compile TypeScript
pnpm watch # Watch mode
pnpm exec # Build + run with .env
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
DB_CONNECTION_LIMIT=20 # Default: 10
⚠️ Not recommended - reduces security:
MYSQL_DISABLE_READ_ONLY_TRANSACTIONS=true
| 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 |
| 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 | ` |
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
Prerequisites
Time Estimate
15-30 minutes including configuration and testing
Steps
Troubleshooting
✓ Do
✗ Don't
💡 Pro Tips
Architecture
MCP server acts as bridge between Claude and database, translating natural language to SQL queries and returning results in structured format.
Protocols
Compatibility
✓ 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.