Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 54 additions & 30 deletions src/zabbix_mcp_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def host_get(hostids: Optional[List[str]] = None,
hostids: List of host IDs to retrieve
groupids: List of host group IDs to filter by
templateids: List of template IDs to filter by
output: Output format (extend or list of specific fields)
output: "extend" or list of fields to return
search: Search criteria
filter: Filter criteria
limit: Maximum number of results
Expand All @@ -130,7 +130,7 @@ def host_get(hostids: Optional[List[str]] = None,
str: JSON formatted list of hosts
"""
client = get_zabbix_client()
params = {"output": output}
params: Dict[str, Any] = {"output": output}

if hostids:
params["hostids"] = hostids
Expand Down Expand Up @@ -243,15 +243,15 @@ def hostgroup_get(groupids: Optional[List[str]] = None,

Args:
groupids: List of group IDs to retrieve
output: Output format (extend or list of specific fields)
output: "extend" or list of fields to return
search: Search criteria
filter: Filter criteria

Returns:
str: JSON formatted list of host groups
"""
client = get_zabbix_client()
params = {"output": output}
params: Dict[str, Any] = {"output": output}

if groupids:
params["groupids"] = groupids
Expand Down Expand Up @@ -333,7 +333,7 @@ def item_get(itemids: Optional[List[str]] = None,
hostids: List of host IDs to filter by
groupids: List of host group IDs to filter by
templateids: List of template IDs to filter by
output: Output format (extend or list of specific fields)
output: "extend" or list of fields to return
search: Search criteria
filter: Filter criteria
limit: Maximum number of results
Expand All @@ -342,7 +342,7 @@ def item_get(itemids: Optional[List[str]] = None,
str: JSON formatted list of items
"""
client = get_zabbix_client()
params = {"output": output}
params: Dict[str, Any] = {"output": output}

if itemids:
params["itemids"] = itemids
Expand Down Expand Up @@ -464,6 +464,12 @@ def trigger_get(triggerids: Optional[List[str]] = None,
output: Union[str, List[str]] = "extend",
search: Optional[Dict[str, str]] = None,
filter: Optional[Dict[str, Any]] = None,
monitored: Optional[bool] = None,
expandDescription: Optional[bool] = None,
selectHosts: Optional[Union[str, List[str]]] = None,
selectLastEvent: Optional[Union[str, List[str]]] = None,
sortfield: Optional[List[str]] = None,
sortorder: Optional[str] = None,
limit: Optional[int] = None) -> str:
"""Get triggers from Zabbix with optional filtering.

Expand All @@ -472,16 +478,22 @@ def trigger_get(triggerids: Optional[List[str]] = None,
hostids: List of host IDs to filter by
groupids: List of host group 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
limit: Maximum number of results
output: "extend" or list of fields to return.
monitored: Return only triggers on monitored hosts/items.
search: Search criteria.
filter: Filter criteria.
expandDescription: Expand macros in description.
selectHosts: "extend" or list of host fields to include.
selectLastEvent: "extend" or list of last event fields to include.
sortfield: Fields to sort by.
sortorder: "ASC" or "DESC".
limit: Maximum number of results.

Returns:
str: JSON formatted list of triggers
"""
client = get_zabbix_client()
params = {"output": output}
params: Dict[str, Any] = {"output": output}

if triggerids:
params["triggerids"] = triggerids
Expand All @@ -497,7 +509,19 @@ def trigger_get(triggerids: Optional[List[str]] = None,
params["filter"] = filter
if limit:
params["limit"] = limit

if monitored:
params["monitored"] = monitored
if expandDescription:
params["expandDescription"] = expandDescription
if selectHosts:
params["selectHosts"] = selectHosts
if selectLastEvent:
params["selectLastEvent"] = selectLastEvent
if sortfield:
params["sortfield"] = sortfield
if sortorder:
params["sortorder"] = sortorder

result = client.trigger.get(**params)
return format_response(result)

Expand Down Expand Up @@ -600,15 +624,15 @@ def template_get(templateids: Optional[List[str]] = None,
templateids: List of template IDs to retrieve
groupids: List of host group IDs to filter by
hostids: List of host IDs to filter by
output: Output format (extend or list of specific fields)
output: "extend" or list of fields to return
search: Search criteria
filter: Filter criteria

Returns:
str: JSON formatted list of templates
"""
client = get_zabbix_client()
params = {"output": output}
params: Dict[str, Any] = {"output": output}

if templateids:
params["templateids"] = templateids
Expand Down Expand Up @@ -722,7 +746,7 @@ def problem_get(eventids: Optional[List[str]] = None,
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)
output: "extend" or list of fields to return
time_from: Start time (Unix timestamp)
time_till: End time (Unix timestamp)
recent: Only recent problems
Expand All @@ -733,7 +757,7 @@ def problem_get(eventids: Optional[List[str]] = None,
str: JSON formatted list of problems
"""
client = get_zabbix_client()
params = {"output": output}
params: Dict[str, Any] = {"output": output}

if eventids:
params["eventids"] = eventids
Expand Down Expand Up @@ -775,7 +799,7 @@ def event_get(eventids: Optional[List[str]] = None,
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)
output: "extend" or list of fields to return
time_from: Start time (Unix timestamp)
time_till: End time (Unix timestamp)
limit: Maximum number of results
Expand All @@ -784,7 +808,7 @@ def event_get(eventids: Optional[List[str]] = None,
str: JSON formatted list of events
"""
client = get_zabbix_client()
params = {"output": output}
params: Dict[str, Any] = {"output": output}

if eventids:
params["eventids"] = eventids
Expand Down Expand Up @@ -914,15 +938,15 @@ def user_get(userids: Optional[List[str]] = None,

Args:
userids: List of user IDs to retrieve
output: Output format (extend or list of specific fields)
output: "extend" or list of fields to return
search: Search criteria
filter: Filter criteria

Returns:
str: JSON formatted list of users
"""
client = get_zabbix_client()
params = {"output": output}
params: Dict[str, Any] = {"output": output}

if userids:
params["userids"] = userids
Expand Down Expand Up @@ -1035,13 +1059,13 @@ def maintenance_get(maintenanceids: Optional[List[str]] = None,
maintenanceids: List of maintenance IDs to retrieve
groupids: List of host group IDs to filter by
hostids: List of host IDs to filter by
output: Output format (extend or list of specific fields)
output: "extend" or list of fields to return

Returns:
str: JSON formatted list of maintenance periods
"""
client = get_zabbix_client()
params = {"output": output}
params: Dict[str, Any] = {"output": output}

if maintenanceids:
params["maintenanceids"] = maintenanceids
Expand Down Expand Up @@ -1161,15 +1185,15 @@ def graph_get(graphids: Optional[List[str]] = None,
graphids: List of graph 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)
output: "extend" or list of fields to return
search: Search criteria
filter: Filter criteria

Returns:
str: JSON formatted list of graphs
"""
client = get_zabbix_client()
params = {"output": output}
params: Dict[str, Any] = {"output": output}

if graphids:
params["graphids"] = graphids
Expand Down Expand Up @@ -1200,15 +1224,15 @@ def discoveryrule_get(itemids: Optional[List[str]] = None,
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)
output: "extend" or list of fields to return
search: Search criteria
filter: Filter criteria

Returns:
str: JSON formatted list of discovery rules
"""
client = get_zabbix_client()
params = {"output": output}
params: Dict[str, Any] = {"output": output}

if itemids:
params["itemids"] = itemids
Expand Down Expand Up @@ -1239,15 +1263,15 @@ def itemprototype_get(itemids: Optional[List[str]] = None,
itemids: List of item prototype IDs to retrieve
discoveryids: List of discovery rule IDs to filter by
hostids: List of host IDs to filter by
output: Output format (extend or list of specific fields)
output: "extend" or list of fields to return
search: Search criteria
filter: Filter criteria

Returns:
str: JSON formatted list of item prototypes
"""
client = get_zabbix_client()
params = {"output": output}
params: Dict[str, Any] = {"output": output}

if itemids:
params["itemids"] = itemids
Expand Down Expand Up @@ -1325,15 +1349,15 @@ def usermacro_get(globalmacroids: Optional[List[str]] = None,
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)
output: "extend" or list of fields to return
search: Search criteria
filter: Filter criteria

Returns:
str: JSON formatted list of global macros
"""
client = get_zabbix_client()
params = {"output": output}
params: Dict[str, Any] = {"output": output}

if globalmacroids:
params["globalmacroids"] = globalmacroids
Expand Down