AI-DBA
Provides database diagnostics, operations, and performance analysis for MySQL databases, including blocking chain detection, via MCP server and CLI.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@AI-DBAcheck blocking chains on mysql-prod"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
AI-DBA
Universal database copilot — diagnostics, operations, and performance analysis via MCP and CLI.
Features
MCP Server — expose database diagnostics as tools for AI agents (Hermes, Claude Code, etc.)
CLI — one-off commands for scripting and automation
Interactive REPL — explore your databases interactively with standard DBA commands
Connection URLs — connect via
mysql://,postgresql://,sqlserver://,oracle://, ormongodb://URLs (no config file needed)Database-agnostic commands —
databases,tables,describe,indexes,processeswork across enginesMulti-engine support — MySQL, PostgreSQL, SQL Server, Oracle, and MongoDB connectors
MySQL blocking chains — detect and report row-level blocking with full query details
Table sizes — list table/collection sizes with human-readable formatting (
table-sizes)Explain plans — execution plan analysis with optional
--analyzeflag (PostgreSQL executes the query)Slow queries — surface slow query data from engine internals (performance_schema, pg_stat_statements, sys.dm_exec_query_stats, V$SQLAREA, currentOp)
Health checks — orchestrate connectivity, blocking, processes, and slow queries into one status call
SQL guard — shared validation module rejects destructive SQL before it reaches connectors
GitHub Actions CI — build + test on Node 20/22, runs on every push/PR to main
Documentation site — MkDocs Material with 8 pages, light/dark mode, search
Related MCP server: MCP OCI OPSI Server
Documentation
Full docs site live at: https://steveramos21.github.io/ai-dba/
To build docs locally:
python3 -m venv .venv
.venv/bin/pip install -r requirements-docs.txt
.venv/bin/mkdocs serve
# Open http://127.0.0.1:8000Quick Start
1. Install dependencies
npm install2. Build
npm run build3. Connect and explore
Option A — Config file (for multiple engines):
cp config.yaml.example config.yaml
# Edit config.yaml with your database credentials
npm run replOption B — Connection URL (no config file needed):
node dist/index.js repl
# Then: connect mysql://root:password@127.0.0.1:3306/mydbOption C — Connect via URL (drops into REPL):
# MySQL
npm run connect -- 'mysql://root:***@127.0.0.1:3306/mydb'
# PostgreSQL
npm run connect -- 'postgresql://postgres:***@127.0.0.1:5432/mydb'
# Connects and opens interactive REPLCommands
Command | Description |
| Start MCP server over stdio (for AI agents) |
| List configured database engines |
| Show current blocking chains |
| List table sizes with human-readable formatting |
| Show execution plan (add |
| List slow queries from engine internals |
| Run health check (connectivity, blocking, processes, slow queries) |
| Connect to a database via URL |
| Interactive REPL for database diagnostics |
Global Options
Option | Description | Default |
| Path to config.yaml |
|
| Show version | — |
| Show help | — |
connect <url>
Connect to a database via URL and open an interactive REPL. No config file needed. Supports mysql://, postgresql://, and postgres:// URL schemes.
# MySQL
npm run connect -- 'mysql://root:***@127.0.0.1:3306/mydb'
# PostgreSQL
npm run connect -- 'postgresql://postgres:***@127.0.0.1:5432/mydb'
# With --type override
npm run connect -- 'postgresql://user:***@host:5432/db' --type postgresThis connects, verifies the connection, then drops you into the REPL where you can run databases, tables, describe, indexes, processes, etc.
blocking-chains
ai-dba blocking-chains <engineId> # Table output
ai-dba blocking-chains <engineId> --json # JSON outputDetects blocking chains across MySQL and PostgreSQL. Returns a list of blocking chain entries:
Field | Description |
| Engine identifier from config |
| Process ID holding the lock |
| Process ID waiting for the lock |
| How long the blocked session has been waiting |
| Wait event name (engine-specific) |
| SQL statement holding the lock |
| SQL statement waiting for the lock |
| Database context |
| Wait type classification |
| Session status |
| Client host address |
| Client program name |
| Session login timestamp |
MySQL uses INNODB_LOCK_WAITS + INNODB_TRX + performance_schema.threads (4-join query). wait_type and program_name are NULL for MySQL (not exposed in the query).
PostgreSQL uses pg_blocking_pids() + pg_stat_activity with query_start for wait duration. All 12 fields are populated natively.
Error cases:
Unknown engine ID →
Unknown engine "x". Available: mysql-primaryUnsupported engine type → error from the connector's
getBlockingChains()method
repl
ai-dba repl # Uses config.yaml
ai-dba repl # No config — start empty, use connectInteractive commands:
Command | Alias | Description |
| Show available commands | |
| Connect to a database via URL | |
|
| List databases on the server |
|
| List tables (with rows, size, engine) |
|
| Show column details (type, nullable, key, default) |
|
| List indexes on a table |
|
| Show active connections/processes |
|
| List configured engines (current marked with *) |
| Switch to a different engine | |
|
| Show connection details for current engine |
|
| Show blocking chains on current engine |
| Run a raw SQL query (escape hatch) | |
|
| Exit the REPL |
SQL keywords are auto-detected — just type SHOW DATABASES or SELECT * FROM users directly.
Example session:
AI-DBA REPL — type 'help' for commands
No engines configured. Use: connect <url>
ai-dba[no-engine]> connect mysql://root:password@127.0.0.1:13306/testdb
Connected to 127.0.0.1-testdb
mysql://root:***@127.0.0.1:13306/testdb
ai-dba[127.0.0.1-testdb]> databases
┌────────────────────┐
│ Database │
├────────────────────┤
│ information_schema │
│ testdb │
└────────────────────┘
2 database(s)
ai-dba[127.0.0.1-testdb]> tables
┌────────────────┬──────┬─────────┬─────────┬─────────────────────┐
│ Table │ Rows │ Size │ Engine │ Collation │
├────────────────┼──────┼─────────┼─────────┼─────────────────────┤
│ blocking_test │ 3 │ 16.0 KB │ InnoDB │ utf8mb4_0900_ai_ci │
└────────────────┴──────┴─────────┴─────────┴─────────────────────┘
1 table(s)
ai-dba[127.0.0.1-testdb]> describe blocking_test
┌─────────┬──────────────┬──────┬─────┬─────────┬────────────────┐
│ Column │ Type │ Null │ Key │ Default │ Extra │
├─────────┼──────────────┼──────┼─────┼─────────┼────────────────┤
│ id │ int │ NO │ PRI │ NULL │ auto_increment │
│ name │ varchar(100) │ YES │ │ NULL │ │
│ value │ int │ YES │ │ NULL │ │
└─────────┴──────────────┴──────┴─────┴─────────┴────────────────┘
ai-dba[127.0.0.1-testdb]> processes
┌──────┬──────┬──────────────────────┬─────────┬─────────┬──────┬─────────────┐
│ PID │ User │ Host │ DB │ Command │ Time │ State │
├──────┼──────┼──────────────────────┼─────────┼─────────┼──────┼─────────────┤
│ 5 │ root │ 172.23.0.1:54312 │ testdb │ Query │ 0s │ starting │
└──────┴──────┴──────────────────────┴─────────┴─────────┴──────┴─────────────┘
1 process(es)serve
Starts an MCP server over stdio. Used by AI agents to call database diagnostics tools.
MCP configuration (e.g., ~/.hermes/config.yaml):
{
"mcpServers": {
"ai-dba-diagnostics": {
"command": "node",
"args": ["/path/to/ai-dba/dist/index.js", "serve", "--config", "/path/to/ai-dba/config.yaml"]
}
}
}The server exposes six tools:
Tool | Parameters | Description |
|
| Show current blocking chains |
|
| List databases/schemas on the server |
|
| List tables in a database/schema |
|
| Show column metadata for a table |
|
| List indexes on a table |
|
| List active database connections/processes |
|
| List table sizes with data/index/total breakdown |
|
| Show execution plan for a query |
|
| List slow queries from engine internals |
|
| Run health check (connectivity, blocking, processes, slow queries) |
All tools return JSON. The database parameter overrides the engine's configured database (MySQL) or schema (PostgreSQL).
Docker Test Environment
A Docker Compose file is included for local testing with MySQL 8.0 and PostgreSQL 16.
Start databases
docker compose up -dWait until healthy:
docker inspect --format='{{.State.Health.Status}}' ai-dba-mysql-test
docker inspect --format='{{.State.Health.Status}}' ai-dba-postgres-test
# Repeat until both show "healthy"Seed MySQL test data
docker exec ai-dba-mysql-test mysql -uroot -ptestpassword testdb \
-e "CREATE TABLE IF NOT EXISTS blocking_test (id INT PRIMARY KEY AUTO_INCREMENT, name VARCHAR(100), value INT); INSERT IGNORE INTO blocking_test (name, value) VALUES ('alpha', 1), ('beta', 2), ('gamma', 3);"Create a test config
cp config.yaml.example config.yamlThe example config points to both Docker MySQL on port 13306 and PostgreSQL on port 15432.
Test blocking detection
MySQL blocking scenario:
node test/test-blocking.mjsPostgreSQL blocking scenario:
# Seed test data first
docker exec ai-dba-postgres-test psql -U postgres -d testdb \
-c "CREATE TABLE IF NOT EXISTS blocking_test (id SERIAL PRIMARY KEY, value INT); INSERT INTO blocking_test (value) VALUES (1) ON CONFLICT DO NOTHING;"
# Run the test
node test/test-blocking-postgres.mjsStop databases
docker compose downAdd -v to also delete the data volume.
Integration tests (require Docker)
# All connector methods against live MySQL + PostgreSQL (49 tests)
npm run test:integration
# Live blocking scenarios — creates real locks, validates detection (21 tests)
npm run test:blockingThese tests catch bugs that mocked unit tests cannot — they exercise real SQL against MySQL 8.0 and PostgreSQL 16.
Configuration
config.yaml format:
Connection URL (recommended)
engines:
mysql-prod:
type: mysql
url: mysql://readonly:***@prod-db.internal:3306/app_db?ssl=true
postgres-prod:
type: postgres
url: postgresql://readonly:***@prod-db.internal:5432/app_db?sslmode=requireThe url field takes priority over individual fields. MySQL supports additional URL params:
ssl=true— enable SSL with certificate verificationssl={"rejectUnauthorized":false}— custom SSL options (JSON)connectionLimit=10— pool size (default: 5)
PostgreSQL URLs are passed directly to pg.Pool({ connectionString }), so any pg-supported parameter works (sslmode, connect_timeout, etc.).
Individual fields (legacy)
engines:
<engine-id>:
type: mysql # or postgres, sqlserver, oracle, mongodb
host: 127.0.0.1 # Hostname or IP (MySQL only)
port: 3306 # Port (MySQL only)
user: root # Database user (MySQL only)
password: secret # Password (MySQL only)
database: mydb # Default database (MySQL only)Note: Individual fields are only supported for MySQL. PostgreSQL requires a connection URL (url field).
Multiple engines are supported:
engines:
mysql-prod:
type: mysql
url: mysql://readonly:***@prod-db.internal:3306/app_db?ssl=true
mysql-staging:
type: mysql
host: staging-db.internal
port: 3306
user: readonly
password: ${MYSQL_STAGING_PASSWORD}
database: app_db
postgres-analytics:
type: postgres
url: postgresql://readonly:***@analytics-db.internal:5432/warehouse?sslmode=requireSecurity: Add config.yaml to .gitignore (already included by default).
Architecture
src/
index.ts CLI entry point (commander, REPL)
server.ts MCP server setup + connector map
config.ts YAML config loader with URL parsing
connector.ts DatabaseConnector interface + shared types (BlockingChain, TableSizeInfo, ExplainResult, SlowQueryInfo, HealthCheckResult)
sql-guard.ts Shared SQL validation (validateReadOnlySql, validateExplainQuery, isJsonCommand)
connectors/
mysql.ts MySQLConnector (implements DatabaseConnector)
postgres.ts PostgreSQLConnector (implements DatabaseConnector)
sqlserver.ts SqlServerConnector (implements DatabaseConnector)
oracle.ts OracleConnector (implements DatabaseConnector)
mongodb.ts MongoDbConnector (implements DatabaseConnector)
tools/
blocking-chains.ts MCP tool — blocking chain diagnostics
databases.ts MCP tool — list databases/schemas
tables.ts MCP tool — list tables
describe-table.ts MCP tool — column metadata
indexes.ts MCP tool — list indexes
processes.ts MCP tool — active processes/connections
table-sizes.ts MCP tool — table size breakdown
explain.ts MCP tool — execution plans
slow-queries.ts MCP tool — slow query analysis
health-check.ts MCP tool — orchestrated health checkDatabaseConnector interface — 10 methods:
listDatabases,listTables,describeTable,listIndexes,listProcesses,query,getBlockingChains,listTableSizes,explainQuery,listSlowQueries. All 5 engines implement the interface.sql-guard.ts — shared validation module used by CLI, REPL, and MCP tool paths. Rejects destructive SQL (INSERT, UPDATE, DELETE, DROP, TRUNCATE, ALTER, CREATE, MERGE, GRANT, REVOKE) using
\bword-boundary regex.Lazy imports — MCP SDK, mysql2, and pg are loaded dynamically only when needed. CLI commands like
list-enginesstart instantly without loading database drivers.Lazy connection pools — Database connections are created on first use, not at startup.
One tool per file — each
src/tools/*.tsfile is self-contained (schema + handler). Adding a new tool means adding a new file and registering it inserver.ts.Graceful degradation —
slow-queriesandexplainreturn empty results when engine features are unavailable (extension not installed, permission denied) rather than throwing errors.GitHub Actions CI —
.github/workflows/ci.ymlruns build + unit tests on Node 20/22 for every push/PR to main.
Requirements
Node.js 18+
MySQL 8.0+ (with
performance_schemaenabled, which is the default)PostgreSQL 12+ (for PostgreSQL connector)
License
MIT
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Latest Blog Posts
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/steveramos21/ai-dba'
If you have feedback or need assistance with the MCP directory API, please join our Discord server