Skip to main content
Glama
ranson21

postgres-readonly-mcp

by ranson21

run_query

Execute read-only SELECT or WITH ... SELECT queries against PostgreSQL databases, returning compact capped rows while rejecting any write or DDL statements before they reach the database.

Instructions

Run a read-only SQL query (SELECT, or WITH ... SELECT) against the database and return compact rows. Results are capped by PG_MAX_ROW_LIMIT. Any INSERT/UPDATE/DELETE/DDL/etc. is rejected before it reaches the database - this server is read-only.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
envNoWhich configured database environment to use. Only "default" is configured, so this can be omitted.
sqlYesA single SELECT (or WITH ... SELECT) statement, e.g. "SELECT * FROM orders WHERE status = 'open'"
limitNoMax rows to return

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.2.0

TDQS

A3.8/5.0
Behavior4/5

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

With no annotations, the description carries the full burden and does well: it discloses the read-only server guarantee, that non-SELECT statements are rejected before reaching the database, and that output is capped by PG_MAX_ROW_LIMIT and returned as compact rows. It omits auth requirements and what happens when the cap is hit (error vs truncation), which keeps it short of a 5.

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?

Three tight sentences with the core capability front-loaded and the read-only constraint immediately after. Every clause carries information; there is no filler.

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

Completeness4/5

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

For a single-query tool with no output schema, the description covers the allowed statement forms, the write-rejection behavior, and the row-cap/return format. It stops just short of describing failure behavior at the cap or transaction semantics, which would make it fully self-contained.

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

Parameters3/5

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

Schema description coverage is 100%, so the baseline is 3. The description adds some value by tying the row ceiling to PG_MAX_ROW_LIMIT, but it does not clarify how the user-supplied 'limit' interacts with that server cap or what the 'env' enum really means beyond the schema text.

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

Purpose4/5

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

States a specific verb (Run) and resource (read-only SQL query) with the exact statement shapes allowed (SELECT, WITH ... SELECT), so the operation is unmistakable. It does not explicitly name how it differs from the introspection siblings (list_tables, describe_table), but the execution-vs-metadata distinction is obvious from the phrasing.

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?

Gives a clear when-not: writes and DDL are rejected, so the agent knows this tool is only for reads. It never routes the agent between this and the sibling tools (e.g. use describe_table to inspect schema before querying), leaving usage context implied rather than stated.

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