MCP server for PostgreSQL, MySQL, and SQLite schema analysis, index optimization, and query plan inspection
MCP Db Analyzer MCP server is a locally run integration for AI assistants that speak the Model Context Protocol. MCP server for PostgreSQL, MySQL, and SQLite schema analysis, index optimization, and query plan inspection.
A Model Context Protocol (MCP) server that gives AI assistants deep visibility into your databases. It inspects schemas, detects index problems, analyzes table bloat/fragmentation, and explains query plans — so your AI can give you actionable database optimization advice instead of generic suggestions.
Installation goes through your MCP client rather than a global install: point it at mcp-db-analyzer on npm and it is fetched when the client starts. The copy-paste blocks for Claude Desktop, Claude Code and Cursor are further down this page.
Once MCP Db Analyzer is connected, these are the calls the assistant has available:
MySQL — Set DATABASE_URL with a MySQL connection string and pass --driver mysql:SQLite — Pass a file path via DATABASE_URL and use --driver sqlite:inspect_schema — List all tables with row counts and sizes, or drill into a specific table's columns, types, constraints, and foreign keysColumns — The Columns tool exposed by this serveranalyze_indexes — Find unused indexes wasting disk space and missing indexes causing slow sequential scans. Also detects unindexed foreign keysexplain_query — Run EXPLAIN on a SQL query and get a formatted execution plan with cost estimates, node types, and optimization warnings. Optionally run EXPLAINanalyze_table_bloat — Analyze table bloat by checking dead tuple ratios, vacuum history, and table sizes. Recommends VACUUM ANALYZE for tables with >10% dead tuplessuggest_missing_indexes — Find tables with high sequential scan counts and zero index usage, cross-referenced with unused indexes wasting space. Provides actionable CREATEanalyze_slow_queries — Find the slowest queries using pg_stat_statements (PostgreSQL) or performance_schema (MySQL). Shows execution times, call counts, and identifiesRecommendations — The Recommendations tool exposed by this serveranalyze_connections — Analyze active database connections. Detects idle-in-transaction sessions, long-running queries, lock contention, and connection pool utilizationanalyze_table_relationships — Analyze foreign key relationships between tables. Builds a dependency graph showing entity connectivity, orphan tables (no FKs), cascading deleteYou will need 2 environment variables: DATABASE_URL, MYSQL_HOST. The server will not start without them, which is usually why the tools fail to appear on a first run. Keep credentials in your client's env block or a secrets manager rather than in a file you might commit.
This sits in the database access group, where several servers overlap in what they claim to do but differ sharply once you actually set them up. MCP Db Analyzer's toolset — MySQL, SQLite, inspect_schema and 10 more — is a fair guide to whether it matches your workflow. It is maintained by dmitriusan; worth a glance at recent repository activity before you build anything load-bearing on it.
This entry was verified against MCP Db Analyzer's own documentation before publication; SyncDev keeps the directory reviewed rather than auto-generated.
| Tool | What it does |
|---|---|
| MySQL | Set DATABASE_URL with a MySQL connection string and pass --driver mysql: |
| SQLite | Pass a file path via DATABASE_URL and use --driver sqlite: |
| inspect_schema | List all tables with row counts and sizes, or drill into a specific table's columns, types, constraints, and foreign keys. |
| Columns | The Columns tool exposed by this server. |
| analyze_indexes | Find unused indexes wasting disk space and missing indexes causing slow sequential scans. Also detects unindexed foreign keys. |
| explain_query | Run EXPLAIN on a SQL query and get a formatted execution plan with cost estimates, node types, and optimization warnings. Optionally run EXPLAIN ANALYZE for actual timing (SELECT queries only). |
| analyze_table_bloat | Analyze table bloat by checking dead tuple ratios, vacuum history, and table sizes. Recommends VACUUM ANALYZE for tables with >10% dead tuples. |
| suggest_missing_indexes | Find tables with high sequential scan counts and zero index usage, cross-referenced with unused indexes wasting space. Provides actionable CREATE INDEX and DROP INDEX recommendations. |
| analyze_slow_queries | Find the slowest queries using pg_stat_statements (PostgreSQL) or performance_schema (MySQL). Shows execution times, call counts, and identifies optimization candidates. |
| Recommendations | The Recommendations tool exposed by this server. |
| analyze_connections | Analyze active database connections. Detects idle-in-transaction sessions, long-running queries, lock contention, and connection pool utilization. PostgreSQL and MySQL only. |
| analyze_table_relationships | Analyze foreign key relationships between tables. Builds a dependency graph showing entity connectivity, orphan tables (no FKs), cascading delete chains, and hub entities. |
| analyze_vacuum | Analyze PostgreSQL VACUUM maintenance status. Checks dead tuple ratios, vacuum staleness, autovacuum configuration, and identifies tables needing manual VACUUM. **PostgreSQL only.** |
### Claude Desktop (MySQL)
```json
{
"mcpServers": {
"db-analyzer": {
"command": "npx",
"args": ["-y", "mcp-db-analyzer", "--driver", "mysql"],
"env": {
"DATABASE_URL": "mysql://user:password@localhost:3306/mydb"
}
}
}
}Configuration as documented by the project. Restart the client after saving.
| Variable | Description | Required |
|---|---|---|
| DATABASE_URL | Endpoint or connection string the server talks to. | Yes |
| MYSQL_HOST | Endpoint or connection string the server talks to. | Optional |
Read-only SQL access to Postgres — let your assistant inspect schemas and answer questions from real data.
Manage your whole Supabase project in conversation — database, auth, storage, Edge Functions and branches.
Query, modify and analyse local SQLite databases in conversation — the fastest way to chat with a data file.
Metabase ships its own MCP endpoint — search your BI content, build and run queries, and save questions and dashboards without leaving the chat.
Official MongoDB server covering data, schemas and Atlas management — from find queries to spinning up clusters.
Serverless Postgres with database branching — point your assistant at Neon and let it work on disposable copies.