Skip to main content
Glama

toggle_firewall_rule

Enable or disable a specific firewall rule on the OPNSense MCP Server by providing the rule's UUID. Simplifies firewall management for network security.

Instructions

Toggle firewall rule enabled/disabled

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
uuidYesFirewall rule UUID

Implementation Reference

  • Handler function for the firewall_toggle_rule tool. Calls OPNsense API to toggle the rule status, applies changes, emits event, updates cache, and returns success status.
    private async toggleRule(params: { uuid: string }): Promise<any> { try { const response = await this.api.post(`/api/firewall/filter/toggleRule/${params.uuid}`); if (response.data?.result === 'saved') { // Apply changes await this.applyChanges({}); // Emit event this.emit('firewall.rule.toggled', { uuid: params.uuid, enabled: response.data.enabled, }); // Invalidate cache this.ruleCache.delete(params.uuid); return { success: true, enabled: response.data.enabled === '1', message: 'Firewall rule toggled successfully', }; } throw new Error('Failed to toggle firewall rule'); } catch (error) { this.logger.error(`Error toggling firewall rule ${params.uuid}:`, error); throw error; } }
  • Registers the 'firewall_toggle_rule' MCP tool in the plugin's getTools() method, specifying name, description, input schema (requires uuid), and binds to toggleRule handler.
    name: 'firewall_toggle_rule', description: 'Toggle a firewall rule enabled/disabled', inputSchema: { type: 'object', properties: { uuid: { type: 'string', description: 'Rule UUID', }, }, required: ['uuid'], }, handler: this.toggleRule.bind(this), },
  • Input schema for firewall_toggle_rule tool requiring a single 'uuid' string property.
    inputSchema: { type: 'object', properties: { uuid: { type: 'string', description: 'Rule UUID', }, }, required: ['uuid'], },
  • Supporting toggle method in FirewallRuleResource class that retrieves rule, flips enabled state, and updates it. Used in scripts but not directly in MCP plugin handler.
    async toggle(uuid: string): Promise<boolean> { const rule = await this.get(uuid); if (!rule) { throw new Error(`Firewall rule ${uuid} not found`); } const newState = rule.enabled === '1' ? '0' : '1'; return this.update(uuid, { enabled: newState }); }

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/vespo92/OPNSenseMCP'

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