Skip to main content
Glama

list_alarms

Retrieve all alarms in an Oracle Cloud Infrastructure compartment to monitor their queries, severity levels, states, and notification destinations.

Instructions

List all alarms in a compartment. Args: compartment_id: OCID of the compartment to list alarms from Returns: List of alarms with their query, severity, state, and destinations

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
compartment_idYes

Implementation Reference

  • Core handler function that executes the logic to list alarms in a compartment using OCI MonitoringClient, processes the response, and returns formatted alarm details.
    def list_alarms(monitoring_client: oci.monitoring.MonitoringClient, compartment_id: str) -> List[Dict[str, Any]]: """ List all alarms in a compartment. Args: monitoring_client: OCI Monitoring client compartment_id: OCID of the compartment Returns: List of alarms with their details """ try: alarms_response = oci.pagination.list_call_get_all_results( monitoring_client.list_alarms, compartment_id ) alarms = [] for alarm in alarms_response.data: alarms.append({ "id": alarm.id, "display_name": alarm.display_name, "compartment_id": alarm.compartment_id, "metric_compartment_id": alarm.metric_compartment_id, "namespace": alarm.namespace, "query": alarm.query, "severity": alarm.severity, "lifecycle_state": alarm.lifecycle_state, "is_enabled": alarm.is_enabled, "destinations": alarm.destinations, "time_created": str(alarm.time_created), "time_updated": str(alarm.time_updated), }) logger.info(f"Found {len(alarms)} alarms in compartment {compartment_id}") return alarms except Exception as e: logger.exception(f"Error listing alarms: {e}") raise
  • MCP tool registration for the 'list_alarms' tool, including the wrapper decorator and the async handler that calls the core list_alarms function.
    @mcp.tool(name="list_alarms") @mcp_tool_wrapper( start_msg="Listing alarms in compartment {compartment_id}...", error_prefix="Error listing alarms" ) async def mcp_list_alarms(ctx: Context, compartment_id: str) -> List[Dict[str, Any]]: """ List all alarms in a compartment. Args: compartment_id: OCID of the compartment to list alarms from Returns: List of alarms with their query, severity, state, and destinations """ return list_alarms(oci_clients["monitoring"], compartment_id)

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/jopsis/mcp-server-oci'

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