Skip to main content
Glama
Moonlight-CL

Redshift MCP Server

by Moonlight-CL

get_execution_plan

Analyze SQL query performance by retrieving execution plans with runtime statistics from Amazon Redshift databases to identify optimization opportunities.

Instructions

Get actual execution plan with runtime statistics for a SQL query

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
sqlYesThe SQL query to analyze

Implementation Reference

  • Specific dispatch handler for the 'get_execution_plan' tool within the call_tool function. It extracts the 'sql' argument, validates its presence (note: minor typo in error message), and modifies the SQL by prefixing 'EXPLAIN ' to obtain the execution plan.
    elif name == "get_execution_plan":
        sql = args.get("sql")
        if not sql:
            raise ValueError("sql parameter is required when calling get_query_plan tool")
        sql = f"EXPLAIN {sql}"
  • Input schema definition for the tool, specifying an object with a required 'sql' property of type string.
    inputSchema={
        "type": "object",
        "properties": {
            "sql": {
                "type": "string",
                "description": "The SQL query to analyze"
            }
        },
        "required": ["sql"]
    }
  • Registration of the 'get_execution_plan' tool in the @server.list_tools() callback, defining its metadata and input schema.
    Tool(
        name="get_execution_plan",
        description="Get actual execution plan with runtime statistics for a SQL query",
        inputSchema={
            "type": "object",
            "properties": {
                "sql": {
                    "type": "string",
                    "description": "The SQL query to analyze"
                }
            },
            "required": ["sql"]
        }
    )
  • Shared execution helper used by all tools (including get_execution_plan): establishes Redshift connection using config, executes the prepared SQL, handles special cases, fetches and formats query results (columns + rows as CSV) into TextContent for MCP response, with error handling and connection cleanup.
    try:
        conn = redshift_connector.connect(
            host=config['host'],
            port=int(config['port']),
            user=config['user'],
            password=config['password'],
            database=config['database'],
        )
        conn.autocommit = True
    
        with conn.cursor() as cursor:
            cursor.execute(sql)
            if name == "analyze_table":
                return [TextContent(type="text", text=f"Successfully analyzed table {schema}.{table}")]
    
            if cursor.description is None:
                return [TextContent(type="text", text=f"Successfully execute sql {sql}")]
    
            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:
        conn.close()
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 an execution plan with runtime statistics, which suggests a read-only, analytical operation, but doesn't clarify permissions, performance impact, data returned format, or any side effects. This is inadequate 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 functionality ('Get actual execution plan with runtime statistics') and specifies the target ('for a SQL query'). There is zero waste, making it highly concise and well-structured for quick comprehension.

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 no annotations and no output schema, the description is incomplete for a tool that analyzes SQL queries. It lacks details on behavioral traits (e.g., read-only nature, performance implications), output format, and differentiation from siblings. This leaves significant gaps for an agent to understand the tool's full context and usage.

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 the single parameter 'sql' documented as 'The SQL query to analyze'. The description adds no additional meaning beyond this, such as SQL dialect requirements, query length limits, or syntax specifics. Baseline 3 is appropriate as the schema handles parameter documentation adequately.

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 tool's purpose with a specific verb ('Get') and resource ('execution plan with runtime statistics'), and specifies the target ('for a SQL query'). It doesn't explicitly differentiate from sibling tools like 'execute_sql' or 'analyze_table', but the focus on 'actual execution plan with runtime statistics' implies analytical rather than execution functionality.

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?

No explicit guidance on when to use this tool versus alternatives like 'execute_sql' or 'analyze_table' is provided. The description implies usage for SQL query analysis but doesn't specify contexts, prerequisites, or exclusions, leaving the agent to infer appropriate scenarios.

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/Moonlight-CL/redshift-mcp-server'

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