Skip to main content
Glama
dkruyt

Hetzner Cloud MCP Server

by dkruyt

update_firewall

Modify firewall configuration by updating its name or labels in Hetzner Cloud to maintain accurate resource identification and organization.

Instructions

Update a firewall.

Updates the name or labels of an existing firewall.

Example:
- Update name: {"firewall_id": 12345, "name": "new-name"}
- Update labels: {"firewall_id": 12345, "labels": {"key": "value"}}

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
paramsYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The handler function for the 'update_firewall' tool. Updates the name and/or labels of a specified Hetzner Cloud firewall using the hcloud client.
    def update_firewall(params: UpdateFirewallParams) -> Dict[str, Any]:
        """
        Update a firewall.
        
        Updates the name or labels of an existing firewall.
        
        Example:
        - Update name: {"firewall_id": 12345, "name": "new-name"}
        - Update labels: {"firewall_id": 12345, "labels": {"key": "value"}}
        """
        try:
            firewall = client.firewalls.get_by_id(params.firewall_id)
            if not firewall:
                return {"error": f"Firewall with ID {params.firewall_id} not found"}
            
            updated_firewall = client.firewalls.update(
                firewall=firewall,
                name=params.name,
                labels=params.labels
            )
            
            return {"firewall": firewall_to_dict(updated_firewall)}
        except Exception as e:
            return {"error": f"Failed to update firewall: {str(e)}"}
  • Pydantic BaseModel schema defining the input parameters for the update_firewall tool.
    class UpdateFirewallParams(BaseModel):
        firewall_id: int = Field(..., description="The ID of the firewall")
        name: Optional[str] = Field(None, description="New name for the firewall")
        labels: Optional[Dict[str, str]] = Field(None, description="User-defined labels (key-value pairs)")
  • Helper function used by the update_firewall tool (and others) to serialize a Firewall object into a dictionary format for the response.
    def firewall_to_dict(firewall: Firewall) -> Dict[str, Any]:
        """Convert a Firewall object to a dictionary with relevant information."""
        # Convert rules to dict
        rules = []
        if firewall.rules:
            for rule in firewall.rules:
                rule_dict = {
                    "direction": rule.direction,
                    "protocol": rule.protocol,
                    "source_ips": rule.source_ips,
                }
                if rule.port:
                    rule_dict["port"] = rule.port
                if rule.destination_ips:
                    rule_dict["destination_ips"] = rule.destination_ips
                if rule.description:
                    rule_dict["description"] = rule.description
                rules.append(rule_dict)
        
        # Convert applied_to resources to dict
        applied_to = []
        if firewall.applied_to:
            for resource in firewall.applied_to:
                resource_dict = {"type": resource.type}
                if resource.server:
                    resource_dict["server"] = {"id": resource.server.id, "name": resource.server.name}
                if resource.label_selector:
                    resource_dict["label_selector"] = {"selector": resource.label_selector.selector}
                if getattr(resource, 'applied_to_resources', None):
                    applied_resources = []
                    for applied_resource in resource.applied_to_resources:
                        applied_resource_dict = {"type": applied_resource.type}
                        if applied_resource.server:
                            applied_resource_dict["server"] = {"id": applied_resource.server.id, "name": applied_resource.server.name}
                        applied_resources.append(applied_resource_dict)
                    resource_dict["applied_to_resources"] = applied_resources
                applied_to.append(resource_dict)
        
        return {
            "id": firewall.id,
            "name": firewall.name,
            "rules": rules,
            "applied_to": applied_to,
            "labels": firewall.labels,
            "created": firewall.created.isoformat() if firewall.created else None,
        }
Behavior2/5

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

With no annotations provided, the description carries full burden but offers minimal behavioral insight. It states this is an update operation (implying mutation) and provides examples, but doesn't disclose permissions needed, whether changes are reversible, rate limits, error conditions, or what the output contains. For a mutation tool with zero annotation coverage, this is inadequate.

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

Conciseness5/5

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

The description is perfectly front-loaded with a clear purpose statement, followed by specific details and practical examples. Every sentence earns its place with zero wasted words, making it easy for an agent to parse quickly.

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?

Given this is a mutation tool with no annotations but with an output schema (which handles return values), the description covers basic purpose and parameters well. However, it lacks critical context about behavioral traits (e.g., permissions, side effects) and usage guidelines, making it minimally adequate but incomplete for safe operation.

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

Parameters4/5

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

Schema description coverage is 0%, so the description must compensate. It effectively explains the three parameters: 'firewall_id' (implied as required), 'name' (new name), and 'labels' (user-defined key-value pairs), with clear examples showing usage. This adds significant meaning beyond the bare schema, though it doesn't cover all edge cases like null handling.

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 action ('Update') and resource ('firewall'), specifying it updates 'name or labels of an existing firewall'. This distinguishes it from sibling tools like 'create_firewall' or 'delete_firewall', though it doesn't explicitly differentiate from 'set_firewall_rules' which might update different aspects.

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 'set_firewall_rules' or other update operations. It mentions updating 'existing firewall' but doesn't specify prerequisites, constraints, or when-not-to-use scenarios, leaving the agent without contextual direction.

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

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/dkruyt/mcp-hetzner'

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