Skip to main content
Glama

Explain a query

explain_query
Read-onlyIdempotent

Validate a SQL query against policy without running it, showing the rewritten SQL, accessed tables and columns, or violations that would cause rejection.

Instructions

Check a query against the policy without running it. Returns ok, the SQL that would actually run (with the current user's row filters, masks and row limit added), the tables and columns it reads, or the violations that explain why it would be rejected.

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

Input Schema

NameRequiredDescriptionDefault
sqlYesOne SELECT query, in the dialect list_tables reports

Output Schema

NameRequiredDescriptionDefault

No arguments

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.5.0-alpha.8

TDQS

A4.1/5.0
Behavior4/5

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

Annotations already declare readOnly, idempotent and non-destructive, so safety is covered. The description adds genuinely non-obvious behavior: the returned SQL is rewritten with the current user's row filters, masks and row limit applied, and rejections come back as explanatory violations rather than a failure. It does not discuss limits or cost of the policy check, but the substantive gaps are small.

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?

Two sentences, front-loaded with the core action and scope, then a compact enumeration of return outcomes. Every clause carries information; nothing is repeated from the title or schema.

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 single-parameter, non-destructive tool with full schema coverage, explicit annotations and an output schema, the description covers what an agent needs: it does not execute, it enforces policy, and its result may differ from the input SQL. No meaningful gap remains.

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 single `sql` parameter is already documented as one SELECT in the dialect `list_tables` reports. The description adds no further meaning about the parameter (e.g. what happens with multiple statements or non-SELECT input), so the schema carries the load and 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?

States a specific verb+resource ("Check a query against the policy") and immediately scopes it with "without running it," which implicitly separates it from the sibling `query` tool. It does not name `query` explicitly, so the differentiation is inferred rather than stated.

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

Usage Guidelines4/5

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

"Without running it" gives clear context for when to reach for this tool (dry-run validation before execution), and the mention of violations explains the outcome that motivates its use. It stops short of an explicit when-not rule or naming `query` as the alternative to use once validation passes.

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

Deploy Server

Other Tools