Skip to main content
Glama
dkruyt

Hetzner Cloud MCP Server

by dkruyt

remove_firewall_from_resources

Remove firewall protection from specific Hetzner Cloud servers or labeled resource groups to modify network access rules.

Instructions

Remove a firewall from resources.

Removes a firewall from multiple resources.

Examples:
- Remove from server: {"firewall_id": 12345, "resources": [{"type": "server", "server_id": 123}]}
- Remove by label: {"firewall_id": 12345, "resources": [{"type": "label_selector", "label_selector": "env=prod"}]}

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
paramsYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The handler function for the 'remove_firewall_from_resources' tool. It retrieves the firewall, converts input resources to Hetzner API objects, calls client.firewalls.remove_from_resources, and returns the actions.
    @mcp.tool()
    def remove_firewall_from_resources(params: FirewallResourcesParams) -> Dict[str, Any]:
        """
        Remove a firewall from resources.
        
        Removes a firewall from multiple resources.
        
        Examples:
        - Remove from server: {"firewall_id": 12345, "resources": [{"type": "server", "server_id": 123}]}
        - Remove by label: {"firewall_id": 12345, "resources": [{"type": "label_selector", "label_selector": "env=prod"}]}
        """
        try:
            firewall = client.firewalls.get_by_id(params.firewall_id)
            if not firewall:
                return {"error": f"Firewall with ID {params.firewall_id} not found"}
            
            # Convert resource parameters to FirewallResource objects
            resources = []
            for resource_param in params.resources:
                if resource_param.type == "server":
                    if not resource_param.server_id:
                        return {"error": "Server ID is required when resource type is 'server'"}
                    server = client.servers.get_by_id(resource_param.server_id)
                    if not server:
                        return {"error": f"Server with ID {resource_param.server_id} not found"}
                    resource = FirewallResource(type=resource_param.type, server=server)
                elif resource_param.type == "label_selector":
                    if not resource_param.label_selector:
                        return {"error": "Label selector is required when resource type is 'label_selector'"}
                    label_selector = FirewallResourceLabelSelector(selector=resource_param.label_selector)
                    resource = FirewallResource(type=resource_param.type, label_selector=label_selector)
                else:
                    return {"error": f"Invalid resource type: {resource_param.type}. Must be 'server' or 'label_selector'"}
                resources.append(resource)
            
            # Remove the firewall from the resources
            actions = client.firewalls.remove_from_resources(firewall, resources)
            
            # Format the response
            return {
                "success": True,
                "actions": [
                    {
                        "id": action.id,
                        "status": action.status,
                        "command": action.command,
                        "progress": action.progress,
                        "error": action.error,
                        "started": action.started.isoformat() if action.started else None,
                        "finished": action.finished.isoformat() if action.finished else None,
                    }
                    for action in actions
                ] if actions else None,
            }
        except Exception as e:
            return {"error": f"Failed to remove firewall from resources: {str(e)}"}
  • Pydantic model defining the input parameters for the remove_firewall_from_resources tool (shared with apply_firewall_to_resources).
    class FirewallResourcesParams(BaseModel):
        firewall_id: int = Field(..., description="The ID of the firewall")
        resources: List[FirewallResourceParam] = Field(..., description="List of resources to apply/remove the firewall to/from")
  • Pydantic model for individual firewall resource parameters used in FirewallResourcesParams.
    class FirewallResourceParam(BaseModel):
        type: str = Field(..., description="Type of resource ('server' or 'label_selector')")
        server_id: Optional[int] = Field(None, description="Server ID (required when type is 'server')")
        label_selector: Optional[str] = Field(None, description="Label selector (required when type is 'label_selector')")
  • The @mcp.tool() decorator registers the remove_firewall_from_resources function as an MCP tool.
    @mcp.tool()
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. It states the action ('removes') but doesn't mention important behavioral aspects: whether this operation requires specific permissions, whether it's reversible, potential side effects (e.g., network disruption), rate limits, or what happens if resources are already detached. The examples help but don't cover behavioral traits.

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 appropriately sized with three sentences: a clear purpose statement, a reinforcing sentence, and two helpful examples. The structure is front-loaded with the core purpose first. The examples could be slightly more concise 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?

Given this is a mutation tool with no annotations, 0% schema description coverage, but with an output schema (which reduces need to describe returns), the description is minimally adequate. It covers the basic operation and provides examples, but lacks important context about permissions, side effects, and error conditions that would be needed for safe use.

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

Parameters3/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. The examples provide concrete parameter usage (firewall_id and resources with type-specific fields), adding meaningful context beyond the bare schema. However, it doesn't explain all parameter semantics comprehensively (e.g., what happens with empty resources array, validation rules for label_selector).

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 ('Remove a firewall from resources') and specifies it works on multiple resources, which distinguishes it from simpler single-resource operations. However, it doesn't explicitly differentiate from sibling tools like 'detach_volume' or other firewall operations beyond the obvious name-based distinction.

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 'delete_firewall' (which might remove the firewall entirely) or 'set_firewall_rules' (which might modify rules rather than detachment). The examples show usage patterns but don't explain the context or prerequisites for using this operation.

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