@usex/mikrotik-mcp 6.11.0 → 6.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. package/dist/cli.js +1 -1
  2. package/dist/index.d.ts +15 -2
  3. package/dist/index.js +1 -1
  4. package/dist/shared/{cli-xkhmxe9c.js → cli-cbs63p0r.js} +334 -142
  5. package/dist/shared/{cli-vrfw477g.js → cli-frg1ynaw.js} +1 -1
  6. package/dist/shared/{cli-p3rfcsg3.js → cli-rbe7s4mf.js} +1 -1
  7. package/dist/shared/{cli-n6heg9q6.js → cli-s9k59ne8.js} +1 -1
  8. package/dist/shared/{cli-xgyy9he1.js → cli-zhfcf33s.js} +1 -1
  9. package/dist/shared/{library-zwdxcca2.js → library-5qaxx124.js} +1 -1
  10. package/dist/shared/{library-y783969c.js → library-9sjsjtd1.js} +1 -1
  11. package/dist/shared/{library-w2eyfdqz.js → library-he7xy22v.js} +332 -141
  12. package/dist/shared/{library-dc9pv2hm.js → library-je5saqvp.js} +1 -1
  13. package/dist/shared/{library-qx9hax3s.js → library-vtet3w1h.js} +1 -1
  14. package/dist/ui/observability.html +69 -69
  15. package/package.json +20 -16
  16. package/schemas/devtools-manifest.json +1 -1
  17. package/schemas/tool-catalog.json +381 -8
  18. package/schemas/tools/apply_plan.json +6 -1
  19. package/schemas/tools/update_bfd_configuration.json +8 -0
  20. package/schemas/tools/update_bgp_connection.json +8 -0
  21. package/schemas/tools/update_bridge.json +8 -0
  22. package/schemas/tools/update_dns_static.json +8 -0
  23. package/schemas/tools/update_dot1x_client.json +8 -0
  24. package/schemas/tools/update_dot1x_server.json +8 -0
  25. package/schemas/tools/update_filter_rule.json +8 -0
  26. package/schemas/tools/update_igmp_proxy_interface.json +8 -0
  27. package/schemas/tools/update_ip_pool.json +8 -0
  28. package/schemas/tools/update_ipsec_peer.json +8 -0
  29. package/schemas/tools/update_ipsec_profile.json +8 -0
  30. package/schemas/tools/update_ipsec_proposal.json +8 -0
  31. package/schemas/tools/update_ipv6_filter_rule.json +8 -0
  32. package/schemas/tools/update_ipv6_mangle_rule.json +8 -0
  33. package/schemas/tools/update_ipv6_nat_rule.json +8 -0
  34. package/schemas/tools/update_ipv6_nd.json +8 -0
  35. package/schemas/tools/update_ipv6_pool.json +8 -0
  36. package/schemas/tools/update_ipv6_raw_rule.json +8 -0
  37. package/schemas/tools/update_mangle_rule.json +8 -0
  38. package/schemas/tools/update_nat_rule.json +8 -0
  39. package/schemas/tools/update_ospf_instance.json +8 -0
  40. package/schemas/tools/update_ovpn_server.json +8 -0
  41. package/schemas/tools/update_ppp_profile.json +8 -0
  42. package/schemas/tools/update_ppp_secret.json +8 -0
  43. package/schemas/tools/update_queue_interface.json +8 -0
  44. package/schemas/tools/update_queue_tree.json +8 -0
  45. package/schemas/tools/update_queue_type.json +8 -0
  46. package/schemas/tools/update_radius_server.json +8 -0
  47. package/schemas/tools/update_rip_instance.json +8 -0
  48. package/schemas/tools/update_route.json +8 -0
  49. package/schemas/tools/update_routing_filter_rule.json +8 -0
  50. package/schemas/tools/update_routing_id.json +8 -0
  51. package/schemas/tools/update_routing_rule.json +8 -0
  52. package/schemas/tools/update_routing_table.json +8 -0
  53. package/schemas/tools/update_rpki_session.json +8 -0
  54. package/schemas/tools/update_simple_queue.json +8 -0
  55. package/schemas/tools/update_switch.json +8 -0
  56. package/schemas/tools/update_switch_port.json +8 -0
  57. package/schemas/tools/update_switch_port_isolation.json +8 -0
  58. package/schemas/tools/update_switch_rule.json +8 -0
  59. package/schemas/tools/update_traffic_monitor.json +8 -0
  60. package/schemas/tools/update_user_manager_user.json +8 -0
  61. package/schemas/tools/update_vlan_interface.json +8 -0
  62. package/schemas/tools/update_wireguard_interface.json +8 -0
  63. package/schemas/tools/update_wireguard_peer.json +8 -0
  64. package/schemas/tools/update_wireless_interface.json +8 -0
  65. package/scripts/service.ts +618 -0
  66. package/scripts/upgrade.ts +7 -0
@@ -10519,7 +10519,7 @@ function stripAnsi(text) {
10519
10519
  }
10520
10520
  var CTRL_X = "\x18";
10521
10521
  var PRINT_PAGER_RE = /(?:^|[\r\n])-- \[Q quit\|D dump\|(?:up\||left\||right\|)*down\][ \t\r]*$/;
10522
- var UNCERTAIN_SESSION = "Safe Mode session is uncertain after a command timeout. Further commands and commit are " + "blocked; call rollback_safe_mode, inspect device state, and re-enable Safe Mode before retrying.";
10522
+ var SESSION_CLOSED = "The Safe Mode session was closed automatically, so RouterOS reverts changes that were still " + "uncommitted. No restart is needed: read back the device state, then retry.";
10523
10523
  var IDLE_TIMEOUT_MS = 15000;
10524
10524
  var HARD_CAP_MS = 120000;
10525
10525
  function isSafeModeActivated(response) {
@@ -10545,7 +10545,7 @@ class SafeModeManager2 {
10545
10545
  channel = null;
10546
10546
  active = false;
10547
10547
  droppedUnexpectedly = false;
10548
- uncertain = false;
10548
+ lastClosure = null;
10549
10549
  probeSequence = 0;
10550
10550
  queue = Promise.resolve();
10551
10551
  commandTimeoutMs = HARD_CAP_MS;
@@ -10556,7 +10556,7 @@ class SafeModeManager2 {
10556
10556
  }
10557
10557
  this.commandTimeoutMs = commandTimeoutMs;
10558
10558
  this.idleTimeoutMs = idleTimeoutMs;
10559
- return `Safe Mode command timeout: ${commandTimeoutMs}ms; idle timeout: ${idleTimeoutMs}ms. Applies to subsequent commands only; does not change RouterOS rollback timing or clear an uncertain session.`;
10559
+ return `Safe Mode command timeout: ${commandTimeoutMs}ms; idle timeout: ${idleTimeoutMs}ms. Applies to subsequent commands only; does not change RouterOS rollback timing.`;
10560
10560
  }
10561
10561
  constructor(deviceName) {
10562
10562
  this.deviceName = deviceName;
@@ -10565,7 +10565,12 @@ class SafeModeManager2 {
10565
10565
  return this.active;
10566
10566
  }
10567
10567
  get requiresRecovery() {
10568
- return this.droppedUnexpectedly || this.uncertain;
10568
+ return this.droppedUnexpectedly;
10569
+ }
10570
+ closeAfterFailure(reason) {
10571
+ this.cleanup();
10572
+ this.droppedUnexpectedly = false;
10573
+ this.lastClosure = `${new Date().toISOString()}: ${reason}`;
10569
10574
  }
10570
10575
  lock(fn) {
10571
10576
  const run = this.queue.then(fn, fn);
@@ -10579,9 +10584,8 @@ class SafeModeManager2 {
10579
10584
  enable() {
10580
10585
  return this.lock(async () => {
10581
10586
  if (this.active)
10582
- return this.uncertain ? `Error: ${UNCERTAIN_SESSION}` : "Safe mode is already active.";
10587
+ return "Safe mode is already active.";
10583
10588
  this.droppedUnexpectedly = false;
10584
- this.uncertain = false;
10585
10589
  const dc = getDevice2(this.deviceName);
10586
10590
  if (dc.mac) {
10587
10591
  return "Error: Safe Mode is not supported for a MAC-Telnet device " + `('${this.deviceName}' is reached by MAC ${dc.mac}). ` + "Connect over SSH (configure host/credentials) to use Safe Mode.";
@@ -10613,23 +10617,22 @@ class SafeModeManager2 {
10613
10617
  execute(command) {
10614
10618
  return this.lock(async () => {
10615
10619
  if (this.droppedUnexpectedly) {
10616
- throw new Error("Safe Mode session dropped. Rollback is unverified; inspect device state against the backup before retrying writes.");
10620
+ this.droppedUnexpectedly = false;
10621
+ throw new Error("Safe Mode session dropped before commit, so RouterOS reverts its uncommitted changes. " + "This command was NOT sent. Rollback is unverified; read back the device state, then retry.");
10617
10622
  }
10618
10623
  if (!this.active || !this.channel) {
10619
- throw new Error("Safe mode session is not active.");
10624
+ throw new Error("Safe mode session is not active (it may have been closed after a failure). This command was NOT sent.");
10620
10625
  }
10621
- if (this.uncertain)
10622
- throw new Error(UNCERTAIN_SESSION);
10623
10626
  const response = this.readUntilPrompt(this.idleTimeoutMs, undefined, this.commandTimeoutMs, true);
10624
10627
  this.channel.write(`${command}\r`);
10625
10628
  const { text, timedOut } = await response;
10626
10629
  if (timedOut) {
10627
- this.uncertain = true;
10628
- throw new Error(`Safe Mode command did not return a recognized prompt before the timeout (command: ${command}). ` + `Execution may have occurred; do not retry the write blindly. ${UNCERTAIN_SESSION}`);
10630
+ this.closeAfterFailure(`command timeout (${command})`);
10631
+ throw new Error(`Safe Mode command did not return a recognized prompt before the timeout (command: ${command}). ` + `Execution may have occurred; do not retry the write blindly. ${SESSION_CLOSED}`);
10629
10632
  }
10630
10633
  if (classifyPrompt(text) !== "safe") {
10631
- this.uncertain = true;
10632
- throw new Error(`Safe Mode protection was lost or could not be confirmed. Changes may already be permanent. ${UNCERTAIN_SESSION}`);
10634
+ this.closeAfterFailure(`Safe Mode protection lost (${command})`);
10635
+ throw new Error(`Safe Mode protection was lost or could not be confirmed. Changes may already be permanent. ${SESSION_CLOSED}`);
10633
10636
  }
10634
10637
  return this.extractOutput(text, command);
10635
10638
  });
@@ -10637,28 +10640,29 @@ class SafeModeManager2 {
10637
10640
  commit() {
10638
10641
  return this.lock(async () => {
10639
10642
  if (this.droppedUnexpectedly) {
10643
+ this.droppedUnexpectedly = false;
10640
10644
  return {
10641
10645
  ok: false,
10642
10646
  message: "Commit FAILED \u2014 the Safe Mode session dropped. Rollback is unverified; compare device state with the backup before retrying."
10643
10647
  };
10644
10648
  }
10645
10649
  if (!this.active || !this.channel) {
10646
- return { ok: true, message: "Safe mode is not active. Nothing to commit." };
10650
+ const last = this.lastClosure ? ` The last session was closed automatically (${this.lastClosure}).` : "";
10651
+ return { ok: true, message: `Safe mode is not active. Nothing to commit.${last}` };
10647
10652
  }
10648
- if (this.uncertain)
10649
- return { ok: false, message: UNCERTAIN_SESSION };
10650
10653
  const before = await this.probeMode();
10651
10654
  if (before === "released") {
10652
- this.uncertain = true;
10655
+ this.closeAfterFailure("Safe Mode had exited before commit");
10653
10656
  return {
10654
10657
  ok: false,
10655
- message: "Safe Mode exited before commit was requested. Changes may be permanent; verify device state against the backup."
10658
+ message: "Safe Mode exited before commit was requested. Changes may be permanent; the session " + "was closed. Read back the device state against the backup."
10656
10659
  };
10657
10660
  }
10658
10661
  if (before === "unknown") {
10662
+ this.closeAfterFailure("no answer to the pre-commit probe");
10659
10663
  return {
10660
10664
  ok: false,
10661
- message: "Could not determine Safe Mode state. Session left open; outcome unverified. " + "Call safe_mode_status or rollback_safe_mode and inspect device state."
10665
+ message: `Could not determine Safe Mode state before commit; nothing was committed. ${SESSION_CLOSED}`
10662
10666
  };
10663
10667
  }
10664
10668
  this.channel.write(CTRL_X);
@@ -10670,12 +10674,13 @@ class SafeModeManager2 {
10670
10674
  case "safe":
10671
10675
  return {
10672
10676
  ok: false,
10673
- message: "Commit NOT completed \u2014 the device is still in Safe Mode (the Ctrl+X commit did not " + "take). Your changes remain held in memory and are NOT yet saved; call commit_safe_mode " + "again to retry, or rollback_safe_mode to discard them. If retries keep failing, this " + "RouterOS build may not accept an interactive Safe Mode commit over SSH \u2014 apply the " + "change without Safe Mode instead."
10677
+ message: "Commit NOT completed \u2014 the device is still in Safe Mode (the Ctrl+X commit did not " + "take). Your changes remain held in memory and are NOT yet saved; commit again to " + "retry, or roll back to discard them. If retries keep failing, this RouterOS build may " + "not accept an interactive Safe Mode commit over SSH \u2014 apply the change without Safe " + "Mode instead (apply_plan with use_safe_mode=false)."
10674
10678
  };
10675
10679
  default:
10680
+ this.closeAfterFailure("no prompt after the commit keystroke");
10676
10681
  return {
10677
10682
  ok: false,
10678
- message: "Commit status unclear \u2014 no prompt seen after commit. Session left open; outcome unverified. " + "Inspect device state before retrying."
10683
+ message: "Commit outcome unconfirmed \u2014 no prompt seen after commit. The session was closed, so " + "the changes are now either saved or reverted. Read back the device state to see which."
10679
10684
  };
10680
10685
  }
10681
10686
  });
@@ -10696,9 +10701,10 @@ class SafeModeManager2 {
10696
10701
  if (this.droppedUnexpectedly) {
10697
10702
  return "Safe mode session DROPPED unexpectedly. Rollback is unverified; inspect device state against the backup before retrying writes.";
10698
10703
  }
10699
- if (this.uncertain && this.active)
10700
- return UNCERTAIN_SESSION;
10701
- return this.active ? `Safe mode is ACTIVE (last observed). Command timeout: ${this.commandTimeoutMs}ms; idle timeout: ${this.idleTimeoutMs}ms. ` + "Call commit_safe_mode to persist or rollback_safe_mode to revert." : "Safe mode is NOT active. Changes take effect and persist immediately.";
10704
+ if (this.active)
10705
+ return `Safe mode is ACTIVE (last observed). Command timeout: ${this.commandTimeoutMs}ms; idle timeout: ${this.idleTimeoutMs}ms. ` + "Commit to persist or roll back to revert.";
10706
+ const last = this.lastClosure ? ` Last session was closed automatically (${this.lastClosure}); RouterOS reverts uncommitted changes on close.` : "";
10707
+ return `Safe mode is NOT active. Changes take effect and persist immediately.${last}`;
10702
10708
  }
10703
10709
  handleUnexpectedDrop = () => {
10704
10710
  if (!this.active)
@@ -10798,7 +10804,6 @@ class SafeModeManager2 {
10798
10804
  }
10799
10805
  cleanup() {
10800
10806
  this.active = false;
10801
- this.uncertain = false;
10802
10807
  if (this.channel) {
10803
10808
  try {
10804
10809
  this.channel.end();
@@ -11252,10 +11257,16 @@ async function runOnce(command, deviceName, opts, ctx) {
11252
11257
  client.disconnect();
11253
11258
  }
11254
11259
  }
11260
+ var READ_COMMAND_RE = /^\/(?:[^;[\]{}]*\s)?(?:print|export)(?:\s[^;[\]{}]*)?$/;
11261
+ function bypassesSafeMode(command, ctx) {
11262
+ if (ctx.risk === "READ")
11263
+ return true;
11264
+ return ctx.risk === undefined && READ_COMMAND_RE.test(command.trim());
11265
+ }
11255
11266
  async function executeMikrotikCommand2(command, ctx, opts) {
11256
11267
  const deviceName = resolveDeviceName2(ctx.device);
11257
11268
  const safe = getSafeModeManager2(deviceName);
11258
- if (safe.isActive || safe.requiresRecovery) {
11269
+ if ((safe.isActive || safe.requiresRecovery) && !bypassesSafeMode(command, ctx)) {
11259
11270
  ctx.info(`[${deviceName}] Executing (safe mode): ${containerCommandForLog(command)}`);
11260
11271
  ctx.transport = "ssh";
11261
11272
  return safe.execute(command);
@@ -11465,6 +11476,15 @@ function splitHostPort(value) {
11465
11476
  return { host: hostPort[1], port: Number(hostPort[2]) };
11466
11477
  return { host: v };
11467
11478
  }
11479
+ function unsetFragments(keys) {
11480
+ return (keys ?? []).map((key) => {
11481
+ const name = key.trim().replace(/^!/, "").replaceAll("_", "-");
11482
+ if (!/^[a-z][a-z0-9-]*$/.test(name)) {
11483
+ throw new Error(`Invalid property name to unset: ${JSON.stringify(key)}`);
11484
+ }
11485
+ return `!${name}`;
11486
+ });
11487
+ }
11468
11488
 
11469
11489
  class Cmd {
11470
11490
  parts;
@@ -11492,6 +11512,10 @@ class Cmd {
11492
11512
  }
11493
11513
  return this;
11494
11514
  }
11515
+ unset(keys) {
11516
+ this.parts.push(...unsetFragments(keys));
11517
+ return this;
11518
+ }
11495
11519
  raw(fragment) {
11496
11520
  if (fragment)
11497
11521
  this.parts.push(fragment);
@@ -13695,6 +13719,7 @@ function defineTool2(def) {
13695
13719
  }
13696
13720
  sendLog?.(level, `[${id}] ${message}`);
13697
13721
  }, device, id);
13722
+ ctx.risk = risk;
13698
13723
  let result;
13699
13724
  try {
13700
13725
  result = await execute(args, ctx);
@@ -15611,13 +15636,13 @@ async function undoMigration(id, confirm, selected) {
15611
15636
  throw new Error("Undo lost Safe Mode or exceeded its time budget.");
15612
15637
  await checkedRead(item.undo, createContext(undefined, device));
15613
15638
  }
15614
- const beforeTarget = (await import("./library-y783969c.js")).openSnapshotStore;
15615
- const db = await beforeTarget((await import("./library-zwdxcca2.js")).DEFAULT_SNAPSHOT_DB);
15639
+ const beforeTarget = (await import("./library-9sjsjtd1.js")).openSnapshotStore;
15640
+ const db = await beforeTarget((await import("./library-5qaxx124.js")).DEFAULT_SNAPSHOT_DB);
15616
15641
  try {
15617
15642
  const original = db.get(p.snapshots.target);
15618
15643
  if (!original)
15619
15644
  throw new Error("Original target snapshot unavailable.");
15620
- const { normalizeExport } = await import("./library-dc9pv2hm.js");
15645
+ const { normalizeExport } = await import("./library-je5saqvp.js");
15621
15646
  if (normalizeExport((await migrationInventory(device)).export) !== normalizeExport(original.body))
15622
15647
  throw new Error("Target differs from its backup. Undo verification failed.");
15623
15648
  } finally {
@@ -23741,6 +23766,7 @@ function interfaceName(description) {
23741
23766
  const s = string().regex(NO_WHITESPACE, INTERFACE_NAME_MESSAGE);
23742
23767
  return description ? s.describe(description) : s;
23743
23768
  }
23769
+ var unsetProperties = array(string().regex(/^[a-z][a-z0-9_-]*$/, "Use a bare property name, e.g. 'dst-address'.")).optional().describe("Properties to UNSET (RouterOS `!prop`), so they no longer apply \u2014 e.g. ['dst-address'] " + "removes the destination-address match. snake_case or kebab-case. Not for setting a value.");
23744
23770
 
23745
23771
  // src/tools/bridge.ts
23746
23772
  var ProtocolMode = _enum(["none", "rstp", "stp", "mstp"]);
@@ -23844,6 +23870,7 @@ ${result}`;
23844
23870
  annotations: WRITE_IDEMPOTENT,
23845
23871
  description: "Modifies settings on an existing bridge interface (`/interface bridge set`). " + "Use to rename a bridge (`new_name`), toggle VLAN filtering, change STP/RSTP/MSTP protocol mode, adjust MTU, or enable/disable the bridge. " + "VLAN filtering can interrupt management: read get_vlan_segmentation_guide, verify CPU membership, PVID/admission and recovery access before enabling it LAST. Do not disable existing filtering to simplify migration. " + "For adding or removing member interfaces use `add_bridge_port` / `remove_bridge_port`; " + "for VLAN table entries use `add_bridge_vlan`. " + "Identified by the current bridge `name`; supply only the fields you want to change.",
23846
23872
  inputSchema: {
23873
+ unset: unsetProperties,
23847
23874
  name: string().describe("Current name of the bridge to update"),
23848
23875
  new_name: interfaceName().optional().describe("Rename the bridge to this (no spaces)."),
23849
23876
  comment: string().optional(),
@@ -23878,8 +23905,8 @@ ${result}`;
23878
23905
  if ((a.arp_inspection || a.ip_source_guard) && !a.confirm_security_disruption)
23879
23906
  return "Enabling ARP inspection or IP source guard can clear DHCP bindings and interrupt clients. Review DHCP snooping and trusted ports, then set confirm_security_disruption=true.";
23880
23907
  ctx.info(`Updating bridge: name=${a.name}`);
23881
- const cmd = new Cmd(`/interface bridge set [find name=${quoteValue(a.name)}]`).opt("name", a.new_name).opt("comment", a.comment).bool("vlan-filtering", a.vlan_filtering).opt("protocol-mode", a.protocol_mode).bool("disabled", a.disabled).opt("mtu", a.mtu).opt("ageing-time", a.ageing_time).opt("arp", a.arp).opt("arp-timeout", a.arp_timeout).bool("auto-mac", a.auto_mac).opt("admin-mac", a.admin_mac).opt("priority", a.priority).opt("ether-type", a.ether_type).opt("pvid", a.pvid).opt("frame-types", a.frame_types).bool("ingress-filtering", a.ingress_filtering).bool("dhcp-snooping", a.dhcp_snooping).bool("arp-inspection", a.arp_inspection).bool("ip-source-guard", a.ip_source_guard).opt("mlag-init-delay", a.mlag_init_delay).bool("mlag-lacp-fallback", a.mlag_lacp_fallback).bool("igmp-snooping", a.igmp_snooping).bool("fast-forward", a.fast_forward).bool("mvrp", a.mvrp).opt("forward-delay", a.forward_delay).opt("max-message-age", a.max_message_age).opt("transmit-hold-count", a.transmit_hold_count).build();
23882
- if (!cmd.includes("=", cmd.indexOf("]")))
23908
+ const cmd = new Cmd(`/interface bridge set [find name=${quoteValue(a.name)}]`).opt("name", a.new_name).opt("comment", a.comment).bool("vlan-filtering", a.vlan_filtering).opt("protocol-mode", a.protocol_mode).bool("disabled", a.disabled).opt("mtu", a.mtu).opt("ageing-time", a.ageing_time).opt("arp", a.arp).opt("arp-timeout", a.arp_timeout).bool("auto-mac", a.auto_mac).opt("admin-mac", a.admin_mac).opt("priority", a.priority).opt("ether-type", a.ether_type).opt("pvid", a.pvid).opt("frame-types", a.frame_types).bool("ingress-filtering", a.ingress_filtering).bool("dhcp-snooping", a.dhcp_snooping).bool("arp-inspection", a.arp_inspection).bool("ip-source-guard", a.ip_source_guard).opt("mlag-init-delay", a.mlag_init_delay).bool("mlag-lacp-fallback", a.mlag_lacp_fallback).bool("igmp-snooping", a.igmp_snooping).bool("fast-forward", a.fast_forward).bool("mvrp", a.mvrp).opt("forward-delay", a.forward_delay).opt("max-message-age", a.max_message_age).opt("transmit-hold-count", a.transmit_hold_count).unset(a.unset).build();
23909
+ if (!/[=!]/.test(cmd.slice(cmd.indexOf("]"))))
23883
23910
  return "No updates specified.";
23884
23911
  const result = await executeMikrotikCommand2(cmd, ctx);
23885
23912
  if (looksLikeError(result))
@@ -24577,6 +24604,44 @@ function diffLines(from, to, opts = {}) {
24577
24604
  }
24578
24605
 
24579
24606
  // src/tools/change-plan.ts
24607
+ var REVERT_SETTLE_MS = 2000;
24608
+ async function exportConfig(readCtx) {
24609
+ const body = await executeMikrotikCommand2("/export terse", readCtx);
24610
+ if (looksLikeError(body) || !/^\/[a-z]/m.test(body)) {
24611
+ throw new Error("could not read `/export terse` from the device");
24612
+ }
24613
+ return normalizeExport2(body);
24614
+ }
24615
+ async function liveState(readCtx, before, after, mayRevert = true) {
24616
+ const read = () => exportConfig(readCtx).catch(() => null);
24617
+ let live = await read();
24618
+ if (mayRevert && live !== null && live !== before) {
24619
+ await new Promise((resolve) => setTimeout(resolve, REVERT_SETTLE_MS));
24620
+ live = await read();
24621
+ }
24622
+ const label = "DEVICE STATE (read back on a fresh connection)";
24623
+ if (live === null) {
24624
+ return {
24625
+ kind: "unreadable",
24626
+ text: `${label}: could not be read. The device did not answer; check it before retrying.`
24627
+ };
24628
+ }
24629
+ if (live === before) {
24630
+ return {
24631
+ kind: "unchanged",
24632
+ text: `${label}: identical to the pre-change export. No change is on the device.`
24633
+ };
24634
+ }
24635
+ if (after !== undefined && live === after) {
24636
+ return { kind: "applied", text: `${label}: the change IS on the device.` };
24637
+ }
24638
+ const diff = diffLines(before, live, { fromLabel: "before", toLabel: "live" });
24639
+ return {
24640
+ kind: "different",
24641
+ text: `${label}: differs from the pre-change export (+${diff.summary.added}/-${diff.summary.removed}):
24642
+ ${diff.unified}`
24643
+ };
24644
+ }
24580
24645
  function collectCommands(a) {
24581
24646
  const fromArray = (a.commands ?? []).map((c) => c.trim()).filter(Boolean);
24582
24647
  const fromScript = a.script ? splitCommands(a.script) : [];
@@ -24605,53 +24670,107 @@ var changePlanTools = [
24605
24670
  }),
24606
24671
  defineTool2({
24607
24672
  name: "apply_plan",
24608
- title: "Apply RouterOS Change Plan in Safe Mode",
24673
+ title: "Apply RouterOS Change Plan",
24609
24674
  annotations: DANGEROUS,
24610
- description: "Executes intended RouterOS commands inside RouterOS Safe Mode (activated by Ctrl+X over " + "an interactive SSH shell) and reports the exact unified diff of what changed, computed " + "from `/export terse` snapshots captured before and after execution. With confirm=false " + "(default) it applies all steps, captures the diff, then rolls everything back \u2014 a true " + "dry-run that shows precisely what would change without persisting anything. With " + "confirm=true it commits permanently, but ONLY after verifying the device still responds " + "to `/system identity print` \u2014 a change that would lock you out auto-reverts instead of " + "sticking. Steps execute in the same safe order that plan_changes computes (additive before " + "destructive); if any step returns a RouterOS error the entire plan rolls back immediately. " + "Safe Mode requires SSH \u2014 not available on MAC-Telnet devices. For a no-device preview " + "use plan_changes instead. ALWAYS call capture_config_snapshot BEFORE this tool to record " + "a restore point \u2014 it stores a local `/export` on the MCP host (~/.mikrotik-mcp/snapshots.db), " + "adding no load to the device's disk and leaving nothing to remove on the router; after the " + "change, diff_config_snapshots (from=latest, to=live) confirms what changed. Returns the " + "plan summary, per-step execution log, unified diff, and commit/rollback outcome.",
24675
+ description: "Executes intended RouterOS commands and reports the exact unified diff of what changed, " + "computed from `/export terse` captured before and after on a separate connection. " + "Default (use_safe_mode=true): the steps run inside RouterOS Safe Mode (Ctrl+X over an " + "interactive SSH shell). With confirm=false (default) it applies all steps, captures the " + "diff, then rolls everything back \u2014 a true dry-run. With confirm=true it commits, but ONLY " + "after a fresh connection to the device still works \u2014 a change that would lock you out " + "reverts instead of sticking. If any step fails, or the Safe Mode session times out, the " + "session is closed (RouterOS reverts uncommitted changes), the real device state is read " + "back and compared with the pre-change export, and the result is reported; this tool never " + "leaves a Safe Mode session open and needs no follow-up tool to recover. " + "use_safe_mode=false (only when the user explicitly asks to write without Safe Mode): " + "stores a restore-point snapshot on the MCP host, runs the steps directly (each one is " + "permanent at once, there is no automatic rollback and no dry-run, confirm=true is " + "required), stops at the first error, then reads back and diffs. This mode also works on " + "MAC-Telnet devices; Safe Mode requires SSH. Steps execute in the same safe order that " + "plan_changes computes (additive before destructive). For a no-device preview use " + "plan_changes. Returns the plan summary, per-step log, unified diff, and the outcome.",
24611
24676
  inputSchema: {
24612
24677
  commands: array(string()).optional(),
24613
24678
  script: string().optional(),
24614
- confirm: boolean().default(false).describe("false = apply, show diff, roll back (dry-run). true = commit if still reachable.")
24679
+ confirm: boolean().default(false).describe("false = apply, show diff, roll back (dry-run). true = commit if still reachable."),
24680
+ use_safe_mode: boolean().default(true).describe("false = write directly without Safe Mode (snapshot first, read-back diff after, no " + "automatic rollback). Use only when the user explicitly asks for it.")
24615
24681
  },
24616
24682
  async handler(a, ctx) {
24617
24683
  const commands = collectCommands(a);
24618
24684
  if (commands.length === 0)
24619
24685
  return "No commands provided to apply.";
24620
24686
  const device = resolveDeviceName2(ctx.device);
24621
- if (getDevice2(ctx.device).mac) {
24622
- throw new Error("Safe Mode (and therefore apply_plan) requires SSH; it is not available on a MAC-Telnet device.");
24623
- }
24624
24687
  const plan = buildChangePlan(commands);
24688
+ const planBody = renderPlan(plan).split(`
24689
+ `).slice(2).join(`
24690
+ `);
24625
24691
  const safe = getSafeModeManager2(device);
24692
+ const readCtx = { ...ctx, risk: "READ" };
24693
+ if (a.use_safe_mode === false) {
24694
+ if (!a.confirm) {
24695
+ return `APPLY PLAN (direct, no Safe Mode) \u2014 ${device}
24696
+
24697
+ ${planBody}
24698
+
24699
+ ` + "NOT APPLIED: a dry-run is not possible without Safe Mode. Re-run with confirm=true " + "to write directly, or keep use_safe_mode=true for a dry-run.";
24700
+ }
24701
+ if (safe.isActive) {
24702
+ throw new Error("A Safe Mode session is open on this device. Commit it or roll it back before a direct write.");
24703
+ }
24704
+ const snapshotId = await captureSnapshot(readCtx, "apply_plan direct (pre-change)", true);
24705
+ const before = await exportConfig(readCtx);
24706
+ const log = [];
24707
+ let failure;
24708
+ for (const step of plan.steps) {
24709
+ const out = await executeMikrotikCommand2(step.command, ctx).catch((e) => `failure: ${e instanceof Error ? e.message : String(e)}`);
24710
+ if (looksLikeError(out) || out.startsWith("failure: ")) {
24711
+ failure = `step ${step.index} failed:
24712
+ ${step.command}
24713
+ \u2192 ${out.trim()}`;
24714
+ break;
24715
+ }
24716
+ log.push(` \u2713 ${step.command}`);
24717
+ }
24718
+ const state = await liveState(readCtx, before, undefined, false);
24719
+ const body = `APPLY PLAN (direct, no Safe Mode) \u2014 ${device}
24720
+
24721
+ ${planBody}
24722
+
24723
+ ` + `Restore point: snapshot ${snapshotId} (get_config_snapshot returns its export).
24724
+ ` + `Executed ${log.length} of ${plan.steps.length} step(s) directly:
24725
+ ${log.join(`
24726
+ `) || " (none)"}
24727
+
24728
+ ${state.text}`;
24729
+ if (failure) {
24730
+ throw new Error(`${body}
24731
+
24732
+ FAILED: ${failure}
24733
+ Steps marked \u2713 are permanent; nothing was rolled back.`);
24734
+ }
24735
+ if (state.kind === "unreadable") {
24736
+ throw new Error(`${body}
24737
+
24738
+ All steps ran, but the read-back check failed.`);
24739
+ }
24740
+ return `${body}
24741
+
24742
+ APPLIED: all steps ran and are permanent (verified by the read-back above).`;
24743
+ }
24744
+ if (getDevice2(ctx.device).mac) {
24745
+ throw new Error("Safe Mode requires SSH; it is not available on a MAC-Telnet device. " + "Use use_safe_mode=false to write directly.");
24746
+ }
24747
+ const before = await exportConfig(readCtx);
24626
24748
  const enabled = await safe.enable();
24627
24749
  if (enabled.startsWith("Error"))
24628
24750
  throw new Error(enabled);
24629
24751
  const APPLY_BUDGET_MS = 180000;
24630
24752
  const startedAt = Date.now();
24631
- const overBudget = () => Date.now() - startedAt > APPLY_BUDGET_MS;
24632
- const applyAndDiff = async () => {
24633
- try {
24634
- const before = normalizeExport2(await safe.execute("/export terse"));
24635
- const log = [];
24636
- for (const step of plan.steps) {
24637
- if (overBudget()) {
24638
- throw new Error(`aborted after ${Math.round((Date.now() - startedAt) / 1000)}s (time budget exceeded). ` + "Safe Mode is slow/unresponsive on this device; apply the change with the direct write tools instead");
24639
- }
24640
- const out = await safe.execute(step.command);
24641
- if (looksLikeError(out)) {
24642
- throw new Error(`step ${step.index} failed:
24753
+ let header;
24754
+ let after;
24755
+ let reachable;
24756
+ try {
24757
+ const log = [];
24758
+ for (const step of plan.steps) {
24759
+ if (Date.now() - startedAt > APPLY_BUDGET_MS) {
24760
+ throw new Error(`aborted after ${Math.round((Date.now() - startedAt) / 1000)}s (time budget exceeded)`);
24761
+ }
24762
+ const out = await safe.execute(step.command);
24763
+ if (looksLikeError(out)) {
24764
+ throw new Error(`step ${step.index} failed:
24643
24765
  ${step.command}
24644
24766
  \u2192 ${out.trim()}`);
24645
- }
24646
- log.push(` \u2713 ${step.command}`);
24647
24767
  }
24648
- const after = normalizeExport2(await safe.execute("/export terse"));
24649
- const diff = diffLines(before, after, { fromLabel: "before", toLabel: "after" });
24650
- const reachable = !looksLikeError(await safe.execute("/system identity print"));
24651
- const planBody = renderPlan(plan).split(`
24652
- `).slice(2).join(`
24653
- `);
24654
- const header = `APPLY PLAN \u2014 ${device}
24768
+ log.push(` \u2713 ${step.command}`);
24769
+ }
24770
+ after = await exportConfig(readCtx);
24771
+ const diff = diffLines(before, after, { fromLabel: "before", toLabel: "after" });
24772
+ reachable = await executeMikrotikCommand2("/system identity print", readCtx).then((out) => !looksLikeError(out), () => false);
24773
+ header = `APPLY PLAN \u2014 ${device}
24655
24774
 
24656
24775
  ${planBody}
24657
24776
 
@@ -24661,35 +24780,51 @@ ${log.join(`
24661
24780
 
24662
24781
  ` + `EXACT DIFF (+${diff.summary.added}/-${diff.summary.removed}):
24663
24782
  ${diff.unified || "(no config change)"}`;
24664
- return { header, reachable };
24665
- } catch (e) {
24666
- await safe.rollback().catch(() => {});
24667
- const msg = e instanceof Error ? e.message : String(e);
24668
- throw new Error(`apply_plan failed and was rolled back (nothing committed): ${msg}`);
24669
- }
24670
- };
24671
- const { header, reachable } = await applyAndDiff();
24783
+ } catch (e) {
24784
+ await safe.rollback().catch(() => {});
24785
+ const msg = e instanceof Error ? e.message : String(e);
24786
+ const state = await liveState(readCtx, before);
24787
+ throw new Error(`apply_plan failed; the Safe Mode session was closed and nothing was committed: ${msg}
24788
+
24789
+ ${state.text}`);
24790
+ }
24672
24791
  if (!a.confirm) {
24673
24792
  await safe.rollback();
24793
+ const state = await liveState(readCtx, before);
24674
24794
  return `${header}
24675
24795
 
24676
- DRY-RUN: all changes rolled back. Re-run with confirm=true to commit.`;
24796
+ DRY-RUN: Safe Mode session closed to roll back. Re-run with confirm=true to commit.
24797
+ ${state.text}`;
24677
24798
  }
24678
24799
  if (!reachable) {
24679
24800
  await safe.rollback();
24801
+ const state = await liveState(readCtx, before);
24680
24802
  throw new Error(`${header}
24681
24803
 
24682
- ABORTED: the device stopped responding after applying \u2014 changes rolled back to avoid a lock-out.`);
24804
+ ABORTED: a new connection to the device failed after applying \u2014 Safe Mode session closed to avoid a lock-out.
24805
+ ${state.text}`);
24683
24806
  }
24684
- const committed = await safe.commit();
24685
- if (!committed.ok) {
24686
- throw new Error(`${header}
24807
+ let committed = await safe.commit();
24808
+ if (!committed.ok && safe.isActive)
24809
+ committed = await safe.commit();
24810
+ if (committed.ok) {
24811
+ return `${header}
24687
24812
 
24688
- COMMIT FAILED \u2014 changes are NOT saved (still pending in Safe Mode). ${committed.message}`);
24813
+ COMMITTED: changes are now permanent. ${committed.message}`;
24689
24814
  }
24690
- return `${header}
24815
+ if (safe.isActive)
24816
+ await safe.rollback().catch(() => {});
24817
+ const state = await liveState(readCtx, before, after);
24818
+ if (state.kind === "applied") {
24819
+ return `${header}
24691
24820
 
24692
- COMMITTED: changes are now permanent. ${committed.message}`;
24821
+ COMMITTED: the commit confirmation was lost (${committed.message}) but the ` + `Safe Mode session is closed and the change was not reverted.
24822
+ ${state.text}`;
24823
+ }
24824
+ throw new Error(`${header}
24825
+
24826
+ COMMIT FAILED: ${committed.message}
24827
+ ${state.text}`);
24693
24828
  }
24694
24829
  })
24695
24830
  ];
@@ -28179,7 +28314,7 @@ var cache3 = null;
28179
28314
  async function gateway() {
28180
28315
  if (cache3)
28181
28316
  return cache3;
28182
- const { moduleCatalog } = await import("./library-qx9hax3s.js");
28317
+ const { moduleCatalog } = await import("./library-vtet3w1h.js");
28183
28318
  const forIndex = [];
28184
28319
  const byName = new Map;
28185
28320
  for (const mod of moduleCatalog) {
@@ -28432,7 +28567,7 @@ ${details}` : "Static DNS entry addition completed but unable to verify.";
28432
28567
  }
28433
28568
  async function updateDnsStatic(a, ctx) {
28434
28569
  ctx.info(`Updating static DNS entry: entry_id=${a.entry_id}`);
28435
- const updates = [];
28570
+ const updates = unsetFragments(a.unset);
28436
28571
  if (a.name)
28437
28572
  updates.push(`name=${quoteValue(a.name)}`);
28438
28573
  if (a.type !== undefined)
@@ -28613,6 +28748,7 @@ ${result}`;
28613
28748
  annotations: WRITE_IDEMPOTENT,
28614
28749
  description: "Modifies fields on an existing static DNS record (`/ip dns static set`) \u2014 can update the " + "hostname (name), record-type data (address, cname, mx_preference, mx_exchange, text, srv " + "fields), ttl, comment, disabled state, or regexp pattern. Pass an empty string for a field " + 'to clear it (e.g. address="" removes the address field). ' + "The `entry_id` is the `.id` from list_dns_static. " + "To activate or deactivate without touching other fields use enable_dns_static or " + "disable_dns_static. " + "Returns the updated entry's full detail.",
28615
28750
  inputSchema: {
28751
+ unset: unsetProperties,
28616
28752
  entry_id: string(),
28617
28753
  name: string().optional(),
28618
28754
  type: string().optional().describe('Record type, e.g. "A", "AAAA", "CNAME", "NS", "FWD", "MX", "SRV", "TXT"'),
@@ -28966,6 +29102,7 @@ ${result}`;
28966
29102
  annotations: WRITE_IDEMPOTENT,
28967
29103
  description: "Modifies an existing 802.1X authenticator entry (`/interface dot1x server set`) identified by interface name or RouterOS `.id`. " + "Pass `server_id` as a `.id` string (starts with `*`, e.g. `*1` \u2014 obtain from `list_dot1x_servers`) or as the interface name (e.g. `ether2`). " + 'Omit any optional field to leave it unchanged; pass `comment=""` to clear the comment. ' + "For creating a new entry use `add_dot1x_server`; for deletion use `remove_dot1x_server`. " + "Returns the updated entry's full detail after the change.",
28968
29104
  inputSchema: {
29105
+ unset: unsetProperties,
28969
29106
  server_id: string().describe("Interface name or RouterOS '.id'"),
28970
29107
  auth_types: AuthTypes.optional(),
28971
29108
  accounting: boolean().optional(),
@@ -28991,7 +29128,7 @@ ${result}`;
28991
29128
  cmd.raw(`comment=${quoteValue(a.comment)}`);
28992
29129
  if (a.disabled !== undefined)
28993
29130
  cmd.raw(`disabled=${yesno(a.disabled)}`);
28994
- const built = cmd.build();
29131
+ const built = cmd.unset(a.unset).build();
28995
29132
  if (built === base)
28996
29133
  return "No updates specified.";
28997
29134
  const result = await executeMikrotikCommand2(built, ctx);
@@ -29104,6 +29241,7 @@ ${result}`;
29104
29241
  annotations: WRITE_IDEMPOTENT,
29105
29242
  description: "Modifies an existing 802.1X supplicant client entry (`/interface dot1x client set`) identified by " + "interface name or RouterOS `.id` from list_dot1x_clients. `client_id` accepts an interface name " + "(e.g. `'ether3'`) or a `.id` string starting with `'*'`. Only supplied fields are changed; " + 'pass `comment=""` to clear the comment. ' + "Returns the updated entry's full detail after the change. To add a new supplicant entry use add_dot1x_client; " + "to delete one use remove_dot1x_client.",
29106
29243
  inputSchema: {
29244
+ unset: unsetProperties,
29107
29245
  client_id: string().describe("Interface name or RouterOS '.id'"),
29108
29246
  eap_methods: string().optional(),
29109
29247
  identity: string().optional(),
@@ -29122,7 +29260,7 @@ ${result}`;
29122
29260
  cmd.raw(`comment=${quoteValue(a.comment)}`);
29123
29261
  if (a.disabled !== undefined)
29124
29262
  cmd.raw(`disabled=${yesno(a.disabled)}`);
29125
- const built = cmd.build();
29263
+ const built = cmd.unset(a.unset).build();
29126
29264
  if (built === base)
29127
29265
  return "No updates specified.";
29128
29266
  const result = await executeMikrotikCommand2(built, ctx);
@@ -32670,7 +32808,7 @@ async function updateFilterRule(a, ctx) {
32670
32808
  ]);
32671
32809
  if (misuse)
32672
32810
  return `Failed to update firewall filter rule: ${misuse}`;
32673
- const updates = [];
32811
+ const updates = unsetFragments(a.unset);
32674
32812
  const put = (key, val) => {
32675
32813
  if (val === undefined)
32676
32814
  return;
@@ -32927,6 +33065,7 @@ ${result}`;
32927
33065
  annotations: WRITE_IDEMPOTENT,
32928
33066
  description: "Updates an existing IPv4 firewall FILTER rule (`/ip firewall filter`) in place and returns " + "its new detail. To reorder it use move_filter_rule; to toggle it on/off use " + "enable_filter_rule / disable_filter_rule; for IPv6 use update_ipv6_filter_rule. " + 'rule_id: the `.id` from list_filter_rules e.g. "*1" or "0". ' + 'connection_state: comma-separated e.g. "established,related". ' + 'limit: RouterOS rate string e.g. "10,5:packet". ' + 'tcp_flags: RouterOS flag expression e.g. "syn,!ack". ' + 'Pass "" to clear an optional field (e.g. src_address="").',
32929
33067
  inputSchema: {
33068
+ unset: unsetProperties,
32930
33069
  rule_id: string(),
32931
33070
  chain: string().optional(),
32932
33071
  action: string().optional(),
@@ -33089,7 +33228,7 @@ ${results.join(`
33089
33228
  var resolveNatRuleId = ruleResolver("/ip firewall nat");
33090
33229
  async function updateNatRule(a, ctx) {
33091
33230
  ctx.info(`Updating NAT rule: rule_id=${a.rule_id}`);
33092
- const updates = [];
33231
+ const updates = unsetFragments(a.unset);
33093
33232
  const put = (key, val) => {
33094
33233
  if (val === undefined)
33095
33234
  return;
@@ -33347,6 +33486,7 @@ ${result}`;
33347
33486
  annotations: WRITE_IDEMPOTENT,
33348
33487
  description: "Modifies fields of an existing IPv4 NAT rule (`/ip firewall nat set`) without recreating it. " + 'rule_id takes the `.id` from list_nat_rules e.g. "*1" or "0"; returns the updated rule\'s full detail. ' + "For IPv6 NAT use update_ipv6_nat_rule; to toggle enabled state only use enable_nat_rule or disable_nat_rule. " + 'to_addresses: single IP or range e.g. "10.0.0.1" or "10.0.0.1-10.0.0.10". ' + 'to_ports: single port or range e.g. "8080" or "8080-8090". ' + 'Pass "" to clear an optional field.',
33349
33488
  inputSchema: {
33489
+ unset: unsetProperties,
33350
33490
  rule_id: string(),
33351
33491
  chain: string().optional(),
33352
33492
  action: string().optional(),
@@ -33473,7 +33613,7 @@ ${result}`;
33473
33613
  var resolveMangleRuleId = ruleResolver("/ip firewall mangle");
33474
33614
  async function updateMangleRule(a, ctx) {
33475
33615
  ctx.info(`Updating mangle rule: rule_id=${a.rule_id}`);
33476
- const updates = [];
33616
+ const updates = unsetFragments(a.unset);
33477
33617
  const put = (key, val) => {
33478
33618
  if (val === undefined)
33479
33619
  return;
@@ -33738,6 +33878,7 @@ ${result}`;
33738
33878
  annotations: WRITE_IDEMPOTENT,
33739
33879
  description: "Updates fields on an existing IPv4 mangle rule (`/ip firewall mangle set`) \u2014 change chain, action, match criteria, mark values, DSCP, TTL, MSS, or flags without recreating the rule. " + "To toggle enabled state only use enable_mangle_rule or disable_mangle_rule; for IPv6 mangle use update_ipv6_mangle_rule. " + "rule_id takes the `.id` from list_mangle_rules. " + 'Pass "" (empty string) for an optional field to clear it. ' + "Returns the updated rule's full detail.",
33740
33880
  inputSchema: {
33881
+ unset: unsetProperties,
33741
33882
  rule_id: string(),
33742
33883
  chain: string().optional(),
33743
33884
  action: string().optional(),
@@ -34523,7 +34664,7 @@ async function updatePool(a, ctx) {
34523
34664
  }
34524
34665
  if (a.comment !== undefined)
34525
34666
  cmd.raw(`comment=${quoteValue(a.comment)}`);
34526
- const built = cmd.build();
34667
+ const built = cmd.unset(a.unset).build();
34527
34668
  if (built === base)
34528
34669
  return "No updates specified.";
34529
34670
  const result = await executeMikrotikCommand2(built, ctx);
@@ -34647,6 +34788,7 @@ ${result}`;
34647
34788
  annotations: WRITE_IDEMPOTENT,
34648
34789
  description: "Modifies an existing IPv4 pool (`/ip pool set`) \u2014 rename it, replace its full ranges" + " string, update the next-pool chain reference, or set a comment. Omit a field to leave" + ' it unchanged; pass `""` (empty string) for `next_pool` to clear the chained-pool' + " reference. Ranges use hyphen notation e.g. `192.168.1.1-192.168.1.100`, multiple" + " ranges comma-separated: `10.0.0.1-10.0.0.50,10.0.0.100-10.0.0.120`. To append ranges" + " without knowing the current set use `expand_ip_pool`. Returns the updated pool detail.",
34649
34790
  inputSchema: {
34791
+ unset: unsetProperties,
34650
34792
  name: string(),
34651
34793
  new_name: string().optional(),
34652
34794
  ranges: string().optional().describe('Hyphen-separated range(s) e.g. "192.168.1.1-192.168.1.100". Multiple ranges comma-separated: "10.0.0.1-10.0.0.50,10.0.0.100-10.0.0.120"'),
@@ -35897,7 +36039,7 @@ ${result}`;
35897
36039
  var resolveRuleId = ruleResolver("/ipv6 firewall filter");
35898
36040
  async function updateFilterRule2(a, ctx) {
35899
36041
  ctx.info(`Updating IPv6 firewall filter rule: rule_id=${a.rule_id}`);
35900
- const updates = [];
36042
+ const updates = unsetFragments(a.unset);
35901
36043
  const put = (key, val) => {
35902
36044
  if (val === undefined)
35903
36045
  return;
@@ -36127,6 +36269,7 @@ ${result}`;
36127
36269
  annotations: WRITE_IDEMPOTENT,
36128
36270
  description: "Modifies one or more fields of an existing IPv6 firewall FILTER rule (`/ipv6 firewall filter set`) then returns the updated rule detail. " + "Only supplied fields are changed; omit a field to leave it untouched. " + 'Pass "" (empty string) to clear an optional field (e.g. src_address=""). ' + "To toggle enabled/disabled state only, prefer enable_ipv6_filter_rule or disable_ipv6_filter_rule. " + "For the IPv4 equivalent use update_filter_rule. " + 'rule_id takes the `.id` from list_ipv6_filter_rules e.g. "*1" or "0".',
36129
36271
  inputSchema: {
36272
+ unset: unsetProperties,
36130
36273
  rule_id: string(),
36131
36274
  chain: string().optional(),
36132
36275
  action: string().optional(),
@@ -36256,7 +36399,7 @@ ${result}`;
36256
36399
  var resolveRuleId2 = ruleResolver("/ipv6 firewall nat");
36257
36400
  async function updateNatRule2(a, ctx) {
36258
36401
  ctx.info(`Updating IPv6 firewall NAT rule: rule_id=${a.rule_id}`);
36259
- const updates = [];
36402
+ const updates = unsetFragments(a.unset);
36260
36403
  const put = (key, val) => {
36261
36404
  if (val === undefined)
36262
36405
  return;
@@ -36479,6 +36622,7 @@ ${result}`;
36479
36622
  annotations: WRITE_IDEMPOTENT,
36480
36623
  description: "Modifies fields of an existing IPv6 NAT rule (`/ipv6 firewall nat set`) \u2014 use to change action, addresses, ports, chain, or flags without removing and recreating the rule. " + "rule_id takes the `.id` from list_ipv6_nat_rules. " + 'Pass "" for any optional field to clear it (e.g. to_address=""). ' + "For IPv4 use update_nat_rule; for the IPv6 filter table use update_ipv6_filter_rule. " + "To only toggle active state use enable_ipv6_nat_rule or disable_ipv6_nat_rule. " + "Returns the updated rule's full detail.",
36481
36624
  inputSchema: {
36625
+ unset: unsetProperties,
36482
36626
  rule_id: string(),
36483
36627
  chain: string().optional(),
36484
36628
  action: string().optional(),
@@ -36598,7 +36742,7 @@ ${result}`;
36598
36742
  var resolveRuleId3 = ruleResolver("/ipv6 firewall mangle");
36599
36743
  async function updateMangleRule2(a, ctx) {
36600
36744
  ctx.info(`Updating IPv6 firewall mangle rule: rule_id=${a.rule_id}`);
36601
- const updates = [];
36745
+ const updates = unsetFragments(a.unset);
36602
36746
  const put = (key, val) => {
36603
36747
  if (val === undefined)
36604
36748
  return;
@@ -36837,6 +36981,7 @@ ${result}`;
36837
36981
  annotations: WRITE_IDEMPOTENT,
36838
36982
  description: "Updates fields on an existing IPv6 mangle rule (`/ipv6 firewall mangle set`) \u2014 change chain, action, match criteria, mark values, DSCP, hop-limit, or flags without recreating the rule. " + "To toggle enabled state only use enable_ipv6_mangle_rule or disable_ipv6_mangle_rule. " + "rule_id takes the `.id` from list_ipv6_mangle_rules. " + 'Pass "" (empty string) for an optional field to clear it. ' + "Returns the updated rule's full detail.",
36839
36983
  inputSchema: {
36984
+ unset: unsetProperties,
36840
36985
  rule_id: string(),
36841
36986
  chain: string().optional(),
36842
36987
  action: string().optional(),
@@ -36963,7 +37108,7 @@ ${result}`;
36963
37108
  var resolveRuleId4 = ruleResolver("/ipv6 firewall raw");
36964
37109
  async function updateRawRule(a, ctx) {
36965
37110
  ctx.info(`Updating IPv6 firewall raw rule: rule_id=${a.rule_id}`);
36966
- const updates = [];
37111
+ const updates = unsetFragments(a.unset);
36967
37112
  const put = (key, val) => {
36968
37113
  if (val === undefined)
36969
37114
  return;
@@ -37128,6 +37273,7 @@ ${result}`;
37128
37273
  annotations: WRITE_IDEMPOTENT,
37129
37274
  description: "Modifies fields of an existing IPv6 raw rule (`/ipv6 firewall raw set`) without deleting and " + "recreating it. Use to change chain, action, match criteria (src/dst address, port, protocol, " + "interface, address list), comment, log settings, or enabled state. " + "To reorder a rule use move_ipv6_raw_rule; to toggle only " + "the enabled state use enable_ipv6_raw_rule or disable_ipv6_raw_rule. " + 'rule_id takes the .id from list_ipv6_raw_rules. Pass "" for any optional string field to clear it. ' + "Returns the updated rule's full details.",
37130
37275
  inputSchema: {
37276
+ unset: unsetProperties,
37131
37277
  rule_id: string(),
37132
37278
  chain: string().optional(),
37133
37279
  action: string().optional(),
@@ -37429,6 +37575,7 @@ ${result}`;
37429
37575
  annotations: WRITE_IDEMPOTENT,
37430
37576
  description: "Modify an existing IPv6 Neighbor Discovery / Router Advertisement configuration " + "(`/ipv6 nd set`) by interface name (e.g. 'all', 'ether1') or `.id` \u2014 " + "use this to tune the global 'all' entry or any per-interface override. " + "Selects by `.id` when nd_id starts with '*', otherwise by interface name. " + "For adding a brand-new interface entry use add_ipv6_nd. " + "For changes to advertised prefixes use add_ipv6_nd_prefix or remove_ipv6_nd_prefix. " + "Returns the updated entry's full detail.",
37431
37577
  inputSchema: {
37578
+ unset: unsetProperties,
37432
37579
  nd_id: string().describe("Interface name (e.g. 'all', 'ether1') or '.id'"),
37433
37580
  ra_interval: string().optional(),
37434
37581
  ra_delay: string().optional(),
@@ -37455,7 +37602,7 @@ ${result}`;
37455
37602
  cmd.raw(`comment=${quoteValue(a.comment)}`);
37456
37603
  if (a.disabled !== undefined)
37457
37604
  cmd.raw(`disabled=${yesno(a.disabled)}`);
37458
- const built = cmd.build();
37605
+ const built = cmd.unset(a.unset).build();
37459
37606
  if (built === base)
37460
37607
  return "No updates specified.";
37461
37608
  const result = await executeMikrotikCommand2(built, ctx);
@@ -37732,6 +37879,7 @@ ${result}`;
37732
37879
  annotations: WRITE_IDEMPOTENT,
37733
37880
  description: "Updates an existing IPv6 prefix pool (`/ipv6 pool set`) \u2014 modifies the pool's " + "name, prefix block, delegation size, or comment. " + "Use `list_ipv6_pools` to find the current pool `name` before updating. " + 'Pass comment="" to clear the comment. ' + "Returns the updated pool's full detail after the change.",
37734
37881
  inputSchema: {
37882
+ unset: unsetProperties,
37735
37883
  name: string(),
37736
37884
  new_name: string().optional(),
37737
37885
  prefix: string().optional(),
@@ -37750,7 +37898,7 @@ ${result}`;
37750
37898
  cmd.set("prefix-length", a.prefix_length);
37751
37899
  if (a.comment !== undefined)
37752
37900
  cmd.raw(`comment=${quoteValue(a.comment)}`);
37753
- const built = cmd.build();
37901
+ const built = cmd.unset(a.unset).build();
37754
37902
  if (built === base)
37755
37903
  return "No updates specified.";
37756
37904
  const result = await executeMikrotikCommand2(built, ctx);
@@ -38086,6 +38234,7 @@ ${result}`;
38086
38234
  annotations: WRITE_IDEMPOTENT,
38087
38235
  description: "Updates an existing IPsec phase-1 profile (`/ip ipsec profile set`) by name \u2014" + " changes IKE algorithm, lifetime, NAT-T, or DPD settings without recreating the profile." + " For phase-2 algorithm changes use update_ipsec_proposal; for peer endpoint changes use" + " update_ipsec_peer. Supply only the fields to change; unchanged fields are left as-is." + " Returns the updated profile detail on success.",
38088
38236
  inputSchema: {
38237
+ unset: unsetProperties,
38089
38238
  name: string().describe("Current name of the IPsec profile to update"),
38090
38239
  new_name: string().optional(),
38091
38240
  dh_group: string().optional(),
@@ -38100,7 +38249,7 @@ ${result}`;
38100
38249
  async handler(a, ctx) {
38101
38250
  ctx.info(`Updating IPsec profile: name=${a.name}`);
38102
38251
  const base = `/ip ipsec profile set [find name="${a.name}"]`;
38103
- const cmd = new Cmd(base).opt("name", a.new_name).opt("dh-group", a.dh_group).opt("enc-algorithm", a.enc_algorithm).opt("hash-algorithm", a.hash_algorithm).opt("prf-algorithm", a.prf_algorithm).opt("lifetime", a.lifetime).bool("nat-traversal", a.nat_traversal).opt("dpd-interval", a.dpd_interval).opt("dpd-maximum-failures", a.dpd_maximum_failures).build();
38252
+ const cmd = new Cmd(base).opt("name", a.new_name).opt("dh-group", a.dh_group).opt("enc-algorithm", a.enc_algorithm).opt("hash-algorithm", a.hash_algorithm).opt("prf-algorithm", a.prf_algorithm).opt("lifetime", a.lifetime).bool("nat-traversal", a.nat_traversal).opt("dpd-interval", a.dpd_interval).opt("dpd-maximum-failures", a.dpd_maximum_failures).unset(a.unset).build();
38104
38253
  if (cmd === base)
38105
38254
  return "No updates specified.";
38106
38255
  const result = await executeMikrotikCommand2(cmd, ctx);
@@ -38198,6 +38347,7 @@ ${result}`;
38198
38347
  annotations: WRITE_IDEMPOTENT,
38199
38348
  description: "Updates an existing IPsec peer entry (`/ip ipsec peer set`) by name \u2014 changes" + " remote address, exchange mode, profile, local address, or passive flag without" + " removing and recreating the peer." + " For IKE algorithm changes use update_ipsec_profile; for auth credential changes" + " use create_ipsec_identity or remove_ipsec_identity (identities have no update tool)." + " Supply only the fields to change; unchanged fields are left as-is." + " Returns the updated peer detail on success.",
38200
38349
  inputSchema: {
38350
+ unset: unsetProperties,
38201
38351
  name: string().describe("Current name of the IPsec peer to update"),
38202
38352
  new_name: string().optional(),
38203
38353
  address: string().optional(),
@@ -38212,7 +38362,7 @@ ${result}`;
38212
38362
  async handler(a, ctx) {
38213
38363
  ctx.info(`Updating IPsec peer: name=${a.name}`);
38214
38364
  const base = `/ip ipsec peer set [find name="${a.name}"]`;
38215
- const cmd = new Cmd(base).opt("name", a.new_name).opt("address", a.address).opt("profile", a.profile).opt("exchange-mode", a.exchange_mode).opt("local-address", a.local_address).opt("port", a.port).bool("passive", a.passive).opt("comment", a.comment).bool("disabled", a.disabled).build();
38365
+ const cmd = new Cmd(base).opt("name", a.new_name).opt("address", a.address).opt("profile", a.profile).opt("exchange-mode", a.exchange_mode).opt("local-address", a.local_address).opt("port", a.port).bool("passive", a.passive).opt("comment", a.comment).bool("disabled", a.disabled).unset(a.unset).build();
38216
38366
  if (cmd === base)
38217
38367
  return "No updates specified.";
38218
38368
  const result = await executeMikrotikCommand2(cmd, ctx);
@@ -38378,6 +38528,7 @@ ${result}`;
38378
38528
  annotations: WRITE_IDEMPOTENT,
38379
38529
  description: "Updates an existing IPsec phase-2 proposal (`/ip ipsec proposal set`) by name \u2014" + " changes ESP/AH auth algorithms, encryption algorithms, PFS group, or SA lifetime" + " without recreating the proposal." + " For IKE/phase-1 algorithm changes use update_ipsec_profile." + " Supply only the fields to change; unchanged fields are left as-is." + " Returns the updated proposal detail on success.",
38380
38530
  inputSchema: {
38531
+ unset: unsetProperties,
38381
38532
  name: string().describe("Current name of the IPsec proposal to update"),
38382
38533
  new_name: string().optional(),
38383
38534
  auth_algorithms: string().optional(),
@@ -38389,7 +38540,7 @@ ${result}`;
38389
38540
  async handler(a, ctx) {
38390
38541
  ctx.info(`Updating IPsec proposal: name=${a.name}`);
38391
38542
  const base = `/ip ipsec proposal set [find name="${a.name}"]`;
38392
- const cmd = new Cmd(base).opt("name", a.new_name).opt("auth-algorithms", a.auth_algorithms).opt("enc-algorithms", a.enc_algorithms).opt("pfs-group", a.pfs_group).opt("lifetime", a.lifetime).bool("disabled", a.disabled).build();
38543
+ const cmd = new Cmd(base).opt("name", a.new_name).opt("auth-algorithms", a.auth_algorithms).opt("enc-algorithms", a.enc_algorithms).opt("pfs-group", a.pfs_group).opt("lifetime", a.lifetime).bool("disabled", a.disabled).unset(a.unset).build();
38393
38544
  if (cmd === base)
38394
38545
  return "No updates specified.";
38395
38546
  const result = await executeMikrotikCommand2(cmd, ctx);
@@ -44120,6 +44271,7 @@ ${result}`;
44120
44271
  annotations: WRITE_IDEMPOTENT,
44121
44272
  description: "Modifies an existing traffic-monitor entry by name (`/tool traffic-monitor set [find name=...]`) \u2014 " + "for changing the watched interface, traffic direction (`received`/`transmitted`), trigger condition " + "(`above`/`below`/`always`), threshold (bits/second), or on-event script without removing and re-adding. " + "Supply only the fields to change; omitted fields are left unchanged. " + 'Pass `comment=""` to clear the comment. ' + "Returns the updated entry's full detail. " + "To create a new entry use `add_traffic_monitor`.",
44122
44273
  inputSchema: {
44274
+ unset: unsetProperties,
44123
44275
  name: string(),
44124
44276
  interface: string().optional(),
44125
44277
  traffic: Traffic.optional(),
@@ -44137,7 +44289,7 @@ ${result}`;
44137
44289
  cmd.raw(`comment=${quoteValue(a.comment)}`);
44138
44290
  if (a.disabled !== undefined)
44139
44291
  cmd.raw(`disabled=${yesno(a.disabled)}`);
44140
- const built = cmd.build();
44292
+ const built = cmd.unset(a.unset).build();
44141
44293
  if (built === base)
44142
44294
  return "No updates specified.";
44143
44295
  const result = await executeMikrotikCommand2(built, ctx);
@@ -44619,6 +44771,7 @@ ${result}`;
44619
44771
  annotations: WRITE_IDEMPOTENT,
44620
44772
  description: "Modify a named OpenVPN server instance (`/interface ovpn-server server set [find name=...]`) on" + " the RouterOS 7.17+ multi-server model \u2014 change port, protocol, mode, certificate, auth/cipher," + " netmask, max_mtu, default_profile, mac_address, comment or require_client_certificate without" + " recreating it. To toggle only the enabled state use enable_ovpn_server / disable_ovpn_server." + " To create a server use add_ovpn_server; to remove one use remove_ovpn_server. For the legacy" + " single-server menu use set_ovpn_server. Returns the updated server's detail.",
44621
44773
  inputSchema: {
44774
+ unset: unsetProperties,
44622
44775
  name: string().describe("Existing OpenVPN server instance name"),
44623
44776
  port: number().int().optional(),
44624
44777
  protocol: _enum(["tcp", "udp"]).optional(),
@@ -44637,7 +44790,7 @@ ${result}`;
44637
44790
  async handler(a, ctx) {
44638
44791
  ctx.info(`Updating OpenVPN server: name=${a.name}`);
44639
44792
  const base = `/interface ovpn-server server set [find name="${a.name}"]`;
44640
- const cmd = new Cmd(base).opt("port", a.port).opt("protocol", a.protocol).opt("mode", a.mode).opt("netmask", a.netmask).opt("mac-address", a.mac_address).opt("certificate", a.certificate).opt("auth", a.auth).opt("cipher", a.cipher).opt("tls-version", a.tls_version).opt("max-mtu", a.max_mtu).opt("default-profile", a.default_profile).bool("require-client-certificate", a.require_client_certificate).opt("comment", a.comment).build();
44793
+ const cmd = new Cmd(base).opt("port", a.port).opt("protocol", a.protocol).opt("mode", a.mode).opt("netmask", a.netmask).opt("mac-address", a.mac_address).opt("certificate", a.certificate).opt("auth", a.auth).opt("cipher", a.cipher).opt("tls-version", a.tls_version).opt("max-mtu", a.max_mtu).opt("default-profile", a.default_profile).bool("require-client-certificate", a.require_client_certificate).opt("comment", a.comment).unset(a.unset).build();
44641
44794
  if (cmd === base)
44642
44795
  return "No updates specified.";
44643
44796
  const count = await executeMikrotikCommand2(`/interface ovpn-server server print count-only where name="${a.name}"`, ctx);
@@ -44988,6 +45141,7 @@ ${result}`;
44988
45141
  annotations: WRITE_IDEMPOTENT,
44989
45142
  description: "Modifies an existing PPP profile's settings (`/ppp profile set [find name=...]`). " + "Targets the profile by its current name; supply `new_name` to rename it. Any combination of fields can be updated \u2014 local/remote address, DNS, rate-limit (e.g. '10M/10M'), encryption, TCP-MSS, bridge, only-one. " + "For updating VPN user credentials use update_ppp_secret instead. " + "Returns the profile's updated detail after the change.",
44990
45143
  inputSchema: {
45144
+ unset: unsetProperties,
44991
45145
  name: string().describe("Current name of the PPP profile to update"),
44992
45146
  new_name: string().optional(),
44993
45147
  local_address: string().optional(),
@@ -45016,8 +45170,8 @@ ${result}`;
45016
45170
  },
45017
45171
  async handler(a, ctx) {
45018
45172
  ctx.info(`Updating PPP profile: name=${a.name}`);
45019
- const cmd = new Cmd(`/ppp profile set [find name="${a.name}"]`).opt("name", a.new_name).opt("local-address", a.local_address).opt("remote-address", a.remote_address).opt("dns-server", a.dns_server).opt("wins-server", a.wins_server).opt("address-list", a.address_list).opt("incoming-filter", a.incoming_filter).opt("outgoing-filter", a.outgoing_filter).opt("rate-limit", a.rate_limit).opt("session-timeout", a.session_timeout).opt("idle-timeout", a.idle_timeout).opt("use-encryption", a.use_encryption).opt("use-mpls", a.use_mpls).opt("use-compression", a.use_compression).opt("change-tcp-mss", a.change_tcp_mss).opt("only-one", a.only_one).opt("bridge", a.bridge).opt("bridge-horizon", a.bridge_horizon).opt("bridge-path-cost", a.bridge_path_cost).opt("bridge-port-priority", a.bridge_port_priority).opt("dhcpv6-pd-pool", a.dhcpv6_pd_pool).opt("on-up", a.on_up).opt("on-down", a.on_down).opt("comment", a.comment).build();
45020
- if (!cmd.includes("=", cmd.indexOf("]")))
45173
+ const cmd = new Cmd(`/ppp profile set [find name="${a.name}"]`).opt("name", a.new_name).opt("local-address", a.local_address).opt("remote-address", a.remote_address).opt("dns-server", a.dns_server).opt("wins-server", a.wins_server).opt("address-list", a.address_list).opt("incoming-filter", a.incoming_filter).opt("outgoing-filter", a.outgoing_filter).opt("rate-limit", a.rate_limit).opt("session-timeout", a.session_timeout).opt("idle-timeout", a.idle_timeout).opt("use-encryption", a.use_encryption).opt("use-mpls", a.use_mpls).opt("use-compression", a.use_compression).opt("change-tcp-mss", a.change_tcp_mss).opt("only-one", a.only_one).opt("bridge", a.bridge).opt("bridge-horizon", a.bridge_horizon).opt("bridge-path-cost", a.bridge_path_cost).opt("bridge-port-priority", a.bridge_port_priority).opt("dhcpv6-pd-pool", a.dhcpv6_pd_pool).opt("on-up", a.on_up).opt("on-down", a.on_down).opt("comment", a.comment).unset(a.unset).build();
45174
+ if (!/[=!]/.test(cmd.slice(cmd.indexOf("]"))))
45021
45175
  return "No updates specified.";
45022
45176
  const result = await executeMikrotikCommand2(cmd, ctx);
45023
45177
  if (looksLikeError(result))
@@ -45119,6 +45273,7 @@ ${redactSecrets(result)}`;
45119
45273
  annotations: WRITE_IDEMPOTENT,
45120
45274
  description: "Modifies an existing PPP secret \u2014 a VPN user credential (`/ppp secret set [find name=...]`). " + "Targets the account by its current username; supply `new_name` to rename it. Any combination of fields can be changed \u2014 password, service restriction (any/l2tp/pptp/sstp/ovpn/pppoe), profile, local/remote address, caller-id, comment, or disabled state. " + "For updating connection templates (rate-limit, encryption, DNS) use update_ppp_profile instead. " + "Password is redacted in the returned output. Returns the account's updated detail after the change.",
45121
45275
  inputSchema: {
45276
+ unset: unsetProperties,
45122
45277
  name: string().describe("Current username of the secret to update"),
45123
45278
  new_name: string().optional(),
45124
45279
  password: string().optional(),
@@ -45135,8 +45290,8 @@ ${redactSecrets(result)}`;
45135
45290
  },
45136
45291
  async handler(a, ctx) {
45137
45292
  ctx.info(`Updating PPP secret: name=${a.name}`);
45138
- const cmd = new Cmd(`/ppp secret set [find name="${a.name}"]`).opt("name", a.new_name).opt("password", a.password).opt("service", a.service).opt("profile", a.profile).opt("local-address", a.local_address).opt("remote-address", a.remote_address).opt("routes", a.routes).opt("caller-id", a.caller_id).opt("limit-bytes-in", a.limit_bytes_in).opt("limit-bytes-out", a.limit_bytes_out).opt("comment", a.comment).bool("disabled", a.disabled).build();
45139
- if (!cmd.includes("=", cmd.indexOf("]")))
45293
+ const cmd = new Cmd(`/ppp secret set [find name="${a.name}"]`).opt("name", a.new_name).opt("password", a.password).opt("service", a.service).opt("profile", a.profile).opt("local-address", a.local_address).opt("remote-address", a.remote_address).opt("routes", a.routes).opt("caller-id", a.caller_id).opt("limit-bytes-in", a.limit_bytes_in).opt("limit-bytes-out", a.limit_bytes_out).opt("comment", a.comment).bool("disabled", a.disabled).unset(a.unset).build();
45294
+ if (!/[=!]/.test(cmd.slice(cmd.indexOf("]"))))
45140
45295
  return "No updates specified.";
45141
45296
  const result = await executeMikrotikCommand2(cmd, ctx);
45142
45297
  if (looksLikeError(result))
@@ -45523,6 +45678,7 @@ ${result}`;
45523
45678
  annotations: WRITE_IDEMPOTENT,
45524
45679
  description: "Modifies an existing queue discipline (`/queue type set [find name=...]`). Supports renaming (`new_name`) and changing CAKE- or PCQ-specific parameters (cake_flowmode, cake_nat, cake_overhead, pcq_rate, pcq_classifier, etc.). Does not change the queue `kind` \u2014 to switch algorithm, remove and recreate the type with `remove_queue_type` then `create_queue_type`. Returns updated detail; if no parameters are provided returns 'No updates specified.' Use `get_queue_type` to confirm current values first.",
45525
45680
  inputSchema: {
45681
+ unset: unsetProperties,
45526
45682
  name: string(),
45527
45683
  new_name: string().optional(),
45528
45684
  cake_flowmode: string().optional(),
@@ -45552,8 +45708,8 @@ ${result}`;
45552
45708
  },
45553
45709
  async handler(a, ctx) {
45554
45710
  ctx.info(`Updating queue type: name=${a.name}`);
45555
- const cmd = new Cmd(`/queue type set [find name="${a.name}"]`).opt("name", a.new_name).opt("cake-flowmode", a.cake_flowmode).bool("cake-nat", a.cake_nat).opt("cake-overhead", a.cake_overhead).opt("cake-mpu", a.cake_mpu).opt("cake-diffserv", a.cake_diffserv).opt("cake-ack-filter", a.cake_ack_filter).opt("cake-rtt", a.cake_rtt).bool("cake-wash", a.cake_wash).opt("cake-overhead-scheme", a.cake_overhead_scheme).opt("cake-bandwidth", a.cake_bandwidth).opt("cake-atm", a.cake_atm).bool("cake-autorate-ingress", a.cake_autorate_ingress).opt("cake-memlimit", a.cake_memlimit).opt("pcq-rate", a.pcq_rate).opt("pcq-limit", a.pcq_limit).opt("pcq-classifier", a.pcq_classifier).opt("pcq-total-limit", a.pcq_total_limit).opt("pcq-burst-rate", a.pcq_burst_rate).opt("pcq-burst-threshold", a.pcq_burst_threshold).opt("pcq-burst-time", a.pcq_burst_time).opt("pcq-src-address-mask", a.pcq_src_address_mask).opt("pcq-dst-address-mask", a.pcq_dst_address_mask).opt("pcq-src-address6-mask", a.pcq_src_address6_mask).opt("pcq-dst-address6-mask", a.pcq_dst_address6_mask).build();
45556
- if (!cmd.includes("=", cmd.indexOf("]")))
45711
+ const cmd = new Cmd(`/queue type set [find name="${a.name}"]`).opt("name", a.new_name).opt("cake-flowmode", a.cake_flowmode).bool("cake-nat", a.cake_nat).opt("cake-overhead", a.cake_overhead).opt("cake-mpu", a.cake_mpu).opt("cake-diffserv", a.cake_diffserv).opt("cake-ack-filter", a.cake_ack_filter).opt("cake-rtt", a.cake_rtt).bool("cake-wash", a.cake_wash).opt("cake-overhead-scheme", a.cake_overhead_scheme).opt("cake-bandwidth", a.cake_bandwidth).opt("cake-atm", a.cake_atm).bool("cake-autorate-ingress", a.cake_autorate_ingress).opt("cake-memlimit", a.cake_memlimit).opt("pcq-rate", a.pcq_rate).opt("pcq-limit", a.pcq_limit).opt("pcq-classifier", a.pcq_classifier).opt("pcq-total-limit", a.pcq_total_limit).opt("pcq-burst-rate", a.pcq_burst_rate).opt("pcq-burst-threshold", a.pcq_burst_threshold).opt("pcq-burst-time", a.pcq_burst_time).opt("pcq-src-address-mask", a.pcq_src_address_mask).opt("pcq-dst-address-mask", a.pcq_dst_address_mask).opt("pcq-src-address6-mask", a.pcq_src_address6_mask).opt("pcq-dst-address6-mask", a.pcq_dst_address6_mask).unset(a.unset).build();
45712
+ if (!/[=!]/.test(cmd.slice(cmd.indexOf("]"))))
45557
45713
  return "No updates specified.";
45558
45714
  const result = await executeMikrotikCommand2(cmd, ctx);
45559
45715
  if (looksLikeError(result))
@@ -45657,6 +45813,7 @@ ${result}`;
45657
45813
  annotations: WRITE_IDEMPOTENT,
45658
45814
  description: "Modifies an existing queue tree node (`/queue tree set [find name=...]`). Accepts `new_name`, `parent`, `queue` (qdisc reference from `create_queue_type`), `packet_mark`, bandwidth params (`max_limit`, `limit_at`, `burst_limit`, `burst_threshold` as RouterOS rate strings e.g. '10M', '512k', '1G'; `burst_time` e.g. '8s'), `priority` (1 highest \u2013 8 lowest), `comment`, and `disabled`. Returns updated detail; if no parameters are specified returns 'No updates specified.' Use `get_queue_tree` to confirm current state before updating. For simple per-target queues use `update_simple_queue`.",
45659
45815
  inputSchema: {
45816
+ unset: unsetProperties,
45660
45817
  name: string(),
45661
45818
  new_name: string().optional(),
45662
45819
  parent: string().optional(),
@@ -45674,8 +45831,8 @@ ${result}`;
45674
45831
  },
45675
45832
  async handler(a, ctx) {
45676
45833
  ctx.info(`Updating queue tree: name=${a.name}`);
45677
- const cmd = new Cmd(`/queue tree set [find name="${a.name}"]`).opt("name", a.new_name).opt("parent", a.parent).opt("queue", a.queue).opt("packet-mark", a.packet_mark).opt("max-limit", a.max_limit).opt("limit-at", a.limit_at).opt("burst-limit", a.burst_limit).opt("burst-threshold", a.burst_threshold).opt("burst-time", a.burst_time).opt("bucket-size", a.bucket_size).opt("priority", a.priority).opt("comment", a.comment).bool("disabled", a.disabled).build();
45678
- if (!cmd.includes("=", cmd.indexOf("]")))
45834
+ const cmd = new Cmd(`/queue tree set [find name="${a.name}"]`).opt("name", a.new_name).opt("parent", a.parent).opt("queue", a.queue).opt("packet-mark", a.packet_mark).opt("max-limit", a.max_limit).opt("limit-at", a.limit_at).opt("burst-limit", a.burst_limit).opt("burst-threshold", a.burst_threshold).opt("burst-time", a.burst_time).opt("bucket-size", a.bucket_size).opt("priority", a.priority).opt("comment", a.comment).bool("disabled", a.disabled).unset(a.unset).build();
45835
+ if (!/[=!]/.test(cmd.slice(cmd.indexOf("]"))))
45679
45836
  return "No updates specified.";
45680
45837
  const result = await executeMikrotikCommand2(cmd, ctx);
45681
45838
  if (looksLikeError(result))
@@ -45816,6 +45973,7 @@ ${result}`;
45816
45973
  annotations: WRITE_IDEMPOTENT,
45817
45974
  description: "Modifies an existing per-target rate-limiting entry (`/queue simple set [find name=...]`). Accepts `new_name`, `target` (IP/CIDR or interface e.g. '192.168.1.0/24', 'ether1'), `dst`, bandwidth params (`max_limit`, `limit_at`, `burst_limit`, `burst_threshold` as 'UL/DL' or single value e.g. '10M/10M', '5M'; `burst_time` e.g. '8s'), `queue` (qdisc reference), `parent`, `priority` (1 highest \u2013 8 lowest), `packet_marks`, `comment`, and `disabled`. Returns updated detail; if no parameters are provided returns 'No updates specified.' Use `get_simple_queue` to confirm current state first. For hierarchical queue nodes use `update_queue_tree`.",
45818
45975
  inputSchema: {
45976
+ unset: unsetProperties,
45819
45977
  name: string(),
45820
45978
  new_name: string().optional(),
45821
45979
  target: string().optional().describe('IP/CIDR or interface e.g. "192.168.1.0/24" or "ether1"'),
@@ -45836,8 +45994,8 @@ ${result}`;
45836
45994
  },
45837
45995
  async handler(a, ctx) {
45838
45996
  ctx.info(`Updating simple queue: name=${a.name}`);
45839
- const cmd = new Cmd(`/queue simple set [find name="${a.name}"]`).opt("name", a.new_name).opt("target", a.target).opt("dst", a.dst).opt("max-limit", a.max_limit).opt("limit-at", a.limit_at).opt("burst-limit", a.burst_limit).opt("burst-threshold", a.burst_threshold).opt("burst-time", a.burst_time).opt("bucket-size", a.bucket_size).opt("queue", a.queue).opt("parent", a.parent).opt("priority", a.priority).opt("packet-marks", a.packet_marks).opt("time", a.time).opt("comment", a.comment).bool("disabled", a.disabled).build();
45840
- if (!cmd.includes("=", cmd.indexOf("]")))
45997
+ const cmd = new Cmd(`/queue simple set [find name="${a.name}"]`).opt("name", a.new_name).opt("target", a.target).opt("dst", a.dst).opt("max-limit", a.max_limit).opt("limit-at", a.limit_at).opt("burst-limit", a.burst_limit).opt("burst-threshold", a.burst_threshold).opt("burst-time", a.burst_time).opt("bucket-size", a.bucket_size).opt("queue", a.queue).opt("parent", a.parent).opt("priority", a.priority).opt("packet-marks", a.packet_marks).opt("time", a.time).opt("comment", a.comment).bool("disabled", a.disabled).unset(a.unset).build();
45998
+ if (!/[=!]/.test(cmd.slice(cmd.indexOf("]"))))
45841
45999
  return "No updates specified.";
45842
46000
  const result = await executeMikrotikCommand2(cmd, ctx);
45843
46001
  if (looksLikeError(result))
@@ -45948,13 +46106,14 @@ ${result}`;
45948
46106
  annotations: WRITE_IDEMPOTENT,
45949
46107
  description: "Assign a queue type to a specific interface (`/queue interface set`) \u2014 controls which egress queuing discipline is applied to outbound traffic on that interface. " + "Use this to switch between built-in types such as 'ethernet-default' or 'only-hardware-queue', or to apply a custom queue type defined under /queue type. " + "This does NOT create a bandwidth-limiting queue; for that use create_simple_queue (simple rate-limit) or create_queue_tree (hierarchical/HTB shaping). " + "Accepts the interface name (e.g. 'ether1') or RouterOS '.id' (from list_queue_interfaces) as interface_id; " + "if the id begins with '*' it is matched by .id, otherwise by interface name. " + "Returns the updated entry detail on success.",
45950
46108
  inputSchema: {
46109
+ unset: unsetProperties,
45951
46110
  interface_id: string().describe("Interface name (e.g. 'ether1') or RouterOS '.id'"),
45952
46111
  queue: string().describe("Queue-type name to apply to the interface")
45953
46112
  },
45954
46113
  async handler(a, ctx) {
45955
46114
  ctx.info(`Updating queue interface: interface_id=${a.interface_id}`);
45956
46115
  const selector = a.interface_id.startsWith("*") ? `.id="${a.interface_id}"` : `interface="${a.interface_id}"`;
45957
- const cmd = new Cmd(`/queue interface set [find ${selector}]`).set("queue", a.queue).build();
46116
+ const cmd = new Cmd(`/queue interface set [find ${selector}]`).set("queue", a.queue).unset(a.unset).build();
45958
46117
  const result = await executeMikrotikCommand2(cmd, ctx);
45959
46118
  if (looksLikeError(result))
45960
46119
  return `Failed to update queue interface: ${result}`;
@@ -46584,6 +46743,7 @@ ${redactSecrets(result)}`;
46584
46743
  annotations: WRITE_IDEMPOTENT,
46585
46744
  description: "Updates one or more fields on an existing RADIUS server entry (`/radius set <id>`) \u2014" + " use to change the address, shared secret, services, ports, timeout, realm, or enabled" + " state without recreating the entry. The `radius_id` is the `.id` returned by" + " `list_radius_servers`. Returns the updated entry's full detail with the shared secret" + " redacted. To create a new entry use `add_radius_server`; to toggle enabled state only" + " use `enable_radius_server` or `disable_radius_server`.",
46586
46745
  inputSchema: {
46746
+ unset: unsetProperties,
46587
46747
  radius_id: string().describe("RADIUS entry internal .id, e.g. '*1'"),
46588
46748
  address: string().optional(),
46589
46749
  secret: string().optional(),
@@ -46603,8 +46763,8 @@ ${redactSecrets(result)}`;
46603
46763
  },
46604
46764
  async handler(a, ctx) {
46605
46765
  ctx.info(`Updating RADIUS server: radius_id=${a.radius_id}`);
46606
- const cmd = new Cmd(`/radius set ${a.radius_id}`).opt("address", a.address).opt("secret", a.secret).opt("service", a.service).opt("authentication-port", a.authentication_port).opt("accounting-port", a.accounting_port).opt("timeout", a.timeout).opt("src-address", a.src_address).opt("realm", a.realm).opt("called-id", a.called_id).opt("domain", a.domain).opt("protocol", a.protocol).opt("certificate", a.certificate).bool("accounting-backup", a.accounting_backup).opt("comment", a.comment).bool("disabled", a.disabled).build();
46607
- if (!cmd.includes("="))
46766
+ const cmd = new Cmd(`/radius set ${a.radius_id}`).opt("address", a.address).opt("secret", a.secret).opt("service", a.service).opt("authentication-port", a.authentication_port).opt("accounting-port", a.accounting_port).opt("timeout", a.timeout).opt("src-address", a.src_address).opt("realm", a.realm).opt("called-id", a.called_id).opt("domain", a.domain).opt("protocol", a.protocol).opt("certificate", a.certificate).bool("accounting-backup", a.accounting_backup).opt("comment", a.comment).bool("disabled", a.disabled).unset(a.unset).build();
46767
+ if (!/[=!]/.test(cmd))
46608
46768
  return "No updates specified.";
46609
46769
  const result = await executeMikrotikCommand2(cmd, ctx);
46610
46770
  if (looksLikeError(result))
@@ -48135,6 +48295,7 @@ ${result}`;
48135
48295
  annotations: WRITE_IDEMPOTENT,
48136
48296
  description: "Modifies an existing IPv4 static route (`/ip route set`) \u2014 change its gateway, dst-address, " + "distance, scope, routing-table, VRF interface, preferred-source, or gateway check method. " + "`route_id` is the `*N` `.id` from list_routes. " + 'Pass an empty string ("") for `routing_table`, `vrf_interface`, or `pref_src` to clear those fields. ' + "For toggling active state without editing attributes use enable_route / disable_route. " + "Returns the updated route detail.",
48137
48297
  inputSchema: {
48298
+ unset: unsetProperties,
48138
48299
  route_id: string().describe('"*N" or "N" from list output e.g. "*3"'),
48139
48300
  dst_address: string().optional().describe('CIDR e.g. "192.168.1.0/24"'),
48140
48301
  gateway: string().optional(),
@@ -48188,7 +48349,7 @@ ${result}`;
48188
48349
  cmd.bool("suppress-hw-offload", a.suppress_hw_offload);
48189
48350
  if (a.type !== undefined)
48190
48351
  cmd.raw(routeTypeArg(a.type, true));
48191
- const built = cmd.build();
48352
+ const built = cmd.unset(a.unset).build();
48192
48353
  if (built === base)
48193
48354
  return "No updates specified.";
48194
48355
  const result = await executeMikrotikCommand2(built, ctx);
@@ -48275,7 +48436,7 @@ ${result}`;
48275
48436
  name: "check_route_path",
48276
48437
  title: "Check IPv4 Route Path",
48277
48438
  annotations: READ,
48278
- description: "Resolves which nexthop RouterOS would use for a given IPv4 destination " + '\u2014 answers "which gateway will this packet take?" without sending any traffic. ' + "Version-aware: uses `/ip route check` on v6, falls back to " + "`/ip route print where <dest> in dst-address active=yes` on v7+ where the check " + "command was removed. Optionally scoped by `routing_table` (v7) / `routing_mark` (v6) " + "for policy-routing table lookups. " + "For listing all known routes use list_routes; for a named-table view use get_routing_table. " + "Returns the resolved nexthop and interface detail.",
48439
+ description: "Resolves which nexthop RouterOS would use for a given IPv4 destination " + '\u2014 answers "which gateway will this packet take?" without sending any traffic. ' + "Version-aware: uses `/ip route check` only on a device known to run v6; on v7+ (and " + "when the version is unknown) it uses " + "`/ip route print where <dest> in dst-address active=yes` and never sends the check " + "command. Optionally scoped by `routing_table` (v7) / `routing_mark` (v6) " + "for policy-routing table lookups. " + "For listing all known routes use list_routes; for a named-table view use get_routing_table. " + "Returns the resolved nexthop and interface detail.",
48279
48440
  inputSchema: {
48280
48441
  destination: string(),
48281
48442
  routing_table: string().optional().describe('Policy-routing table name (v7) or routing-mark (v6), e.g. "VPN"')
@@ -48283,12 +48444,17 @@ ${result}`;
48283
48444
  async handler(a, ctx) {
48284
48445
  ctx.info(`Checking route path to: ${a.destination}`);
48285
48446
  const table = a.routing_table;
48286
- const v6Cmd = new Cmd(`/ip route check ${a.destination}`).opt("routing-mark", table).build();
48287
- const v6Result = await executeMikrotikCommand2(v6Cmd, ctx);
48288
- if (!commandUnsupported(v6Result) && !looksLikeError(v6Result) && !isEmpty(v6Result)) {
48289
- return `ROUTE PATH TO ${a.destination}:
48447
+ const major = (await getCapabilities(ctx.device).catch(() => {
48448
+ return;
48449
+ }))?.version?.major;
48450
+ if (major !== undefined && major < 7) {
48451
+ const v6Cmd = new Cmd(`/ip route check ${a.destination}`).opt("routing-mark", table).build();
48452
+ const v6Result = await executeMikrotikCommand2(v6Cmd, ctx);
48453
+ if (!commandUnsupported(v6Result) && !looksLikeError(v6Result) && !isEmpty(v6Result)) {
48454
+ return `ROUTE PATH TO ${a.destination}:
48290
48455
 
48291
48456
  ${v6Result}`;
48457
+ }
48292
48458
  }
48293
48459
  const where = [`${a.destination} in dst-address`, "active=yes"];
48294
48460
  if (table && table !== "main")
@@ -48466,6 +48632,7 @@ ${result}`;
48466
48632
  annotations: WRITE_IDEMPOTENT,
48467
48633
  description: "Updates an existing BFD timer-profile entry (`/routing bfd configuration set`) by its `.id` " + "(obtain from `list_bfd_configurations`). Adjusts `interfaces`, `vrf`, `min_rx`/`min_tx` intervals " + '(e.g. "200ms"), `multiplier`, `comment`, or `disabled` state. To toggle enabled state only use ' + "`set_bfd_configuration_enabled`. Returns the updated entry's full detail.",
48468
48634
  inputSchema: {
48635
+ unset: unsetProperties,
48469
48636
  config_id: string().describe('Configuration id, e.g. "*1"'),
48470
48637
  interfaces: string().optional(),
48471
48638
  vrf: string().optional(),
@@ -48484,7 +48651,7 @@ ${result}`;
48484
48651
  cmd.set("comment", a.comment);
48485
48652
  if (a.disabled !== undefined)
48486
48653
  cmd.bool("disabled", a.disabled);
48487
- const built = cmd.build();
48654
+ const built = cmd.unset(a.unset).build();
48488
48655
  if (built === base)
48489
48656
  return "No updates specified.";
48490
48657
  const result = await executeMikrotikCommand2(built, ctx);
@@ -48705,6 +48872,7 @@ ${details}`;
48705
48872
  annotations: WRITE_IDEMPOTENT,
48706
48873
  description: 'Modifies settings of an existing BGP connection by name (`/routing bgp connection set [find name="<name>"]`). ' + "Only supplied fields are changed; omitted fields are left unchanged. To enable or disable a connection " + "without touching other settings use `set_bgp_connection_enabled`. To delete a connection use " + "`remove_bgp_connection`. Returns the full updated connection detail on success.",
48707
48874
  inputSchema: {
48875
+ unset: unsetProperties,
48708
48876
  name: string().describe("Existing BGP connection name"),
48709
48877
  remote_address: string().optional(),
48710
48878
  remote_as: number().int().optional(),
@@ -48763,7 +48931,7 @@ ${details}`;
48763
48931
  cmd.set("comment", a.comment);
48764
48932
  if (a.disabled !== undefined)
48765
48933
  cmd.bool("disabled", a.disabled);
48766
- const built = cmd.build();
48934
+ const built = cmd.unset(a.unset).build();
48767
48935
  if (built === base)
48768
48936
  return "No updates specified.";
48769
48937
  const result = await executeMikrotikCommand2(built, ctx);
@@ -48977,6 +49145,7 @@ ${result}`;
48977
49145
  annotations: WRITE_IDEMPOTENT,
48978
49146
  description: "Updates an existing routing filter rule's chain, script expression, comment, or enabled state " + "(`/routing filter rule set`) on RouterOS v7. `rule_id` takes the `.id` from list_routing_filter_rules " + '(e.g. `"*3"`). Returns the updated rule\'s full detail. ' + "To toggle only enabled/disabled state use set_routing_filter_rule_enabled.",
48979
49147
  inputSchema: {
49148
+ unset: unsetProperties,
48980
49149
  rule_id: string().describe('Rule id, e.g. "*3"'),
48981
49150
  chain: string().optional(),
48982
49151
  rule: string().optional(),
@@ -48995,7 +49164,7 @@ ${result}`;
48995
49164
  cmd.set("comment", a.comment);
48996
49165
  if (a.disabled !== undefined)
48997
49166
  cmd.bool("disabled", a.disabled);
48998
- const built = cmd.build();
49167
+ const built = cmd.unset(a.unset).build();
48999
49168
  if (built === base)
49000
49169
  return "No updates specified.";
49001
49170
  const result = await executeMikrotikCommand2(built, ctx);
@@ -49236,6 +49405,7 @@ ${details}`;
49236
49405
  annotations: WRITE_IDEMPOTENT,
49237
49406
  description: "Modifies an existing Router-ID instance (`/routing id set [find name=...]`). " + "Supply any combination of fields to change; omitted fields are left untouched. " + 'Pass `""` for `id` to clear the fixed router-id (RouterOS unsets it with `!id`); ' + 'pass `""` for `select_dynamic_id` to clear dynamic interface selection (`!select-dynamic-id`). ' + "Use `add_routing_id` to create a new instance; " + "use `set_routing_id_enabled` to toggle enabled state without changing other properties. " + "For updating IPv4 routes use `update_route`; for policy routing rules use `update_routing_rule`. " + "Returns the updated instance's full detail.",
49238
49407
  inputSchema: {
49408
+ unset: unsetProperties,
49239
49409
  name: string().describe("Existing Router-ID instance name"),
49240
49410
  id: string().optional().describe('IPv4 router-id, or "" to clear'),
49241
49411
  select_dynamic_id: string().optional().describe('Interface/loopback name, or "" to clear'),
@@ -49255,7 +49425,7 @@ ${details}`;
49255
49425
  cmd.set("comment", a.comment);
49256
49426
  if (a.disabled !== undefined)
49257
49427
  cmd.bool("disabled", a.disabled);
49258
- const built = cmd.build();
49428
+ const built = cmd.unset(a.unset).build();
49259
49429
  if (built === base)
49260
49430
  return "No updates specified.";
49261
49431
  const result = await executeMikrotikCommand2(built, ctx);
@@ -49400,6 +49570,7 @@ ${result}`;
49400
49570
  annotations: WRITE_IDEMPOTENT,
49401
49571
  description: "Update an existing IGMP proxy interface entry by name (`/routing igmp-proxy interface set " + "[find interface=...]`). Modifies the upstream/downstream role, alternative subnets, TTL threshold, " + "comment, or disabled state of the named interface. For adding a new interface use " + "`add_igmp_proxy_interface`; to toggle only the enabled state use `set_igmp_proxy_interface_enabled`. " + "Returns updated interface detail on success.",
49402
49572
  inputSchema: {
49573
+ unset: unsetProperties,
49403
49574
  interface: string().describe("Existing IGMP-proxy interface name"),
49404
49575
  upstream: boolean().optional(),
49405
49576
  alternative_subnets: string().optional(),
@@ -49417,7 +49588,7 @@ ${result}`;
49417
49588
  cmd.set("comment", a.comment);
49418
49589
  if (a.disabled !== undefined)
49419
49590
  cmd.bool("disabled", a.disabled);
49420
- const built = cmd.build();
49591
+ const built = cmd.unset(a.unset).build();
49421
49592
  if (built === base)
49422
49593
  return "No updates specified.";
49423
49594
  const result = await executeMikrotikCommand2(built, ctx);
@@ -49594,6 +49765,7 @@ ${details}`;
49594
49765
  annotations: WRITE_IDEMPOTENT,
49595
49766
  description: "Update an existing OSPF instance (`/routing ospf instance set`) by name \u2014 change router-id, " + "redistribution list, import/export filter chains, originate-default policy, comment, or disabled state. " + "Only supplied fields are modified; omitting a field leaves it unchanged. " + "`name` identifies the target instance (use list_ospf_instances to find names). " + "Returns the updated instance detail. To remove an instance entirely use remove_ospf_instance.",
49596
49767
  inputSchema: {
49768
+ unset: unsetProperties,
49597
49769
  name: string().describe("Existing OSPF instance name"),
49598
49770
  router_id: string().optional(),
49599
49771
  redistribute: string().optional(),
@@ -49618,7 +49790,7 @@ ${details}`;
49618
49790
  cmd.set("comment", a.comment);
49619
49791
  if (a.disabled !== undefined)
49620
49792
  cmd.bool("disabled", a.disabled);
49621
- const built = cmd.build();
49793
+ const built = cmd.unset(a.unset).build();
49622
49794
  if (built === base)
49623
49795
  return "No updates specified.";
49624
49796
  const result = await executeMikrotikCommand2(built, ctx);
@@ -50143,6 +50315,7 @@ ${details}`;
50143
50315
  annotations: WRITE_IDEMPOTENT,
50144
50316
  description: "Modify an existing RIP process instance (`/routing rip instance set`) identified by its name. Use to " + "change redistribution policy, filter chains, router-id, or enabled/disabled state without recreating the " + "instance. Obtain the name from list_rip_instances. For creating a new instance use add_rip_instance; for " + "removing one use remove_rip_instance. Returns the updated instance's detail. Requires RouterOS v7 with " + "the routing package.",
50145
50317
  inputSchema: {
50318
+ unset: unsetProperties,
50146
50319
  name: string().describe("Existing RIP instance name"),
50147
50320
  router_id: string().optional(),
50148
50321
  routing_table: string().optional().describe("Routing table to install routes into"),
@@ -50161,7 +50334,7 @@ ${details}`;
50161
50334
  cmd.set("comment", a.comment);
50162
50335
  if (a.disabled !== undefined)
50163
50336
  cmd.bool("disabled", a.disabled);
50164
- const built = cmd.build();
50337
+ const built = cmd.unset(a.unset).build();
50165
50338
  if (built === base)
50166
50339
  return "No updates specified.";
50167
50340
  const result = await executeMikrotikCommand2(built, ctx);
@@ -50386,6 +50559,7 @@ ${result}`;
50386
50559
  annotations: WRITE_IDEMPOTENT,
50387
50560
  description: "Modifies an existing RPKI RTR session (`/routing rpki set`) by its `.id`. Use `list_rpki_sessions` to " + 'obtain the `session_id` (e.g. "*1"). Updatable fields include `address`, `port`, interval timings ' + '(`refresh_interval`, `expire_interval`, `retry_interval`, e.g. "10m", "30s", "2h"), `comment`, and ' + "`disabled`. To toggle enabled/disabled only, prefer `set_rpki_session_enabled`. Returns the updated session " + "detail.",
50388
50561
  inputSchema: {
50562
+ unset: unsetProperties,
50389
50563
  session_id: string().describe('Session id, e.g. "*1"'),
50390
50564
  address: string().optional(),
50391
50565
  port: number().int().optional(),
@@ -50403,7 +50577,7 @@ ${result}`;
50403
50577
  cmd.set("comment", a.comment);
50404
50578
  if (a.disabled !== undefined)
50405
50579
  cmd.bool("disabled", a.disabled);
50406
- const built = cmd.build();
50580
+ const built = cmd.unset(a.unset).build();
50407
50581
  if (built === base)
50408
50582
  return "No updates specified.";
50409
50583
  const result = await executeMikrotikCommand2(built, ctx);
@@ -50583,6 +50757,7 @@ ${result}`;
50583
50757
  annotations: WRITE_IDEMPOTENT,
50584
50758
  description: "Modify an existing policy routing rule (`/routing rule set`) by its `.id` (obtain from `list_routing_rules`). " + 'Pass `""` for `src_address`, `dst_address`, `routing_mark`, `interface`, or `table` to clear that field. ' + "Requires RouterOS v7 with the routing package. For updating static routes use `update_route`. " + "Returns the rule's updated detail after applying changes.",
50585
50759
  inputSchema: {
50760
+ unset: unsetProperties,
50586
50761
  rule_id: string().describe('Rule id, e.g. "*3"'),
50587
50762
  action: _enum(ACTIONS).optional(),
50588
50763
  table: string().optional(),
@@ -50616,7 +50791,7 @@ ${result}`;
50616
50791
  cmd.set("comment", a.comment);
50617
50792
  if (a.disabled !== undefined)
50618
50793
  cmd.bool("disabled", a.disabled);
50619
- const built = cmd.build();
50794
+ const built = cmd.unset(a.unset).build();
50620
50795
  if (built === base)
50621
50796
  return "No updates specified.";
50622
50797
  const result = await executeMikrotikCommand2(built, ctx);
@@ -50746,6 +50921,7 @@ ${details}`;
50746
50921
  annotations: WRITE_IDEMPOTENT,
50747
50922
  description: "Modifies an existing routing table (`/routing table set [find name=\u2026]`) \u2014 changes its `fib` flag, " + "`comment`, or `disabled` state. " + "To create a new table use `add_routing_table`; to toggle only the enabled/disabled state use `set_routing_table_enabled`. " + "No-ops safely if no optional arguments are provided. " + "Returns the updated table's full detail record on success.",
50748
50923
  inputSchema: {
50924
+ unset: unsetProperties,
50749
50925
  name: string().describe("Existing routing table name"),
50750
50926
  fib: boolean().optional().describe("Install routes into the FIB"),
50751
50927
  comment: string().optional(),
@@ -50760,7 +50936,7 @@ ${details}`;
50760
50936
  cmd.set("comment", a.comment);
50761
50937
  if (a.disabled !== undefined)
50762
50938
  cmd.bool("disabled", a.disabled);
50763
- const built = cmd.build();
50939
+ const built = cmd.unset(a.unset).build();
50764
50940
  if (built === base)
50765
50941
  return "No updates specified.";
50766
50942
  const result = await executeMikrotikCommand2(built, ctx);
@@ -50817,7 +50993,7 @@ var safeModeTools = [
50817
50993
  name: "set_safe_mode_timeout",
50818
50994
  title: "Set Safe Mode Command Timeouts",
50819
50995
  annotations: WRITE,
50820
- description: "Set per-device MCP Safe Mode command deadlines before or during a session. Applies only to subsequent commands. Increase for slow exports, decrease for faster failure detection. Does not change RouterOS rollback timing, MCP client deadlines, or unblock an uncertain session. Settings are in-memory and reset on MCP restart. Defaults: command 120000ms, idle 15000ms.",
50996
+ description: "Set per-device MCP Safe Mode command deadlines before or during a session. Applies only to subsequent commands. Increase for slow exports, decrease for faster failure detection. Does not change RouterOS rollback timing or MCP client deadlines. Settings are in-memory and reset on MCP restart. Defaults: command 120000ms, idle 15000ms.",
50821
50997
  inputSchema: {
50822
50998
  commandTimeoutMs: number().int().min(1000).max(600000).describe("Absolute command deadline in milliseconds."),
50823
50999
  idleTimeoutMs: number().int().min(1000).max(600000).describe("Maximum silence in milliseconds; must not exceed commandTimeoutMs.")
@@ -50830,7 +51006,7 @@ var safeModeTools = [
50830
51006
  name: "safe_mode_status",
50831
51007
  title: "Get Safe Mode Session Status",
50832
51008
  annotations: READ,
50833
- description: "Queries the Safe Mode SSH session state for the targeted device \u2014 reports whether a Safe Mode window is currently open (active) or closed." + " Safe Mode (RouterOS Ctrl+X) stages all configuration changes in memory for automatic revert on disconnect; this tool does not modify any state." + " Returns a status string indicating whether Safe Mode is currently active." + " Use enable_safe_mode to open a session, commit_safe_mode to persist staged changes, or rollback_safe_mode to discard them.",
51009
+ description: "Queries the Safe Mode SSH session state for the targeted device \u2014 reports whether a Safe Mode window is currently open (active) or closed, and why the last session was closed automatically, if it was." + " Safe Mode (RouterOS Ctrl+X) stages all configuration changes in memory for automatic revert on disconnect; this tool does not modify any state." + " Returns a status string indicating whether Safe Mode is currently active." + " Use enable_safe_mode to open a session, commit_safe_mode to persist staged changes, or rollback_safe_mode to discard them.",
50834
51010
  handler(_a, ctx) {
50835
51011
  const device = resolveDeviceName2(ctx.device);
50836
51012
  ctx.info(`[${device}] Checking safe mode status`);
@@ -50845,7 +51021,10 @@ var safeModeTools = [
50845
51021
  async handler(_a, ctx) {
50846
51022
  const device = resolveDeviceName2(ctx.device);
50847
51023
  ctx.info(`[${device}] Enabling MikroTik safe mode`);
50848
- return getSafeModeManager2(device).enable();
51024
+ const result = await getSafeModeManager2(device).enable();
51025
+ if (result.startsWith("Error"))
51026
+ throw new Error(result.replace(/^Error:\s*/, ""));
51027
+ return result;
50849
51028
  }
50850
51029
  }),
50851
51030
  defineTool2({
@@ -50856,14 +51035,17 @@ var safeModeTools = [
50856
51035
  async handler(_a, ctx) {
50857
51036
  const device = resolveDeviceName2(ctx.device);
50858
51037
  ctx.info(`[${device}] Committing safe mode changes`);
50859
- return (await getSafeModeManager2(device).commit()).message;
51038
+ const result = await getSafeModeManager2(device).commit();
51039
+ if (!result.ok)
51040
+ throw new Error(result.message);
51041
+ return result.message;
50860
51042
  }
50861
51043
  }),
50862
51044
  defineTool2({
50863
51045
  name: "rollback_safe_mode",
50864
51046
  title: "Roll Back Safe Mode Changes",
50865
51047
  annotations: WRITE,
50866
- description: "Closes the targeted Safe Mode SSH session to request RouterOS automatic rollback. Completion is unverified and may be delayed; compare live configuration against a backup before retrying writes." + " Use this when staged changes are incorrect or need to be abandoned without saving." + " To persist staged changes instead, use commit_safe_mode." + " Check current Safe Mode state with safe_mode_status.",
51048
+ description: "Closes the targeted Safe Mode SSH session to request RouterOS automatic rollback. Completion is unverified and may be delayed; compare live configuration against a backup before retrying writes. A session that times out or loses its prompt is closed automatically, so this tool is never required to recover." + " Use this when staged changes are incorrect or need to be abandoned without saving." + " To persist staged changes instead, use commit_safe_mode." + " Check current Safe Mode state with safe_mode_status.",
50867
51049
  async handler(_a, ctx) {
50868
51050
  const device = resolveDeviceName2(ctx.device);
50869
51051
  ctx.info(`[${device}] Rolling back safe mode changes`);
@@ -53415,7 +53597,7 @@ var riskByTool = null;
53415
53597
  async function riskIndex() {
53416
53598
  if (riskByTool)
53417
53599
  return riskByTool;
53418
- const { moduleCatalog } = await import("./library-qx9hax3s.js");
53600
+ const { moduleCatalog } = await import("./library-vtet3w1h.js");
53419
53601
  const index = new Map;
53420
53602
  for (const mod of moduleCatalog) {
53421
53603
  for (const tool of mod.tools)
@@ -57874,6 +58056,7 @@ ${result}`;
57874
58056
 
57875
58057
  ` + "Returns updated switch details on success.",
57876
58058
  inputSchema: {
58059
+ unset: unsetProperties,
57877
58060
  switch_id: string().describe("Switch name (e.g. 'switch1') or RouterOS '.id'"),
57878
58061
  name: string().optional().describe("Rename the switch"),
57879
58062
  cpu_flow_control: boolean().optional(),
@@ -57888,7 +58071,7 @@ ${result}`;
57888
58071
  const selector = a.switch_id.startsWith("*") ? `.id="${a.switch_id}"` : `name="${a.switch_id}"`;
57889
58072
  const base = `/interface ethernet switch set [find ${selector}]`;
57890
58073
  const cmd = new Cmd(base).opt("name", a.name).bool("cpu-flow-control", a.cpu_flow_control).opt("mirror-source", a.mirror_source).opt("mirror-target", a.mirror_target).opt("mirror-egress", a.mirror_egress).opt("mirror-egress-target", a.mirror_egress_target).bool("switch-all-ports", a.switch_all_ports);
57891
- const built = cmd.build();
58074
+ const built = cmd.unset(a.unset).build();
57892
58075
  if (built === base)
57893
58076
  return "No updates specified.";
57894
58077
  const result = await executeMikrotikCommand2(built, ctx);
@@ -57961,6 +58144,7 @@ ${result}`;
57961
58144
  ` + ` 'always-strip', or 'add-if-missing'.
57962
58145
  ` + " default_vlan_id: PVID for untagged ingress ('auto', 'none', or a number).",
57963
58146
  inputSchema: {
58147
+ unset: unsetProperties,
57964
58148
  port_id: string().describe("Port name (e.g. 'ether1') or RouterOS '.id'"),
57965
58149
  default_vlan_id: string().optional().describe("PVID: 'auto', 'none', or a VLAN id number"),
57966
58150
  vlan_mode: VlanMode.optional(),
@@ -57972,7 +58156,7 @@ ${result}`;
57972
58156
  const selector = a.port_id.startsWith("*") ? `.id="${a.port_id}"` : `name="${a.port_id}"`;
57973
58157
  const base = `/interface ethernet switch port set [find ${selector}]`;
57974
58158
  const cmd = new Cmd(base).opt("default-vlan-id", a.default_vlan_id).opt("vlan-mode", a.vlan_mode).opt("vlan-header", a.vlan_header).bool("force-vlan-id", a.force_vlan_id);
57975
- const built = cmd.build();
58159
+ const built = cmd.unset(a.unset).build();
57976
58160
  if (built === base)
57977
58161
  return "No updates specified.";
57978
58162
  const result = await executeMikrotikCommand2(built, ctx);
@@ -58068,6 +58252,7 @@ ${result}`;
58068
58252
 
58069
58253
  ` + "Returns the entry's updated detail block.",
58070
58254
  inputSchema: {
58255
+ unset: unsetProperties,
58071
58256
  isolation_id: string().describe("Source port name or RouterOS '.id'"),
58072
58257
  forwarding_override_ports: string().optional().describe("Comma-separated allowed destination ports"),
58073
58258
  comment: string().optional()
@@ -58079,7 +58264,7 @@ ${result}`;
58079
58264
  const cmd = new Cmd(base).opt("forwarding-override-ports", a.forwarding_override_ports);
58080
58265
  if (a.comment !== undefined)
58081
58266
  cmd.raw(`comment=${quoteValue(a.comment)}`);
58082
- const built = cmd.build();
58267
+ const built = cmd.unset(a.unset).build();
58083
58268
  if (built === base)
58084
58269
  return "No updates specified.";
58085
58270
  const result = await executeMikrotikCommand2(built, ctx);
@@ -58118,7 +58303,7 @@ ${details}`;
58118
58303
  // src/tools/switch-rule.ts
58119
58304
  async function updateSwitchRule(a, ctx) {
58120
58305
  ctx.info(`Updating switch rule: rule_id=${a.rule_id}`);
58121
- const updates = [];
58306
+ const updates = unsetFragments(a.unset);
58122
58307
  const put = (key, val) => {
58123
58308
  if (val === undefined)
58124
58309
  return;
@@ -58266,6 +58451,7 @@ ${result}`;
58266
58451
  annotations: WRITE_IDEMPOTENT,
58267
58452
  description: "Modifies an existing hardware switch ACL/redirect rule " + "(`/interface ethernet switch rule set`) by `.id`. " + "Use this to change match criteria (ports, addresses, VLAN, protocol) or actions " + "(redirect target ports, mirror, rate limit, disabled state). " + 'Pass an empty string ("") for any optional field to clear it. ' + "`rule_id` takes the `.id` from list_switch_rules. Returns the updated rule's full detail. " + "For software firewall rule edits use update_filter_rule; " + "to only toggle the enabled state use enable_switch_rule or disable_switch_rule.",
58268
58453
  inputSchema: {
58454
+ unset: unsetProperties,
58269
58455
  rule_id: string(),
58270
58456
  switch: string().optional(),
58271
58457
  ports: string().optional(),
@@ -59351,6 +59537,7 @@ ${redactSecrets(result)}`;
59351
59537
  annotations: WRITE_IDEMPOTENT,
59352
59538
  description: "Modifies an existing User Manager RADIUS user (`/user-manager user set [find name=...]`)" + " \u2014 change name, password, group, shared-users limit, RADIUS attributes, comment, or" + " enabled/disabled state. Locate the user by its current `name` (from" + " list_user_manager_users or get_user_manager_user). Returns the updated record with" + " secrets redacted. To permanently delete the user use remove_user_manager_user.",
59353
59539
  inputSchema: {
59540
+ unset: unsetProperties,
59354
59541
  name: string().describe("Current name of the user to update"),
59355
59542
  new_name: string().optional(),
59356
59543
  password: string().optional(),
@@ -59364,8 +59551,8 @@ ${redactSecrets(result)}`;
59364
59551
  },
59365
59552
  async handler(a, ctx) {
59366
59553
  ctx.info(`Updating User Manager user: name=${a.name}`);
59367
- const cmd = new Cmd(`/user-manager user set [find name="${a.name}"]`).opt("name", a.new_name).opt("password", a.password).opt("group", a.group).opt("shared-users", a.shared_users).opt("attributes", a.attributes).opt("caller-id", a.caller_id).opt("otp-secret", a.otp_secret).opt("comment", a.comment).bool("disabled", a.disabled).build();
59368
- if (!cmd.includes("=", cmd.indexOf("]")))
59554
+ const cmd = new Cmd(`/user-manager user set [find name="${a.name}"]`).opt("name", a.new_name).opt("password", a.password).opt("group", a.group).opt("shared-users", a.shared_users).opt("attributes", a.attributes).opt("caller-id", a.caller_id).opt("otp-secret", a.otp_secret).opt("comment", a.comment).bool("disabled", a.disabled).unset(a.unset).build();
59555
+ if (!/[=!]/.test(cmd.slice(cmd.indexOf("]"))))
59369
59556
  return "No updates specified.";
59370
59557
  const result = await executeMikrotikCommand2(cmd, ctx);
59371
59558
  if (commandUnsupported(result))
@@ -60356,6 +60543,7 @@ ${result}`;
60356
60543
  annotations: WRITE_IDEMPOTENT,
60357
60544
  description: 'Modifies properties of an existing VLAN sub-interface (`/interface vlan set [find name="..."]`).' + " Accepts any subset of the create parameters; omit fields to leave them unchanged." + " Supply the current `name` from `list_vlan_interfaces` or `get_vlan_interface`; use `new_name` to rename the interface." + " For creating a new VLAN interface use `create_vlan_interface`; to permanently delete use `remove_vlan_interface`." + " Returns the updated interface's full detail after applying the change." + " ARP mode accepts: enabled, disabled, proxy-arp, reply-only.",
60358
60545
  inputSchema: {
60546
+ unset: unsetProperties,
60359
60547
  name: string().describe("Current name of the VLAN interface to update"),
60360
60548
  new_name: interfaceName().optional().describe("Rename the interface to this (no spaces)."),
60361
60549
  vlan_id: number().int().min(1).max(4094).optional(),
@@ -60373,8 +60561,8 @@ ${result}`;
60373
60561
  },
60374
60562
  async handler(a, ctx) {
60375
60563
  ctx.info(`Updating VLAN interface: name=${a.name}`);
60376
- const cmd = new Cmd(`/interface vlan set [find name="${a.name}"]`).opt("name", a.new_name).opt("vlan-id", a.vlan_id).opt("interface", a.interface).opt("comment", a.comment).bool("disabled", a.disabled).opt("mtu", a.mtu).opt("forced-mac-address", a.forced_mac_address).bool("use-service-tag", a.use_service_tag).opt("arp", a.arp).opt("arp-timeout", a.arp_timeout).opt("loop-protect", a.loop_protect).opt("loop-protect-disable-time", a.loop_protect_disable_time).opt("loop-protect-send-interval", a.loop_protect_send_interval).build();
60377
- if (!cmd.includes("=", cmd.indexOf("]")))
60564
+ const cmd = new Cmd(`/interface vlan set [find name="${a.name}"]`).opt("name", a.new_name).opt("vlan-id", a.vlan_id).opt("interface", a.interface).opt("comment", a.comment).bool("disabled", a.disabled).opt("mtu", a.mtu).opt("forced-mac-address", a.forced_mac_address).bool("use-service-tag", a.use_service_tag).opt("arp", a.arp).opt("arp-timeout", a.arp_timeout).opt("loop-protect", a.loop_protect).opt("loop-protect-disable-time", a.loop_protect_disable_time).opt("loop-protect-send-interval", a.loop_protect_send_interval).unset(a.unset).build();
60565
+ if (!/[=!]/.test(cmd.slice(cmd.indexOf("]"))))
60378
60566
  return "No updates specified.";
60379
60567
  const result = await executeMikrotikCommand2(cmd, ctx);
60380
60568
  if (looksLikeError(result))
@@ -60694,6 +60882,7 @@ ${peerBlock}`;
60694
60882
  annotations: WRITE_IDEMPOTENT,
60695
60883
  description: "Modifies settings on an existing WireGuard tunnel interface (`/interface wireguard set [find name=]`)" + " \u2014 rename (new_name), change listen-port, rotate private-key, adjust MTU, or toggle disabled state." + " Only supplied fields are changed; omitted fields are left as-is." + " For updating remote peers use update_wireguard_peer." + " Returns the updated interface's detail.",
60696
60884
  inputSchema: {
60885
+ unset: unsetProperties,
60697
60886
  name: string(),
60698
60887
  new_name: interfaceName().optional().describe("Rename the interface to this (no spaces)."),
60699
60888
  listen_port: number().int().optional(),
@@ -60705,7 +60894,7 @@ ${peerBlock}`;
60705
60894
  async handler(a, ctx) {
60706
60895
  ctx.info(`Updating WireGuard interface: name=${a.name}`);
60707
60896
  const base = `/interface wireguard set [find name="${a.name}"]`;
60708
- const cmd = new Cmd(base).opt("name", a.new_name).opt("listen-port", a.listen_port).opt("private-key", a.private_key).opt("mtu", a.mtu).raw(a.comment !== undefined ? `comment=${quoteValue(a.comment)}` : null).bool("disabled", a.disabled).build();
60897
+ const cmd = new Cmd(base).opt("name", a.new_name).opt("listen-port", a.listen_port).opt("private-key", a.private_key).opt("mtu", a.mtu).raw(a.comment !== undefined ? `comment=${quoteValue(a.comment)}` : null).bool("disabled", a.disabled).unset(a.unset).build();
60709
60898
  if (cmd === base)
60710
60899
  return "No updates specified.";
60711
60900
  const result = await executeMikrotikCommand2(cmd, ctx);
@@ -60870,6 +61059,7 @@ ${result}`;
60870
61059
  ` + ` persistent_keepalive: seconds as string e.g. "25"
60871
61060
  ` + ' Pass "" for endpoint_address or preshared_key to clear them.',
60872
61061
  inputSchema: {
61062
+ unset: unsetProperties,
60873
61063
  peer_id: string().describe('"*N" or "N" from list output e.g. "*2"'),
60874
61064
  public_key: string().optional().describe("The peer's base64 public key \u2014 re-key a peer in place instead of removing and " + "re-adding it (which would lose the rest of its configuration)."),
60875
61065
  allowed_address: string().optional(),
@@ -60895,7 +61085,7 @@ ${result}`;
60895
61085
  if (!id)
60896
61086
  return peerNotFound(a.peer_id);
60897
61087
  const base = `/interface wireguard peers set ${id}`;
60898
- const cmd = new Cmd(base).raw(a.public_key !== undefined ? `public-key=${quoteValue(a.public_key)}` : null).raw(a.allowed_address !== undefined ? `allowed-address=${quoteValue(a.allowed_address)}` : null).raw(a.endpoint_address !== undefined ? a.endpoint_address === "" ? "!endpoint-address" : `endpoint-address=${quoteValue(a.endpoint_address)}` : null).opt("endpoint-port", a.endpoint_port).raw(a.preshared_key !== undefined ? a.preshared_key === "" ? "!preshared-key" : `preshared-key=${quoteValue(a.preshared_key)}` : null).raw(a.persistent_keepalive !== undefined ? `persistent-keepalive=${a.persistent_keepalive}` : null).opt("name", a.name).opt("private-key", a.private_key).bool("responder", a.responder).raw(a.client_address !== undefined ? a.client_address === "" ? "!client-address" : `client-address=${quoteValue(a.client_address)}` : null).raw(a.client_dns !== undefined ? a.client_dns === "" ? "!client-dns" : `client-dns=${quoteValue(a.client_dns)}` : null).raw(a.client_endpoint !== undefined ? a.client_endpoint === "" ? "!client-endpoint" : `client-endpoint=${quoteValue(a.client_endpoint)}` : null).opt("client-keepalive", a.client_keepalive).raw(a.client_listen_port === "" ? "!client-listen-port" : null).opt("client-listen-port", a.client_listen_port === "" ? undefined : a.client_listen_port).opt("client-mtu", a.client_mtu).raw(a.comment !== undefined ? `comment=${quoteValue(a.comment)}` : null).bool("disabled", a.disabled).build();
61088
+ const cmd = new Cmd(base).raw(a.public_key !== undefined ? `public-key=${quoteValue(a.public_key)}` : null).raw(a.allowed_address !== undefined ? `allowed-address=${quoteValue(a.allowed_address)}` : null).raw(a.endpoint_address !== undefined ? a.endpoint_address === "" ? "!endpoint-address" : `endpoint-address=${quoteValue(a.endpoint_address)}` : null).opt("endpoint-port", a.endpoint_port).raw(a.preshared_key !== undefined ? a.preshared_key === "" ? "!preshared-key" : `preshared-key=${quoteValue(a.preshared_key)}` : null).raw(a.persistent_keepalive !== undefined ? `persistent-keepalive=${a.persistent_keepalive}` : null).opt("name", a.name).opt("private-key", a.private_key).bool("responder", a.responder).raw(a.client_address !== undefined ? a.client_address === "" ? "!client-address" : `client-address=${quoteValue(a.client_address)}` : null).raw(a.client_dns !== undefined ? a.client_dns === "" ? "!client-dns" : `client-dns=${quoteValue(a.client_dns)}` : null).raw(a.client_endpoint !== undefined ? a.client_endpoint === "" ? "!client-endpoint" : `client-endpoint=${quoteValue(a.client_endpoint)}` : null).opt("client-keepalive", a.client_keepalive).raw(a.client_listen_port === "" ? "!client-listen-port" : null).opt("client-listen-port", a.client_listen_port === "" ? undefined : a.client_listen_port).opt("client-mtu", a.client_mtu).raw(a.comment !== undefined ? `comment=${quoteValue(a.comment)}` : null).bool("disabled", a.disabled).unset(a.unset).build();
60899
61089
  if (cmd === base)
60900
61090
  return "No updates specified.";
60901
61091
  const result = await executeMikrotikCommand2(cmd, ctx);
@@ -61598,6 +61788,7 @@ ${redactSecrets(result)}`;
61598
61788
  annotations: WRITE_IDEMPOTENT,
61599
61789
  description: "Updates settings on an existing named wireless interface (`<auto-detected path> set [find name=...] ...`). " + "Supports renaming (new_name), changing SSID, toggling disabled state, and updating comment. " + "Verifies the interface exists before applying; returns 'No updates specified.' if no optional fields are provided. " + "To only enable or disable the interface prefer enable_wireless_interface or disable_wireless_interface; " + "to create a new interface use create_wireless_interface; to delete one use remove_wireless_interface. " + "Returns the updated interface's full detail print.",
61600
61790
  inputSchema: {
61791
+ unset: unsetProperties,
61601
61792
  name: string(),
61602
61793
  new_name: interfaceName().optional().describe("Rename the interface to this (no spaces)."),
61603
61794
  ssid: string().optional(),
@@ -61632,8 +61823,8 @@ ${redactSecrets(result)}`;
61632
61823
  const count = await executeMikrotikCommand2(`${interfaceType} print count-only where name="${a.name}"`, ctx);
61633
61824
  if (count.trim() === "0")
61634
61825
  return `Wireless interface '${a.name}' not found.`;
61635
- const cmd = new Cmd(`${interfaceType} set [find name="${a.name}"]`).opt("name", a.new_name).opt("ssid", a.ssid).bool("disabled", a.disabled).opt("comment", a.comment).opt("mtu", a.mtu).opt("arp", a.arp).bool("hide-ssid", a.hide_ssid).opt("wireless-protocol", a.wireless_protocol).opt("scan-list", a.scan_list).opt("frequency", a.frequency).opt("band", a.band).opt("channel-width", a.channel_width).opt("frequency-mode", a.frequency_mode).opt("country", a.country).opt("antenna-gain", a.antenna_gain).opt("wds-mode", a.wds_mode).opt("wds-default-bridge", a.wds_default_bridge).bool("default-authentication", a.default_authentication).bool("default-forwarding", a.default_forwarding).opt("tx-power", a.tx_power).opt("tx-power-mode", a.tx_power_mode).opt("distance", a.distance).opt("disconnect-timeout", a.disconnect_timeout).opt("security-profile", a.security_profile).build();
61636
- if (!cmd.includes("=", cmd.indexOf("]")))
61826
+ const cmd = new Cmd(`${interfaceType} set [find name="${a.name}"]`).opt("name", a.new_name).opt("ssid", a.ssid).bool("disabled", a.disabled).opt("comment", a.comment).opt("mtu", a.mtu).opt("arp", a.arp).bool("hide-ssid", a.hide_ssid).opt("wireless-protocol", a.wireless_protocol).opt("scan-list", a.scan_list).opt("frequency", a.frequency).opt("band", a.band).opt("channel-width", a.channel_width).opt("frequency-mode", a.frequency_mode).opt("country", a.country).opt("antenna-gain", a.antenna_gain).opt("wds-mode", a.wds_mode).opt("wds-default-bridge", a.wds_default_bridge).bool("default-authentication", a.default_authentication).bool("default-forwarding", a.default_forwarding).opt("tx-power", a.tx_power).opt("tx-power-mode", a.tx_power_mode).opt("distance", a.distance).opt("disconnect-timeout", a.disconnect_timeout).opt("security-profile", a.security_profile).unset(a.unset).build();
61827
+ if (!/[=!]/.test(cmd.slice(cmd.indexOf("]"))))
61637
61828
  return "No updates specified.";
61638
61829
  const result = await executeMikrotikCommand2(cmd, ctx);
61639
61830
  if (looksLikeError(result))