Skip to main content
Glama

handle_execute_ad_hoc_query

Execute custom SQL queries directly via Redshift Data API. Returns structured results or detailed error messages for troubleshooting. Ideal for advanced queries not covered by specialized tools.

Instructions

Executes an arbitrary SQL query provided by the user via Redshift Data API.

Designed as an escape hatch for advanced users or queries not covered by
specialized tools. Returns a structured dictionary indicating success
(with results) or failure (with error details).

Args:
    ctx: The MCP context object.
    sql_query: The exact SQL query string to execute.

Returns:
    A dictionary conforming to ExecuteAdHocQueryResult structure:
    - On success: {"status": "success", "columns": [...], "rows": [...], "row_count": ...}
    - On error: {"status": "error", "error_message": "...", "error_type": "..."}
    (Note: Actual return might be handled by FastMCP error handling for raised exceptions)

Raises:
    DataApiConfigError: If configuration is invalid.
    SqlExecutionError: If the SQL execution itself fails.
    DataApiTimeoutError: If the Data API call times out.
    DataApiError: For other Data API related errors or unexpected issues.
    ClientError: For AWS client-side errors.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
sql_queryYes
Behavior4/5

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

With no annotations provided, the description carries full burden and does an excellent job disclosing behavioral traits. It describes the return structure in detail (success vs error cases), mentions potential exceptions raised (DataApiConfigError, SqlExecutionError, etc.), and notes that 'Actual return might be handled by FastMCP error handling for raised exceptions.' This provides comprehensive behavioral context beyond basic functionality.

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 well-structured and appropriately sized. It begins with the core purpose, then provides usage context, followed by parameter documentation, return value details, and exception information. Every section adds value, though the detailed exception list could be slightly condensed. Overall, it's efficiently organized with clear sections.

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?

Given the tool's complexity (executing arbitrary SQL queries via Redshift Data API) and the absence of both annotations and output schema, the description provides substantial context. It covers purpose, usage guidelines, parameter semantics, return structure, and potential exceptions. The main gap is lack of information about query limitations, performance implications, or security considerations for arbitrary SQL execution.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The description adds significant meaning beyond the input schema. With 0% schema description coverage (schema only shows sql_query is a required string), the description explains that 'sql_query: The exact SQL query string to execute.' This clarifies the parameter's purpose and format. While it doesn't provide SQL syntax guidance, it adequately compensates for the schema's lack of documentation.

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?

The description clearly states the tool's purpose: 'Executes an arbitrary SQL query provided by the user via Redshift Data API.' It specifies the exact action (execute SQL query), the mechanism (Redshift Data API), and distinguishes it from specialized tools by calling it an 'escape hatch for advanced users or queries not covered by specialized tools.' This differentiates it from sibling tools like handle_get_table_definition or handle_inspect_table.

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

Usage Guidelines5/5

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

The description explicitly states when to use this tool: 'Designed as an escape hatch for advanced users or queries not covered by specialized tools.' This provides clear guidance that this tool should be used when other specialized tools (the siblings listed) don't cover the needed functionality, establishing clear alternatives and 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

Related 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/vinodismyname/redshift-utils-mcp'

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