hostgroup_get
Retrieve Zabbix host groups using group IDs, search criteria, or filters. Returns a JSON-formatted list for integration with AI assistants or monitoring workflows.
Instructions
Get host groups from Zabbix.
Args:
groupids: List of group IDs to retrieve
output: Output format
search: Search criteria
filter: Filter criteria
Returns:
str: JSON formatted list of host groups
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| filter | No | ||
| groupids | No | ||
| output | No | extend | |
| search | No |
Input Schema (JSON Schema)
{
"properties": {
"filter": {
"anyOf": [
{
"additionalProperties": true,
"type": "object"
},
{
"type": "null"
}
],
"default": null,
"title": "Filter"
},
"groupids": {
"anyOf": [
{
"items": {
"type": "string"
},
"type": "array"
},
{
"type": "null"
}
],
"default": null,
"title": "Groupids"
},
"output": {
"default": "extend",
"title": "Output",
"type": "string"
},
"search": {
"anyOf": [
{
"additionalProperties": {
"type": "string"
},
"type": "object"
},
{
"type": "null"
}
],
"default": null,
"title": "Search"
}
},
"type": "object"
}
Implementation Reference
- src/zabbix_mcp_server.py:241-268 (handler)The main handler function for the 'hostgroup_get' tool. It is registered via the @mcp.tool() decorator and implements the logic to fetch host groups from the Zabbix API based on provided parameters (groupids, output, search, filter), formats the params, calls client.hostgroup.get(**params), and returns JSON-formatted result using format_response.@mcp.tool() def hostgroup_get(groupids: Optional[List[str]] = None, output: Union[str, List[str]] = "extend", search: Optional[Dict[str, str]] = None, filter: Optional[Dict[str, Any]] = None) -> str: """Get host groups from Zabbix. Args: groupids: List of group IDs to retrieve output: Output format (extend or list of specific fields) search: Search criteria filter: Filter criteria Returns: str: JSON formatted list of host groups """ client = get_zabbix_client() params = {"output": output} if groupids: params["groupids"] = groupids if search: params["search"] = search if filter: params["filter"] = filter result = client.hostgroup.get(**params) return format_response(result)