postgres-dba-mcp
Server Configuration
Describes the environment variables required to run the server.
| Name | Required | Description | Default |
|---|---|---|---|
| PGSSLMODE | No | libpq SSL mode setting read by the PostgreSQL driver. | |
| PGPASSFILE | No | Path to a .pgpass file used by the PostgreSQL driver for credentials. | |
| PGPASSWORD | No | Password read by the PostgreSQL driver when the connection URI does not include one. | |
| DATABASE_URI | Yes | PostgreSQL connection string/URI. It may also be supplied as the first positional argument; when both are provided, DATABASE_URI takes precedence. | |
| PGSERVICEFILE | No | Path to a pg_service.conf file used by the PostgreSQL driver for named service definitions. |
Instructions
Guidance the server publishes about itself, which clients place ahead of the tool catalog so the model reads it before choosing anything.
PostgreSQL tools for one database. Access mode: restricted (read-only). Tabular results are CSV with a header row; NULL is \N. In values, \n \r \t are control characters and \ is a backslash. A tsvector value is shown as [tsvector: lexemes]; select col::text to read it. The last line starts with "--" and reports row count, truncation and timing. If a result is truncated, refine the query (WHERE, LIMIT, aggregates) rather than asking for more rows. A long cell is cut and ends with …[+ chars]; execute_sql takes max_cell to read more of it. When a column holds jsonb or long text, pass max_cell on the first call: reading the same row twice costs more than one wider call.
Capabilities
Features and capabilities supported by this server
Protocol revision2025-11-25
| Capability | Details |
|---|---|
| tools | {
"listChanged": true
} |
| logging | {} |
Tools
Functions exposed to the LLM to take actions
| Name | Description |
|---|---|
| analyze_db_healthA | Analyzes database health. Here are the available health checks:
|
| analyze_locksA | Reports the lock waits in progress: which sessions are blocked, which sessions block them, through how many hops, on which lock and for how long. Read-only diagnosis of a single snapshot: it never cancels or terminates anything. |
| analyze_query_indexesA | Analyze a list of (up to 10) SQL queries and recommend optimal indexes |
| analyze_workload_indexesB | Analyze frequently executed queries in the database and recommend optimal indexes |
| execute_sqlA | Execute a read-only SQL query. Long cells are shortened; pass max_cell to read more. The result is also capped at 32768 bytes, whatever max_rows says; the footer says so when it is cut. |
| explain_queryB | Explains the execution plan for a SQL query, showing how the database will execute it and provides detailed cost estimates. Queries with $n parameters get a generic plan. |
| get_object_detailsC | Show detailed information about a database object |
| get_top_queriesA | Reports the slowest or most resource-intensive queries using data from the 'pg_stat_statements' extension. Only statements of the current database are reported. |
| list_objectsC | List objects in a schema |
| list_schemasB | List all schemas in the database |
Prompts
Interactive templates invoked by user choice
| Name | Description |
|---|---|
No prompts | |
Resources
Contextual data attached and managed by the client
| Name | Description |
|---|---|
No resources | |
TDQS
Scored across 10 tools
Each tool has a largely distinct purpose: locks vs. health vs. query plans vs. object listing. The main fuzzy pair is analyze_query_indexes (analyze a supplied query list) vs. analyze_workload_indexes (analyze pg_stat_statements workload), which an agent could confuse, but the descriptions make the input difference clear. get_object_details vs. list_objects/list_schemas are also adequately separated.
All ten tools follow a consistent snake_case verb_noun pattern (analyze_*, get_*, list_*, execute_sql, explain_query). No mixed casing or inconsistent verb styles. The convention makes the action+resource of each tool predictable.
Ten tools is well within the ideal 3-15 range for a DBA diagnostic server. Each tool covers a distinct diagnostic area (locks, health, indexes, execution, object introspection) with no apparent filler.
The surface covers the main read-only DBA workflows: health checks, lock analysis, slow-query inspection, plan explanation, index recommendations, and schema/object exploration. The deliberate read-only stance (no cancel/terminate, no config parameter inspection or pg_stat_activity detail dump) leaves some operational gaps, but they are minor and consistent with the server's stated scope.