Skip to main content
Glama

Run read-only query

run_query
Read-onlyIdempotent

Executes a single read-only SQL statement (SELECT/WITH/SHOW) inside a rolled-back transaction, with $1 placeholders and row caps, so agents can inspect data without writes.

Instructions

Run one SELECT / WITH / VALUES / TABLE / SHOW statement inside a READ ONLY transaction that is always rolled back. Use $1, $2 … placeholders with params for values. Results are capped at POSTGRES_MAX_ROWS. Refused while POSTGRES_SCHEMA_ALLOWLIST is set (free-form SQL can reach any schema) — use select_rows then.

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": "run_query"
  }
}

Input Schema

NameRequiredDescriptionDefault
sqlYesA single read statement, e.g. SELECT id, total FROM orders WHERE status = $1
paramsNoValues for $1, $2 … placeholders

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A4.7/5.0
Behavior5/5

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

Annotations already declare readOnlyHint/idempotent/destructive=false, but the description adds meaningful behavior: the READ ONLY transaction is always rolled back, results are capped at POSTGRES_MAX_ROWS, and execution is refused under the allowlist. These are operational constraints an agent cannot infer from the annotations.

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?

Every sentence carries a distinct constraint (statement scope, placeholder usage, row cap, allowlist refusal) and the core restriction is front-loaded. No filler or redundancy.

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 free-form SQL tool with no output schema, the description covers execution semantics, result-size limits, parameter passing, and the key denial condition — everything needed to invoke it correctly or route elsewhere.

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 coverage is 100%, and the schema examples already show the $1 placeholder pattern, so the description's note about $1, $2 with params largely reinforces existing documentation. Baseline 3 is appropriate since the schema does the heavy lifting.

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 ('Run') and precisely enumerates the accepted statement types (SELECT / WITH / VALUES / TABLE / SHOW), scoping a single statement. It also names the sibling to use when it cannot run, so an agent distinguishes it from select_rows without opening schemas.

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

Usage Guidelines5/5

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

Explicitly says when it applies (single read statement) and, crucially, the when-not case: it is refused while POSTGRES_SCHEMA_ALLOWLIST is set, in which case use select_rows. That is a concrete exclusion plus a named alternative.

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