Skip to main content
Glama
itunified-io

mcp-opnsense

by itunified-io

opnsense_route_apply

Applies pending static route configuration changes to reconfigure routing on the OPNsense firewall.

Instructions

Apply static route configuration changes (reconfigure routing)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Handler for opnsense_route_apply: sends POST to /routes/routes/reconfigure to apply static route configuration changes.
    case "opnsense_route_apply": {
      const result = await client.post("/routes/routes/reconfigure");
      return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
    }
  • Schema definition for opnsense_route_apply: no input parameters required (empty object schema).
    {
      name: "opnsense_route_apply",
      description: "Apply static route configuration changes (reconfigure routing)",
      inputSchema: { type: "object" as const, properties: {} },
    },
  • src/index.ts:67-67 (registration)
    Registers the routing tool handler (including opnsense_route_apply) in the toolHandlers map with the OPNsense MCP server.
    for (const def of routingToolDefinitions) toolHandlers.set(def.name, handleRoutingTool);
  • The handleRoutingTool function dispatches all routing tool calls, including opnsense_route_apply which calls the reconfigure endpoint.
    export async function handleRoutingTool(
      name: string,
      args: Record<string, unknown>,
      client: OPNsenseClient,
    ): Promise<{ content: Array<{ type: "text"; text: string }> }> {
      try {
        switch (name) {
          case "opnsense_route_list": {
            const result = await client.get("/routes/routes/searchroute");
            return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
          }
    
          case "opnsense_route_add": {
            const parsed = AddRouteSchema.parse(args);
            const result = await client.post("/routes/routes/addroute", {
              route: {
                network: parsed.network,
                gateway: parsed.gateway,
                disabled: parsed.disabled ? "1" : "0",
                description: parsed.description ?? "",
              },
            });
            return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
          }
    
          case "opnsense_route_update": {
            const parsed = UpdateRouteSchema.parse(args);
            const existing = await client.get<{ route: Record<string, unknown> }>(
              `/routes/routes/getroute/${parsed.uuid}`,
            );
            const route = existing.route;
            const result = await client.post(`/routes/routes/setroute/${parsed.uuid}`, {
              route: {
                network: parsed.network ?? route["network"],
                gateway: parsed.gateway ?? route["gateway"],
                disabled:
                  parsed.disabled !== undefined
                    ? parsed.disabled
                      ? "1"
                      : "0"
                    : route["disabled"],
                description: parsed.description ?? route["description"],
              },
            });
            return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
          }
    
          case "opnsense_route_delete": {
            const { uuid } = DeleteRouteSchema.parse(args);
            const result = await client.post(`/routes/routes/delroute/${uuid}`);
            return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
          }
    
          case "opnsense_route_apply": {
            const result = await client.post("/routes/routes/reconfigure");
            return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
          }
    
          case "opnsense_route_gateway_list": {
            const result = await client.get("/routing/settings/searchGateway");
            return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
          }
    
          case "opnsense_route_gateway_status": {
            const result = await client.get("/routes/gateway/status");
            return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
          }
    
          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) }] };
          }
    
          case "opnsense_route_gateway_apply": {
            GatewayApplySchema.parse(args);
            const result = await client.post("/routing/settings/reconfigure", {});
            return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
          }
    
          default:
            return { content: [{ type: "text", text: `Unknown routing tool: ${name}` }] };
        }
      } catch (error: unknown) {
        const message = error instanceof Error ? error.message : "Unknown error";
        return { content: [{ type: "text", text: `Error executing ${name}: ${message}` }] };
      }
    }
Behavior2/5

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

With no annotations, the description carries full burden for behavioral disclosure. It only states the operation ('apply'), implying mutation but offering no details on side effects (e.g., service restart, idempotency, permission requirements, or what happens if no changes exist). This is insufficient for an agent to assess risks or consequences.

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, front-loaded sentence that efficiently communicates the tool's function. Every word is meaningful, and there is no extraneous 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?

For a simple apply tool with no parameters and no output schema, the description is adequate but minimal. It lacks usage guidance and behavioral transparency, which are important for an agent to use the tool correctly in a workflow. The presence of sibling apply tools (e.g., opnsense_fw_apply) further underscores the need for more context.

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 zero parameters, so no parameter description is needed. Baseline for 0 parameters is 4. The description does not add anything about the lack of parameters, but this is acceptable since the schema already conveys the empty input.

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 clearly states the action ('Apply') and the resource ('static route configuration changes'), with a parenthetical clarification. The tool name reinforces this, making the purpose unambiguous and distinct from sibling tools like opnsense_route_add or opnsense_fw_apply.

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 usage guidelines are provided. The description does not indicate when to use this tool (e.g., after making route modifications) or contrast it with alternatives like opnsense_route_gateway_apply or other apply tools. The agent must infer usage context from the name alone.

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