Skip to main content
Glama

preflight_query

Estimate SQL query cost and risk on the real schema before execution. Get risk tier, rows scanned vs returned, scan strategy, and overhead flags without running the query.

Instructions

Before running ANY SQL query you (the agent) just wrote, check how costly it will be on the real schema — WITHOUT executing it. Returns a risk tier (cheap/moderate/expensive/dangerous), rows scanned vs returned, scan strategy, and overhead flags (missing index, SELECT *, no LIMIT, N+1 / nested-loop blowup). EXPLAIN only — never runs the query. In a multi-DB setup pass target= (see list_targets). For similarity search use preflight_vector_search; with no DB use preflight_schema_only.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
sqlYes
targetNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.2.0

TDQS

A4.9/5.0
Behavior5/5

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

With no annotations, the description carries the full burden and does so: it declares the tool never executes the query, describes the risk tiering, rows scanned vs returned, scan strategy, and the specific overhead flags it detects. That is exactly the behavioral context an agent needs before committing to a costly query.

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-loaded with the primary directive, then returns, then the safety guarantee, then routing. Every sentence earns its place with no filler.

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?

An output schema exists, so return-value enumeration is not strictly required, yet the description still previews the payload. Combined with the sibling routing and target guidance, nothing an agent needs to invoke this correctly is missing.

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. It explains target fully ('in a multi-DB setup pass target=<name>', pointing to list_targets), but leaves sql undocumented beyond the obvious name. Adequate but not complete.

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 (preflight/check cost), resource (SQL query against the real schema), and scope (EXPLAIN only, never executes). It explicitly distinguishes itself from preflight_vector_search and preflight_schema_only, so an agent can route without opening either schema.

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?

Gives explicit when-to-use ('before running ANY SQL query you just wrote'), when-not-to-use (similarity search, no DB), and names the exact alternatives with the condition that selects each. The multi-DB case is covered with the target=<name> instruction.

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