Skip to main content
Glama

list_cloudwatch_alarms

Retrieve and filter AWS CloudWatch alarms by state to monitor system health and performance metrics.

Instructions

Lists CloudWatch alarms, optionally filtering by state.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
stateNoFilter alarms by state.

Implementation Reference

  • The handler function for the 'list_cloudwatch_alarms' tool. It optionally filters CloudWatch alarms by state using DescribeAlarmsCommand on the cloudWatchClient, maps relevant fields (AlarmName, StateValue, StateReason, MetricName, Namespace), and returns them as JSON.
    if (name === "list_cloudwatch_alarms") { const state = (args as any)?.state; const commandInput: any = {}; if (state) commandInput.StateValue = state; const command = new DescribeAlarmsCommand(commandInput); const response = await cloudWatchClient.send(command); const alarms = response.MetricAlarms?.map(a => ({ AlarmName: a.AlarmName, StateValue: a.StateValue, StateReason: a.StateReason, MetricName: a.MetricName, Namespace: a.Namespace })) || []; return { content: [{ type: "text", text: JSON.stringify(alarms, null, 2) }] }; }
  • src/index.ts:161-173 (registration)
    Registration of the 'list_cloudwatch_alarms' tool in the ListTools response, including name, description, and input schema definition.
    name: "list_cloudwatch_alarms", description: "Lists CloudWatch alarms, optionally filtering by state.", inputSchema: { type: "object", properties: { state: { type: "string", enum: ["OK", "ALARM", "INSUFFICIENT_DATA"], description: "Filter alarms by state." } } } },
  • Input schema for the 'list_cloudwatch_alarms' tool, defining optional 'state' parameter with valid enum values.
    name: "list_cloudwatch_alarms", description: "Lists CloudWatch alarms, optionally filtering by state.", inputSchema: { type: "object", properties: { state: { type: "string", enum: ["OK", "ALARM", "INSUFFICIENT_DATA"], description: "Filter alarms by state." } } } },
  • Initialization of the CloudWatchClient used by the list_cloudwatch_alarms handler.
    const cloudWatchClient = new CloudWatchClient({});
  • Import of CloudWatchClient and DescribeAlarmsCommand required for the tool implementation.
    import { CloudWatchClient, DescribeAlarmsCommand } from "@aws-sdk/client-cloudwatch";

Latest Blog Posts

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/Bhavesh8890/MCP-server'

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