mcp-postgres
Server Configuration
Describes the environment variables required to run the server.
| Name | Required | Description | Default |
|---|---|---|---|
| POSTGRES_URL | Yes | PostgreSQL connection URL, e.g. postgresql://mcp_readonly:PASSWORD@localhost:5432/app. | |
| POSTGRES_MODE | No | Access mode: read-only, read-write, or admin. Tools above the mode are never registered. | read-only |
| POSTGRES_DRY_RUN | No | When true, write and admin tools validate and log intent, then return without touching the database. | false |
| POSTGRES_MAX_ROWS | No | Maximum rows returned to the model per call. | 200 |
| POSTGRES_AUDIT_LOG | No | When true, emits a JSON audit line to stderr per guarded operation. | true |
| POSTGRES_GUARD_MODE | No | Optional laya-guard check mode for mutating calls: off, monitor, or enforce. It can only add a confirmation or block, never grant. | off |
| POSTGRES_ALLOW_DELETE | No | Whether delete_rows, drop_table, and terminate_backend are allowed. Requires admin mode and this flag. | false |
| POSTGRES_ALLOW_RAW_SQL | No | Whether execute_sql may be registered. Requires admin mode and this flag. | false |
| POSTGRES_ALLOW_SUPERUSER | No | Whether superuser connections are allowed. Connecting as a superuser is refused by default. | false |
| POSTGRES_SCHEMA_ALLOWLIST | No | When set, schemas outside the allowlist are refused, and free-form SQL tools such as run_query, explain_query, and execute_sql are refused. | |
| POSTGRES_MAX_AFFECTED_ROWS | No | Maximum rows an insert, update, or delete may affect; operations touching more rows are rolled back. | 1000 |
| POSTGRES_PROTECTED_SCHEMAS | No | Additional schemas that are read-only forever. | |
| POSTGRES_STATEMENT_TIMEOUT_MS | No | Statement timeout in milliseconds applied to every statement the server runs. | 15000 |
| POSTGRES_REDACT_SECRET_COLUMNS | No | When true, secret-like column values are replaced with [REDACTED], and inline passwords and connection strings in errors are masked. | true |
| POSTGRES_PROTECT_SYSTEM_SCHEMAS | No | When true, system schemas such as pg_catalog, information_schema, pg_toast, and pg_* can be read but never mutated. | true |
| POSTGRES_REQUIRE_HUMAN_APPROVAL | No | When true, destructive operations are refused if the client cannot elicit human approval. | false |
Instructions
Guidance the server publishes about itself, which clients place ahead of the tool catalog so the model reads it before choosing anything.
This server publishes no instructions, or was last inspected before Glama recorded them.
Capabilities
Features and capabilities supported by this server
Protocol revision2025-11-25
| Capability | Details |
|---|---|
| tools | {
"listChanged": true
} |
Tools
Functions exposed to the LLM to take actions
| Name | Description |
|---|---|
| get_server_infoA | PostgreSQL version, current database and role, database size, uptime, and whether it is a replica. |
| list_schemasA | List schemas with owner and relation count (filtered to POSTGRES_SCHEMA_ALLOWLIST when set). |
| list_tablesA | List tables, views, and materialized views with estimated row counts and on-disk size. |
| describe_tableC | Columns (type, nullability, default), constraints, indexes (with scan counts), size, and estimated rows. |
| select_rowsA | Read rows from one table with equality filters — no SQL needed, and held to the schema allowlist. Results are capped at POSTGRES_MAX_ROWS; secret-like columns are redacted. |
| run_queryA | Run one SELECT / WITH / VALUES / TABLE / SHOW statement inside a READ ONLY transaction that is always rolled back. Use $1, $2 … placeholders with |
| explain_queryA | Show the planner's JSON plan for one statement (SELECT/WITH/VALUES/TABLE, or INSERT/UPDATE/DELETE/MERGE — not executed). |
| list_active_queriesB | Sessions from pg_stat_activity: role, state, wait event, transaction/query age, and query text (inline secrets masked). |
| get_database_statsB | Connections by state, commits/rollbacks, deadlocks, temp usage, cache hit ratio, and key memory settings. |
| get_top_queriesA | Most expensive statements from pg_stat_statements (requires the extension), with inline secrets masked. |
| list_rolesA | Roles with their attributes (superuser, login, replication, bypass RLS …) and memberships. Never returns passwords. |
| list_extensionsB | Installed extensions with their version, schema, and the newest available version. |
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 12 tools
Most tools target clearly distinct subjects (table structure, schemas, sessions, roles, extensions, planner output). The only real overlaps are select_rows vs run_query and get_server_info vs get_database_stats, but the descriptions explicitly spell out the boundary (allowlist-safe row reads vs free-form read-only SQL) well enough that an agent can choose correctly.
Every tool follows a predictable verb_noun snake_case pattern (describe_table, list_schemas, get_server_info, select_rows, run_query, explain_query). Verbs are used consistently by semantic class: list_* for enumerations, get_* for aggregate snapshots, describe_* for structure.
Twelve tools sit in the sweet spot for a database inspection server, with no filler — introspection, data access, planning, and performance/ops views each contribute distinct capability. Nothing obviously redundant or missing at this granularity.
The read-only diagnostic lifecycle is well covered: schema discovery, structural detail, row sampling, ad-hoc querying, plan analysis, live/aggregated query stats, roles, and extensions. Minor gaps remain — no way to enumerate functions, triggers, sequences, or view definitions, and no object-name search — but agents can fall back to run_query/describe_table for most of these.