Skip to main content
Glama

Run database query (read-only)

postgres_query
Read-only

Run a strictly read-only query against a database connection you can use (your own or one shared with you), identified by its name. Accepts the native query language of the connection's engine: SQL/CQL for relational and Cassandra, a JSON query object for MongoDB, Elasticsearch/OpenSearch, and DynamoDB, Cypher for Neo4j, and a command string for Redis. The query runs inside a read-only transaction and any mutating statement is rejected — this tool never writes. To modify data, use postgres_execute on a connection you own that has 'Allow writes' enabled. Results are capped at 1000 rows.

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": {
      "connection": "<connection>",
      "sql": "<sql>"
    },
    "name": "postgres_query"
  }
}

Input Schema

NameRequiredDescriptionDefault
sqlYesRead-only query in the connection engine's native language (SQL/CQL, a JSON query object, Cypher, or a Redis command)
connectionYesName of the connection to run against

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

A4.9/5.0
Behavior5/5

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

Beyond the readOnlyHint/destructiveHint annotations, it discloses enforcement mechanics an agent could not infer: the query runs inside a read-only transaction, mutating statements are rejected outright, and results are capped at 1000 rows. It also clarifies connection ownership semantics (own or shared with you).

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?

Front-loads the read-only guarantee and connection identification, then dialect support, then the write alternative and the row cap. Every sentence carries distinct information with no padding.

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 two-parameter tool with no output schema, it covers everything an agent needs: which connection, which query language, safety guarantees, result-size limit, and the sibling to use for writes. Nothing material is left to inference.

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%, so the baseline is 3, but the description adds real meaning by enumerating the accepted query dialect per engine family (SQL/CQL, JSON query object, Cypher, Redis command) and noting the connection may be one shared with you. That goes modestly beyond the schema's generic wording.

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 a strictly read-only query against a database connection") plus the scope of supported engines and languages. It is clearly distinguishable from postgres_execute, which the description explicitly frames as the write path.

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 states when to use this tool (read-only reads on a connection you can access) and when to use the alternative ("To modify data, use postgres_execute on a connection you own that has 'Allow writes' enabled"), including the precondition for that alternative.

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

Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.

Resources