list_query_snippets
Retrieve all reusable query snippets to quickly find and reuse SQL fragments in Redash.
Instructions
List all reusable query snippets
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/index.ts:1388-1401 (handler)Handler function 'listQuerySnippets' that implements the tool logic. It calls redashClient.getQuerySnippets() and returns the list of all query snippets as JSON text.
async function listQuerySnippets() { try { const result = await redashClient.getQuerySnippets(); return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] }; } catch (error) { logger.error(`Error listing query snippets: ${error}`); return { isError: true, content: [{ type: "text", text: `Error listing query snippets: ${error instanceof Error ? error.message : String(error)}` }] }; } } - src/index.ts:1387-1387 (schema)No input schema is needed for this tool (no parameters, no Zod schema defined). The tool takes no arguments.
// Tool: list_query_snippets - src/index.ts:2223-2230 (registration)Tool registration in the ListToolsRequestSchema handler, defining name 'list_query_snippets' with description and empty inputSchema.
{ name: "list_query_snippets", description: "List all reusable query snippets", inputSchema: { type: "object", properties: {} } }, - src/index.ts:2534-2536 (registration)Tool dispatch in CallToolRequestSchema switch case routing 'list_query_snippets' to the listQuerySnippets handler.
case "list_query_snippets": logger.debug(`Handling list_query_snippets`); return await listQuerySnippets(); - src/redashClient.ts:1165-1173 (helper)Supporting API method 'getQuerySnippets' in RedashClient that makes the actual HTTP GET request to /api/query_snippets endpoint.
async getQuerySnippets(): Promise<RedashQuerySnippet[]> { try { const response = await this.client.get('/api/query_snippets'); return response.data; } catch (error) { logger.error(`Error fetching query snippets: ${error}`); throw new Error(`Failed to fetch query snippets: ${error instanceof Error ? error.message : String(error)}`); } }