archive_query
Archive a Redash query by its ID to soft-delete it, removing it from active use while preserving data for potential recovery.
Instructions
Archive (soft-delete) a query in Redash
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| queryId | Yes | ID of the query to archive |
Implementation Reference
- src/index.ts:187-212 (handler)Handler function for the archive_query tool. Calls redashClient.archiveQuery(queryId) and returns the result as JSON content.
async function archiveQuery(params: z.infer<typeof archiveQuerySchema>) { try { const { queryId } = params; const result = await redashClient.archiveQuery(queryId); return { content: [ { type: "text", text: JSON.stringify(result, null, 2) } ] }; } catch (error) { logger.error(`Error archiving query ${params.queryId}: ${error}`); return { isError: true, content: [ { type: "text", text: `Error archiving query ${params.queryId}: ${error instanceof Error ? error.message : String(error)}` } ] }; } } - src/index.ts:182-185 (schema)Zod schema for archive_query tool input validation. Expects a single required parameter: queryId (coerced number).
// Tool: archive_query const archiveQuerySchema = z.object({ queryId: z.coerce.number() }); - src/index.ts:1665-1675 (registration)Registration of the archive_query tool in the ListToolsRequestSchema handler. Defines name, description, and inputSchema with required queryId (number).
{ name: "archive_query", description: "Archive (soft-delete) a query in Redash", inputSchema: { type: "object", properties: { queryId: { type: "number", description: "ID of the query to archive" } }, required: ["queryId"] } }, - src/redashClient.ts:465-476 (helper)Helper/API client method that performs the actual HTTP DELETE request to /api/queries/{queryId} to archive (soft-delete) a query in Redash.
// Archive (soft delete) a query async archiveQuery(queryId: number): Promise<{ success: boolean }> { try { logger.debug(`Archiving query ${queryId}`); await this.client.delete(`/api/queries/${queryId}`); logger.debug(`Archived query ${queryId}`); return { success: true }; } catch (error) { logger.error(`Error archiving query ${queryId}: ${error}`); throw new Error(`Failed to archive query ${queryId}: ${error instanceof Error ? error.message : String(error)}`); } }