DB Health MCP
Provides read-only health checks for MySQL databases, including overview, slow queries, missing indexes, table bloat/fragmentation, index usage, and a combined scored health report with suggested SQL fixes.
Provides read-only health checks for PostgreSQL databases, including overview, slow queries, missing indexes/sequential scans, dead-tuple bloat, index usage, and a combined scored health report with suggested SQL fixes.
Click on "Deploy 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., "@DB Health MCP run a health check on my database and list prioritized fixes"
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.
db-health-mcp
One call. One health report for your database. An MCP server that lets Claude, Cursor, or any MCP client run a real checkup on your MySQL database — slow queries, missing indexes, fragmentation, dead-weight indexes — and returns a single scored report with a concrete fix for every finding. PostgreSQL is supported too.
Ask your agent: "What's wrong with my database?" — and watch it run
health_reportinstead of guessing.
The headline: health_report
Most database MCP servers hand the agent a bag of small tools and let it
improvise. health_report runs every check at once and folds the results
into one report:
Score 0–100 with a letter grade (transparent heuristic: severity deductions, capped per category — see
src/db_health_mcp/report.py)Findings sorted by severity, each with the numbers behind it
A suggested fix per finding, as SQL text — e.g. the exact
CREATE INDEX/OPTIMIZE TABLE/DROP INDEXstatement. The server is read-only: it proposes fixes, it never executes them.
Sample output (abridged, from a real run against MySQL 8.0.46):
# Database health report (mysql)
**Score: 44/100 (grade D)**
- Server: 8.0.46-0ubuntu0.24.04.5
- Database size: 5.2 MB
- Active connections: 2
- Largest table: healthdemo.logs (2.5 MB)
Findings: 14 (1 high, 3 warning, 10 info)
## [HIGH] Table bloat / fragmentation: healthdemo.logs
80% of the table's allocated space is free (10.0 MB of 12.5 MB), left
behind by deletes/updates.
Suggested fix: `OPTIMIZE TABLE `healthdemo`.`logs`;`
## [WARNING] Missing indexes: healthdemo.orders
Full table scans have read 600,000 rows from this ~19,922-row table
(30 full passes).
Suggested fix: `CREATE INDEX idx_orders_<column> ON `healthdemo`.`orders` (<column>); ...`
## [INFO] Unused indexes: healthdemo.users
Index has never been used since the server started, but still costs write
overhead on every insert/update.
Suggested fix: `DROP INDEX `idx_nickname_unused` ON `healthdemo`.`users`;`Verified end to end against live MySQL 8.0.46 and PostgreSQL 16.15 (all six tools, both engines), plus 30 unit tests with mocked rows.
Related MCP server: pgtriage
Individual check tools
For follow-up questions, each check is also a tool of its own:
Tool | MySQL source | PostgreSQL source |
| version, size, connections, largest tables | same |
|
|
|
|
| sequential-scan stats |
| InnoDB fragmentation ( | dead-tuple ratio |
|
|
|
The engine is picked automatically from the connection-string scheme
(mysql:// vs postgresql://), and every tool accepts an optional
database_url argument, so one server instance can check several
databases.
Read-only by design. Sessions are opened read-only
(SET SESSION TRANSACTION READ ONLY / default_transaction_read_only=on)
with a statement timeout, and every query is a SELECT against
catalog/statistics views. The server cannot modify your database.
Quick start
pip install db-health-mcp # or: pip install -e . from a cloneClaude Code
claude mcp add db-health \
-e DATABASE_URL=mysql://user:pass@localhost:3306/mydb \
-- db-health-mcpCursor / other MCP clients
{
"mcpServers": {
"db-health": {
"command": "db-health-mcp",
"env": {
"DATABASE_URL": "mysql://user:pass@localhost:3306/mydb"
}
}
}
}PostgreSQL works the same way with a postgresql:// URL.
Then just ask:
"What's wrong with my database?"
"Give my database a health check and list the fixes in priority order."
"Which tables are missing indexes?"
"Are there any indexes I can safely drop?"
Notes
MySQL checks need MySQL 8 with
performance_schemaand thesysschema enabled (both are defaults). If statement digests are unavailable,slow_queriestells you how to enable them instead of failing; the other checks still run.PostgreSQL
slow_queriesneeds thepg_stat_statementsextension; same deal — you get enable instructions, not an error.Statistics accumulate over time (MySQL: since server start; PostgreSQL: since the last stats reset) — on a freshly restarted database the scan/index findings need some real traffic before they mean much.
Use a least-privilege, read-only database user for extra safety.
Development
python -m venv .venv && source .venv/bin/activate
pip install -e ".[dev]"
pytest # unit tests (mocked rows, no live DB needed)
python scripts/selftest.py # MCP handshake + tool list + error pathsRoadmap
MariaDB compatibility pass (the
sysschema andmax_execution_timediffer slightly)SQLite quick-check for local dev databases
explain_querytool: runEXPLAINon a query and interpret the planLock contention and long-running transaction checks
Replication lag check
A sibling project: cloud capacity/quota checks for AWS/GCP
License
MIT
Available Tools
6 toolsdb_overviewB
Get a quick snapshot: server version, database size, active connection count, and the largest tables by total size.
Inputs: database_url.
health_reportA
Run every health check in one call and return a single report: an overall score (0-100), findings sorted by severity, and a concrete suggested fix for each finding (SQL text, never executed). Works for MySQL and PostgreSQL; the engine is picked from the URL scheme.
Inputs: database_url.
index_usageB
Find indexes that have never been used for a scan — they still cost write overhead and disk. Primary-key and unique indexes are excluded.
Inputs: database_url.
missing_indexesC
Find tables that are read mostly by full/sequential scans — the classic symptom of a missing index.
Inputs: database_url.
slow_queriesA
List the slowest queries by mean execution time (MySQL: performance_schema statement digests; PostgreSQL: pg_stat_statements). If the statistics source is unavailable, returns instructions for enabling it instead of failing.
Inputs: limit, database_url.
table_bloatB
Find bloated tables (PostgreSQL: dead-tuple ratio; MySQL: InnoDB fragmentation via data_free).
Inputs: database_url.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 6 tools
Each tool targets a single, distinct diagnostic concern: missing indexes, table bloat, unused indexes, slow queries, and a snapshot overview. The one potential overlap (health_report vs. individual checks) is clearly framed as an aggregate that runs all checks in one call, so there's no confusion about when to use which.
All names are snake_case noun phrases describing the returned data (missing_indexes, table_bloat, index_usage, health_report, db_overview, slow_queries) — internally consistent rather than verb_noun. Minor singular/plural mixing (missing_indexes vs. table_bloat) keeps it just short of perfect.
Six tools is well-scoped for a DB health diagnostic server: five focused checks plus one aggregate report. Each tool earns its place with no redundancy beyond the intentional roll-up.
Covers the core health signals — index gaps, bloat, unused indexes, slow queries, and a version/size/connection snapshot — with an aggregate report. Gaps exist for lock/wait analysis, cache hit ratios, and replication lag, but these are workaround-able omissions rather than blocking holes.
Maintenance
Related MCP Connectors
Hosted MCP server for PostgreSQL diagnostics: slow queries, missing indexes, connection pressure.
Scans schema metadata to classify PHI, score HIPAA readiness, and generate compliant migrations.
Database design review audit, delivered per API call as an atom service on Conduit Atoms.
Database intelligence, AST SQL injection auditing, query optimization & schema guards.
Related MCP Servers
- AlicenseAqualityBmaintenanceAgent-readiness scorecard for any MCP server: protocol checks, 0-100 score and actionable findings.1104 npm1MIT
- AlicenseAqualityBmaintenanceRead-only PostgreSQL performance auditing via MCP. Collects metrics from PostgreSQL system views, applies deterministic checks for index, query, vacuum, configuration, and connection issues, and returns structured findings for MCP clients.6MIT
- AlicenseBqualityCmaintenanceEnables AI coding agents to perform deterministic database architecture audits and performance engineering for PostgreSQL and MySQL, covering migration analysis with schema health scoring, ESR-based composite index recommendations, N+1 query detection, EXPLAIN plan diagnosis, transaction and deadlock analysis, partitioning and archival design, and capacity or configuration tuning. It also generates phased Expand & Contract runbooks that turn blocking DDL into zero-downtime production migrations.8MIT

codeDB Lensofficial
AlicenseAqualityBmaintenanceRead-only MCP server for SQL Server and PostgreSQL health checks. It runs the codeDB Lens diagnosis (A–F grade with rule coverage, findings with evidence, impact and next actions), reads 24-hour performance recordings, lists databases and tables, describes table schemas, and runs one guarded SELECT at a time within per-profile row and time limits. It uses the user's saved connection profiles; pass148Apache 2.0