Skip to main content
Glama
dkruyt

Hetzner Cloud MCP Server

by dkruyt

get_firewall

Retrieve detailed configuration and status information for a specific Hetzner Cloud firewall using its unique ID to manage network security rules.

Instructions

Get details about a specific firewall. Returns detailed information about a firewall identified by its ID. Example: - Get firewall details: {"firewall_id": 12345}

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
paramsYes

Implementation Reference

  • The main handler function for the 'get_firewall' tool. It takes a firewall_id parameter, fetches the firewall using the Hetzner Cloud client, and returns its details as a dictionary using the firewall_to_dict helper.
    @mcp.tool() def get_firewall(params: FirewallIdParam) -> Dict[str, Any]: """ Get details about a specific firewall. Returns detailed information about a firewall identified by its ID. Example: - Get firewall details: {"firewall_id": 12345} """ try: firewall = client.firewalls.get_by_id(params.firewall_id) if not firewall: return {"error": f"Firewall with ID {params.firewall_id} not found"} return {"firewall": firewall_to_dict(firewall)} except Exception as e: return {"error": f"Failed to get firewall: {str(e)}"}
  • Pydantic input schema for the get_firewall tool, defining the required firewall_id integer parameter.
    class FirewallIdParam(BaseModel): firewall_id: int = Field(..., description="The ID of the firewall")
  • Helper function that converts a Hetzner Cloud Firewall object to a dictionary format suitable for JSON serialization, used by get_firewall and other firewall tools.
    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, }

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