MCP Db Analyzer MCP Server

MCP server for PostgreSQL, MySQL, and SQLite schema analysis, index optimization, and query plan inspection

Local serverstdioPython

What is the MCP Db Analyzer MCP server?

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.

What you get

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.

Setting it up

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.

What the assistant can call

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 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_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
  • analyze_slow_queries — Find the slowest queries using pg_stat_statements (PostgreSQL) or performance_schema (MySQL). Shows execution times, call counts, and identifies
  • 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
  • analyze_table_relationships — Analyze foreign key relationships between tables. Builds a dependency graph showing entity connectivity, orphan tables (no FKs), cascading delete

Configuration and credentials

You 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.

Before you rely on it

  • It runs with your machine's permissions. That is convenient and also the reason to think about what you point it at before you approve a tool call.
  • With 13 tools registered it takes up a noticeable share of the context window; turn it off in projects that never touch MCP Db Analyzer.
  • Missing credentials fail quietly in some clients — if no tools show up, check the environment block first.
  • MCP clients confirm each tool call by default. Leave that on until you have watched what the mcp db analyzer mcp server does with a few real requests.

Choosing this one

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.

Available tools

ToolWhat it does
MySQLSet DATABASE_URL with a MySQL connection string and pass --driver mysql:
SQLitePass a file path via DATABASE_URL and use --driver sqlite:
inspect_schemaList all tables with row counts and sizes, or drill into a specific table's columns, types, constraints, and foreign keys.
ColumnsThe Columns tool exposed by this server.
analyze_indexesFind unused indexes wasting disk space and missing indexes causing slow sequential scans. Also detects unindexed foreign keys.
explain_queryRun 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_bloatAnalyze table bloat by checking dead tuple ratios, vacuum history, and table sizes. Recommends VACUUM ANALYZE for tables with >10% dead tuples.
suggest_missing_indexesFind 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_queriesFind the slowest queries using pg_stat_statements (PostgreSQL) or performance_schema (MySQL). Shows execution times, call counts, and identifies optimization candidates.
RecommendationsThe Recommendations tool exposed by this server.
analyze_connectionsAnalyze active database connections. Detects idle-in-transaction sessions, long-running queries, lock contention, and connection pool utilization. PostgreSQL and MySQL only.
analyze_table_relationshipsAnalyze foreign key relationships between tables. Builds a dependency graph showing entity connectivity, orphan tables (no FKs), cascading delete chains, and hub entities.
analyze_vacuumAnalyze PostgreSQL VACUUM maintenance status. Checks dead tuple ratios, vacuum staleness, autovacuum configuration, and identifies tables needing manual VACUUM. **PostgreSQL only.**

How to install the MCP Db Analyzer MCP server

### 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.

Configuration

VariableDescriptionRequired
DATABASE_URLEndpoint or connection string the server talks to.Yes
MYSQL_HOSTEndpoint or connection string the server talks to.Optional

Example prompts to try

  • Use MCP Db Analyzer to MySQL.
  • Use MCP Db Analyzer to SQLite.
  • Use MCP Db Analyzer to inspect schema.

Frequently asked questions

It connects MCP Db Analyzer to MCP-compatible AI assistants such as Claude and Cursor, exposing 13 tools (MySQL, SQLite, inspect_schema, and more) that the assistant can call on your behalf. Instead of copying data back and forth by hand, the assistant works with MCP Db Analyzer directly.