Skip to main content
Glama

pg_safe_query

Run read-only PostgreSQL SELECT queries with AST validation and PII redaction to inspect data without exposing sensitive information.

Instructions

Execute a read-only, AST-validated PostgreSQL SELECT query with PII redaction.

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

Input Schema

NameRequiredDescriptionDefault
sqlYes

Output Schema

NameRequiredDescriptionDefault

No arguments

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A3.5/5.0
Behavior3/5

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

With no annotations, the description carries the full disclosure burden, and it does name real behaviors: read-only enforcement, AST validation, and PII redaction. It is silent on row limits, execution timeouts, what redaction actually masks, and how rejected queries fail, which are material for an agent deciding whether a query is safe to send.

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?

A single front-loaded sentence with the action first and the safety characteristics immediately after; there is no filler to remove.

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?

An output schema already documents the return values, and the single-parameter surface is small, so the description does not need to explain results. It still omits failure modes, limits, and any guidance on choosing this tool over pg_explain_query, which is a gap for a query-execution tool.

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?

There is one parameter, sql, at 0% schema description coverage, so the description must compensate. It adds a meaningful constraint (the statement must be a single SELECT, as anything else is rejected by AST validation) but says nothing about parameterization, placeholders, or size limits.

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 gives a specific verb and resource (Execute ... PostgreSQL SELECT query) and adds distinguishing qualifiers: read-only, AST-validated, PII redaction. It does not differentiate from the sibling pg_explain_query, so an agent comparing the two gets no explicit routing signal.

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 phrase 'read-only ... SELECT query' implies applicability (data retrieval only, no writes) and therefore hints at when-not-to-use. However, it never states prerequisites, cost/timeout expectations, or names any alternative such as pg_explain_query for query plans, leaving the choice to inference.

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