Skip to main content
Glama

Show a SQL query plan

explain_query
Destructive

Explain a SQL statement using the target datasource. Requires its Execution grant. Returns the query plan text and optimization hints. This tool is potentially destructive and shares execute authorization. Write the SQL in the target datasource's dialect (get_schema lists every datasource with its dialect). Raw exploration tools do not apply probe redaction and are not bound by schema exposure: they reach any object the datasource credential reaches, and are offered to Administrators, and to members whose Role grants Full; separate access checks apply. Schema exposure governs get_schema, the ontology and approved requests.

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
sqlYesSQL statement to explain in the target datasource dialect
datasourceNoOptional datasource ID to target. Omit to use the project's configured default; required when the project has multiple datasources and no default is configured. Each datasource has its own SQL dialect: get_schema lists every datasource with its type, dialect and identifier quote, and every result carries datasource_type and dialect. A datasource that has not finished setup is refused with datasource_not_ready. Use datasource (not datasource_id) here; Request authoring uses datasource_id. Unknown top-level arguments and malformed supplied datasource values return invalid_parameters before datasource selection. Supply a nonzero UUID string, or omit datasource intentionally to use the default/sole datasource.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Added

TDQS

B3.4/5.0
Behavior4/5

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

Beyond the annotations (which already declare destructiveHint=true, readOnlyHint=false), it adds real behavioral context: a required Execution grant, shared execute authorization, and that plan text plus optimization hints are returned. The closing passage about 'raw exploration tools', probe redaction and schema exposure is confusing for a single explain tool and blurs what actually applies here.

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

Conciseness2/5

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

The opening sentences are efficient and front-loaded, but the final two sentences are a long, dense policy digression about probe redaction, schema exposure, ontology and approved requests that does not clearly attach to this tool. That trailing text dilutes the operative instructions and makes the definition harder to act on.

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, the description must cover returns, and it does so only in one clause ("query plan text and optimization hints"). Authorization and dialect are covered, but the ambiguous class-level security paragraph leaves it unclear which access constraints genuinely govern explain_query.

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 schema already spells out sql, datasource defaults, datasource_not_ready, invalid_parameters and the datasource vs datasource_id distinction. The description's dialect remark merely restates schema content, so it adds little beyond the structured fields; 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 first sentence gives a specific verb and resource ("Explain a SQL statement using the target datasource") and the second states what comes back (query plan text and optimization hints). It never explicitly contrasts itself with the sibling execute/query tools, so an agent must infer that explain shows a plan rather than running the statement.

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?

Usage is only implied: you explain a statement to see its plan, and you must hold the Execution grant and write in the datasource dialect. There is no explicit statement of when to prefer this over execute/query (e.g., 'use before running to check cost'), and no when-not-to-use guidance.

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