get_alert_subscriptions
Retrieve all subscriptions for a specified alert to manage notification recipients.
Instructions
Get all subscriptions for an alert
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| alertId | Yes | ID of the alert |
Implementation Reference
- src/index.ts:2052-2061 (registration)Tool registration in ListToolsRequestSchema handler - defines the tool named 'get_alert_subscriptions' with description and input schema requiring alertId
name: "get_alert_subscriptions", description: "Get all subscriptions for an alert", inputSchema: { type: "object", properties: { alertId: { type: "number", description: "ID of the alert" } }, required: ["alertId"] } }, - src/index.ts:1059-1077 (handler)Handler function for get_alert_subscriptions tool. Defines the Zod schema (getAlertSubscriptionsSchema) with alertId (coerced number), and the async handler that calls redashClient.getAlertSubscriptions() and returns JSON results.
// Tool: get_alert_subscriptions const getAlertSubscriptionsSchema = z.object({ alertId: z.coerce.number() }); async function getAlertSubscriptions(params: z.infer<typeof getAlertSubscriptionsSchema>) { try { const result = await redashClient.getAlertSubscriptions(params.alertId); return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] }; } catch (error) { logger.error(`Error getting alert ${params.alertId} subscriptions: ${error}`); return { isError: true, content: [{ type: "text", text: `Error getting alert ${params.alertId} subscriptions: ${error instanceof Error ? error.message : String(error)}` }] }; } } - src/index.ts:2471-2473 (registration)Tool dispatch in CallToolRequestSchema handler - routes 'get_alert_subscriptions' to getAlertSubscriptions() with parsed args
case "get_alert_subscriptions": logger.debug(`Handling get_alert_subscriptions`); return await getAlertSubscriptions(getAlertSubscriptionsSchema.parse(args)); - src/redashClient.ts:973-981 (helper)Client helper method - makes GET request to /api/alerts/{alertId}/subscriptions to fetch alert subscriptions from the Redash API
async getAlertSubscriptions(alertId: number): Promise<AlertSubscription[]> { try { const response = await this.client.get(`/api/alerts/${alertId}/subscriptions`); return response.data; } catch (error) { logger.error(`Error fetching alert ${alertId} subscriptions: ${error}`); throw new Error(`Failed to fetch alert ${alertId} subscriptions: ${error instanceof Error ? error.message : String(error)}`); } } - src/redashClient.ts:184-197 (schema)AlertSubscription type definition - interface with id, alert_id, user, and destination fields
export interface AlertSubscription { id: number; alert_id: number; user?: { id: number; name: string; email: string; }; destination?: { id: number; name: string; type: string; }; }