discoveryrule_get
Retrieve discovery rules from Zabbix with customizable filters for item IDs, host IDs, and template IDs. Returns JSON-formatted data for precise monitoring and integration.
Instructions
Get discovery rules from Zabbix with optional filtering.
Args:
itemids: List of discovery rule IDs to retrieve
hostids: List of host IDs to filter by
templateids: List of template IDs to filter by
output: Output format
search: Search criteria
filter: Filter criteria
Returns:
str: JSON formatted list of discovery rules
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| filter | No | ||
| hostids | No | ||
| itemids | No | ||
| output | No | extend | |
| search | No | ||
| templateids | No |
Implementation Reference
- src/zabbix_mcp_server.py:1320-1355 (handler)The discoveryrule_get MCP tool handler function, registered via @mcp.tool() decorator. Retrieves discovery rules using Zabbix API with filtering parameters and returns JSON-formatted response.def discoveryrule_get(itemids: Optional[List[str]] = None, hostids: Optional[List[str]] = None, templateids: Optional[List[str]] = None, output: Union[str, List[str]] = "extend", search: Optional[Dict[str, str]] = None, filter: Optional[Dict[str, Any]] = None) -> str: """Get discovery rules from Zabbix with optional filtering. Args: itemids: List of discovery rule IDs to retrieve hostids: List of host IDs to filter by templateids: List of template IDs to filter by output: Output format (extend or list of specific fields) search: Search criteria filter: Filter criteria Returns: str: JSON formatted list of discovery rules """ client = get_zabbix_client() params = {"output": output} if itemids: params["itemids"] = itemids if hostids: params["hostids"] = hostids if templateids: params["templateids"] = templateids if search: params["search"] = search if filter: params["filter"] = filter result = client.discoveryrule.get(**params) return format_response(result)