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

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()

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