MCP Database Service
Provides tools to query and modify MySQL databases, inspect schemas, tables, indexes, statistics, DDL, and views, analyze queries, run SQL scripts, and manage session-scoped transactions.
Provides tools to query and modify PostgreSQL databases, inspect schemas, tables, indexes, statistics, DDL, and views, analyze query plans, search metadata, and manage session-scoped transactions.
Provides read-only Redis operations for GET, HGETALL, SCAN, and connectivity checks.
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
English | 简体中文
MCP Database Service
An MCP server for MySQL, PostgreSQL, Oracle, and Redis with explicit persistent connections and SQL session continuity.
Quick Start
Use Node.js 24 or later and install the service:
npm install -g @jadchene/mcp-database-serviceSave the configuration below as databases.json and replace the connection details. Use the absolute path to that file when adding the service.
Codex:
codex mcp add database -- mcp-database-service --config /absolute/path/databases.jsonClaude Code:
claude mcp add database -- mcp-database-service --config /absolute/path/databases.jsonOn Windows, a path such as C:/mcp/database/databases.json works. The client starts the stdio service; no separate background process or HTTP port is needed. The config path can also be supplied through MCP_DATABASE_CONFIG; there is no default config path.
Related MCP server: 多数据库 MCP Server
Configuration
{
"sessionIdleTimeoutMs": 1800000,
"maxSessions": 32,
"query": {
"timeoutMs": 5000
},
"logging": {
"enabled": false,
"directory": "./logs"
},
"databases": [
{
"key": "main-mysql",
"type": "mysql",
"enable": true,
"readonly": true,
"dangerMode": false,
"codexAutoReview": false,
"connection": {
"host": "127.0.0.1",
"port": 3306,
"databaseName": "app_db",
"user": "app_reader",
"password": "replace-with-password",
"connectTimeoutMs": 5000,
"ssl": false
}
},
{
"key": "main-postgresql",
"type": "postgresql",
"enable": false,
"readonly": true,
"dangerMode": false,
"codexAutoReview": false,
"connection": {
"host": "127.0.0.1",
"port": 5432,
"databaseName": "app_db",
"user": "app_reader",
"password": "replace-with-password",
"connectTimeoutMs": 5000,
"ssl": false
}
},
{
"key": "oracle-thick-example",
"type": "oracle",
"enable": false,
"readonly": true,
"dangerMode": false,
"codexAutoReview": false,
"connection": {
"host": "127.0.0.1",
"port": 1521,
"serviceName": "XEPDB1",
"user": "app_reader",
"password": "replace-with-password",
"connectTimeoutMs": 5000,
"clientMode": "thick",
"clientLibDir": "C:/oracle/instantclient_19_25"
}
},
{
"key": "cache-redis",
"type": "redis",
"enable": false,
"readonly": true,
"dangerMode": false,
"codexAutoReview": false,
"connection": {
"host": "127.0.0.1",
"port": 6379,
"databaseName": 0,
"username": "default",
"password": "replace-with-password",
"connectTimeoutMs": 5000
}
}
]
}The same configuration is available in databases.example.json. Keep the targets you need, replace their connection details, and set enable to true. Oracle Thin mode uses "clientMode": "thin" without clientLibDir; Redis without authentication can omit username and password. Config values are literal; ${VAR} placeholders are not expanded.
enable: false hides a target and closes its sessions. Configuration reloads automatically or through reload_config; invalid updates keep the last valid config. Connection or permission changes invalidate existing sessions.
Timeouts are in milliseconds. Idle time restarts after each operation, and maxSessions includes connections being established. Logging is off by default; relative log directories resolve from the config directory.
Supported Databases
Database | SQL Query | SQL Write | Runtime Analysis | SQL Script |
MySQL | ✓ | ✓ | ✓ | ✓ |
PostgreSQL | ✓ | ✓ | ✓ | — |
Oracle | ✓ | ✓ | — | — |
Redis | — | — | — | — |
Redis supports GET, HGETALL, SCAN, and connectivity checks.
Tools
Tool | Purpose |
| List enabled targets; inspect or reload sanitized configuration. |
| Open an independent connection for an enabled |
| Close an idle session; uncommitted work is rolled back. |
| Read actual transaction state without changing it. |
| Commit the current SQL transaction. |
| Roll back the whole current SQL transaction. |
| Inspect schemas, tables, and columns. |
| Inspect indexes, statistics, and DDL. |
| List views or search table/column names. |
| Inspect settings and slow activity. |
| Inspect blocking and locks, subject to engine support and privileges. |
| Execute one read-only SQL statement with parameters and a row limit. |
| Inspect a static plan or run runtime analysis; pass the original SQL. |
| Execute one non-query statement, including SET, USE, transaction control, DML, or DDL. |
| Execute a whole MySQL script from |
| Read strings/hashes or cursor-scan Redis keys. |
Sessions and Transactions
Call connect with a databaseKey, reuse the returned sessionId for subsequent operations, and call disconnect when finished. Variables, temporary tables, the current schema, and transactions persist within that session.
Run same-session operations sequentially. Reconnect after idle expiry, connection loss, or a service restart. If a write times out or loses its connection, check the result before retrying.
Start SQL transactions with native SQL through execute_statement; use commit_transaction, rollback_transaction, and get_transaction_status to manage them. Queries do not automatically commit or roll back transactions. execute_script uses the current transaction by default; use useTransaction: true for a script-owned transaction without an existing transaction or transaction-control statements in the script. DDL follows the database's own commit rules.
Writes and Approval
Set the target's readonly to false to allow writes. Statements, scripts, and non-empty transaction commits require a client that supports interactive approval; rollback does not require approval.
Optional codexAutoReview: true allows compatible Codex clients to review operations automatically. dangerMode: true overrides readonly and skips approval. Both are disabled by default; database account permissions still apply.
Oracle
Enabled Oracle targets in one process must share the client mode and library directory. DML requires manual commit, and explain_query requires an active transaction.
Development
npm install
npm run build
npm test
npm run verify:reload
npm run verify:packageAgent skill: database-mcp.
Web configuration
Disabled by default. Web binds only to 127.0.0.1, needs no token, and uses a separate port from MCP communication.
mcp-database-service --config ./config/databases.json --web --web-port 3102Open the printed URL. Alternatively, add "web": { "enabled": true, "port": 3102 } to your existing configuration.
CLI overrides the file:
--webenables,--no-webdisables; with neither,web.enabledapplies and defaults to false. A port alone does not enable Web.Click Save configuration to write the original file and reload it. External edits trigger a conflict; reload failures are reported separately.
Runtime information shows listener settings and the configuration file location. Web enablement and port are read-only in the UI; change the file or startup arguments and restart.
Web stops with the process. If Web fails to start, a warning is logged and MCP continues running. Change the port and restart to resolve a port conflict.
License
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
Governed SQL access to your databases: redaction, query review and an audit log.
Query Postgres, MySQL, SQL Server, Oracle, BigQuery, ClickHouse and Redshift from your AI client.
Database intelligence, AST SQL injection auditing, query optimization & schema guards.
Query your databases and build dashboards, Streamlit apps and reports your team logs in to.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceEnables secure database interactions with MySQL, PostgreSQL, and SQLite through granular permissions, multi-database support, and cloud-ready SSL/TLS connections. Supports read-only modes, schema-specific permissions, and transaction management for safe database operations.12 npm1MIT
- AlicenseAqualityCmaintenanceEnables MCP clients to securely query databases, list tables, inspect table schemas, and test connections across Oracle, SQL Server, MySQL, PostgreSQL, and SQLite using read-only SQL tools.4MIT
- AlicenseNot gradedqualityCmaintenanceEnables controlled access to Oracle/PLSQL databases, allowing querying, schema browsing, and optional PL/SQL execution with per-connection safety controls.MIT
- AlicenseAqualityBmaintenanceProvides secure, multi-user access to Oracle Database for MCP clients, enabling SQL querying, execution, schema exploration, and performance analysis through various connection methods including TNS, JDBC, and TCPS.17Apache 2.0