Skip to main content
Glama
aliyun

Adb MySQL MCP Server

Official
by aliyun

get_execution_plan

Analyze SQL query performance by retrieving actual execution plans with runtime statistics to identify optimization opportunities.

Instructions

Get the actual execution plan with runtime statistics for a SQL query

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesThe SQL query to analyze

Implementation Reference

  • Handler dispatch for 'get_execution_plan': extracts query argument and modifies it to 'EXPLAIN ANALYZE {query}' for execution.
    elif name == "get_execution_plan":
        query = arguments.get("query")
        if not query:
            raise ValueError("Query is required")
        query = f"EXPLAIN ANALYZE {query}"
  • Registration of the 'get_execution_plan' tool in list_tools(), including its description and input schema.
    Tool(
        name="get_execution_plan",
        description="Get the actual execution plan with runtime statistics for a SQL query",
        inputSchema={
            "type": "object",
            "properties": {
                "query": {
                    "type": "string",
                    "description": "The SQL query to analyze"
                }
            },
            "required": ["query"]
        }
    )
  • Shared database execution helper: connects to MySQL using config, executes the query (EXPLAIN ANALYZE), fetches results, formats as CSV text content, handles exceptions.
    conn = pymysql.connect(**config)
    conn.autocommit(True)
    cursor = conn.cursor()
    
    try:
        # Execute the query
        cursor.execute(query)
    
        columns = [desc[0] for desc in cursor.description]
        rows = cursor.fetchall()
        result = [",".join(map(str, row)) for row in rows]
        return [TextContent(type="text", text="\n".join([",".join(columns)] + result))]
    except Exception as e:
        return [TextContent(type="text", text=f"Error executing query: {str(e)}")]
    finally:
        if cursor:
            cursor.close()
        if conn.open:
            conn.close()
  • Pydantic input schema validation for the tool: requires a single 'query' string property.
    inputSchema={
        "type": "object",
        "properties": {
            "query": {
                "type": "string",
                "description": "The SQL query to analyze"
            }
        },
        "required": ["query"]
    }
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the tool retrieves 'actual execution plan with runtime statistics', which implies a read-only, non-destructive operation, but doesn't clarify performance impact, permissions needed, or what 'runtime statistics' include (e.g., execution time, row counts). This leaves significant gaps for a tool that likely interacts with a database system.

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 a single, efficient sentence that front-loads the core purpose without unnecessary words. Every part of the sentence contributes directly to understanding the tool's function, making it highly concise and well-structured.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity of SQL execution plans and the lack of annotations or output schema, the description is incomplete. It doesn't explain what an 'execution plan' entails, how runtime statistics are presented, or potential limitations (e.g., only for certain databases). For a tool with no structured output documentation, this leaves the agent with insufficient context for effective use.

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?

The schema description coverage is 100%, with the single parameter 'query' fully documented in the schema as 'The SQL query to analyze'. The description adds no additional semantic context beyond this, such as query format requirements or supported SQL dialects, so it meets the baseline for high schema coverage.

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 clearly states the action ('Get') and resource ('execution plan with runtime statistics for a SQL query'), making the purpose immediately understandable. It distinguishes from 'execute_sql' (which runs queries) and 'get_query_plan' (which likely provides theoretical plans without runtime data), though the distinction from the latter could be more explicit.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives like 'execute_sql' or 'get_query_plan'. It doesn't mention prerequisites, such as needing a valid SQL query or when runtime statistics are available, leaving the agent to infer usage context.

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/aliyun/alibabacloud-adb-mysql-mcp-server'

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