Skip to main content
Glama
postgres-mcp

postgres-mcp

by cleondev

Run read-only SQL

query
Read-only

Run a single read-only SQL statement in a rolled-back transaction; returns capped rows and rejects multiple statements or transaction control.

Instructions

Run ONE read-only SQL statement (SELECT, WITH, VALUES, TABLE, SHOW, EXPLAIN) in a READ ONLY transaction that is always rolled back. Returns at most 500 rows; long cells are cut. Multiple statements and transaction control are rejected.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "sql": "<sql>"
    },
    "name": "query"
  }
}

Input Schema

NameRequiredDescriptionDefault
sqlYesA single SQL statement

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A4.5/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Goes well beyond the readOnlyHint/openWorldHint annotations: it discloses that execution happens in a READ ONLY transaction that is always rolled back, that results are capped at 500 rows, that long cells are truncated, and that multiple statements or transaction control are rejected. These are exactly the behavioral traits an agent needs to predict outcomes and failure modes.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

One dense sentence, front-loaded with the verb and the statement whitelist, followed by limits and rejection rules. No filler and nothing redundant with the title.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a single-parameter tool with no output schema, the definition covers the operation, constraints, result size, truncation behavior, and rejection rules. Nothing an agent needs to call it correctly is missing.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100% and there is only one required parameter, so the schema already documents `sql`. The description still adds real meaning by constraining the accepted value to one statement from a specific keyword list, which the schema's 'A single SQL statement' does not fully convey.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

States a specific verb and resource (run one read-only SQL statement) and enumerates the accepted statement kinds (SELECT, WITH, VALUES, TABLE, SHOW, EXPLAIN), which clearly separates it from metadata siblings like describe_table and list_tables. An agent can identify the tool without inspecting the schema.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description makes the read-only querying context clear and rules out writes and transaction control, but it never says when to prefer this over describe_table/list_tables for schema questions. Usage is implied by the statement whitelist rather than stated as explicit routing guidance.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Deploy Server

Other Tools