Skip to main content
Glama
dkruyt

Hetzner Cloud MCP Server

by dkruyt

list_firewalls

Retrieve all firewall configurations from your Hetzner Cloud account to monitor and manage network security rules.

Instructions

List all firewalls in your Hetzner Cloud account.

Returns a list of all firewall instances with their details.

Example:
- Basic list: list_firewalls()

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The main handler function for the 'list_firewalls' tool. It retrieves all firewalls using the Hetzner Cloud client and formats the output using the firewall_to_dict helper.
    @mcp.tool()
    def list_firewalls() -> Dict[str, Any]:
        """
        List all firewalls in your Hetzner Cloud account.
        
        Returns a list of all firewall instances with their details.
        
        Example:
        - Basic list: list_firewalls()
        """
        try:
            firewalls = client.firewalls.get_all()
            return {
                "firewalls": [firewall_to_dict(firewall) for firewall in firewalls]
            }
        except Exception as e:
            return {"error": f"Failed to list firewalls: {str(e)}"}
  • Helper function that converts a Hetzner Cloud Firewall object into a structured dictionary, including detailed rules and applied resources, used by the list_firewalls handler.
    # Helper function to convert Firewall object to dict
    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 the full burden of behavioral disclosure. It states the tool returns a list with details, which is helpful, but lacks critical information such as pagination behavior, rate limits, authentication requirements, or error handling. For a read operation in a cloud API context, this leaves significant gaps in understanding how the tool behaves.

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 concise and front-loaded, with the core purpose in the first sentence. The second sentence adds useful detail about the return value, and the example is minimal but illustrative. There's no wasted text, though it could be slightly more structured (e.g., bullet points for key points).

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 the tool's simplicity (0 parameters, output schema exists), the description is adequate but incomplete. It covers the basic purpose and return value, but with no annotations and missing behavioral details (e.g., pagination), it doesn't fully prepare an agent for robust use. The output schema likely handles return values, so that gap is mitigated.

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?

The input schema has 0 parameters with 100% coverage, so no parameter documentation is needed. The description correctly omits parameter details, and the example 'list_firewalls()' reinforces the lack of parameters. This is efficient and appropriate, though not a 5 since it doesn't add any semantic value beyond the schema (which is fine given the context).

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 ('List') and resource ('all firewalls in your Hetzner Cloud account'), making the purpose unambiguous. It distinguishes from siblings like 'get_firewall' (singular) by emphasizing 'all' firewalls. However, it doesn't explicitly contrast with other list tools (e.g., 'list_servers'), so it's not a perfect 5.

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. It doesn't mention when to use 'list_firewalls' instead of 'get_firewall' (for a single firewall) or other list tools, nor does it specify prerequisites or exclusions. The example shows basic usage but lacks contextual advice.

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