list_triggers
Retrieve all configured alerts and their metadata for a specific dataset in Honeycomb to monitor system performance and identify issues.
Instructions
Lists available triggers (alerts) for a specific dataset. This tool returns a list of all triggers available in the specified dataset, including their names, descriptions, thresholds, and other metadata. NOTE: all is NOT supported as a dataset name -- it is not possible to list all triggers in an environment.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| environment | Yes | The Honeycomb environment | |
| dataset | Yes | The dataset to fetch triggers from |
Implementation Reference
- src/tools/list-triggers.ts:45-94 (handler)Handler for the list_triggers tool: validates environment and dataset parameters, fetches triggers via api.getTriggers, maps to SimplifiedTrigger format, calculates active and triggered counts, returns JSON content and metadata.handler: async ({ environment, dataset }: z.infer<typeof DatasetArgumentsSchema>) => { // Validate input parameters if (!environment) { return handleToolError(new Error("environment parameter is required"), "list_triggers"); } if (!dataset) { return handleToolError(new Error("dataset parameter is required"), "list_triggers"); } try { // Fetch triggers from the API const triggers = await api.getTriggers(environment, dataset); // Simplify the response to reduce context window usage const simplifiedTriggers: SimplifiedTrigger[] = triggers.map(trigger => ({ id: trigger.id, name: trigger.name, description: trigger.description || '', threshold: { op: trigger.threshold.op, value: trigger.threshold.value, }, triggered: trigger.triggered, disabled: trigger.disabled, frequency: trigger.frequency, alert_type: trigger.alert_type, })); const activeCount = simplifiedTriggers.filter(trigger => !trigger.disabled).length; const triggeredCount = simplifiedTriggers.filter(trigger => trigger.triggered).length; return { content: [ { type: "text", text: JSON.stringify(simplifiedTriggers, null, 2), }, ], metadata: { count: simplifiedTriggers.length, activeCount, triggeredCount, dataset, environment } }; } catch (error) { return handleToolError(error, "list_triggers"); } }
- src/tools/list-triggers.ts:33-36 (schema)Zod schema defining input parameters: environment (string) and dataset (string) for the list_triggers tool.schema: { environment: z.string().describe("The Honeycomb environment"), dataset: z.string().describe("The dataset to fetch triggers from"), },
- src/tools/index.ts:50-50 (registration)Creation of the list_triggers tool instance using createListTriggersTool and addition to the tools array.createListTriggersTool(api),
- src/tools/index.ts:61-107 (registration)Loop that registers each tool, including list_triggers, to the MCP server by calling server.tool with name, description, schema, and wrapper handler.for (const tool of tools) { // Register the tool with the server using type assertion to bypass TypeScript's strict type checking (server as any).tool( tool.name, tool.description, tool.schema, async (args: Record<string, any>, extra: any) => { try { // Validate and ensure required fields are present before passing to handler if (tool.name.includes("analyze_columns") && (!args.environment || !args.dataset || !args.columns)) { throw new Error("Missing required fields: environment, dataset, and columns are required"); } else if (tool.name.includes("run_query") && (!args.environment || !args.dataset)) { throw new Error("Missing required fields: environment and dataset are required"); } // Use type assertion to satisfy TypeScript's type checking const result = await tool.handler(args as any); // If the result already has the expected format, return it directly if (result && typeof result === 'object' && 'content' in result) { return result as any; } // Otherwise, format the result as expected by the SDK return { content: [ { type: "text", text: typeof result === 'string' ? result : JSON.stringify(result, null, 2), }, ], } as any; } catch (error) { // Format errors to match the SDK's expected format return { content: [ { type: "text", text: error instanceof Error ? error.message : String(error), }, ], isError: true, } as any; } } ); }
- src/tools/list-triggers.ts:9-21 (helper)Interface defining the simplified trigger data structure returned by the tool.interface SimplifiedTrigger { id: string; name: string; description: string; threshold: { op: string; value: number; }; triggered: boolean; disabled: boolean; frequency: number; alert_type?: string; }