Skip to main content
Glama

optimize_query

Analyze a slow query and generate optimization recommendations with rewritten SQL

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": {
      "query": "<query>",
      "database": "<database>"
    },
    "name": "optimize_query"
  }
}

Input Schema

NameRequiredDescriptionDefault
queryYesSQL query to analyze
databaseYesTarget database
tableStatsNoOptional: table row counts and cardinality hints

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

B3.2/5.0
Behavior2/5

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

No annotations are provided, so the description carries the full behavioral burden. It never states whether the tool actually executes the supplied SQL against the target database (a real safety and cost concern), whether it is read-only, how long analysis takes, or what permissions are needed — the one thing an agent must know before firing an arbitrary query at a live database.

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?

A single well-formed sentence with the action front-loaded and the deliverable stated at the end; nothing is padded. It is perhaps too terse for a tool with no annotations, but no wording is wasted.

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 and no annotations, the description should say more about what comes back (plan analysis? index suggestions? confidence?) and whether the query is executed. Stating that rewritten SQL is produced is a start, but it leaves the mutation/execution question and the shape of recommendations unresolved.

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%, with each parameter documented and the database enum enumerated, so the schema does the heavy lifting and baseline 3 applies. The description adds nothing about how tableStats changes recommendation quality, which would have been valuable guidance.

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 description names a specific verb set (analyze, generate recommendations) and a specific resource (a slow query), plus the concrete deliverable of rewritten SQL. It does not, however, distinguish itself from adjacent siblings such as explain_query_plan, create_indexes, or build_repository_query, which an agent would need in order to pick correctly.

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 phrase 'slow query' implicitly signals the trigger condition, so an agent can infer this is for performance troubleshooting rather than query authoring. There is no explicit when-not guidance and no named alternative, even though explain_query_plan and create_indexes overlap heavily with this space.

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.