Skip to main content
Glama
itunified-io

mcp-opnsense

by itunified-io

opnsense_route_gateway_update

Update an existing gateway's monitoring, IP, weight, priority, or enabled state. Confirmation required before changes are applied.

Instructions

Update an existing gateway's settings (toggle monitoring, set monitor IP, change weight/priority, enable/disable). Round-trips current config and only overrides explicitly provided fields. After updating, call opnsense_route_gateway_apply to activate the change. DESTRUCTIVE: requires explicit confirmation.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
uuidYesGateway UUID (from opnsense_route_gateway_list)
monitor_disableNoDisable gateway monitoring (true = no health probe)
monitorNoMonitor IP address (used when monitor_disable=false). Empty string clears it.
disabledNoDisable the gateway entirely
defaultgwNoMark as default gateway
descriptionNoHuman-readable description
weightNoLoad-balancing weight (1-30)
priorityNoFailover priority (1-255, lower = higher priority)
confirmYesMust be true to confirm the update

Implementation Reference

  • Zod schema validating inputs for opnsense_route_gateway_update: uuid (required), monitor_disable, monitor, disabled, defaultgw, description, weight (1-30), priority (1-255), confirm (must be true).
    const GatewayUpdateSchema = z.object({
      uuid: UuidSchema,
      monitor_disable: CoerceBoolean.optional(),
      monitor: z.string().optional(),
      disabled: CoerceBoolean.optional(),
      defaultgw: CoerceBoolean.optional(),
      description: z.string().optional(),
      weight: z.coerce.number().int().min(1).max(30).optional(),
      priority: z.coerce.number().int().min(1).max(255).optional(),
      confirm: ConfirmTrue("confirm must be true to proceed with the gateway update"),
    });
  • Handler logic for opnsense_route_gateway_update: parses args via GatewayUpdateSchema, round-trips current gateway config via GET /routing/settings/getGateway/{uuid}, overrides only explicitly provided fields, builds flat object with bool-to-flag conversion, then POSTs to /routing/settings/setGateway/{uuid}.
    case "opnsense_route_gateway_update": {
      const parsed = GatewayUpdateSchema.parse(args);
    
      // Round-trip: get current state, flatten multi-selects, override only provided fields
      const current = (await client.get<{ gateway_item?: Record<string, unknown> }>(
        `/routing/settings/getGateway/${encodeURIComponent(parsed.uuid)}`,
      ))?.gateway_item ?? {};
    
      const flat: Record<string, unknown> = {
        name: extractSelected(current["name"]) ?? current["name"],
        descr: parsed.description ?? (extractSelected(current["descr"]) ?? current["descr"] ?? ""),
        interface: extractSelected(current["interface"]) ?? "",
        ipprotocol: extractSelected(current["ipprotocol"]) ?? "inet",
        gateway: extractSelected(current["gateway"]) ?? current["gateway"] ?? "",
        defaultgw:
          boolToFlag(parsed.defaultgw) ??
          (extractSelected(current["defaultgw"]) ?? current["defaultgw"] ?? "0"),
        fargw: extractSelected(current["fargw"]) ?? current["fargw"] ?? "",
        monitor_disable:
          boolToFlag(parsed.monitor_disable) ??
          (extractSelected(current["monitor_disable"]) ?? current["monitor_disable"] ?? "0"),
        monitor_noroute:
          extractSelected(current["monitor_noroute"]) ?? current["monitor_noroute"] ?? "",
        monitor:
          parsed.monitor !== undefined
            ? parsed.monitor
            : (extractSelected(current["monitor"]) ?? current["monitor"] ?? ""),
        force_down: extractSelected(current["force_down"]) ?? current["force_down"] ?? "",
        priority:
          parsed.priority !== undefined
            ? String(parsed.priority)
            : (extractSelected(current["priority"]) ?? current["priority"] ?? "255"),
        weight:
          parsed.weight !== undefined
            ? String(parsed.weight)
            : (extractSelected(current["weight"]) ?? current["weight"] ?? "1"),
        latencylow: extractSelected(current["latencylow"]) ?? current["latencylow"] ?? "",
        latencyhigh: extractSelected(current["latencyhigh"]) ?? current["latencyhigh"] ?? "",
        losslow: extractSelected(current["losslow"]) ?? current["losslow"] ?? "",
        losshigh: extractSelected(current["losshigh"]) ?? current["losshigh"] ?? "",
        interval: extractSelected(current["interval"]) ?? current["interval"] ?? "",
        time_period: extractSelected(current["time_period"]) ?? current["time_period"] ?? "",
        loss_interval: extractSelected(current["loss_interval"]) ?? current["loss_interval"] ?? "",
        data_length: extractSelected(current["data_length"]) ?? current["data_length"] ?? "",
        disabled:
          boolToFlag(parsed.disabled) ??
          (extractSelected(current["disabled"]) ?? current["disabled"] ?? "0"),
      };
    
      const result = await client.post(
        `/routing/settings/setGateway/${encodeURIComponent(parsed.uuid)}`,
        { gateway_item: flat },
      );
      return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
    }
  • Tool definition entry in routingToolDefinitions array: registers name 'opnsense_route_gateway_update', description, and inputSchema (matching GatewayUpdateSchema) for ListTools capability.
    {
      name: "opnsense_route_gateway_update",
      description: "Update an existing gateway's settings (toggle monitoring, set monitor IP, change weight/priority, enable/disable). Round-trips current config and only overrides explicitly provided fields. After updating, call opnsense_route_gateway_apply to activate the change. DESTRUCTIVE: requires explicit confirmation.",
      inputSchema: {
        type: "object" as const,
        properties: {
          uuid: { type: "string", description: "Gateway UUID (from opnsense_route_gateway_list)" },
          monitor_disable: { type: "boolean", description: "Disable gateway monitoring (true = no health probe)" },
          monitor: { type: "string", description: "Monitor IP address (used when monitor_disable=false). Empty string clears it." },
          disabled: { type: "boolean", description: "Disable the gateway entirely" },
          defaultgw: { type: "boolean", description: "Mark as default gateway" },
          description: { type: "string", description: "Human-readable description" },
          weight: { type: "number", description: "Load-balancing weight (1-30)" },
          priority: { type: "number", description: "Failover priority (1-255, lower = higher priority)" },
          confirm: { type: "boolean", description: "Must be true to confirm the update", enum: [true] },
        },
        required: ["uuid", "confirm"],
      },
  • src/index.ts:67-67 (registration)
    Registration: routes all routingToolDefinitions (including opnsense_route_gateway_update) to handleRoutingTool in the MCP server's tool handler map.
    for (const def of routingToolDefinitions) toolHandlers.set(def.name, handleRoutingTool);
  • boolToFlag helper: converts JavaScript boolean to OPNsense '0'/'1' string representation, used for monitor_disable, defaultgw, and disabled fields.
    function boolToFlag(v: boolean | undefined): string | undefined {
      if (v === undefined) return undefined;
      return v ? "1" : "0";
    }
Behavior3/5

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

With no annotations, the description must disclose behavioral traits. It states the round-trip partial update behavior and the destructive/confirmation requirement. However, it does not explain error conditions, validation, or what happens on failure.

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 four efficient sentences, each serving a purpose: purpose, behavior, activation step, and warning. No wasted words, front-loaded with key information.

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?

No output schema is provided, and the description does not specify the return value or response format. While the round-trip behavior and activation step are covered, a complete tool definition should indicate what the agent can expect back.

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 description coverage is 100%, so each parameter is well-documented in the schema. The description adds overarching context (round-trip, only override provided fields) but does not enrich individual parameter meanings beyond the schema.

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?

The description explicitly states 'Update an existing gateway's settings' and lists specific fields (monitoring, monitor IP, weight/priority, enable/disable). It distinguishes from sibling tools like opnsense_route_gateway_apply by noting that an apply call is needed after update.

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?

The description explains the round-trip behavior (only overrides provided fields) and directs the agent to call opnsense_route_gateway_apply afterward. It also warns 'DESTRUCTIVE: requires explicit confirmation,' tying to the confirm parameter. It could explicitly mention alternatives but is clear.

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