Skip to main content
Glama
db-conn-mcp

db-conn-mcp

explain_query

Show a read-only query's execution plan to confirm index usage or diagnose slowness; enable analyze to collect real timings and buffer stats with bound parameters.

Instructions

Show the execution plan for a read-only query (EXPLAIN; optionally ANALYZE).

Use to confirm index usage or diagnose a slow query. analyze=true actually runs the (read-only, validated) query to collect real timings and buffer stats.

EXPLAIN the query you will ACTUALLY run: a plan for bound parameters can differ from the plan for the same SQL with the values pasted in. Pass params with the $1/$2/... placeholders exactly as you would to execute_read_query (real driver binds), instead of rewriting the query with literals just to explain it. params composes with analyze=true.

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": {
      "database": "<database>",
      "sql": "<sql>"
    },
    "name": "explain_query"
  }
}

Input Schema

NameRequiredDescriptionDefault
sqlYes
paramsNo
analyzeNo
databaseYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

A4.5/5.0
Behavior4/5

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

With no annotations supplied, the description carries the full burden, and it does the most important part: it discloses that analyze=true actually executes the (validated, read-only) query and collects timings and buffer stats. That is a real behavioral consequence an agent must know. It leaves unstated what the plan output looks like and any permission/cost implications, so it falls short of a 5.

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

Conciseness4/5

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

The description is front-loaded with purpose, then the analyze caveat, then the params guidance in rough priority order, with no filler sentences. The final paragraph on bound-parameter plans is slightly long but conveys a genuinely non-obvious tip rather than restating the schema.

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

Completeness4/5

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

For a 4-parameter, no-annotation, no-output-schema tool, the description covers what the tool produces conceptually (an execution plan), the side effect of ANALYZE, and correct parameter usage. It does not describe the return shape or how a plan is presented, which is the main remaining gap.

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 description coverage is 0%, so the description must compensate, and for the two non-obvious parameters it does: `analyze` is explained as actually running the query, and `params` is explained as real driver binds for $1/$2 placeholders that compose with analyze=true. The `database` parameter and the exact form of `sql` receive no direct explanation, which keeps it below a 5.

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?

The first sentence states a specific verb and resource: "Show the execution plan for a read-only query (EXPLAIN; optionally ANALYZE)." It immediately distinguishes this from the query-execution siblings by naming the EXPLAIN semantics and the read-only constraint.

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?

It gives explicit when-to-use guidance ("confirm index usage or diagnose a slow query") and names the relevant alternative behavior — use execute_read_query to actually run, or explain_query with the same placeholders. It also flags the key decision point for `analyze=true`.

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