Index tuning needs `hypopg` to simulate plans and `pg_stat_statements` to know what your workload actually runs — without them the interesting half of this server is unavailable. On managed RDS, Azure or Cloud SQL both are usually present and a `CREATE EXTENSION` is enough; self-managed Postgres needs a config change and a restart. Access mode is a launch flag, so read-only is a deployment decision rather than a prompt.
A Postgres MCP server aimed at the whole development lifecycle, not just query execution. Alongside schema browsing and SQL it does industrial-strength index tuning, simulates plans with indexes that do not exist yet, and runs comprehensive database health checks. Everything is exposed as tools; it does not use MCP resources.
- Schema exploration: schemas listed, objects listed within one, and a single object's columns, constraints and indexes — `list_schemas`, `list_objects`, `get_object_details`
- SQL executed, with read-only limits applied when the server runs in restricted mode — `execute_sql`
- Execution plans exposing the planner's cost model, and the same plan simulated with hypothetical indexes — `explain_query`
- The slowest queries by total execution time from `pg_stat_statements` — `get_top_queries`
- Index recommendations two ways: analyse the whole workload to find resource-intensive queries and recommend indexes for them, or hand over up to 10 specific queries — `analyze_workload_indexes`, `analyze_query_indexes`
- A comprehensive health report: buffer cache hit rates, connection health, constraint validation, duplicate, unused and invalid indexes, sequence limits and vacuum health — `analyze_db_health`
- Both stdio and SSE transports, so several clients can share one server
Database credentials in `DATABASE_URI`, and either Docker or Python 3.12 or higher. Run `crystaldba/postgres-mcp` as a container — it remaps `localhost` to reach your host automatically — or install with `pipx` or `uv`. Access mode is explicit on the command line, with `--access-mode=unrestricted` opting out of read-only. `--transport=sse` serves multiple clients on a port. Index tuning and full performance analysis need two extensions loaded on the database: `CREATE EXTENSION` for `pg_stat_statements` and `hypopg`; on self-managed Postgres, `pg_stat_statements` must also be listed in `shared_preload_libraries`. Version 0.3.0.
One command plus a key — docker pull crystaldba/postgres-mcp, then supply credentials
