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)
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. While it indicates this is a read operation ('List') and specifies the return format, it doesn't mention important behavioral aspects like pagination, rate limits, authentication requirements, error conditions, or whether the operation is safe/destructive. For a tool with zero annotation coverage, this leaves significant gaps in understanding its behavior.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is efficiently structured with a clear purpose statement followed by Args and Returns sections. Every sentence serves a purpose, though the 'Returns' section could be more specific about the data structure. The information is front-loaded with the core functionality stated first.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's moderate complexity (single parameter list operation), no annotations, and no output schema, the description provides basic operational context but lacks completeness. It explains what the tool does and the parameter, but doesn't cover behavioral aspects, error handling, or detailed return format. For a tool with no structured metadata, it's minimally adequate but leaves important questions unanswered.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The description explicitly documents the single parameter ('compartment_id: OCID of the compartment to list alarms from'), adding crucial semantic meaning beyond the schema's minimal coverage (0%). Since there's only one parameter and the description fully explains it, this compensates well for the schema's lack of description, though it doesn't provide format examples or validation rules.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the specific action ('List all alarms') and the resource ('in a compartment'), distinguishing it from sibling tools like 'get_alarm' (which retrieves a single alarm) and other list_* tools for different resources. It provides a precise verb+resource combination that leaves no ambiguity about the tool's function.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage context by specifying 'in a compartment' and listing a required compartment_id parameter, but doesn't explicitly state when to use this tool versus alternatives like 'get_alarm' or other list_* tools. It provides basic operational context but lacks explicit guidance on tool selection or exclusion criteria.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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