opnsense_vlan_create
Create an 802.1Q VLAN interface on a parent device. After creation, assign it to a logical interface and configure an IP address.
Instructions
Create a new 802.1Q VLAN interface on a parent interface. After create, run opnsense_if_assign to bind the VLAN to a logical interface (opt1, opt2, ...) and opnsense_if_configure to assign an IP.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| parent_interface | Yes | Parent physical interface device name (e.g. 're0', 'igb0') | |
| vlan_tag | Yes | 802.1Q VLAN ID (1-4094) | |
| description | No | Human-readable description of the VLAN | |
| priority | No | 802.1p priority (0-7, default 0) |
Implementation Reference
- src/tools/vlan.ts:117-131 (handler)The handler function for the opnsense_vlan_create tool. Parses input via VlanCreateSchema, POSTs to /interfaces/vlan_settings/addItem with vlan payload (parent interface, tag, description, priority), then triggers reconfigure.
case "opnsense_vlan_create": { const parsed = VlanCreateSchema.parse(args); const result = await client.post("/interfaces/vlan_settings/addItem", { vlan: { if: parsed.parent_interface, tag: String(parsed.vlan_tag), descr: parsed.description ?? "", pcp: String(parsed.priority ?? 0), vlanif: "", }, }); // Trigger reconfigure so the tagged interface becomes available await client.post("/interfaces/vlan_settings/reconfigure"); return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] }; } - src/tools/vlan.ts:9-16 (schema)Zod schema for validating vlan_create input: parent_interface (string), vlan_tag (int 1-4094), optional description and priority (0-7).
const VlanCreateSchema = z.object({ parent_interface: z .string() .min(1, "Parent interface is required (e.g. 're0', 'igb0')"), vlan_tag: z.number().int().min(1).max(4094), description: z.string().optional(), priority: z.number().int().min(0).max(7).optional(), }); - src/tools/vlan.ts:41-67 (registration)Tool definition registration in the vlanToolDefinitions array with name, description, and inputSchema for the opnsense_vlan_create tool.
{ name: "opnsense_vlan_create", description: "Create a new 802.1Q VLAN interface on a parent interface. After create, run opnsense_if_assign to bind the VLAN to a logical interface (opt1, opt2, ...) and opnsense_if_configure to assign an IP.", inputSchema: { type: "object" as const, properties: { parent_interface: { type: "string", description: "Parent physical interface device name (e.g. 're0', 'igb0')", }, vlan_tag: { type: "number", description: "802.1Q VLAN ID (1-4094)", }, description: { type: "string", description: "Human-readable description of the VLAN", }, priority: { type: "number", description: "802.1p priority (0-7, default 0)", }, }, required: ["parent_interface", "vlan_tag"], }, }, - src/index.ts:68-68 (registration)Registration of all vlan tool definitions (including opnsense_vlan_create) with the shared handleVlanTool handler in the central toolHandlers map.
for (const def of vlanToolDefinitions) toolHandlers.set(def.name, handleVlanTool); - src/index.ts:35-35 (registration)Import of vlanToolDefinitions and handleVlanTool from the vlan.ts module into the main index.ts entry point.
import { vlanToolDefinitions, handleVlanTool } from './tools/vlan.js';