Skip to main content
Glama

get_alarm_history

Retrieve historical state changes and transitions for Oracle Cloud Infrastructure alarms to analyze monitoring patterns and troubleshoot issues.

Instructions

Get alarm state history.

Args:
    alarm_id: OCID of the alarm
    alarm_historytype: Type of history (STATE_TRANSITION_HISTORY, STATE_HISTORY, RULE_HISTORY)

Returns:
    List of alarm history entries with timestamps and state changes

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
alarm_idYes
alarm_historytypeNoSTATE_TRANSITION_HISTORY

Implementation Reference

  • The core handler function implementing the get_alarm_history tool. It uses the OCI MonitoringClient to fetch all alarm history entries via pagination, processes them into a list of dictionaries with summary, timestamp, and optional timestamp_triggered, and handles exceptions.
    def get_alarm_history(monitoring_client: oci.monitoring.MonitoringClient,
                          alarm_id: str,
                          alarm_historytype: str = "STATE_TRANSITION_HISTORY") -> List[Dict[str, Any]]:
        """
        Get alarm state history.
    
        Args:
            monitoring_client: OCI Monitoring client
            alarm_id: OCID of the alarm
            alarm_historytype: Type of history (STATE_TRANSITION_HISTORY, STATE_HISTORY, RULE_HISTORY)
    
        Returns:
            List of alarm history entries
        """
        try:
            history_response = oci.pagination.list_call_get_all_results(
                monitoring_client.get_alarm_history,
                alarm_id,
                alarm_historytype=alarm_historytype
            )
    
            history = []
            for entry in history_response.data:
                history.append({
                    "summary": entry.summary,
                    "timestamp": str(entry.timestamp),
                    "timestamp_triggered": str(entry.timestamp_triggered) if hasattr(entry, 'timestamp_triggered') and entry.timestamp_triggered else None,
                })
    
            logger.info(f"Retrieved {len(history)} history entries for alarm {alarm_id}")
            return history
    
        except Exception as e:
            logger.exception(f"Error getting alarm history: {e}")
            raise
  • The MCP tool registration for 'get_alarm_history'. This wrapper function is decorated with @mcp.tool and @mcp_tool_wrapper, receives MCP Context and parameters, and delegates to the core handler function using the shared oci_clients["monitoring"] instance.
    @mcp.tool(name="get_alarm_history")
    @mcp_tool_wrapper(
        start_msg="Getting alarm history for {alarm_id}...",
        error_prefix="Error getting alarm history"
    )
    async def mcp_get_alarm_history(ctx: Context, alarm_id: str,
                                    alarm_historytype: str = "STATE_TRANSITION_HISTORY") -> List[Dict[str, Any]]:
        """
        Get alarm state history.
    
        Args:
            alarm_id: OCID of the alarm
            alarm_historytype: Type of history (STATE_TRANSITION_HISTORY, STATE_HISTORY, RULE_HISTORY)
    
        Returns:
            List of alarm history entries with timestamps and state changes
        """
        return get_alarm_history(oci_clients["monitoring"], alarm_id, alarm_historytype)
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It mentions that the tool returns a list of entries with timestamps and state changes, which adds some context about output format. However, it lacks critical details such as whether this is a read-only operation, if it requires specific permissions, how data is paginated or limited, or any rate limits. For a tool with no annotations, 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.

Conciseness5/5

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

The description is appropriately sized and well-structured. It starts with a clear purpose statement, followed by organized sections for 'Args' and 'Returns', using bullet-like formatting. Every sentence adds value without redundancy, making it easy to scan and understand quickly.

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 (2 parameters, no output schema, no annotations), the description is partially complete. It covers the basic purpose and parameters adequately but lacks output details beyond a high-level description. Without annotations or an output schema, it doesn't fully address behavioral aspects like error handling or data scope, leaving room for improvement in contextual understanding.

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?

Schema description coverage is 0%, so the description must compensate. It adds meaningful semantics: 'alarm_id' is explained as 'OCID of the alarm', and 'alarm_historytype' is described with its types (STATE_TRANSITION_HISTORY, STATE_HISTORY, RULE_HISTORY) and a default value. This clarifies parameter purposes beyond the schema's basic titles, though it doesn't detail format constraints or usage examples.

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

Purpose4/5

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

The description clearly states the tool's purpose: 'Get alarm state history.' It specifies the verb ('Get') and resource ('alarm state history'), making it easy to understand what the tool does. However, it doesn't explicitly differentiate from sibling tools like 'get_alarm' or 'list_alarms', which might retrieve current alarm data or lists of alarms, respectively.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives. With sibling tools like 'get_alarm' (likely for current alarm details) and 'list_alarms' (likely for listing alarms), there's no indication of when historical data is needed or how this tool fits into broader workflows. Usage is implied only by the tool's name and description.

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