PG Sheets MCP
Server Configuration
Describes the environment variables required to run the server.
| Name | Required | Description | Default |
|---|---|---|---|
| MAX_ROWS | No | Per-query row cap. | 500 |
| READ_ONLY | No | Set to 'false' to register the two Sheets write tools. | true |
| TRANSPORT | No | Set to 'http' for remote mode, which requires OAUTH_ISSUER and OAUTH_AUDIENCE. | stdio |
| REDACT_ARGS | No | Whether audit log arguments are redacted. | true |
| DATABASE_URL | Yes | Connection string for the read-only database role. | |
| OAUTH_ISSUER | No | OAuth issuer used for remote HTTP mode. | |
| ALLOWED_TABLES | No | Tables the AI may query. | all |
| AUDIT_LOG_PATH | No | Audit log destination. | stderr |
| OAUTH_AUDIENCE | No | OAuth audience used for remote HTTP mode. | |
| SHEETS_BACKEND | No | Set to 'memory' for a demo spreadsheet backend. | |
| ALLOWED_SCHEMAS | No | Schemas the AI may query. | public |
| DB_POOL_MAX_SIZE | No | Maximum database connection pool size, used for replica and connection-limit scaling. | |
| QUERY_TIMEOUT_MS | No | Per-query timeout in milliseconds. | 5000 |
| ALLOWED_SHEET_IDS | No | Allowed Google Sheet IDs. | |
| GOOGLE_SERVICE_ACCOUNT_JSON | No | Google service account JSON for Sheets access. Share each sheet with the service account. |
Instructions
Guidance the server publishes about itself, which clients place ahead of the tool catalog so the model reads it before choosing anything.
Answers questions from a PostgreSQL database and Google Sheets, safely. For database questions: postgres_list_tables → postgres_describe_table → postgres_query (one SELECT; aggregate in SQL). For spreadsheets: sheets_list_tabs → sheets_read_range or sheets_find_rows. READ-ONLY mode: Google Sheets write tools are disabled. Every call is audited.
Capabilities
Features and capabilities supported by this server
Protocol revision2025-11-25
| Capability | Details |
|---|---|
| tools | {
"listChanged": false
} |
| prompts | {
"listChanged": false
} |
| resources | {
"subscribe": false,
"listChanged": false
} |
| experimental | {} |
Tools
Functions exposed to the LLM to take actions
| Name | Description |
|---|---|
| postgres_list_tablesA | List the tables and views the AI may query in the allowed schemas (public), with approximate row counts and table comments. Call this first to discover what data exists, then postgres_describe_table for column details. |
| postgres_describe_tableA | Describe one table or view: columns with types, nullability, defaults and comments, the primary key, foreign keys to other tables, and foreign keys from other tables (use these to write correct JOINs). Call before writing a query against a table you haven't seen. |
| postgres_queryA | Run ONE read-only PostgreSQL SELECT and return the rows as JSON objects. Only tables in the allowed schemas (public) can be read. Rejected: anything that is not a single SELECT (INSERT/UPDATE/DELETE/DDL, multiple statements, SELECT INTO, FOR UPDATE), system catalogs (pg_*), and unsafe functions (pg_sleep, pg_read_file, dblink, set_config…). Results are capped at 500 rows (truncated=true means more rows exist) and the query is cancelled after 5000 ms, so aggregate in SQL (GROUP BY, ORDER BY … LIMIT) rather than fetching raw rows. Use postgres_describe_table first to get exact column names. |
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 3 tools
The three tools form a clean discovery→inspection→execution pipeline with no overlap: one lists tables, one describes a single table's schema, and one runs queries. Descriptions explicitly state the ordering and dependencies, so an agent cannot reasonably confuse them.
All names are snake_case with a consistent postgres_ prefix, and list/describe follow a verb_noun pattern. postgres_query deviates slightly by using a bare noun rather than an explicit verb like postgres_run_query, but the family is clearly recognizable.
Three tools is lean but each is essential to the read-only workflow, so nothing feels padded. A slightly richer surface (e.g. listing schemas or explaining a query plan) could exist, but the minimal set matches the narrow purpose.
For a read-only Postgres bridge the loop is closed: discover tables, inspect columns/keys, then query with corrective hints on ordering and aggregation. No write operations exist, but that is a deliberate scope choice; only minor conveniences like schema enumeration or query-plan inspection are absent.