MCP PostgreSQL Server
Server Configuration
Describes the environment variables required to run the server.
| Name | Required | Description | Default |
|---|---|---|---|
| PG_HOST | No | Database host (fallback when DATABASE_URL is not set) | |
| PG_PORT | No | Database port. Defaults to 5432 | 5432 |
| PG_USER | No | Database user | |
| PG_SSL_CA | No | Path to a CA certificate file. Setting it by itself implies verify-full | |
| PG_SSLMODE | No | SSL mode: disable | allow | prefer | require | verify-ca | verify-full | |
| PG_DATABASE | No | Database name | |
| PG_PASSWORD | No | Database password | |
| PG_SSH_HOST | No | SSH bastion host. Setting it enables tunneling. | |
| PG_SSH_PORT | No | SSH bastion port | 22 |
| PG_SSH_USER | No | SSH username | |
| DATABASE_URL | No | Full PostgreSQL connection string (preferred). Supports SSL mode via query parameter, e.g. postgres://user:password@localhost:5432/mydb?sslmode=require | |
| PG_SSH_AGENT | No | true to use the ambient SSH agent, or an explicit socket path / Windows named pipe | |
| PG_ALLOW_WRITE | No | When true, execute performs writes and reads are sent directly. Off (default) is read-only: execute refuses writes and each read runs in a READ ONLY transaction | false |
| PG_SSH_PASSWORD | No | SSH login password. Opt-in; a key or agent takes precedence | |
| PG_SSH_PASSPHRASE | No | Passphrase for the private key, if encrypted | |
| PG_CONNECT_TIMEOUT | No | Timeout in milliseconds for a single connect attempt | 10000 |
| PG_SSH_FINGERPRINT | No | Pinned host-key fingerprint (SHA256:...). Required when PG_SSH_HOST is set. | |
| PG_SSH_PRIVATE_KEY | No | Path to a private key file | |
| PG_MAX_RESULT_BYTES | No | Byte budget for a query result sent to the model | 32768 |
| PG_STATEMENT_TIMEOUT | No | Statement timeout in milliseconds, applied to every session | 30000 |
| PG_ENABLE_RUNTIME_CONNECT | No | Register the connect_db tool for runtime credential switching | false |
| PG_SSH_KEEPALIVE_INTERVAL | No | SSH keepalive interval in ms; the tunnel drops after 3 unanswered keepalives | 15000 |
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 |
|---|---|
| queryA | Run one read-only SQL statement against the connected PostgreSQL database and get rows back as JSON. Send exactly one statement per call (SELECT, WITH, EXPLAIN, or SHOW). It runs inside an engine-enforced read-only transaction, so any write is refused by the database. Use this tool for all data reading, aggregation, and query planning. Returns {rows, rowCount, returnedRows, truncated}, plus hint when truncated is true. Prefer $1, $2 placeholders with the params array over interpolating values. Results are capped at ~32768 bytes; truncated:true means rows were dropped - add LIMIT/WHERE or select fewer columns. |
| executeA | Run a data-modifying SQL statement (INSERT/UPDATE/DELETE or DDL). Currently DISABLED: the server is read-only, so this returns an error and changes nothing. To enable writes, the operator must start the server with PG_ALLOW_WRITE=true. |
| list_schemasA | List every schema in the connected database. Start here when exploring an unfamiliar database, then call list_tables for the schema you care about. Returns {schemas: [name, ...]}. |
| list_tablesA | List all tables in a schema (default: 'public'). Use this before querying tables you have not seen yet, then call describe_table for column details. Returns {tables: [name, ...]}. |
| describe_tableA | Show the structure of one table: column names, data types, nullability, defaults, and primary-key membership. Call this before writing non-trivial queries against a table. Returns {columns: [{column, type, nullable, default, is_primary_key}, ...]}. |
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 5 tools
Each tool targets a clearly separate concern: read queries, write execution, schema discovery, table discovery, and column metadata. There is no meaningful overlap, and the descriptions reinforce the boundaries.
All tool names follow a clean verb_object pattern in snake_case: query, execute, list_schemas, list_tables, describe_table. The naming convention is consistent and predictable.
Five tools is well-scoped for a PostgreSQL server: one read path, one write path, and three introspection tools for exploring the database structure. No tool feels redundant or missing.
The tool surface covers the core database workflow well: discover schemas, inspect tables, describe columns, run read queries, and execute writes. The only caveat is that execute is disabled by default, so write workflows are not available unless the operator explicitly enables them.