usermacro_get
Retrieve global macros from Zabbix using optional filters like globalmacroids, hostids, or custom criteria. Output results in JSON format for integration or analysis.
Instructions
Get global macros from Zabbix with optional filtering.
Args:
globalmacroids: List of global macro IDs to retrieve
hostids: List of host IDs to filter by (for host macros)
output: Output format (extend, shorten, or specific fields)
search: Search criteria
filter: Filter criteria
Returns:
str: JSON formatted list of global macros
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| filter | No | ||
| globalmacroids | No | ||
| hostids | No | ||
| output | No | extend | |
| search | No |
Input Schema (JSON Schema)
{
"properties": {
"filter": {
"anyOf": [
{
"additionalProperties": true,
"type": "object"
},
{
"type": "null"
}
],
"default": null,
"title": "Filter"
},
"globalmacroids": {
"anyOf": [
{
"items": {
"type": "string"
},
"type": "array"
},
{
"type": "null"
}
],
"default": null,
"title": "Globalmacroids"
},
"hostids": {
"anyOf": [
{
"items": {
"type": "string"
},
"type": "array"
},
{
"type": "null"
}
],
"default": null,
"title": "Hostids"
},
"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:1446-1478 (handler)Handler function for the usermacro_get tool, decorated with @mcp.tool() for registration and execution. Retrieves user macros (global or host-specific) from Zabbix API.@mcp.tool() def usermacro_get(globalmacroids: Optional[List[str]] = None, hostids: Optional[List[str]] = None, output: Union[str, List[str]] = "extend", search: Optional[Dict[str, str]] = None, filter: Optional[Dict[str, Any]] = None) -> str: """Get global macros from Zabbix with optional filtering. Args: globalmacroids: List of global macro IDs to retrieve hostids: List of host IDs to filter by (for host macros) output: Output format (extend or list of specific fields) search: Search criteria filter: Filter criteria Returns: str: JSON formatted list of global macros """ client = get_zabbix_client() params = {"output": output} if globalmacroids: params["globalmacroids"] = globalmacroids if hostids: params["hostids"] = hostids if search: params["search"] = search if filter: params["filter"] = filter result = client.usermacro.get(**params) return format_response(result)