Skip to main content
Glama
itunified-io

mcp-opnsense

by itunified-io

opnsense_fw_add_rule

Add a firewall rule to OPNsense by specifying action, direction, interface, protocol, source, destination, and optional port. Apply afterwards to activate.

Instructions

Add a new firewall filter rule. Run opnsense_fw_apply afterwards to activate.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
actionYesRule action
directionYesTraffic direction
interfaceNoInterface name (e.g. 'lan', 'wan')
protocolNoProtocol
source_netNoSource network (CIDR, alias, or 'any')
destination_netNoDestination network (CIDR, alias, or 'any')
destination_portNoDestination port or range (e.g. '443', '80-443')
descriptionNoRule description

Implementation Reference

  • Tool definition (registration) for opnsense_fw_add_rule — defines name, description, and input schema for the MCP tool list
    export const firewallToolDefinitions = [
      {
        name: "opnsense_fw_list_rules",
        description: "List all firewall filter rules",
        inputSchema: { type: "object" as const, properties: {} },
      },
      {
        name: "opnsense_fw_add_rule",
  • Zod input validation schema for opnsense_fw_add_rule — validates action (pass/block/reject), direction (in/out), and optional fields
    const AddRuleSchema = z.object({
      action: FirewallActionSchema,
      direction: DirectionSchema,
      interface: z.string().optional(),
      protocol: ProtocolSchema.optional(),
      source_net: z.string().optional(),
      destination_net: z.string().optional(),
      destination_port: z.string().optional(),
      description: z.string().optional(),
    });
  • Handler logic for opnsense_fw_add_rule — parses args via AddRuleSchema, POSTs to /firewall/filter/addRule with default values, returns JSON result
    case "opnsense_fw_add_rule": {
      const parsed = AddRuleSchema.parse(args);
      const result = await client.post("/firewall/filter/addRule", {
        rule: {
          enabled: "1",
          action: parsed.action,
          direction: parsed.direction,
          interface: parsed.interface ?? "",
          ipprotocol: "inet",
          protocol: parsed.protocol ?? "any",
          source_net: parsed.source_net ?? "any",
          destination_net: parsed.destination_net ?? "any",
          destination_port: parsed.destination_port ?? "",
          description: parsed.description ?? "",
        },
      });
      return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
    }
  • src/index.ts:60-60 (registration)
    Registers the handleFirewallTool handler for all firewall tool definitions, including opnsense_fw_add_rule
    for (const def of firewallToolDefinitions) toolHandlers.set(def.name, handleFirewallTool);
  • Reusable Zod schemas (FirewallActionSchema, DirectionSchema, ProtocolSchema) used by the AddRuleSchema validation
    export const ProtocolSchema = z.enum(["TCP", "UDP", "ICMP", "any"]);
    
    export const FirewallActionSchema = z.enum(["pass", "block", "reject"]);
    
    export const DirectionSchema = z.enum(["in", "out"]);
Behavior3/5

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

Discloses activation delay via fw_apply, but absent annotation burden means missing authorization, idempotency, side effects on existing rules.

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?

Two efficient sentences: first states purpose, second gives critical activation instruction. No fluff.

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?

Adequate for a simple tool but missing context like rule ordering, duplicate handling, validation, and required permissions.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema covers 100% of parameters; description adds no extra semantics beyond what schema already provides.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

Description clearly states action (Add) and resource (firewall filter rule), distinguishing it from sibling tools like delete, list, apply.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Provides explicit post-action step (run fw_apply), but lacks guidance on when to use this vs update_rule or ordering considerations.

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/itunified-io/mcp-opnsense'

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