Skip to main content
Glama

query_rewrite

Rewrites SQL queries for optimal performance while preserving correctness. Choose your database and optimization goal to get a rewritten query tailored to speed or memory.

Instructions

Pro: Rewrite SQL queries for optimal performance while preserving correctness

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesThe SQL query to rewrite
api_keyNoAPI key for authentication
databaseNoDatabase enginepostgresql
optimization_goalNoPrimary optimization goalbalanced
Behavior2/5

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

With no annotations, the description carries the full burden of behavioral disclosure. It communicates the intent to rewrite for performance and correctness, but it does not state whether the tool returns rewritten SQL, modifies a file, requires authentication, or how it handles invalid queries. The api_key parameter hints at auth but the description never explains its role.

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 short, front-loaded with the core action, and contains no unnecessary elaboration. The 'Pro:' prefix is an unexplained label but does not materially hurt clarity.

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?

The description is adequate for a straightforward transformation tool, and the schema covers all parameters. However, with no annotations and no output schema, the agent is left to infer the return format, auth behavior, failure semantics, and whether the rewrite is performed on a file or in-memory string.

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 description coverage is 100%, so the schema already documents all parameters. The description adds general context about performance and correctness but does not clarify how optimization_goal or database affect the rewrite. Baseline 3 is appropriate.

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?

Description uses a specific verb ('rewrite') and resource ('SQL queries') with a clear success criterion ('optimal performance while preserving correctness'). It clearly distinguishes the tool from diagnostic siblings like query_analyze_slow and query_suggest_indexes, which analyze or suggest rather than transform.

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?

The description implies the tool should be used when SQL query performance needs improvement, but it gives no explicit when-to-use guidance, exclusions, or pointers to alternative tools. It does not mention that query_analyze_slow or query_suggest_indexes might be more appropriate first steps.

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/barnburner121/claude-plugin-marketplace'

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