Skip to main content
Glama
postgres-mcp-server

postgres-mcp-server

run_query

Read-only

Execute read-only SELECT queries to retrieve structured rows from PostgreSQL, with optional parameters, role, limit, and offset for controlled pagination.

Instructions

Execute a read-only SELECT query and return structured rows (FR-003)

Input Schema

NameRequiredDescriptionDefault
sqlYesRead-only SQL query to execute (e.g. SELECT)
roleNoOptional PostgreSQL role to assume (SET ROLE) for this query only
limitNoMaximum number of rows to return (capped by server maxRowLimit)
offsetNoNumber of rows to skip before returning results
paramsNoOptional parameterized query values ($1, $2, etc.)

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.4

TDQS

B3.3/5.0
Behavior3/5

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

The annotations already declare readOnlyHint=true, and the description is consistent with that by calling the query read-only. It adds the return shape ('structured rows') but says nothing about server-side row caps, role/permission failures, or error behavior, which matter for a query executor.

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

Conciseness3/5

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

It is a single front-loaded sentence with no padding, but it is arguably too terse for a five-parameter SQL executor. The '(FR-003)' requirement tag is internal noise that does not help an agent select or invoke the tool.

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

Completeness3/5

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

With no output schema and five parameters, the description confirms the return is structured rows, which is helpful. It still leaves gaps on row-limit behavior and role/permission semantics that are only partially covered elsewhere, making it minimally adequate rather than complete.

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 all five parameters (sql, role, limit, offset, params) are already documented in the schema. The description adds no parameter-level meaning beyond what the schema provides, so the baseline 3 applies.

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?

The description states a specific verb ('Execute') and resource ('read-only SELECT query') with a clear outcome ('return structured rows'). The 'read-only SELECT' phrasing implicitly separates it from the sibling run_write_query, though it does not name that sibling outright.

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 read-only qualifier signals this is for reads, which is implied guidance against write usage. However, it never explicitly says when to use this versus run_write_query, nor does it mention prerequisites such as assuming a role or how pagination interacts with limit/offset.

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