mcp-db-bridge

mcp-db-bridge

db-bridge•bylucassiqueirasurreco

mcp-db-bridge is an MCP server for MySQL, PostgreSQL, and SQLite with granular permissions, multi-DB access, cloud-ready SSL/TLS, and optional remote HTTP mode.

License: MIT•Runtime: Awaiting documentation review•Category: databases storage

WHAT IT DOES

  • •Provides an MCP server for MySQL, PostgreSQL, and SQLite.
  • •Offers read-only mode plus granular global and schema-specific write permissions for INSERT, UPDATE, DELETE, and DDL operations.
  • •Supports multi-database access through a single connection and makes multi-DB mode read-only by default.
  • •Provides SSL/TLS support for cloud databases and an optional remote HTTP server mode with authentication.

BEST FOR

  • •Projects needing an MCP server for MySQL, PostgreSQL, or SQLite databases.
  • •Teams that want operation-level and schema-specific control over database writes.
  • •Deployments that need a remote MCP server over HTTP with authentication.

ABOUT DB-BRIDGE

mcp-db-bridge is cataloged as an MCP server attributed to lucassiqueirasurreco. mcp-db-bridge is an MCP server for MySQL, PostgreSQL, and SQLite with granular permissions, multi-DB access, cloud-ready SSL/TLS, and optional remote HTTP mode. It is categorized under databases storage. See the capability inspector for recorded interfaces and their independent review status; consult upstream documentation for the current interface.

HOW TO INSTALL

Installation configuration is not reviewed. No executable setup is offered for this entry; inspect the source repository before proceeding.

LICENSE

Catalog license label: MIT. Check the source repository's current license and terms before using, modifying or distributing this software.

Capability inspector

Capability definitions are not reviewed. Unreviewed imports are not exposed as trusted interfaces.

Tools (0)

No reviewed records to display. This does not establish that upstream lacks this capability.

Resources (0)

No reviewed records to display. This does not establish that upstream lacks this capability.

Prompts (0)

No reviewed records to display. This does not establish that upstream lacks this capability.

NEWSLETTER - COMING LATER

Newsletter subscriptions are not open yet

Email delivery is not connected. This page does not collect email addresses or create subscriptions.

Browse the registry for current listings instead.

Community Reviews

Coming later

Reviews for mcp-db-bridge are not available yet

Review publishing and storage are not connected. This page does not collect or publish ratings or comments, including after sign-in.

FREQUENTLY ASKED QUESTIONS

Which database engines does mcp-db-bridge support?

The README lists MySQL, PostgreSQL, and SQLite.

Can write access be restricted by operation or schema?

Yes. The server offers read-only mode, global operation permissions, and schema-specific overrides.

Can mcp-db-bridge run as a remote MCP server?

Yes. It supports running the MCP server via HTTP with authentication.

Upstream README

View this exact version on GitHub

README.md · beeda422a5f3 · Fetched 2026-11-13 08:20:31 UTC

Original upstream text, without AI rewriting. Scripts, forms and unsafe links are filtered for safety.

Showing the last retrieved documentation snapshot; check the source for current changes.

mcp-db-bridge

English | Português


English

Version

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

VariableDescriptionDefaultExample
DB_TYPEDatabase typemysqlmysql, postgresql, sqlite
DB_HOSTDatabase host127.0.0.1localhost, db.example.com
DB_PORTDatabase port33063306 (MySQL), 5432 (PostgreSQL)
DB_USERDatabase userrootadmin, postgres
DB_PASSDatabase password""secure_password
DB_NAMEDatabase nameundefinedmydb, "" (multi-DB)
DB_CONNECTION_LIMITPool size1020

Security Settings

VariableDescriptionDefaultValues
DB_READ_ONLY_MODEGlobal read-only modefalsetrue, false
ALLOW_INSERT_OPERATIONGlobal INSERT permissionfalsetrue, false
ALLOW_UPDATE_OPERATIONGlobal UPDATE permissionfalsetrue, false
ALLOW_DELETE_OPERATIONGlobal DELETE permissionfalsetrue, false
ALLOW_DDL_OPERATIONGlobal DDL permissionfalsetrue, false
MULTI_DB_WRITE_MODEAllow writes in multi-DBfalsetrue, false

Schema Permissions

VariableFormatExample
SCHEMA_INSERT_PERMISSIONSschema:bool,schema:booltest_db:true,prod_db:false
SCHEMA_UPDATE_PERMISSIONSschema:bool,schema:booltest_db:true,prod_db:false
SCHEMA_DELETE_PERMISSIONSschema:bool,schema:booltest_db:false,prod_db:false
SCHEMA_DDL_PERMISSIONSschema:bool,schema:booltest_db:true,prod_db:false

SSL/TLS Settings

VariableDescriptionRequiredExample
DB_SSLEnable SSL/TLSCloud DBstrue, false
DB_SSL_REJECT_UNAUTHORIZEDStrict SSL validationProductiontrue, false
DB_SSL_CACA certificate pathCloud SQL/path/to/ca.pem
DB_SSL_CERTClient certificateCloud SQL/path/to/cert.pem
DB_SSL_KEYClient keyCloud SQL/path/to/key.pem

Remote MCP Settings

VariableDescriptionRequiredExample
IS_REMOTE_MCPEnable HTTP modeNotrue, false
REMOTE_SECRET_KEYAuth tokenIf remoteyour-secret-key
PORTHTTP server portNo3000

Troubleshooting

Connection Errors

MySQL socket not found:

# Check socket path
sudo mysql -u root -p -e "SELECT @@socket;"

# Set in .env
MYSQL_SOCKET_PATH=/var/run/mysqld/mysqld.sock

PostgreSQL connection refused:

# Check if PostgreSQL is running
sudo systemctl status postgresql

# Check port
sudo netstat -tulpn | grep 5432

Permission Errors

"Operation not allowed in read-only mode":

# Check global read-only mode
DB_READ_ONLY_MODE=false

# Check multi-DB mode
MULTI_DB_WRITE_MODE=true  # If needed

# Or use schema permissions
SCHEMA_INSERT_PERMISSIONS=mydb:true

"INSERT not allowed for schema 'mydb'":

# Check global permission
ALLOW_INSERT_OPERATION=true

# Or add schema exception
SCHEMA_INSERT_PERMISSIONS=mydb:true

License

MIT

Credits


Português

Version

Servidor MCP (Model Context Protocol) para MySQL, PostgreSQL e SQLite com permissões granulares, suporte multi-DB e SSL/TLS pronto para nuvem. Construído com adapter pattern para extensibilidade.

Funcionalidades

  • 🔌 Multi-Database: MySQL, PostgreSQL, SQLite
  • 🏗️ Adapter Pattern: Arquitetura limpa e extensível
  • ☁️ Cloud-Ready: SSL/TLS para AWS RDS, Google Cloud SQL, Azure Database
  • 🔒 Security First: Modo read-only + permissões granulares por schema
  • 🌐 Multi-DB Mode: Acesso simultâneo a múltiplos schemas/databases
  • 🔄 Transações: BEGIN/COMMIT/ROLLBACK automático
  • 🚀 Modo HTTP: Servidor HTTP remoto opcional (Express)

Instalação

npm install mcp-db-bridge
# ou
pnpm add mcp-db-bridge

Início Rápido

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:

Executar

pnpm build
pnpm start
# ou
node dist/index.js

Configuração

Tipos de Banco de Dados

DB_TYPE=mysql          # MySQL
DB_TYPE=postgresql     # PostgreSQL
DB_TYPE=sqlite         # SQLite

Configurações de Conexão

Genéricas (Todos os Bancos)

DB_HOST=127.0.0.1
DB_PORT=3306           # MySQL: 3306, PostgreSQL: 5432
DB_USER=root
DB_PASS=password
DB_NAME=mydb           # Deixe vazio para modo multi-DB
DB_CONNECTION_LIMIT=10

Específicas do MySQL (Compatibilidade)

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 (prioridade sobre host/port)

Específicas do PostgreSQL

POSTGRESQL_HOST=127.0.0.1
POSTGRESQL_PORT=5432
POSTGRESQL_DB=mydb

Específicas do SQLite

SQLITE_DB=:memory:              # Database em memória
SQLITE_DB=/var/lib/app/data.db  # Database em arquivo

Segurança & Permissões

Modo Read-Only

Bloqueia todas as operações de escrita em nível de aplicação:

DB_READ_ONLY_MODE=true

Permissões Globais de Escrita

Controle fino de operações por tipo (aplicado globalmente):

ALLOW_INSERT_OPERATION=true   # Permite INSERT
ALLOW_UPDATE_OPERATION=true   # Permite UPDATE
ALLOW_DELETE_OPERATION=false  # Bloqueia DELETE
ALLOW_DDL_OPERATION=false     # Bloqueia CREATE/ALTER/DROP/TRUNCATE

Permissões Específicas por Schema

Sobrescreve permissões globais para schemas específicos:

# Formato: "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

Como funciona:

  • Se schema tem permissão específica → usa ela
  • Caso contrário → usa flag global

Exemplo:

# Global: INSERT bloqueado
ALLOW_INSERT_OPERATION=false

# test_db pode inserir, prod_db não pode
SCHEMA_INSERT_PERMISSIONS=test_db:true,prod_db:false

# Resultado:
# - INSERT em test_db: ✅ permitido (permissão do schema)
# - INSERT em prod_db: ❌ bloqueado (permissão do schema)
# - INSERT em other_db: ❌ bloqueado (permissão global)

Modo Multi-DB

Acessa múltiplos databases/schemas através de uma única conexão.

Ativação

Deixe DB_NAME vazio (MySQL/PostgreSQL apenas):

DB_TYPE=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_USER=root
DB_PASS=password
DB_NAME=                # Vazio = modo multi-DB

Proteção de Escrita

Por padrão, modo multi-DB é read-only por segurança. Para permitir escritas:

MULTI_DB_WRITE_MODE=true  # ⚠️ Use com cautela!

Recomendação: Use SCHEMA_*_PERMISSIONS para controle granular ao invés de MULTI_DB_WRITE_MODE=true.

Exemplo Completo

# Multi-DB com permissões granulares
DB_TYPE=mysql
DB_NAME=                                    # Modo multi-DB
ALLOW_INSERT_OPERATION=false                # Global: bloqueado
SCHEMA_INSERT_PERMISSIONS=test_db:true      # Exceção: test_db pode inserir
SCHEMA_UPDATE_PERMISSIONS=test_db:true      # Exceção: test_db pode atualizar
SCHEMA_DELETE_PERMISSIONS=test_db:false     # test_db: DELETE bloqueado
SCHEMA_DDL_PERMISSIONS=test_db:true         # test_db: DDL permitido

SSL/TLS para Bancos na Nuvem

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
# Opcional: 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

MCP Remoto (Servidor HTTP)

Execute o servidor MCP via HTTP com autenticação:

# .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

Arquitetura

src/
├── db/
│   ├── adapters/
│   │   ├── types.ts              # Interfaces e tipos
│   │   ├── 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                  # Configuração de ambiente
├── utils/
│   └── index.ts                  # Logging & utilitários
└── types/
    └── index.ts                  # Definições de tipos

Adapter Pattern

Cada adapter implementa a interface DatabaseAdapter:

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;
}

Fluxos de Transação

Operações de Leitura:

BEGIN → SET TRANSACTION READ ONLY → QUERY → ROLLBACK → RESET TO READ WRITE

Operações de Escrita:

BEGIN → QUERY → COMMIT (ou ROLLBACK em caso de erro)

Exemplos

MySQL com Unix Socket

DB_TYPE=mysql
MYSQL_SOCKET_PATH=/tmp/mysql.sock
DB_USER=root
DB_PASS=password
DB_NAME=mydb

PostgreSQL Multi-DB com Permissões

DB_TYPE=postgresql
DB_HOST=localhost
DB_PORT=5432
DB_USER=postgres
DB_PASS=password
DB_NAME=                                      # Modo multi-DB
SCHEMA_INSERT_PERMISSIONS=app_db:true         # app_db pode inserir
SCHEMA_UPDATE_PERMISSIONS=app_db:true         # app_db pode atualizar
SCHEMA_DELETE_PERMISSIONS=app_db:false        # app_db: DELETE bloqueado

SQLite Read-Only

DB_TYPE=sqlite
SQLITE_DB=/var/lib/data/production.db
DB_READ_ONLY_MODE=true

AWS RDS MySQL com 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

Desenvolvimento

pnpm dev              # Executar em modo dev (tsx)
pnpm build            # Compilar TypeScript
pnpm watch            # Modo watch
pnpm exec             # Build + executar com .env

Testes

pnpm test              # Executar todos os testes (setup + vitest run)
pnpm test:watch        # Modo watch
pnpm test:unit         # Apenas testes unitários
pnpm test:integration  # Testes de integração (MySQL, socket, permissões)
pnpm test:e2e          # Testes end-to-end
pnpm test:coverage     # Relatório de cobertura

Estrutura de Testes:

tests/
├── unit/           # Funções isoladas (parsing de queries, utils)
├── integration/    # Operações reais de banco de dados
└── e2e/           # Fluxos completos do servidor MCP

Ajustes de Performance

Connection Pool

DB_CONNECTION_LIMIT=20  # Padrão: 10

Desabilitar Transações Read-Only (MySQL)

⚠️ Não recomendado - reduz segurança:

MYSQL_DISABLE_READ_ONLY_TRANSACTIONS=true

Referência de Variáveis de Ambiente

Configurações Principais do Banco

VariávelDescriçãoPadrãoExemplo
DB_TYPETipo de bancomysqlmysql, postgresql, sqlite
DB_HOSTHost do banco127.0.0.1localhost, db.example.com
DB_PORTPorta do banco33063306 (MySQL), 5432 (PostgreSQL)
DB_USERUsuário do bancorootadmin, postgres
DB_PASSSenha do banco""secure_password
DB_NAMENome do bancoundefinedmydb, "" (multi-DB)
DB_CONNECTION_LIMITTamanho do pool1020

Configurações de Segurança

VariávelDescriçãoPadrãoValores
DB_READ_ONLY_MODEModo global read-onlyfalsetrue, false
ALLOW_INSERT_OPERATIONPermissão global de INSERTfalsetrue, false
ALLOW_UPDATE_OPERATIONPermissão global de UPDATEfalsetrue, false
ALLOW_DELETE_OPERATIONPermissão global de DELETEfalsetrue, false
ALLOW_DDL_OPERATIONPermissão global de DDLfalsetrue, false
MULTI_DB_WRITE_MODEPermitir escritas em multi-DBfalsetrue, false

Permissões por Schema

VariávelFormatoExemplo
SCHEMA_INSERT_PERMISSIONSschema:bool,schema:booltest_db:true,prod_db:false
SCHEMA_UPDATE_PERMISSIONSschema:bool,schema:booltest_db:true,prod_db:false
SCHEMA_DELETE_PERMISSIONSschema:bool,schema:booltest_db:false,prod_db:false
SCHEMA_DDL_PERMISSIONSschema:bool,schema:booltest_db:true,prod_db:false

Configurações SSL/TLS

VariávelDescriçãoNecessáriaExemplo
DB_SSLHabilitar SSL/TLSBancos Cloudtrue, false
DB_SSL_REJECT_UNAUTHORIZEDValidação SSL estritaProduçãotrue, false
DB_SSL_CACaminho do certificado CACloud SQL/path/to/ca.pem
DB_SSL_CERTCertificado do clienteCloud SQL/path/to/cert.pem
DB_SSL_KEYChave do clienteCloud SQL/path/to/key.pem

Configurações MCP Remoto

VariávelDescriçãoNecessáriaExemplo
IS_REMOTE_MCPHabilitar modo HTTPNãotrue, false
REMOTE_SECRET_KEYToken de autenticaçãoSe remotoyour-secret-key
PORTPorta do servidor HTTPNão3000

Solução de Problemas

Erros de Conexão

Socket MySQL não encontrado:

# Verificar caminho do socket
sudo mysql -u root -p -e "SELECT @@socket;"

# Configurar no .env
MYSQL_SOCKET_PATH=/var/run/mysqld/mysqld.sock

Conexão PostgreSQL recusada:

# Verificar se PostgreSQL está rodando
sudo systemctl status postgresql

# Verificar porta
sudo netstat -tulpn | grep 5432

Erros de Permissão

"Operation not allowed in read-only mode":

# Verificar modo global read-only
DB_READ_ONLY_MODE=false

# Verificar modo multi-DB
MULTI_DB_WRITE_MODE=true  # Se necessário

# Ou usar permissões de schema
SCHEMA_INSERT_PERMISSIONS=mydb:true

"INSERT not allowed for schema 'mydb'":

# Verificar permissão global
ALLOW_INSERT_OPERATION=true

# Ou adicionar exceção de schema
SCHEMA_INSERT_PERMISSIONS=mydb:true

Licença

MIT

Créditos

Install configuration

Are you the maintainer?

Claim this server with your GitHub account to request manual ownership verification.

README Embed Badge
Markdown

Link to the catalog listing for mcp-db-bridge from your README. This badge does not certify ownership, compatibility or security.

[![MCP catalog listing](https://img.shields.io/badge/MCP-awesome--mcp-orange?style=flat-square)](https://awesome-mcp.com/servers/db-bridge)

REPOSITORY STATS

GitHub StarsUnavailable
ForksUnavailable

Public repository statistics could not be verified. Check the configured source address; unavailable counts are not zero.

Downloads and pulls

Separate sources, scopes and periods. Never combined or treated as installations, active users or security reviews.

No reviewed package or image identity; download statistics are not listed yet.

Related databases storage MCP Servers

Alternative and complementary servers in the same category

View all in databases storage →
AIStor MCP server
mcp-server-aistor•minio

This is a Model Context Protocol (MCP) server for interacting with AIStor object stores.

Repository stats unavailable
Databases & Storage
InfluxDB v2 MCP Server
influxdb-mcp-server•idoru

A Model Context Protocol (MCP) server that exposes access to an InfluxDB v2 instance using the InfluxDB OSS API v2.

Repository stats unavailable
Databases & Storage