Skip to main content
Glama
mpeirone

zabbix-mcp-server

event_get

Retrieve and filter events from Zabbix by event IDs, host groups, hosts, objects, or time range. Returns a JSON-formatted list of events for monitoring and analysis.

Instructions

Get events from Zabbix with optional filtering.

Args:
    eventids: List of event IDs to retrieve
    groupids: List of host group IDs to filter by
    hostids: List of host IDs to filter by
    objectids: List of object IDs to filter by
    output: Output format
    time_from: Start time (Unix timestamp)
    time_till: End time (Unix timestamp)
    limit: Maximum number of results
    
Returns:
    str: JSON formatted list of events

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
eventidsNo
groupidsNo
hostidsNo
limitNo
objectidsNo
outputNoextend
time_fromNo
time_tillNo

Implementation Reference

  • Handler function for the 'event_get' MCP tool. Decorated with @mcp.tool() for automatic registration. Fetches events from Zabbix API using the provided filters and returns JSON-formatted results.
    def event_get(eventids: Optional[List[str]] = None,
                  groupids: Optional[List[str]] = None,
                  hostids: Optional[List[str]] = None,
                  objectids: Optional[List[str]] = None,
                  output: Union[str, List[str]] = "extend",
                  time_from: Optional[int] = None,
                  time_till: Optional[int] = None,
                  limit: Optional[int] = None) -> str:
        """Get events from Zabbix with optional filtering.
        
        Args:
            eventids: List of event IDs to retrieve
            groupids: List of host group IDs to filter by
            hostids: List of host IDs to filter by
            objectids: List of object IDs to filter by
            output: Output format (extend or list of specific fields)
            time_from: Start time (Unix timestamp)
            time_till: End time (Unix timestamp)
            limit: Maximum number of results
            
        Returns:
            str: JSON formatted list of events
        """
        client = get_zabbix_client()
        params = {"output": output}
        
        if eventids:
            params["eventids"] = eventids
        if groupids:
            params["groupids"] = groupids
        if hostids:
            params["hostids"] = hostids
        if objectids:
            params["objectids"] = objectids
        if time_from:
            params["time_from"] = time_from
        if time_till:
            params["time_till"] = time_till
        if limit:
            params["limit"] = limit
        
        result = client.event.get(**params)
        return format_response(result)
  • Docstring defining the input parameters and return type for the event_get tool, used by FastMCP for schema generation.
    """Get events from Zabbix with optional filtering.
    
    Args:
        eventids: List of event IDs to retrieve
        groupids: List of host group IDs to filter by
        hostids: List of host IDs to filter by
        objectids: List of object IDs to filter by
        output: Output format (extend or list of specific fields)
        time_from: Start time (Unix timestamp)
        time_till: End time (Unix timestamp)
        limit: Maximum number of results
        
    Returns:
        str: JSON formatted list of events
    """
  • FastMCP decorator that registers the event_get function as a tool named 'event_get'.
    def event_get(eventids: Optional[List[str]] = None,
  • Helper function used by event_get to format the API response as indented JSON.
    def format_response(data: Any) -> str:
        """Format response data as JSON string.
        
        Args:
            data: Data to format
            
        Returns:
            str: JSON formatted string
        """
        return json.dumps(data, indent=2, default=str)
  • Helper function to obtain authenticated ZabbixAPI client instance, used by event_get.
    def get_zabbix_client() -> ZabbixAPI:
        """Get or create Zabbix API client with proper authentication.
        
        Returns:
            ZabbixAPI: Authenticated Zabbix API client
            
        Raises:
            ValueError: If required environment variables are missing
            Exception: If authentication fails
        """
        global zabbix_api
        
        if zabbix_api is None:
            url = os.getenv("ZABBIX_URL")
            if not url:
                raise ValueError("ZABBIX_URL environment variable is required")
            
            logger.info(f"Initializing Zabbix API client for {url}")
            
            # Configure SSL verification
            verify_ssl = os.getenv("VERIFY_SSL", "true").lower() in ("true", "1", "yes")
            logger.info(f"SSL certificate verification: {'enabled' if verify_ssl else 'disabled'}")
            
            # Initialize client
            zabbix_api = ZabbixAPI(url=url, validate_certs=verify_ssl)
    
            # Authenticate using token or username/password
            token = os.getenv("ZABBIX_TOKEN")
            if token:
                logger.info("Authenticating with API token")
                zabbix_api.login(token=token)
            else:
                user = os.getenv("ZABBIX_USER")
                password = os.getenv("ZABBIX_PASSWORD")
                if not user or not password:
                    raise ValueError("Either ZABBIX_TOKEN or ZABBIX_USER/ZABBIX_PASSWORD must be set")
                logger.info(f"Authenticating with username: {user}")
                zabbix_api.login(user=user, password=password)
            
            logger.info("Successfully authenticated with Zabbix API")
        
        return zabbix_api
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. It mentions the return format ('JSON formatted list of events') but lacks critical behavioral details: whether this is a read-only operation, if it requires authentication, rate limits, pagination behavior beyond the 'limit' parameter, or error handling. The description is minimal and doesn't adequately compensate for the absence of annotations.

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 well-structured and appropriately sized. It opens with a clear purpose statement, followed by an 'Args' section listing parameters with concise explanations, and ends with return information. Every sentence earns its place, though the parameter explanations could be slightly more detailed given the lack of schema descriptions.

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 complexity (8 parameters, no annotations, no output schema), the description is minimally adequate but has clear gaps. It covers parameters and return format, but lacks behavioral context, usage differentiation from siblings, and details about authentication or error handling. For a data retrieval tool in a monitoring system, this leaves the agent with insufficient guidance for robust use.

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 adds significant value beyond the input schema, which has 0% description coverage. It lists all 8 parameters with brief explanations (e.g., 'List of event IDs to retrieve', 'Start time (Unix timestamp)'), providing essential semantic context that the schema's bare titles lack. While it doesn't explain defaults or interdependencies, it meaningfully compensates for the schema's deficiencies.

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 events from Zabbix with optional filtering.' It specifies the verb ('Get') and resource ('events from Zabbix'), making the function unambiguous. However, it doesn't explicitly differentiate from sibling tools like 'problem_get' or 'history_get', which likely retrieve related but different data types.

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 siblings like 'problem_get', 'history_get', and 'event_acknowledge' available, there's no indication of how this tool differs in scope or use case. The mention of 'optional filtering' is generic and doesn't help the agent choose between similar retrieval tools.

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

Related 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/mpeirone/zabbix-mcp-server'

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