Skip to main content
Glama

hny-mcp

by honeycombio
MIT License
2
36
  • Linux
  • Apple
list-triggers.ts3.46 kB
import { z } from "zod"; import { HoneycombAPI } from "../api/client.js"; import { handleToolError } from "../utils/tool-error.js"; import { DatasetArgumentsSchema } from "../types/schema.js"; /** * Interface for simplified trigger data returned by the list_triggers tool */ interface SimplifiedTrigger { id: string; name: string; description: string; threshold: { op: string; value: number; }; triggered: boolean; disabled: boolean; frequency: number; alert_type?: string; } /** * Tool to list 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. * * @param api - The Honeycomb API client * @returns An MCP tool object with name, schema, and handler function */ export function createListTriggersTool(api: HoneycombAPI) { return { name: "list_triggers", description: "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.", schema: { environment: z.string().describe("The Honeycomb environment"), dataset: z.string().describe("The dataset to fetch triggers from"), }, /** * Handler for the list_triggers tool * * @param params - The parameters for the tool * @param params.environment - The Honeycomb environment * @param params.dataset - The dataset to fetch triggers from * @returns Simplified list of triggers with relevant 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"); } } }; }

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/honeycombio/honeycomb-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server