Skip to main content
Glama

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); }

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