Skip to main content
Glama
jsebgiraldo

OpenWRT SSH MCP Server

by jsebgiraldo

openwrt_get_firewall_rules

Retrieve current iptables firewall rules from an OpenWRT router via SSH for monitoring and network management.

Instructions

Get current firewall rules (iptables)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The actual handler implementation that executes 'iptables -L -n -v' to retrieve firewall rules from the OpenWRT router
    @staticmethod
    async def get_firewall_rules() -> dict[str, Any]:
        """
        Get firewall rules.
        
        Returns:
            dict: Firewall rules
        """
        command = "iptables -L -n -v"
        result = await OpenWRTTools.execute_command(command)
    
        if result["success"]:
            return {
                "success": True,
                "rules": result["output"],
            }
        else:
            return {
                "success": False,
                "error": result["error"],
            }
  • Tool schema definition registered with MCP server - defines name, description, and input validation (no parameters required)
        name="openwrt_get_firewall_rules",
        description="Get current firewall rules (iptables)",
        inputSchema={
            "type": "object",
            "properties": {},
            "required": [],
        },
    ),
  • Tool call routing - maps the tool name to its handler method in OpenWRTTools class
    elif name == "openwrt_get_firewall_rules":
        result = await OpenWRTTools.get_firewall_rules()
  • The execute_command helper method used by get_firewall_rules - validates commands via SecurityValidator and executes them via ssh_client
    @staticmethod
    async def execute_command(command: str) -> dict[str, Any]:
        """
        Execute a validated command on the OpenWRT router.
        
        Args:
            command: Shell command to execute
            
        Returns:
            dict: Execution result
        """
        # Validate command
        is_valid, error_msg = SecurityValidator.validate_command(command)
        if not is_valid:
            return {
                "success": False,
                "error": error_msg,
                "output": "",
            }
    
        # Execute
        await ssh_client.ensure_connected()
        result = await ssh_client.execute(command)
    
        return {
            "success": result["success"],
            "output": result["stdout"],
            "error": result["stderr"],
            "exit_code": result["exit_code"],
            "execution_time": result["execution_time"],
        }
Behavior2/5

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

No annotations are provided, so the description carries the full burden. It states 'Get current firewall rules' which implies a read-only operation, but doesn't disclose behavioral traits such as whether it requires specific permissions, how it handles errors, or if it returns live data versus cached information. This is a significant gap for a tool with zero annotation coverage.

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 a single, efficient sentence with zero waste. It's front-loaded with the core purpose and uses clear terminology, making it appropriately sized for a simple tool.

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 has no parameters, no annotations, and no output schema, the description is minimally adequate. It states what the tool does, but lacks details on return values, error handling, or usage context. For a read operation, this is acceptable but leaves gaps in understanding the full behavior.

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 tool has 0 parameters, and schema description coverage is 100%, so no parameter information is needed. The description doesn't add param details beyond the schema, but with no parameters, a baseline score of 4 is appropriate as there's nothing to compensate for.

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 'Get' and the resource 'current firewall rules (iptables)', making the purpose specific and understandable. However, it doesn't explicitly differentiate from sibling tools like 'openwrt_read_config' which might also retrieve configuration data, though the focus on firewall rules is distinct.

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?

No guidance is provided on when to use this tool versus alternatives. For example, it doesn't mention if this is for real-time status versus configuration files, or how it compares to 'openwrt_read_config' for firewall-related data. The description lacks any context on prerequisites or exclusions.

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/jsebgiraldo/openwrt_ssh_mcp'

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