Skip to main content
Glama

query

Runs a single SQL statement against a chosen PostgreSQL connection, read-only by default. Use positional parameters and row limits to control results safely.

Instructions

Run a single SQL statement. Read-only by default; writes need the connection policy to allow them. Use params for positional parameters ($1) rather than string interpolation. Rows are capped by min(limit, the connection max_rows): applied_limit is the cap that was used and truncated says rows were dropped. When applied_limit is below the limit you asked for, max_rows cut the result and the answer is incomplete. A separate cap on response size can also cut it; when it does, notes says so and the fix is fewer columns, not fewer rows.

Input Schema

NameRequiredDescriptionDefault
limitNoMaximum rows to return.
paramsNoPositional PostgreSQL parameters ($1, $2, ...).
statementYesA single SQL statement.
connection_idYesConnection id. See list_connections.

Output Schema

NameRequiredDescriptionDefault
resultYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A3.7/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: read-only by default, writes gated by connection policy, row caps as min(limit, max_rows), and a distinct response-size cap. It doesn't cover transaction behavior, DDL permissibility, or timeouts, so it stops short of fully describing execution semantics.

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

Conciseness4/5

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

Front-loaded with the action, then proceeds in priority order: safety model, parameter binding, then truncation semantics. Dense but every sentence carries operational meaning; the closing sentence on the size cap is the only one that could be tightened.

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?

An output schema exists, so return-field naming needn't be explained, yet the description still tells the agent how to act on applied_limit, truncated, and notes — the practically important part. What's missing is execution context such as statement-type restrictions or timeout behavior for a tool whose whole job is arbitrary SQL execution.

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%, so the baseline is 3. The description adds genuine meaning for limit by defining the effective cap as min(limit, connection max_rows) and explaining the applied_limit/truncated interaction, but connection_id and statement get no elaboration beyond the schema.

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?

Opens with a specific verb+resource: 'Run a single SQL statement,' which cleanly separates it from schema-inspection siblings like list_tables or describe_table. It doesn't explicitly name explain_query as the non-executing alternative, so the boundary with that sibling is left implicit.

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 real usage guidance on parameter binding ('use params for positional parameters ($1) rather than string interpolation') and on interpreting truncation. But it never states when to prefer this over explain_query or the list_* discovery tools, and no when-not-to-use condition is given.

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