Skip to main content
Glama
lishenxydlgzs

aws-athena-mcp

run_saved_query

Execute a saved Athena query by its ID to analyze data from AWS Glue catalog. Specify database, row limits, and timeout as needed.

Instructions

Execute a saved (named) Athena query by its query ID.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
namedQueryIdYesAthena NamedQueryId
databaseOverrideNoOptional database override
maxRowsNoMaximum number of rows to return (default: 1000)
timeoutMsNoTimeout in milliseconds (default: 60000)

Implementation Reference

  • src/index.ts:107-135 (registration)
    Registration of the 'run_saved_query' tool, including its description and input schema in the ListTools response.
    {
      name: "run_saved_query",
      description: "Execute a saved (named) Athena query by its query ID.",
      inputSchema: {
        type: "object",
        properties: {
          namedQueryId: {
            type: "string",
            description: "Athena NamedQueryId",
          },
          databaseOverride: {
            type: "string",
            description: "Optional database override",
          },
          maxRows: {
            type: "number",
            description: "Maximum number of rows to return (default: 1000)",
            minimum: 1,
            maximum: 10000,
          },
          timeoutMs: {
            type: "number",
            description: "Timeout in milliseconds (default: 60000)",
            minimum: 1000,
          },
        },
        required: ["namedQueryId"],
      },
    },
  • MCP tool handler for 'run_saved_query': validates input, calls AthenaService.executeNamedQuery, and formats response.
    case "run_saved_query": {
      const args = request.params.arguments;
      if (!args || typeof args.namedQueryId !== 'string') {
        throw new McpError(
          ErrorCode.InvalidParams,
          "Missing required parameter: namedQueryId (string)"
        );
      }
    
      const result = await this.athenaService.executeNamedQuery(
        args.namedQueryId,
        typeof args.databaseOverride === 'string' ? args.databaseOverride : undefined,
        typeof args.maxRows === 'number' ? args.maxRows : undefined,
        typeof args.timeoutMs === 'number' ? args.timeoutMs : undefined,
      );
    
      return {
        content: [
          {
            type: "text",
            text: JSON.stringify(result, null, 2),
          },
        ],
      };
    }
  • Core implementation in AthenaService: fetches the named query details using GetNamedQueryCommand and executes it via executeQuery.
    async executeNamedQuery(
      namedQueryId: string,
      databaseOverride?: string,
      maxRows?: number,
      timeoutMs?: number
    ): Promise<QueryResult | { queryExecutionId: string }> {
      const namedQueryResp = await this.client.send(
        new GetNamedQueryCommand({ NamedQueryId: namedQueryId })
      );
    
      if (!namedQueryResp.NamedQuery || !namedQueryResp.NamedQuery.QueryString) {
        throw {
          message: "Named query not found or empty",
          code: "NAMED_QUERY_NOT_FOUND",
        };
      }
    
      const queryInput: QueryInput = {
        query: namedQueryResp.NamedQuery.QueryString,
        database: databaseOverride || namedQueryResp.NamedQuery.Database || "",
        maxRows,
        timeoutMs,
      };
    
      return this.executeQuery(queryInput);
    }
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. It states the tool executes a query but doesn't mention what happens during execution (e.g., query runs on Athena, may take time, returns results directly or via reference), potential side effects, authentication needs, rate limits, or error handling. This is inadequate for a tool that likely involves computational resources and timeouts.

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 earns its place by specifying the action, resource type, and key identifier, making it easy to parse quickly.

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 executing Athena queries (involving timeouts, row limits, and potential async behavior), no annotations, and no output schema, the description is insufficient. It doesn't explain what the tool returns (e.g., results, status ID, error details), how to handle large results, or integration with sibling tools like 'get_status' for monitoring. This leaves critical gaps for an agent to use it effectively.

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 schema already documents all parameters thoroughly. The description doesn't add any parameter-specific information beyond implying 'namedQueryId' is required. It doesn't explain relationships between parameters (e.g., how databaseOverride interacts with saved query settings) or provide usage examples, so it meets the baseline but doesn't enhance understanding.

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 ('Execute') and resource ('saved (named) Athena query by its query ID'), making the purpose immediately understandable. It doesn't explicitly differentiate from sibling tools like 'run_query' or 'get_result', but the focus on saved/named queries provides some implicit distinction.

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 'run_query' (for ad-hoc queries) or 'get_result' (for retrieving results). It mentions saved/named queries but doesn't clarify prerequisites (e.g., needing a saved query ID from 'list_saved_queries') or when this is preferred over other execution methods.

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