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"], }

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