add_query_favorite
Adds a specified query to your favorites list for quick access and organization.
Instructions
Add a query to favorites
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| queryId | Yes | ID of the query to add to favorites |
Implementation Reference
- src/index.ts:1230-1243 (handler)MCP tool handler function for 'add_query_favorite' - validates input with Zod schema, calls redashClient.addQueryFavorite(), and returns the result or an error.
async function addQueryFavorite(params: z.infer<typeof addQueryFavoriteSchema>) { try { const result = await redashClient.addQueryFavorite(params.queryId); return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] }; } catch (error) { logger.error(`Error adding query ${params.queryId} to favorites: ${error}`); return { isError: true, content: [{ type: "text", text: `Error adding query ${params.queryId} to favorites: ${error instanceof Error ? error.message : String(error)}` }] }; } } - src/index.ts:1226-1228 (schema)Zod schema for the 'add_query_favorite' tool - expects a single 'queryId' (number) parameter.
const addQueryFavoriteSchema = z.object({ queryId: z.coerce.number() }); - src/index.ts:2139-2149 (registration)Tool registration in ListToolsRequestSchema - defines the tool name 'add_query_favorite', description, and input schema for MCP discovery.
{ name: "add_query_favorite", description: "Add a query to favorites", inputSchema: { type: "object", properties: { queryId: { type: "number", description: "ID of the query to add to favorites" } }, required: ["queryId"] } }, - src/index.ts:2503-2507 (registration)Tool dispatch in CallToolRequestSchema switch statement - routes the 'add_query_favorite' tool name to the handler function.
case "add_query_favorite": logger.debug(`Handling add_query_favorite`); return await addQueryFavorite(addQueryFavoriteSchema.parse(args)); - src/redashClient.ts:1083-1092 (helper)Redash API client method - sends a POST request to /api/queries/{queryId}/favorite to add a query to favorites.
// Add query to favorites async addQueryFavorite(queryId: number): Promise<{ success: boolean }> { try { await this.client.post(`/api/queries/${queryId}/favorite`); return { success: true }; } catch (error) { logger.error(`Error adding query ${queryId} to favorites: ${error}`); throw new Error(`Failed to add query ${queryId} to favorites: ${error instanceof Error ? error.message : String(error)}`); } }