Skip to main content
Glama
mpeirone

zabbix-mcp-server

host_create

Quickly add a new host to Zabbix monitoring by specifying host name, groups, interfaces, and templates. Configure inventory mode and status for precise host management.

Instructions

Create a new host in Zabbix.

Args:
    host: Host name
    groups: List of host groups (format: [{"groupid": "1"}])
    interfaces: List of host interfaces
    templates: List of templates to link (format: [{"templateid": "1"}])
    inventory_mode: Inventory mode (-1=disabled, 0=manual, 1=automatic)
    status: Host status (0=enabled, 1=disabled)
    
Returns:
    str: JSON formatted creation result

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
groupsYes
hostYes
interfacesYes
inventory_modeNo
statusNo
templatesNo

Implementation Reference

  • The core handler function for the 'host_create' MCP tool. It is registered via the @mcp.tool() decorator. The function signature and docstring define the input schema. It validates read-only mode, gets the Zabbix client, prepares parameters, calls client.host.create, and formats the JSON response.
    @mcp.tool()
    def host_create(host: str, groups: List[Dict[str, str]], 
                    interfaces: List[Dict[str, Any]],
                    templates: Optional[List[Dict[str, str]]] = None,
                    inventory_mode: int = -1,
                    status: int = 0) -> str:
        """Create a new host in Zabbix.
        
        Args:
            host: Host name
            groups: List of host groups (format: [{"groupid": "1"}])
            interfaces: List of host interfaces
            templates: List of templates to link (format: [{"templateid": "1"}])
            inventory_mode: Inventory mode (-1=disabled, 0=manual, 1=automatic)
            status: Host status (0=enabled, 1=disabled)
            
        Returns:
            str: JSON formatted creation result
        """
        validate_read_only()
        
        client = get_zabbix_client()
        params = {
            "host": host,
            "groups": groups,
            "interfaces": interfaces,
            "inventory_mode": inventory_mode,
            "status": status
        }
        
        if templates:
            params["templates"] = templates
        
        result = client.host.create(**params)
        return format_response(result)
  • Helper function called by host_create to ensure the server is not in read-only mode before performing write operations.
    def validate_read_only() -> None:
        """Validate that write operations are allowed.
        
        Raises:
            ValueError: If server is in read-only mode
        """
        if is_read_only():
            raise ValueError("Server is in read-only mode - write operations are not allowed")
  • Helper function used by host_create to format the API response as indented JSON string.
    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)
  • Helper function called by host_create to obtain an authenticated ZabbixAPI client instance.
    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
  • The @mcp.tool() decorator registers the host_create function as an MCP tool with the name 'host_create'.
    @mcp.tool()
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It states this is a creation operation (implying mutation) but doesn't cover critical aspects like authentication requirements, error conditions (e.g., invalid group IDs), side effects, or whether the operation is idempotent. The return value is mentioned but not explained in terms of success/failure indicators.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is well-structured with clear sections (Args, Returns) and uses bullet-like formatting for parameters. Every sentence adds value, with no redundant information. It could be slightly more concise by integrating the format examples into the parameter descriptions more seamlessly, but overall it's efficient.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a creation tool with 6 parameters, no annotations, and no output schema, the description does a decent job covering parameter semantics but lacks behavioral context. It explains what to provide but not how the tool behaves, what errors might occur, or what the return value actually contains. This leaves gaps for safe and effective usage.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Given 0% schema description coverage, the description compensates fully by providing clear semantics for all 6 parameters. It explains what each parameter represents (e.g., 'host: Host name'), provides format examples for complex parameters (groups, templates), and documents enum values for inventory_mode and status. This adds significant value beyond the bare schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb ('Create') and resource ('new host in Zabbix'), making the purpose immediately understandable. However, it doesn't explicitly differentiate from sibling tools like 'host_update' or 'template_create', which would require mentioning it's specifically for initial creation rather than modification.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives like 'host_update' or 'template_create'. It doesn't mention prerequisites (e.g., existing host groups), nor does it explain when creation might fail (e.g., duplicate host names). The absence of usage context leaves the agent without decision-making criteria.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/mpeirone/zabbix-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server