Skip to main content
Glama
lishenxydlgzs

aws-athena-mcp

get_result

Retrieve query results from AWS Athena after execution completes, specifying the query ID and optional row limit.

Instructions

Get results for a completed query. Returns error if query is still running.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryExecutionIdYesThe query execution ID
maxRowsNoMaximum number of rows to return (default: 1000)

Implementation Reference

  • Core implementation of the get_result tool: validates query status, fetches results from AWS Athena using GetQueryResultsCommand, processes columns and rows into structured output.
    async getQueryResults(queryExecutionId: string, maxRows?: number): Promise<QueryResult> {
      try {
        // Check query state first
        const status = await this.getQueryStatus(queryExecutionId);
    
        if (status.state === QueryExecutionState.RUNNING || status.state === QueryExecutionState.QUEUED) {
          throw {
            message: "Query is still running",
            code: "QUERY_STILL_RUNNING",
            queryExecutionId,
          };
        }
    
        if (status.state === QueryExecutionState.FAILED) {
          throw {
            message: status.stateChangeReason || "Query failed",
            code: "QUERY_FAILED",
            queryExecutionId,
          };
        }
    
        if (status.state !== QueryExecutionState.SUCCEEDED) {
          throw {
            message: `Unexpected query state: ${status.state}`,
            code: "UNEXPECTED_STATE",
            queryExecutionId,
          };
        }
    
        const results = await this.client.send(
          new GetQueryResultsCommand({
            QueryExecutionId: queryExecutionId,
            MaxResults: maxRows || 1000,
          })
        );
    
        if (!results.ResultSet) {
          throw new Error("No results returned from query");
        }
    
        const columns = results.ResultSet.ResultSetMetadata?.ColumnInfo?.map(
          (col) => col.Name || ""
        ) || [];
    
        const rows = (results.ResultSet.Rows || [])
          .slice(status.substatementType === 'SELECT' ? 1 : 0) // Skip header row if query is SELECT
          .map((row) => {
            const obj: Record<string, unknown> = {};
            row.Data?.forEach((data, index) => {
              if (columns[index]) {
                obj[columns[index]] = data.VarCharValue;
              }
            });
            return obj;
          });
    
        return {
          columns,
          rows,
          queryExecutionId,
          bytesScanned: status.statistics?.dataScannedInBytes || 0,
          executionTime: status.statistics?.engineExecutionTimeInMillis || 0,
        };
      } catch (error) {
        if (error instanceof InvalidRequestException) {
          throw {
            message: "Query execution not found",
            code: "QUERY_NOT_FOUND",
          };
        }
        throw error;
      }
    }
  • MCP CallToolRequest handler for get_result: validates input parameters and calls AthenaService.getQueryResults, returns JSON response.
    case "get_result": {
      if (!request.params.arguments?.queryExecutionId ||
          typeof request.params.arguments.queryExecutionId !== 'string') {
        throw new McpError(
          ErrorCode.InvalidParams,
          "Missing or invalid required parameter: queryExecutionId (string)"
        );
      }
    
      const maxRows = typeof request.params.arguments.maxRows === 'number' ?
        request.params.arguments.maxRows : undefined;
      const result = await this.athenaService.getQueryResults(
        request.params.arguments.queryExecutionId,
        maxRows
      );
      return {
        content: [
          {
            type: "text",
            text: JSON.stringify(result, null, 2),
          },
        ],
      };
    }
  • Tool schema and registration: defines name, description, input schema with queryExecutionId (required) and optional maxRows for the get_result tool in ListTools response.
    {
      name: "get_result",
      description: "Get results for a completed query. Returns error if query is still running.",
      inputSchema: {
        type: "object",
        properties: {
          queryExecutionId: {
            type: "string",
            description: "The query execution ID",
          },
          maxRows: {
            type: "number",
            description: "Maximum number of rows to return (default: 1000)",
            minimum: 1,
            maximum: 10000,
          },
        },
        required: ["queryExecutionId"],
      },
    },
  • TypeScript interface defining the output structure for query results returned by get_result.
    export interface QueryResult {
      columns: string[];
      rows: Record<string, unknown>[];
      queryExecutionId: string;
      bytesScanned: number;
      executionTime: number;
    }
Behavior3/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 adds value by stating the error condition ('Returns error if query is still running'), which is useful context beyond the input schema. However, it lacks details on permissions, rate limits, response format, or pagination behavior (e.g., how maxRows affects output). For a tool with no annotations, this is a moderate disclosure, scoring a 3.

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 extremely concise and front-loaded: two sentences that directly state the tool's function and a key behavioral constraint. Every sentence earns its place by providing essential information without waste, making it efficient and well-structured for an AI agent.

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?

Given the tool's moderate complexity (2 parameters, no output schema, no annotations), the description is somewhat complete but has gaps. It covers the basic purpose and an error condition, but lacks details on return values (since no output schema exists), authentication, or how it integrates with sibling tools. For a result-retrieval tool, this is minimally adequate, scoring a 3.

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%, so the input schema fully documents both parameters (queryExecutionId and maxRows). The description does not add any parameter-specific semantics beyond what the schema provides (e.g., it doesn't explain the format of queryExecutionId or how maxRows interacts with query results). According to the rules, with high schema coverage (>80%), the baseline is 3 even with no param info in the description, which applies here.

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: 'Get results for a completed query.' It specifies the verb ('Get') and resource ('results'), and distinguishes it from siblings like 'get_status' (which checks query status) and 'run_query' (which executes queries). However, it doesn't explicitly differentiate from 'list_saved_queries' or 'run_saved_query' in terms of result retrieval, making it a 4 rather than 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 Guidelines3/5

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

The description provides implied usage guidance: it should be used only for completed queries ('Returns error if query is still running'), suggesting an alternative might be 'get_status' to check completion first. However, it doesn't explicitly state when to use this tool versus alternatives like 'get_status' for status checks or 'run_query' for execution, nor does it mention prerequisites (e.g., needing a queryExecutionId from a prior run). This is adequate but has gaps, scoring a 3.

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/lishenxydlgzs/aws-athena-mcp'

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