apiinfo_version
Retrieve Zabbix API version details in JSON format. This tool provides essential version information for seamless integration and monitoring setup.
Instructions
Get Zabbix API version information.
Returns:
str: JSON formatted API version info
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Input Schema (JSON Schema)
{
"properties": {},
"type": "object"
}
Implementation Reference
- src/zabbix_mcp_server.py:1482-1491 (handler)The handler function for the 'apiinfo_version' tool. It retrieves the Zabbix API version using the ZabbixAPI client and formats the result as JSON.def apiinfo_version() -> str: """Get Zabbix API version information. Returns: str: JSON formatted API version info """ client = get_zabbix_client() result = client.apiinfo.version() return format_response(result)
- src/zabbix_mcp_server.py:38-79 (helper)Helper function that initializes and returns the authenticated Zabbix API client, used by the apiinfo_version tool.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
- src/zabbix_mcp_server.py:91-100 (helper)Helper function that formats the API response data as a JSON string, used by the apiinfo_version tool.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)