readonly-postgres-mcp
Server Configuration
Describes the environment variables required to run the server.
| Name | Required | Description | Default |
|---|---|---|---|
| PG_SSL | No | Enable SSL connection | false |
| PG_HOST | No | PostgreSQL server host | |
| PG_PORT | No | PostgreSQL server port | 5432 |
| PG_DATABASE | No | Database name | |
| PG_MAX_ROWS | No | Maximum rows returned by queries | 10000 |
| PG_PASSWORD | No | Database password | |
| PG_USERNAME | No | Database user with readonly access | |
| PG_SEARCH_PATH | No | Schema search path | public |
| PG_MCP_ALLOW_ADHOC | No | Allow ad-hoc SQL queries (true/false) | true |
| PG_STATEMENT_TIMEOUT_MS | No | Statement timeout in milliseconds | 30000 |
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 | {} |
Tools
Functions exposed to the LLM to take actions
| Name | Description |
|---|---|
| pg_query_sqlA | Run a single read-only SQL query against a PostgreSQL database. Only SELECT, WITH and EXPLAIN are permitted. Writes and DDL (INSERT, UPDATE, DELETE, MERGE, COPY, CREATE, DROP, ALTER, TRUNCATE) are rejected before reaching the database, as are data-modifying CTEs. Exactly one statement per call — do not send two statements separated by a semicolon. A single trailing semicolon is fine. Results are capped at 1000 rows and 15s. The response reports "truncated": true when more rows matched than were returned, and "rowCount" is the number of rows returned, not the number matched — use a COUNT(*) query if you need the true total. Pass literals through "values" as $1, $2 placeholders rather than building them into the SQL string. bigint and numeric columns are returned as JSON strings, not numbers. Use pg_describe to discover tables and columns instead of guessing at names. EXPLAIN ANALYZE is rejected by default because it executes the statement it explains; plain EXPLAIN always works. |
| pg_describeA | Inspect the database schema. Call with no arguments to list the tables, views and materialized views in the configured search path, with their estimated row counts and comments. Call with "table" to list that relation's columns, types, nullability, defaults, primary keys and comments. Prefer this over querying information_schema by hand: it is faster and reports partitioned tables and comments correctly. |
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 2 tools
The two tools have completely distinct purposes: pg_query_sql executes read-only queries while pg_describe inspects schema metadata. There is no realistic scenario where an agent would confuse the two, and the descriptions even cross-reference each other (use pg_describe before pg_query_sql).
Both names use a consistent 'pg_' prefix and snake_case, which reads well as a set. The second segments differ structurally (query_sql is verb+format while describe is a bare verb), a minor deviation from a strict verb_noun pattern.
Two tools is minimal but justified for a deliberately read-only server whose entire surface is 'run a query' and 'inspect the schema'. It does not feel arbitrarily thin given the narrowly scoped purpose, though there is little room to grow.
Query execution plus schema discovery covers the core read-only lifecycle (explore schema, then query it). Minor gaps remain, such as no dedicated pagination/offset helper or multi-statement/session tooling, but row caps and the 'truncated' flag give agents workable paths.