Skip to main content
Glama
MySQL MCP Server

MySQL MCP Server

by berthojoris

analyze_query

Read-onlyIdempotent

Analyze SQL queries with EXPLAIN to identify missing indexes, inefficient operations, and cost estimates, then receive actionable optimization recommendations before running expensive queries.

Instructions

🔍 Analyzes a SQL query using EXPLAIN and provides optimization suggestions: missing indexes, inefficient operations, cost estimates. Returns actionable recommendations. Use before running expensive queries.

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>"
    },
    "name": "analyze_query"
  }
}

Input Schema

NameRequiredDescriptionDefault
queryYesSQL query to analyze

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv1.46.0

TDQS

A3.6/5.0
Behavior3/5

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

Annotations already declare readOnlyHint, idempotentHint, destructiveHint=false and closed-world scope, so the safety profile is covered. The description adds that analysis is driven by EXPLAIN and that recommendations are returned, but it never clarifies whether the query is actually executed, whether it must be a single statement, or any cost/latency implications — meaningful gaps for a tool that touches arbitrary SQL.

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?

Three short sentences, front-loaded with the verb and mechanism. There is mild redundancy between 'provides optimization suggestions' and 'Returns actionable recommendations,' which is the only thing keeping it from a 5.

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?

With no output schema, the description carries the burden of describing returns and does so by listing the recommendation categories. Combined with the annotations covering the safety profile and a fully documented single parameter, an agent has enough to call it correctly; only the execution-semantics ambiguity remains.

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?

There is only one parameter and schema coverage is 100%, with the schema already describing 'query' as 'SQL query to analyze.' The description adds no further meaning such as dialect requirements, statement-count limits, or whether parameterized queries are acceptable, so it sits at the baseline where the schema does the work.

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?

States a specific verb and resource ('Analyzes a SQL query') plus the mechanism ('using EXPLAIN') and the output categories (missing indexes, inefficient operations, cost estimates). It does not distinguish itself from plausible siblings such as get_optimization_hints or repair_query, so it falls short of a 5.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Gives a clear timing rule: 'Use before running expensive queries.' That tells the agent when this tool belongs in a workflow, but there are no explicit exclusions and no named alternative for cases where the agent wants static hints or query rewriting instead.

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