db-health-mcp
Your database looks fine. Probably.
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.
How it works
flowchart LR
A["💬 You ask:<br/>'What's wrong with my database?'"] --> B["🤖 MCP client<br/>(Claude, Cursor, ...)"]
B -->|health_report| C["🩺 db-health-mcp"]
C -->|read-only SELECTs| D[("MySQL 8 / PostgreSQL 16<br/>performance_schema · sys · pg_stat")]
C --> E["📋 Scored report<br/>0–100 + grade · findings by severity<br/>fix SQL for every finding"]
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.
Individual check tools
For follow-up questions, each check is also a tool of its own:
| Tool | MySQL source | PostgreSQL source |
|---|---|---|
db_overview |
version, size, connections, largest tables | same |
slow_queries |
performance_schema statement digests |
pg_stat_statements |
missing_indexes |
sys.schema_tables_with_full_table_scans |
sequential-scan stats |
table_bloat |
InnoDB fragmentation (information_schema.data_free) |
dead-tuple ratio |
index_usage |
sys.schema_unused_indexes |
pg_stat_user_indexes |
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 clone
Claude Code
claude mcp add db-health \
-e DATABASE_URL=mysql://user:pass@localhost:3306/mydb \
-- db-health-mcp
Cursor / 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 paths
Roadmap
- MariaDB compatibility pass (the
sysschema andmax_execution_timediffer slightly) - SQLite quick-check for local dev databases
-
explain_querytool: runEXPLAINon a query and interpret the plan - Lock contention and long-running transaction checks
- Replication lag check
- A sibling project: cloud capacity/quota checks for AWS/GCP
License
MIT
Metadata
Release files for db-health-mcp 0.2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| db_health_mcp-0.2.1.tar.gz | 21.1 kB | With provenance | Details for db_health_mcp-0.2.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| db_health_mcp-0.2.1-py3-none-any.whl | Python 3 | none | any | Details for db_health_mcp-0.2.1-py3-none-any.whl |
Total release size: 40.5 kB
Release files / db_health_mcp-0.2.1.tar.gz
| Download URL | db_health_mcp-0.2.1.tar.gz |
|---|---|
| Size | 21.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6d9c9f96305c5d0af54c0bad4b43aac9dbaa5ccbbcd6a113a82c9ecfb19b9944
|
|
BLAKE2b-256 checksum How to use checksums |
33942cbe1d0b140caff17d171443aa89e807e165f3934ffc38f0dee45eb1f0be
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 5, 2026.
Transparency logRelease files / db_health_mcp-0.2.1-py3-none-any.whl
| Download URL | db_health_mcp-0.2.1-py3-none-any.whl |
|---|---|
| Size | 19.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b0b027937364759a0b653b1dac38f20253cb9161bcec242126276dad1573425d
|
|
BLAKE2b-256 checksum How to use checksums |
638f1a9024cf3df9373daaab855cfa58dca5bda606f0e57c0f1f1f197de62cdd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 5, 2026.
Transparency logSecurity for db-health-mcp 0.2.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for db_health_mcp-0.2.1.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 5, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.