Skip to main content
Glama

analyze_query

Validate SQL syntax and detect anti-patterns like N+1 queries and duplicates. Optionally include EXPLAIN plans for deeper analysis.

Instructions

Validate SQL syntax, detect anti-patterns, N+1, duplicates.

LEVEL: Query (SQL statement analysis - no DB connection needed for basic parsing)

USE FOR: SQL validation, N+1 detection, batch analysis. DO NOT USE FOR: running queries (execute_query), write impact (analyze_impact).

Examples: analyze_query(query='SELECT * FROM users') analyze_query(query='SELECT * FROM users', schema='shipment', include_explain=True)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesSQL string or JSON array [{"id":"q1","sql":"..."}]
detect_duplicatesNoDetect duplicates in batch
include_explainNoInclude EXPLAIN plan
schemaNoSchema name for batch analysis context. Required for EXPLAIN. Use get_schema() to list available schemas.
formatNoOutput formatjson

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes
Behavior4/5

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

No annotations provided, so the description carries full burden. It discloses that basic parsing requires no DB connection, and that schema is required for EXPLAIN. It does not explicitly state lack of side effects, but that is implied. Output schema exists, reducing need for return value details.

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?

The description is concise: a brief paragraph, LEVEL line, USE FOR/DO NOT USE FOR, and examples. It is front-loaded with purpose, no fluff, and well-structured.

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?

Given the output schema exists, the description adequately covers tool purpose, usage context (batch vs single, no DB needed), and parameter relevance. All aspects are addressed without missing critical details.

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 coverage is 100%, but the description adds value by explaining batch input format (JSON array) and that schema is needed for EXPLAIN, directing users to get_schema(). This goes beyond the schema's parameter descriptions.

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 description clearly states the tool validates SQL syntax and detects anti-patterns, N+1, and duplicates. It uses specific verbs and resources, and distinguishes from siblings like execute_query and analyze_impact.

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?

Explicit 'USE FOR' and 'DO NOT USE FOR' sections provide clear guidance on when to use (SQL validation, N+1 detection) and when not (running queries, write impact). Examples further clarify usage.

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

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/snss10/DBeast'

If you have feedback or need assistance with the MCP directory API, please join our Discord server