@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
@@ -10724,7 +10724,7 @@ function stripAnsi(text) {
10724
10724
  }
10725
10725
  var CTRL_X = "\x18";
10726
10726
  var PRINT_PAGER_RE = /(?:^|[\r\n])-- \[Q quit\|D dump\|(?:up\||left\||right\|)*down\][ \t\r]*$/;
10727
- 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.";
10727
+ 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.";
10728
10728
  var IDLE_TIMEOUT_MS = 15000;
10729
10729
  var HARD_CAP_MS = 120000;
10730
10730
  function isSafeModeActivated(response) {
@@ -10750,7 +10750,7 @@ class SafeModeManager {
10750
10750
  channel = null;
10751
10751
  active = false;
10752
10752
  droppedUnexpectedly = false;
10753
- uncertain = false;
10753
+ lastClosure = null;
10754
10754
  probeSequence = 0;
10755
10755
  queue = Promise.resolve();
10756
10756
  commandTimeoutMs = HARD_CAP_MS;
@@ -10761,7 +10761,7 @@ class SafeModeManager {
10761
10761
  }
10762
10762
  this.commandTimeoutMs = commandTimeoutMs;
10763
10763
  this.idleTimeoutMs = idleTimeoutMs;
10764
- 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.`;
10764
+ return `Safe Mode command timeout: ${commandTimeoutMs}ms; idle timeout: ${idleTimeoutMs}ms. Applies to subsequent commands only; does not change RouterOS rollback timing.`;
10765
10765
  }
10766
10766
  constructor(deviceName) {
10767
10767
  this.deviceName = deviceName;
@@ -10770,7 +10770,12 @@ class SafeModeManager {
10770
10770
  return this.active;
10771
10771
  }
10772
10772
  get requiresRecovery() {
10773
- return this.droppedUnexpectedly || this.uncertain;
10773
+ return this.droppedUnexpectedly;
10774
+ }
10775
+ closeAfterFailure(reason) {
10776
+ this.cleanup();
10777
+ this.droppedUnexpectedly = false;
10778
+ this.lastClosure = `${new Date().toISOString()}: ${reason}`;
10774
10779
  }
10775
10780
  lock(fn) {
10776
10781
  const run = this.queue.then(fn, fn);
@@ -10784,9 +10789,8 @@ class SafeModeManager {
10784
10789
  enable() {
10785
10790
  return this.lock(async () => {
10786
10791
  if (this.active)
10787
- return this.uncertain ? `Error: ${UNCERTAIN_SESSION}` : "Safe mode is already active.";
10792
+ return "Safe mode is already active.";
10788
10793
  this.droppedUnexpectedly = false;
10789
- this.uncertain = false;
10790
10794
  const dc = getDevice(this.deviceName);
10791
10795
  if (dc.mac) {
10792
10796
  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.";
@@ -10818,23 +10822,22 @@ class SafeModeManager {
10818
10822
  execute(command) {
10819
10823
  return this.lock(async () => {
10820
10824
  if (this.droppedUnexpectedly) {
10821
- throw new Error("Safe Mode session dropped. Rollback is unverified; inspect device state against the backup before retrying writes.");
10825
+ this.droppedUnexpectedly = false;
10826
+ 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.");
10822
10827
  }
10823
10828
  if (!this.active || !this.channel) {
10824
- throw new Error("Safe mode session is not active.");
10829
+ throw new Error("Safe mode session is not active (it may have been closed after a failure). This command was NOT sent.");
10825
10830
  }
10826
- if (this.uncertain)
10827
- throw new Error(UNCERTAIN_SESSION);
10828
10831
  const response = this.readUntilPrompt(this.idleTimeoutMs, undefined, this.commandTimeoutMs, true);
10829
10832
  this.channel.write(`${command}\r`);
10830
10833
  const { text, timedOut } = await response;
10831
10834
  if (timedOut) {
10832
- this.uncertain = true;
10833
- 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}`);
10835
+ this.closeAfterFailure(`command timeout (${command})`);
10836
+ 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}`);
10834
10837
  }
10835
10838
  if (classifyPrompt(text) !== "safe") {
10836
- this.uncertain = true;
10837
- throw new Error(`Safe Mode protection was lost or could not be confirmed. Changes may already be permanent. ${UNCERTAIN_SESSION}`);
10839
+ this.closeAfterFailure(`Safe Mode protection lost (${command})`);
10840
+ throw new Error(`Safe Mode protection was lost or could not be confirmed. Changes may already be permanent. ${SESSION_CLOSED}`);
10838
10841
  }
10839
10842
  return this.extractOutput(text, command);
10840
10843
  });
@@ -10842,28 +10845,29 @@ class SafeModeManager {
10842
10845
  commit() {
10843
10846
  return this.lock(async () => {
10844
10847
  if (this.droppedUnexpectedly) {
10848
+ this.droppedUnexpectedly = false;
10845
10849
  return {
10846
10850
  ok: false,
10847
10851
  message: "Commit FAILED \u2014 the Safe Mode session dropped. Rollback is unverified; compare device state with the backup before retrying."
10848
10852
  };
10849
10853
  }
10850
10854
  if (!this.active || !this.channel) {
10851
- return { ok: true, message: "Safe mode is not active. Nothing to commit." };
10855
+ const last = this.lastClosure ? ` The last session was closed automatically (${this.lastClosure}).` : "";
10856
+ return { ok: true, message: `Safe mode is not active. Nothing to commit.${last}` };
10852
10857
  }
10853
- if (this.uncertain)
10854
- return { ok: false, message: UNCERTAIN_SESSION };
10855
10858
  const before = await this.probeMode();
10856
10859
  if (before === "released") {
10857
- this.uncertain = true;
10860
+ this.closeAfterFailure("Safe Mode had exited before commit");
10858
10861
  return {
10859
10862
  ok: false,
10860
- message: "Safe Mode exited before commit was requested. Changes may be permanent; verify device state against the backup."
10863
+ message: "Safe Mode exited before commit was requested. Changes may be permanent; the session " + "was closed. Read back the device state against the backup."
10861
10864
  };
10862
10865
  }
10863
10866
  if (before === "unknown") {
10867
+ this.closeAfterFailure("no answer to the pre-commit probe");
10864
10868
  return {
10865
10869
  ok: false,
10866
- message: "Could not determine Safe Mode state. Session left open; outcome unverified. " + "Call safe_mode_status or rollback_safe_mode and inspect device state."
10870
+ message: `Could not determine Safe Mode state before commit; nothing was committed. ${SESSION_CLOSED}`
10867
10871
  };
10868
10872
  }
10869
10873
  this.channel.write(CTRL_X);
@@ -10875,12 +10879,13 @@ class SafeModeManager {
10875
10879
  case "safe":
10876
10880
  return {
10877
10881
  ok: false,
10878
- 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."
10882
+ 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)."
10879
10883
  };
10880
10884
  default:
10885
+ this.closeAfterFailure("no prompt after the commit keystroke");
10881
10886
  return {
10882
10887
  ok: false,
10883
- message: "Commit status unclear \u2014 no prompt seen after commit. Session left open; outcome unverified. " + "Inspect device state before retrying."
10888
+ 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."
10884
10889
  };
10885
10890
  }
10886
10891
  });
@@ -10901,9 +10906,10 @@ class SafeModeManager {
10901
10906
  if (this.droppedUnexpectedly) {
10902
10907
  return "Safe mode session DROPPED unexpectedly. Rollback is unverified; inspect device state against the backup before retrying writes.";
10903
10908
  }
10904
- if (this.uncertain && this.active)
10905
- return UNCERTAIN_SESSION;
10906
- 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.";
10909
+ if (this.active)
10910
+ 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.";
10911
+ const last = this.lastClosure ? ` Last session was closed automatically (${this.lastClosure}); RouterOS reverts uncommitted changes on close.` : "";
10912
+ return `Safe mode is NOT active. Changes take effect and persist immediately.${last}`;
10907
10913
  }
10908
10914
  handleUnexpectedDrop = () => {
10909
10915
  if (!this.active)
@@ -11003,7 +11009,6 @@ class SafeModeManager {
11003
11009
  }
11004
11010
  cleanup() {
11005
11011
  this.active = false;
11006
- this.uncertain = false;
11007
11012
  if (this.channel) {
11008
11013
  try {
11009
11014
  this.channel.end();
@@ -11457,10 +11462,16 @@ async function runOnce(command, deviceName, opts, ctx) {
11457
11462
  client.disconnect();
11458
11463
  }
11459
11464
  }
11465
+ var READ_COMMAND_RE = /^\/(?:[^;[\]{}]*\s)?(?:print|export)(?:\s[^;[\]{}]*)?$/;
11466
+ function bypassesSafeMode(command, ctx) {
11467
+ if (ctx.risk === "READ")
11468
+ return true;
11469
+ return ctx.risk === undefined && READ_COMMAND_RE.test(command.trim());
11470
+ }
11460
11471
  async function executeMikrotikCommand(command, ctx, opts) {
11461
11472
  const deviceName = resolveDeviceName(ctx.device);
11462
11473
  const safe = getSafeModeManager(deviceName);
11463
- if (safe.isActive || safe.requiresRecovery) {
11474
+ if ((safe.isActive || safe.requiresRecovery) && !bypassesSafeMode(command, ctx)) {
11464
11475
  ctx.info(`[${deviceName}] Executing (safe mode): ${containerCommandForLog(command)}`);
11465
11476
  ctx.transport = "ssh";
11466
11477
  return safe.execute(command);
@@ -11472,7 +11483,8 @@ async function executeMikrotikJson(command, ctx, opts) {
11472
11483
  const deviceName = resolveDeviceName(ctx.device);
11473
11484
  const dc = getDevice(deviceName);
11474
11485
  const safe = getSafeModeManager(deviceName);
11475
- if (!safe.isActive && !safe.requiresRecovery && isRestDevice(dc)) {
11486
+ const viaSafeMode = (safe.isActive || safe.requiresRecovery) && !bypassesSafeMode(command, ctx);
11487
+ if (!viaSafeMode && isRestDevice(dc)) {
11476
11488
  const req = toRequest(command);
11477
11489
  if (req) {
11478
11490
  const json = await tryRestJson(command, dc, deviceName, ctx);
@@ -11724,6 +11736,15 @@ function splitHostPort(value) {
11724
11736
  return { host: hostPort[1], port: Number(hostPort[2]) };
11725
11737
  return { host: v };
11726
11738
  }
11739
+ function unsetFragments(keys) {
11740
+ return (keys ?? []).map((key) => {
11741
+ const name = key.trim().replace(/^!/, "").replaceAll("_", "-");
11742
+ if (!/^[a-z][a-z0-9-]*$/.test(name)) {
11743
+ throw new Error(`Invalid property name to unset: ${JSON.stringify(key)}`);
11744
+ }
11745
+ return `!${name}`;
11746
+ });
11747
+ }
11727
11748
 
11728
11749
  class Cmd {
11729
11750
  parts;
@@ -11751,6 +11772,10 @@ class Cmd {
11751
11772
  }
11752
11773
  return this;
11753
11774
  }
11775
+ unset(keys) {
11776
+ this.parts.push(...unsetFragments(keys));
11777
+ return this;
11778
+ }
11754
11779
  raw(fragment) {
11755
11780
  if (fragment)
11756
11781
  this.parts.push(fragment);
@@ -14201,6 +14226,7 @@ function defineTool(def) {
14201
14226
  }
14202
14227
  sendLog?.(level, `[${id}] ${message}`);
14203
14228
  }, device, id);
14229
+ ctx.risk = risk;
14204
14230
  let result;
14205
14231
  try {
14206
14232
  result = await execute(args, ctx);
@@ -16818,13 +16844,13 @@ async function undoMigration(id, confirm, selected) {
16818
16844
  throw new Error("Undo lost Safe Mode or exceeded its time budget.");
16819
16845
  await checkedRead(item.undo, createContext(undefined, device));
16820
16846
  }
16821
- const beforeTarget = (await import("./cli-n6heg9q6.js")).openSnapshotStore;
16822
- const db = await beforeTarget((await import("./cli-vrfw477g.js")).DEFAULT_SNAPSHOT_DB);
16847
+ const beforeTarget = (await import("./cli-s9k59ne8.js")).openSnapshotStore;
16848
+ const db = await beforeTarget((await import("./cli-frg1ynaw.js")).DEFAULT_SNAPSHOT_DB);
16823
16849
  try {
16824
16850
  const original = db.get(p.snapshots.target);
16825
16851
  if (!original)
16826
16852
  throw new Error("Original target snapshot unavailable.");
16827
- const { normalizeExport } = await import("./cli-xgyy9he1.js");
16853
+ const { normalizeExport } = await import("./cli-zhfcf33s.js");
16828
16854
  if (normalizeExport((await migrationInventory(device)).export) !== normalizeExport(original.body))
16829
16855
  throw new Error("Target differs from its backup. Undo verification failed.");
16830
16856
  } finally {
@@ -24302,6 +24328,7 @@ function interfaceName(description) {
24302
24328
  const s = string().regex(NO_WHITESPACE, INTERFACE_NAME_MESSAGE);
24303
24329
  return description ? s.describe(description) : s;
24304
24330
  }
24331
+ 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.");
24305
24332
 
24306
24333
  // src/tools/bridge.ts
24307
24334
  var ProtocolMode = _enum(["none", "rstp", "stp", "mstp"]);
@@ -24405,6 +24432,7 @@ ${result}`;
24405
24432
  annotations: WRITE_IDEMPOTENT,
24406
24433
  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.",
24407
24434
  inputSchema: {
24435
+ unset: unsetProperties,
24408
24436
  name: string().describe("Current name of the bridge to update"),
24409
24437
  new_name: interfaceName().optional().describe("Rename the bridge to this (no spaces)."),
24410
24438
  comment: string().optional(),
@@ -24439,8 +24467,8 @@ ${result}`;
24439
24467
  if ((a.arp_inspection || a.ip_source_guard) && !a.confirm_security_disruption)
24440
24468
  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.";
24441
24469
  ctx.info(`Updating bridge: name=${a.name}`);
24442
- 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();
24443
- if (!cmd.includes("=", cmd.indexOf("]")))
24470
+ 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();
24471
+ if (!/[=!]/.test(cmd.slice(cmd.indexOf("]"))))
24444
24472
  return "No updates specified.";
24445
24473
  const result = await executeMikrotikCommand(cmd, ctx);
24446
24474
  if (looksLikeError(result))
@@ -25138,6 +25166,44 @@ function diffLines(from, to, opts = {}) {
25138
25166
  }
25139
25167
 
25140
25168
  // src/tools/change-plan.ts
25169
+ var REVERT_SETTLE_MS = 2000;
25170
+ async function exportConfig(readCtx) {
25171
+ const body = await executeMikrotikCommand("/export terse", readCtx);
25172
+ if (looksLikeError(body) || !/^\/[a-z]/m.test(body)) {
25173
+ throw new Error("could not read `/export terse` from the device");
25174
+ }
25175
+ return normalizeExport2(body);
25176
+ }
25177
+ async function liveState(readCtx, before, after, mayRevert = true) {
25178
+ const read = () => exportConfig(readCtx).catch(() => null);
25179
+ let live = await read();
25180
+ if (mayRevert && live !== null && live !== before) {
25181
+ await new Promise((resolve) => setTimeout(resolve, REVERT_SETTLE_MS));
25182
+ live = await read();
25183
+ }
25184
+ const label = "DEVICE STATE (read back on a fresh connection)";
25185
+ if (live === null) {
25186
+ return {
25187
+ kind: "unreadable",
25188
+ text: `${label}: could not be read. The device did not answer; check it before retrying.`
25189
+ };
25190
+ }
25191
+ if (live === before) {
25192
+ return {
25193
+ kind: "unchanged",
25194
+ text: `${label}: identical to the pre-change export. No change is on the device.`
25195
+ };
25196
+ }
25197
+ if (after !== undefined && live === after) {
25198
+ return { kind: "applied", text: `${label}: the change IS on the device.` };
25199
+ }
25200
+ const diff = diffLines(before, live, { fromLabel: "before", toLabel: "live" });
25201
+ return {
25202
+ kind: "different",
25203
+ text: `${label}: differs from the pre-change export (+${diff.summary.added}/-${diff.summary.removed}):
25204
+ ${diff.unified}`
25205
+ };
25206
+ }
25141
25207
  function collectCommands(a) {
25142
25208
  const fromArray = (a.commands ?? []).map((c) => c.trim()).filter(Boolean);
25143
25209
  const fromScript = a.script ? splitCommands(a.script) : [];
@@ -25166,53 +25232,107 @@ var changePlanTools = [
25166
25232
  }),
25167
25233
  defineTool({
25168
25234
  name: "apply_plan",
25169
- title: "Apply RouterOS Change Plan in Safe Mode",
25235
+ title: "Apply RouterOS Change Plan",
25170
25236
  annotations: DANGEROUS,
25171
- 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.",
25237
+ 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.",
25172
25238
  inputSchema: {
25173
25239
  commands: array(string()).optional(),
25174
25240
  script: string().optional(),
25175
- confirm: boolean().default(false).describe("false = apply, show diff, roll back (dry-run). true = commit if still reachable.")
25241
+ confirm: boolean().default(false).describe("false = apply, show diff, roll back (dry-run). true = commit if still reachable."),
25242
+ 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.")
25176
25243
  },
25177
25244
  async handler(a, ctx) {
25178
25245
  const commands = collectCommands(a);
25179
25246
  if (commands.length === 0)
25180
25247
  return "No commands provided to apply.";
25181
25248
  const device = resolveDeviceName(ctx.device);
25182
- if (getDevice(ctx.device).mac) {
25183
- throw new Error("Safe Mode (and therefore apply_plan) requires SSH; it is not available on a MAC-Telnet device.");
25184
- }
25185
25249
  const plan = buildChangePlan(commands);
25250
+ const planBody = renderPlan(plan).split(`
25251
+ `).slice(2).join(`
25252
+ `);
25186
25253
  const safe = getSafeModeManager(device);
25254
+ const readCtx = { ...ctx, risk: "READ" };
25255
+ if (a.use_safe_mode === false) {
25256
+ if (!a.confirm) {
25257
+ return `APPLY PLAN (direct, no Safe Mode) \u2014 ${device}
25258
+
25259
+ ${planBody}
25260
+
25261
+ ` + "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.";
25262
+ }
25263
+ if (safe.isActive) {
25264
+ throw new Error("A Safe Mode session is open on this device. Commit it or roll it back before a direct write.");
25265
+ }
25266
+ const snapshotId = await captureSnapshot(readCtx, "apply_plan direct (pre-change)", true);
25267
+ const before = await exportConfig(readCtx);
25268
+ const log = [];
25269
+ let failure;
25270
+ for (const step of plan.steps) {
25271
+ const out = await executeMikrotikCommand(step.command, ctx).catch((e) => `failure: ${e instanceof Error ? e.message : String(e)}`);
25272
+ if (looksLikeError(out) || out.startsWith("failure: ")) {
25273
+ failure = `step ${step.index} failed:
25274
+ ${step.command}
25275
+ \u2192 ${out.trim()}`;
25276
+ break;
25277
+ }
25278
+ log.push(` \u2713 ${step.command}`);
25279
+ }
25280
+ const state = await liveState(readCtx, before, undefined, false);
25281
+ const body = `APPLY PLAN (direct, no Safe Mode) \u2014 ${device}
25282
+
25283
+ ${planBody}
25284
+
25285
+ ` + `Restore point: snapshot ${snapshotId} (get_config_snapshot returns its export).
25286
+ ` + `Executed ${log.length} of ${plan.steps.length} step(s) directly:
25287
+ ${log.join(`
25288
+ `) || " (none)"}
25289
+
25290
+ ${state.text}`;
25291
+ if (failure) {
25292
+ throw new Error(`${body}
25293
+
25294
+ FAILED: ${failure}
25295
+ Steps marked \u2713 are permanent; nothing was rolled back.`);
25296
+ }
25297
+ if (state.kind === "unreadable") {
25298
+ throw new Error(`${body}
25299
+
25300
+ All steps ran, but the read-back check failed.`);
25301
+ }
25302
+ return `${body}
25303
+
25304
+ APPLIED: all steps ran and are permanent (verified by the read-back above).`;
25305
+ }
25306
+ if (getDevice(ctx.device).mac) {
25307
+ throw new Error("Safe Mode requires SSH; it is not available on a MAC-Telnet device. " + "Use use_safe_mode=false to write directly.");
25308
+ }
25309
+ const before = await exportConfig(readCtx);
25187
25310
  const enabled = await safe.enable();
25188
25311
  if (enabled.startsWith("Error"))
25189
25312
  throw new Error(enabled);
25190
25313
  const APPLY_BUDGET_MS = 180000;
25191
25314
  const startedAt = Date.now();
25192
- const overBudget = () => Date.now() - startedAt > APPLY_BUDGET_MS;
25193
- const applyAndDiff = async () => {
25194
- try {
25195
- const before = normalizeExport2(await safe.execute("/export terse"));
25196
- const log = [];
25197
- for (const step of plan.steps) {
25198
- if (overBudget()) {
25199
- 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");
25200
- }
25201
- const out = await safe.execute(step.command);
25202
- if (looksLikeError(out)) {
25203
- throw new Error(`step ${step.index} failed:
25315
+ let header;
25316
+ let after;
25317
+ let reachable;
25318
+ try {
25319
+ const log = [];
25320
+ for (const step of plan.steps) {
25321
+ if (Date.now() - startedAt > APPLY_BUDGET_MS) {
25322
+ throw new Error(`aborted after ${Math.round((Date.now() - startedAt) / 1000)}s (time budget exceeded)`);
25323
+ }
25324
+ const out = await safe.execute(step.command);
25325
+ if (looksLikeError(out)) {
25326
+ throw new Error(`step ${step.index} failed:
25204
25327
  ${step.command}
25205
25328
  \u2192 ${out.trim()}`);
25206
- }
25207
- log.push(` \u2713 ${step.command}`);
25208
25329
  }
25209
- const after = normalizeExport2(await safe.execute("/export terse"));
25210
- const diff = diffLines(before, after, { fromLabel: "before", toLabel: "after" });
25211
- const reachable = !looksLikeError(await safe.execute("/system identity print"));
25212
- const planBody = renderPlan(plan).split(`
25213
- `).slice(2).join(`
25214
- `);
25215
- const header = `APPLY PLAN \u2014 ${device}
25330
+ log.push(` \u2713 ${step.command}`);
25331
+ }
25332
+ after = await exportConfig(readCtx);
25333
+ const diff = diffLines(before, after, { fromLabel: "before", toLabel: "after" });
25334
+ reachable = await executeMikrotikCommand("/system identity print", readCtx).then((out) => !looksLikeError(out), () => false);
25335
+ header = `APPLY PLAN \u2014 ${device}
25216
25336
 
25217
25337
  ${planBody}
25218
25338
 
@@ -25222,35 +25342,51 @@ ${log.join(`
25222
25342
 
25223
25343
  ` + `EXACT DIFF (+${diff.summary.added}/-${diff.summary.removed}):
25224
25344
  ${diff.unified || "(no config change)"}`;
25225
- return { header, reachable };
25226
- } catch (e) {
25227
- await safe.rollback().catch(() => {});
25228
- const msg = e instanceof Error ? e.message : String(e);
25229
- throw new Error(`apply_plan failed and was rolled back (nothing committed): ${msg}`);
25230
- }
25231
- };
25232
- const { header, reachable } = await applyAndDiff();
25345
+ } catch (e) {
25346
+ await safe.rollback().catch(() => {});
25347
+ const msg = e instanceof Error ? e.message : String(e);
25348
+ const state = await liveState(readCtx, before);
25349
+ throw new Error(`apply_plan failed; the Safe Mode session was closed and nothing was committed: ${msg}
25350
+
25351
+ ${state.text}`);
25352
+ }
25233
25353
  if (!a.confirm) {
25234
25354
  await safe.rollback();
25355
+ const state = await liveState(readCtx, before);
25235
25356
  return `${header}
25236
25357
 
25237
- DRY-RUN: all changes rolled back. Re-run with confirm=true to commit.`;
25358
+ DRY-RUN: Safe Mode session closed to roll back. Re-run with confirm=true to commit.
25359
+ ${state.text}`;
25238
25360
  }
25239
25361
  if (!reachable) {
25240
25362
  await safe.rollback();
25363
+ const state = await liveState(readCtx, before);
25241
25364
  throw new Error(`${header}
25242
25365
 
25243
- ABORTED: the device stopped responding after applying \u2014 changes rolled back to avoid a lock-out.`);
25366
+ ABORTED: a new connection to the device failed after applying \u2014 Safe Mode session closed to avoid a lock-out.
25367
+ ${state.text}`);
25244
25368
  }
25245
- const committed = await safe.commit();
25246
- if (!committed.ok) {
25247
- throw new Error(`${header}
25369
+ let committed = await safe.commit();
25370
+ if (!committed.ok && safe.isActive)
25371
+ committed = await safe.commit();
25372
+ if (committed.ok) {
25373
+ return `${header}
25248
25374
 
25249
- COMMIT FAILED \u2014 changes are NOT saved (still pending in Safe Mode). ${committed.message}`);
25375
+ COMMITTED: changes are now permanent. ${committed.message}`;
25250
25376
  }
25251
- return `${header}
25377
+ if (safe.isActive)
25378
+ await safe.rollback().catch(() => {});
25379
+ const state = await liveState(readCtx, before, after);
25380
+ if (state.kind === "applied") {
25381
+ return `${header}
25252
25382
 
25253
- COMMITTED: changes are now permanent. ${committed.message}`;
25383
+ COMMITTED: the commit confirmation was lost (${committed.message}) but the ` + `Safe Mode session is closed and the change was not reverted.
25384
+ ${state.text}`;
25385
+ }
25386
+ throw new Error(`${header}
25387
+
25388
+ COMMIT FAILED: ${committed.message}
25389
+ ${state.text}`);
25254
25390
  }
25255
25391
  })
25256
25392
  ];
@@ -28894,7 +29030,7 @@ var cache3 = null;
28894
29030
  async function gateway() {
28895
29031
  if (cache3)
28896
29032
  return cache3;
28897
- const { moduleCatalog } = await import("./cli-p3rfcsg3.js");
29033
+ const { moduleCatalog } = await import("./cli-rbe7s4mf.js");
28898
29034
  const forIndex = [];
28899
29035
  const byName = new Map;
28900
29036
  for (const mod of moduleCatalog) {
@@ -29147,7 +29283,7 @@ ${details}` : "Static DNS entry addition completed but unable to verify.";
29147
29283
  }
29148
29284
  async function updateDnsStatic(a, ctx) {
29149
29285
  ctx.info(`Updating static DNS entry: entry_id=${a.entry_id}`);
29150
- const updates = [];
29286
+ const updates = unsetFragments(a.unset);
29151
29287
  if (a.name)
29152
29288
  updates.push(`name=${quoteValue(a.name)}`);
29153
29289
  if (a.type !== undefined)
@@ -29328,6 +29464,7 @@ ${result}`;
29328
29464
  annotations: WRITE_IDEMPOTENT,
29329
29465
  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.",
29330
29466
  inputSchema: {
29467
+ unset: unsetProperties,
29331
29468
  entry_id: string(),
29332
29469
  name: string().optional(),
29333
29470
  type: string().optional().describe('Record type, e.g. "A", "AAAA", "CNAME", "NS", "FWD", "MX", "SRV", "TXT"'),
@@ -29681,6 +29818,7 @@ ${result}`;
29681
29818
  annotations: WRITE_IDEMPOTENT,
29682
29819
  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.",
29683
29820
  inputSchema: {
29821
+ unset: unsetProperties,
29684
29822
  server_id: string().describe("Interface name or RouterOS '.id'"),
29685
29823
  auth_types: AuthTypes.optional(),
29686
29824
  accounting: boolean().optional(),
@@ -29706,7 +29844,7 @@ ${result}`;
29706
29844
  cmd.raw(`comment=${quoteValue(a.comment)}`);
29707
29845
  if (a.disabled !== undefined)
29708
29846
  cmd.raw(`disabled=${yesno(a.disabled)}`);
29709
- const built = cmd.build();
29847
+ const built = cmd.unset(a.unset).build();
29710
29848
  if (built === base)
29711
29849
  return "No updates specified.";
29712
29850
  const result = await executeMikrotikCommand(built, ctx);
@@ -29819,6 +29957,7 @@ ${result}`;
29819
29957
  annotations: WRITE_IDEMPOTENT,
29820
29958
  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.",
29821
29959
  inputSchema: {
29960
+ unset: unsetProperties,
29822
29961
  client_id: string().describe("Interface name or RouterOS '.id'"),
29823
29962
  eap_methods: string().optional(),
29824
29963
  identity: string().optional(),
@@ -29837,7 +29976,7 @@ ${result}`;
29837
29976
  cmd.raw(`comment=${quoteValue(a.comment)}`);
29838
29977
  if (a.disabled !== undefined)
29839
29978
  cmd.raw(`disabled=${yesno(a.disabled)}`);
29840
- const built = cmd.build();
29979
+ const built = cmd.unset(a.unset).build();
29841
29980
  if (built === base)
29842
29981
  return "No updates specified.";
29843
29982
  const result = await executeMikrotikCommand(built, ctx);
@@ -33385,7 +33524,7 @@ async function updateFilterRule(a, ctx) {
33385
33524
  ]);
33386
33525
  if (misuse)
33387
33526
  return `Failed to update firewall filter rule: ${misuse}`;
33388
- const updates = [];
33527
+ const updates = unsetFragments(a.unset);
33389
33528
  const put = (key, val) => {
33390
33529
  if (val === undefined)
33391
33530
  return;
@@ -33642,6 +33781,7 @@ ${result}`;
33642
33781
  annotations: WRITE_IDEMPOTENT,
33643
33782
  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="").',
33644
33783
  inputSchema: {
33784
+ unset: unsetProperties,
33645
33785
  rule_id: string(),
33646
33786
  chain: string().optional(),
33647
33787
  action: string().optional(),
@@ -33804,7 +33944,7 @@ ${results.join(`
33804
33944
  var resolveNatRuleId = ruleResolver("/ip firewall nat");
33805
33945
  async function updateNatRule(a, ctx) {
33806
33946
  ctx.info(`Updating NAT rule: rule_id=${a.rule_id}`);
33807
- const updates = [];
33947
+ const updates = unsetFragments(a.unset);
33808
33948
  const put = (key, val) => {
33809
33949
  if (val === undefined)
33810
33950
  return;
@@ -34062,6 +34202,7 @@ ${result}`;
34062
34202
  annotations: WRITE_IDEMPOTENT,
34063
34203
  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.',
34064
34204
  inputSchema: {
34205
+ unset: unsetProperties,
34065
34206
  rule_id: string(),
34066
34207
  chain: string().optional(),
34067
34208
  action: string().optional(),
@@ -34188,7 +34329,7 @@ ${result}`;
34188
34329
  var resolveMangleRuleId = ruleResolver("/ip firewall mangle");
34189
34330
  async function updateMangleRule(a, ctx) {
34190
34331
  ctx.info(`Updating mangle rule: rule_id=${a.rule_id}`);
34191
- const updates = [];
34332
+ const updates = unsetFragments(a.unset);
34192
34333
  const put = (key, val) => {
34193
34334
  if (val === undefined)
34194
34335
  return;
@@ -34453,6 +34594,7 @@ ${result}`;
34453
34594
  annotations: WRITE_IDEMPOTENT,
34454
34595
  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.",
34455
34596
  inputSchema: {
34597
+ unset: unsetProperties,
34456
34598
  rule_id: string(),
34457
34599
  chain: string().optional(),
34458
34600
  action: string().optional(),
@@ -35238,7 +35380,7 @@ async function updatePool(a, ctx) {
35238
35380
  }
35239
35381
  if (a.comment !== undefined)
35240
35382
  cmd.raw(`comment=${quoteValue(a.comment)}`);
35241
- const built = cmd.build();
35383
+ const built = cmd.unset(a.unset).build();
35242
35384
  if (built === base)
35243
35385
  return "No updates specified.";
35244
35386
  const result = await executeMikrotikCommand(built, ctx);
@@ -35362,6 +35504,7 @@ ${result}`;
35362
35504
  annotations: WRITE_IDEMPOTENT,
35363
35505
  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.",
35364
35506
  inputSchema: {
35507
+ unset: unsetProperties,
35365
35508
  name: string(),
35366
35509
  new_name: string().optional(),
35367
35510
  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"'),
@@ -36612,7 +36755,7 @@ ${result}`;
36612
36755
  var resolveRuleId = ruleResolver("/ipv6 firewall filter");
36613
36756
  async function updateFilterRule2(a, ctx) {
36614
36757
  ctx.info(`Updating IPv6 firewall filter rule: rule_id=${a.rule_id}`);
36615
- const updates = [];
36758
+ const updates = unsetFragments(a.unset);
36616
36759
  const put = (key, val) => {
36617
36760
  if (val === undefined)
36618
36761
  return;
@@ -36842,6 +36985,7 @@ ${result}`;
36842
36985
  annotations: WRITE_IDEMPOTENT,
36843
36986
  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".',
36844
36987
  inputSchema: {
36988
+ unset: unsetProperties,
36845
36989
  rule_id: string(),
36846
36990
  chain: string().optional(),
36847
36991
  action: string().optional(),
@@ -36971,7 +37115,7 @@ ${result}`;
36971
37115
  var resolveRuleId2 = ruleResolver("/ipv6 firewall nat");
36972
37116
  async function updateNatRule2(a, ctx) {
36973
37117
  ctx.info(`Updating IPv6 firewall NAT rule: rule_id=${a.rule_id}`);
36974
- const updates = [];
37118
+ const updates = unsetFragments(a.unset);
36975
37119
  const put = (key, val) => {
36976
37120
  if (val === undefined)
36977
37121
  return;
@@ -37194,6 +37338,7 @@ ${result}`;
37194
37338
  annotations: WRITE_IDEMPOTENT,
37195
37339
  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.",
37196
37340
  inputSchema: {
37341
+ unset: unsetProperties,
37197
37342
  rule_id: string(),
37198
37343
  chain: string().optional(),
37199
37344
  action: string().optional(),
@@ -37313,7 +37458,7 @@ ${result}`;
37313
37458
  var resolveRuleId3 = ruleResolver("/ipv6 firewall mangle");
37314
37459
  async function updateMangleRule2(a, ctx) {
37315
37460
  ctx.info(`Updating IPv6 firewall mangle rule: rule_id=${a.rule_id}`);
37316
- const updates = [];
37461
+ const updates = unsetFragments(a.unset);
37317
37462
  const put = (key, val) => {
37318
37463
  if (val === undefined)
37319
37464
  return;
@@ -37552,6 +37697,7 @@ ${result}`;
37552
37697
  annotations: WRITE_IDEMPOTENT,
37553
37698
  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.",
37554
37699
  inputSchema: {
37700
+ unset: unsetProperties,
37555
37701
  rule_id: string(),
37556
37702
  chain: string().optional(),
37557
37703
  action: string().optional(),
@@ -37678,7 +37824,7 @@ ${result}`;
37678
37824
  var resolveRuleId4 = ruleResolver("/ipv6 firewall raw");
37679
37825
  async function updateRawRule(a, ctx) {
37680
37826
  ctx.info(`Updating IPv6 firewall raw rule: rule_id=${a.rule_id}`);
37681
- const updates = [];
37827
+ const updates = unsetFragments(a.unset);
37682
37828
  const put = (key, val) => {
37683
37829
  if (val === undefined)
37684
37830
  return;
@@ -37843,6 +37989,7 @@ ${result}`;
37843
37989
  annotations: WRITE_IDEMPOTENT,
37844
37990
  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.",
37845
37991
  inputSchema: {
37992
+ unset: unsetProperties,
37846
37993
  rule_id: string(),
37847
37994
  chain: string().optional(),
37848
37995
  action: string().optional(),
@@ -38144,6 +38291,7 @@ ${result}`;
38144
38291
  annotations: WRITE_IDEMPOTENT,
38145
38292
  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.",
38146
38293
  inputSchema: {
38294
+ unset: unsetProperties,
38147
38295
  nd_id: string().describe("Interface name (e.g. 'all', 'ether1') or '.id'"),
38148
38296
  ra_interval: string().optional(),
38149
38297
  ra_delay: string().optional(),
@@ -38170,7 +38318,7 @@ ${result}`;
38170
38318
  cmd.raw(`comment=${quoteValue(a.comment)}`);
38171
38319
  if (a.disabled !== undefined)
38172
38320
  cmd.raw(`disabled=${yesno(a.disabled)}`);
38173
- const built = cmd.build();
38321
+ const built = cmd.unset(a.unset).build();
38174
38322
  if (built === base)
38175
38323
  return "No updates specified.";
38176
38324
  const result = await executeMikrotikCommand(built, ctx);
@@ -38447,6 +38595,7 @@ ${result}`;
38447
38595
  annotations: WRITE_IDEMPOTENT,
38448
38596
  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.",
38449
38597
  inputSchema: {
38598
+ unset: unsetProperties,
38450
38599
  name: string(),
38451
38600
  new_name: string().optional(),
38452
38601
  prefix: string().optional(),
@@ -38465,7 +38614,7 @@ ${result}`;
38465
38614
  cmd.set("prefix-length", a.prefix_length);
38466
38615
  if (a.comment !== undefined)
38467
38616
  cmd.raw(`comment=${quoteValue(a.comment)}`);
38468
- const built = cmd.build();
38617
+ const built = cmd.unset(a.unset).build();
38469
38618
  if (built === base)
38470
38619
  return "No updates specified.";
38471
38620
  const result = await executeMikrotikCommand(built, ctx);
@@ -38801,6 +38950,7 @@ ${result}`;
38801
38950
  annotations: WRITE_IDEMPOTENT,
38802
38951
  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.",
38803
38952
  inputSchema: {
38953
+ unset: unsetProperties,
38804
38954
  name: string().describe("Current name of the IPsec profile to update"),
38805
38955
  new_name: string().optional(),
38806
38956
  dh_group: string().optional(),
@@ -38815,7 +38965,7 @@ ${result}`;
38815
38965
  async handler(a, ctx) {
38816
38966
  ctx.info(`Updating IPsec profile: name=${a.name}`);
38817
38967
  const base = `/ip ipsec profile set [find name="${a.name}"]`;
38818
- 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();
38968
+ 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();
38819
38969
  if (cmd === base)
38820
38970
  return "No updates specified.";
38821
38971
  const result = await executeMikrotikCommand(cmd, ctx);
@@ -38913,6 +39063,7 @@ ${result}`;
38913
39063
  annotations: WRITE_IDEMPOTENT,
38914
39064
  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.",
38915
39065
  inputSchema: {
39066
+ unset: unsetProperties,
38916
39067
  name: string().describe("Current name of the IPsec peer to update"),
38917
39068
  new_name: string().optional(),
38918
39069
  address: string().optional(),
@@ -38927,7 +39078,7 @@ ${result}`;
38927
39078
  async handler(a, ctx) {
38928
39079
  ctx.info(`Updating IPsec peer: name=${a.name}`);
38929
39080
  const base = `/ip ipsec peer set [find name="${a.name}"]`;
38930
- 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();
39081
+ 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();
38931
39082
  if (cmd === base)
38932
39083
  return "No updates specified.";
38933
39084
  const result = await executeMikrotikCommand(cmd, ctx);
@@ -39093,6 +39244,7 @@ ${result}`;
39093
39244
  annotations: WRITE_IDEMPOTENT,
39094
39245
  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.",
39095
39246
  inputSchema: {
39247
+ unset: unsetProperties,
39096
39248
  name: string().describe("Current name of the IPsec proposal to update"),
39097
39249
  new_name: string().optional(),
39098
39250
  auth_algorithms: string().optional(),
@@ -39104,7 +39256,7 @@ ${result}`;
39104
39256
  async handler(a, ctx) {
39105
39257
  ctx.info(`Updating IPsec proposal: name=${a.name}`);
39106
39258
  const base = `/ip ipsec proposal set [find name="${a.name}"]`;
39107
- 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();
39259
+ 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();
39108
39260
  if (cmd === base)
39109
39261
  return "No updates specified.";
39110
39262
  const result = await executeMikrotikCommand(cmd, ctx);
@@ -44945,6 +45097,7 @@ ${result}`;
44945
45097
  annotations: WRITE_IDEMPOTENT,
44946
45098
  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`.",
44947
45099
  inputSchema: {
45100
+ unset: unsetProperties,
44948
45101
  name: string(),
44949
45102
  interface: string().optional(),
44950
45103
  traffic: Traffic.optional(),
@@ -44962,7 +45115,7 @@ ${result}`;
44962
45115
  cmd.raw(`comment=${quoteValue(a.comment)}`);
44963
45116
  if (a.disabled !== undefined)
44964
45117
  cmd.raw(`disabled=${yesno(a.disabled)}`);
44965
- const built = cmd.build();
45118
+ const built = cmd.unset(a.unset).build();
44966
45119
  if (built === base)
44967
45120
  return "No updates specified.";
44968
45121
  const result = await executeMikrotikCommand(built, ctx);
@@ -45444,6 +45597,7 @@ ${result}`;
45444
45597
  annotations: WRITE_IDEMPOTENT,
45445
45598
  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.",
45446
45599
  inputSchema: {
45600
+ unset: unsetProperties,
45447
45601
  name: string().describe("Existing OpenVPN server instance name"),
45448
45602
  port: number().int().optional(),
45449
45603
  protocol: _enum(["tcp", "udp"]).optional(),
@@ -45462,7 +45616,7 @@ ${result}`;
45462
45616
  async handler(a, ctx) {
45463
45617
  ctx.info(`Updating OpenVPN server: name=${a.name}`);
45464
45618
  const base = `/interface ovpn-server server set [find name="${a.name}"]`;
45465
- 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();
45619
+ 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();
45466
45620
  if (cmd === base)
45467
45621
  return "No updates specified.";
45468
45622
  const count = await executeMikrotikCommand(`/interface ovpn-server server print count-only where name="${a.name}"`, ctx);
@@ -45813,6 +45967,7 @@ ${result}`;
45813
45967
  annotations: WRITE_IDEMPOTENT,
45814
45968
  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.",
45815
45969
  inputSchema: {
45970
+ unset: unsetProperties,
45816
45971
  name: string().describe("Current name of the PPP profile to update"),
45817
45972
  new_name: string().optional(),
45818
45973
  local_address: string().optional(),
@@ -45841,8 +45996,8 @@ ${result}`;
45841
45996
  },
45842
45997
  async handler(a, ctx) {
45843
45998
  ctx.info(`Updating PPP profile: name=${a.name}`);
45844
- 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();
45845
- if (!cmd.includes("=", cmd.indexOf("]")))
45999
+ 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();
46000
+ if (!/[=!]/.test(cmd.slice(cmd.indexOf("]"))))
45846
46001
  return "No updates specified.";
45847
46002
  const result = await executeMikrotikCommand(cmd, ctx);
45848
46003
  if (looksLikeError(result))
@@ -45944,6 +46099,7 @@ ${redactSecrets(result)}`;
45944
46099
  annotations: WRITE_IDEMPOTENT,
45945
46100
  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.",
45946
46101
  inputSchema: {
46102
+ unset: unsetProperties,
45947
46103
  name: string().describe("Current username of the secret to update"),
45948
46104
  new_name: string().optional(),
45949
46105
  password: string().optional(),
@@ -45960,8 +46116,8 @@ ${redactSecrets(result)}`;
45960
46116
  },
45961
46117
  async handler(a, ctx) {
45962
46118
  ctx.info(`Updating PPP secret: name=${a.name}`);
45963
- 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();
45964
- if (!cmd.includes("=", cmd.indexOf("]")))
46119
+ 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();
46120
+ if (!/[=!]/.test(cmd.slice(cmd.indexOf("]"))))
45965
46121
  return "No updates specified.";
45966
46122
  const result = await executeMikrotikCommand(cmd, ctx);
45967
46123
  if (looksLikeError(result))
@@ -46348,6 +46504,7 @@ ${result}`;
46348
46504
  annotations: WRITE_IDEMPOTENT,
46349
46505
  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.",
46350
46506
  inputSchema: {
46507
+ unset: unsetProperties,
46351
46508
  name: string(),
46352
46509
  new_name: string().optional(),
46353
46510
  cake_flowmode: string().optional(),
@@ -46377,8 +46534,8 @@ ${result}`;
46377
46534
  },
46378
46535
  async handler(a, ctx) {
46379
46536
  ctx.info(`Updating queue type: name=${a.name}`);
46380
- 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();
46381
- if (!cmd.includes("=", cmd.indexOf("]")))
46537
+ 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();
46538
+ if (!/[=!]/.test(cmd.slice(cmd.indexOf("]"))))
46382
46539
  return "No updates specified.";
46383
46540
  const result = await executeMikrotikCommand(cmd, ctx);
46384
46541
  if (looksLikeError(result))
@@ -46482,6 +46639,7 @@ ${result}`;
46482
46639
  annotations: WRITE_IDEMPOTENT,
46483
46640
  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`.",
46484
46641
  inputSchema: {
46642
+ unset: unsetProperties,
46485
46643
  name: string(),
46486
46644
  new_name: string().optional(),
46487
46645
  parent: string().optional(),
@@ -46499,8 +46657,8 @@ ${result}`;
46499
46657
  },
46500
46658
  async handler(a, ctx) {
46501
46659
  ctx.info(`Updating queue tree: name=${a.name}`);
46502
- 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();
46503
- if (!cmd.includes("=", cmd.indexOf("]")))
46660
+ 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();
46661
+ if (!/[=!]/.test(cmd.slice(cmd.indexOf("]"))))
46504
46662
  return "No updates specified.";
46505
46663
  const result = await executeMikrotikCommand(cmd, ctx);
46506
46664
  if (looksLikeError(result))
@@ -46641,6 +46799,7 @@ ${result}`;
46641
46799
  annotations: WRITE_IDEMPOTENT,
46642
46800
  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`.",
46643
46801
  inputSchema: {
46802
+ unset: unsetProperties,
46644
46803
  name: string(),
46645
46804
  new_name: string().optional(),
46646
46805
  target: string().optional().describe('IP/CIDR or interface e.g. "192.168.1.0/24" or "ether1"'),
@@ -46661,8 +46820,8 @@ ${result}`;
46661
46820
  },
46662
46821
  async handler(a, ctx) {
46663
46822
  ctx.info(`Updating simple queue: name=${a.name}`);
46664
- 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();
46665
- if (!cmd.includes("=", cmd.indexOf("]")))
46823
+ 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();
46824
+ if (!/[=!]/.test(cmd.slice(cmd.indexOf("]"))))
46666
46825
  return "No updates specified.";
46667
46826
  const result = await executeMikrotikCommand(cmd, ctx);
46668
46827
  if (looksLikeError(result))
@@ -46773,13 +46932,14 @@ ${result}`;
46773
46932
  annotations: WRITE_IDEMPOTENT,
46774
46933
  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.",
46775
46934
  inputSchema: {
46935
+ unset: unsetProperties,
46776
46936
  interface_id: string().describe("Interface name (e.g. 'ether1') or RouterOS '.id'"),
46777
46937
  queue: string().describe("Queue-type name to apply to the interface")
46778
46938
  },
46779
46939
  async handler(a, ctx) {
46780
46940
  ctx.info(`Updating queue interface: interface_id=${a.interface_id}`);
46781
46941
  const selector = a.interface_id.startsWith("*") ? `.id="${a.interface_id}"` : `interface="${a.interface_id}"`;
46782
- const cmd = new Cmd(`/queue interface set [find ${selector}]`).set("queue", a.queue).build();
46942
+ const cmd = new Cmd(`/queue interface set [find ${selector}]`).set("queue", a.queue).unset(a.unset).build();
46783
46943
  const result = await executeMikrotikCommand(cmd, ctx);
46784
46944
  if (looksLikeError(result))
46785
46945
  return `Failed to update queue interface: ${result}`;
@@ -47409,6 +47569,7 @@ ${redactSecrets(result)}`;
47409
47569
  annotations: WRITE_IDEMPOTENT,
47410
47570
  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`.",
47411
47571
  inputSchema: {
47572
+ unset: unsetProperties,
47412
47573
  radius_id: string().describe("RADIUS entry internal .id, e.g. '*1'"),
47413
47574
  address: string().optional(),
47414
47575
  secret: string().optional(),
@@ -47428,8 +47589,8 @@ ${redactSecrets(result)}`;
47428
47589
  },
47429
47590
  async handler(a, ctx) {
47430
47591
  ctx.info(`Updating RADIUS server: radius_id=${a.radius_id}`);
47431
- 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();
47432
- if (!cmd.includes("="))
47592
+ 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();
47593
+ if (!/[=!]/.test(cmd))
47433
47594
  return "No updates specified.";
47434
47595
  const result = await executeMikrotikCommand(cmd, ctx);
47435
47596
  if (looksLikeError(result))
@@ -48960,6 +49121,7 @@ ${result}`;
48960
49121
  annotations: WRITE_IDEMPOTENT,
48961
49122
  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.",
48962
49123
  inputSchema: {
49124
+ unset: unsetProperties,
48963
49125
  route_id: string().describe('"*N" or "N" from list output e.g. "*3"'),
48964
49126
  dst_address: string().optional().describe('CIDR e.g. "192.168.1.0/24"'),
48965
49127
  gateway: string().optional(),
@@ -49013,7 +49175,7 @@ ${result}`;
49013
49175
  cmd.bool("suppress-hw-offload", a.suppress_hw_offload);
49014
49176
  if (a.type !== undefined)
49015
49177
  cmd.raw(routeTypeArg(a.type, true));
49016
- const built = cmd.build();
49178
+ const built = cmd.unset(a.unset).build();
49017
49179
  if (built === base)
49018
49180
  return "No updates specified.";
49019
49181
  const result = await executeMikrotikCommand(built, ctx);
@@ -49100,7 +49262,7 @@ ${result}`;
49100
49262
  name: "check_route_path",
49101
49263
  title: "Check IPv4 Route Path",
49102
49264
  annotations: READ,
49103
- 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.",
49265
+ 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.",
49104
49266
  inputSchema: {
49105
49267
  destination: string(),
49106
49268
  routing_table: string().optional().describe('Policy-routing table name (v7) or routing-mark (v6), e.g. "VPN"')
@@ -49108,12 +49270,17 @@ ${result}`;
49108
49270
  async handler(a, ctx) {
49109
49271
  ctx.info(`Checking route path to: ${a.destination}`);
49110
49272
  const table = a.routing_table;
49111
- const v6Cmd = new Cmd(`/ip route check ${a.destination}`).opt("routing-mark", table).build();
49112
- const v6Result = await executeMikrotikCommand(v6Cmd, ctx);
49113
- if (!commandUnsupported(v6Result) && !looksLikeError(v6Result) && !isEmpty(v6Result)) {
49114
- return `ROUTE PATH TO ${a.destination}:
49273
+ const major = (await getCapabilities(ctx.device).catch(() => {
49274
+ return;
49275
+ }))?.version?.major;
49276
+ if (major !== undefined && major < 7) {
49277
+ const v6Cmd = new Cmd(`/ip route check ${a.destination}`).opt("routing-mark", table).build();
49278
+ const v6Result = await executeMikrotikCommand(v6Cmd, ctx);
49279
+ if (!commandUnsupported(v6Result) && !looksLikeError(v6Result) && !isEmpty(v6Result)) {
49280
+ return `ROUTE PATH TO ${a.destination}:
49115
49281
 
49116
49282
  ${v6Result}`;
49283
+ }
49117
49284
  }
49118
49285
  const where = [`${a.destination} in dst-address`, "active=yes"];
49119
49286
  if (table && table !== "main")
@@ -49291,6 +49458,7 @@ ${result}`;
49291
49458
  annotations: WRITE_IDEMPOTENT,
49292
49459
  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.",
49293
49460
  inputSchema: {
49461
+ unset: unsetProperties,
49294
49462
  config_id: string().describe('Configuration id, e.g. "*1"'),
49295
49463
  interfaces: string().optional(),
49296
49464
  vrf: string().optional(),
@@ -49309,7 +49477,7 @@ ${result}`;
49309
49477
  cmd.set("comment", a.comment);
49310
49478
  if (a.disabled !== undefined)
49311
49479
  cmd.bool("disabled", a.disabled);
49312
- const built = cmd.build();
49480
+ const built = cmd.unset(a.unset).build();
49313
49481
  if (built === base)
49314
49482
  return "No updates specified.";
49315
49483
  const result = await executeMikrotikCommand(built, ctx);
@@ -49530,6 +49698,7 @@ ${details}`;
49530
49698
  annotations: WRITE_IDEMPOTENT,
49531
49699
  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.",
49532
49700
  inputSchema: {
49701
+ unset: unsetProperties,
49533
49702
  name: string().describe("Existing BGP connection name"),
49534
49703
  remote_address: string().optional(),
49535
49704
  remote_as: number().int().optional(),
@@ -49588,7 +49757,7 @@ ${details}`;
49588
49757
  cmd.set("comment", a.comment);
49589
49758
  if (a.disabled !== undefined)
49590
49759
  cmd.bool("disabled", a.disabled);
49591
- const built = cmd.build();
49760
+ const built = cmd.unset(a.unset).build();
49592
49761
  if (built === base)
49593
49762
  return "No updates specified.";
49594
49763
  const result = await executeMikrotikCommand(built, ctx);
@@ -49802,6 +49971,7 @@ ${result}`;
49802
49971
  annotations: WRITE_IDEMPOTENT,
49803
49972
  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.",
49804
49973
  inputSchema: {
49974
+ unset: unsetProperties,
49805
49975
  rule_id: string().describe('Rule id, e.g. "*3"'),
49806
49976
  chain: string().optional(),
49807
49977
  rule: string().optional(),
@@ -49820,7 +49990,7 @@ ${result}`;
49820
49990
  cmd.set("comment", a.comment);
49821
49991
  if (a.disabled !== undefined)
49822
49992
  cmd.bool("disabled", a.disabled);
49823
- const built = cmd.build();
49993
+ const built = cmd.unset(a.unset).build();
49824
49994
  if (built === base)
49825
49995
  return "No updates specified.";
49826
49996
  const result = await executeMikrotikCommand(built, ctx);
@@ -50061,6 +50231,7 @@ ${details}`;
50061
50231
  annotations: WRITE_IDEMPOTENT,
50062
50232
  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.",
50063
50233
  inputSchema: {
50234
+ unset: unsetProperties,
50064
50235
  name: string().describe("Existing Router-ID instance name"),
50065
50236
  id: string().optional().describe('IPv4 router-id, or "" to clear'),
50066
50237
  select_dynamic_id: string().optional().describe('Interface/loopback name, or "" to clear'),
@@ -50080,7 +50251,7 @@ ${details}`;
50080
50251
  cmd.set("comment", a.comment);
50081
50252
  if (a.disabled !== undefined)
50082
50253
  cmd.bool("disabled", a.disabled);
50083
- const built = cmd.build();
50254
+ const built = cmd.unset(a.unset).build();
50084
50255
  if (built === base)
50085
50256
  return "No updates specified.";
50086
50257
  const result = await executeMikrotikCommand(built, ctx);
@@ -50225,6 +50396,7 @@ ${result}`;
50225
50396
  annotations: WRITE_IDEMPOTENT,
50226
50397
  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.",
50227
50398
  inputSchema: {
50399
+ unset: unsetProperties,
50228
50400
  interface: string().describe("Existing IGMP-proxy interface name"),
50229
50401
  upstream: boolean().optional(),
50230
50402
  alternative_subnets: string().optional(),
@@ -50242,7 +50414,7 @@ ${result}`;
50242
50414
  cmd.set("comment", a.comment);
50243
50415
  if (a.disabled !== undefined)
50244
50416
  cmd.bool("disabled", a.disabled);
50245
- const built = cmd.build();
50417
+ const built = cmd.unset(a.unset).build();
50246
50418
  if (built === base)
50247
50419
  return "No updates specified.";
50248
50420
  const result = await executeMikrotikCommand(built, ctx);
@@ -50419,6 +50591,7 @@ ${details}`;
50419
50591
  annotations: WRITE_IDEMPOTENT,
50420
50592
  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.",
50421
50593
  inputSchema: {
50594
+ unset: unsetProperties,
50422
50595
  name: string().describe("Existing OSPF instance name"),
50423
50596
  router_id: string().optional(),
50424
50597
  redistribute: string().optional(),
@@ -50443,7 +50616,7 @@ ${details}`;
50443
50616
  cmd.set("comment", a.comment);
50444
50617
  if (a.disabled !== undefined)
50445
50618
  cmd.bool("disabled", a.disabled);
50446
- const built = cmd.build();
50619
+ const built = cmd.unset(a.unset).build();
50447
50620
  if (built === base)
50448
50621
  return "No updates specified.";
50449
50622
  const result = await executeMikrotikCommand(built, ctx);
@@ -50968,6 +51141,7 @@ ${details}`;
50968
51141
  annotations: WRITE_IDEMPOTENT,
50969
51142
  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.",
50970
51143
  inputSchema: {
51144
+ unset: unsetProperties,
50971
51145
  name: string().describe("Existing RIP instance name"),
50972
51146
  router_id: string().optional(),
50973
51147
  routing_table: string().optional().describe("Routing table to install routes into"),
@@ -50986,7 +51160,7 @@ ${details}`;
50986
51160
  cmd.set("comment", a.comment);
50987
51161
  if (a.disabled !== undefined)
50988
51162
  cmd.bool("disabled", a.disabled);
50989
- const built = cmd.build();
51163
+ const built = cmd.unset(a.unset).build();
50990
51164
  if (built === base)
50991
51165
  return "No updates specified.";
50992
51166
  const result = await executeMikrotikCommand(built, ctx);
@@ -51211,6 +51385,7 @@ ${result}`;
51211
51385
  annotations: WRITE_IDEMPOTENT,
51212
51386
  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.",
51213
51387
  inputSchema: {
51388
+ unset: unsetProperties,
51214
51389
  session_id: string().describe('Session id, e.g. "*1"'),
51215
51390
  address: string().optional(),
51216
51391
  port: number().int().optional(),
@@ -51228,7 +51403,7 @@ ${result}`;
51228
51403
  cmd.set("comment", a.comment);
51229
51404
  if (a.disabled !== undefined)
51230
51405
  cmd.bool("disabled", a.disabled);
51231
- const built = cmd.build();
51406
+ const built = cmd.unset(a.unset).build();
51232
51407
  if (built === base)
51233
51408
  return "No updates specified.";
51234
51409
  const result = await executeMikrotikCommand(built, ctx);
@@ -51408,6 +51583,7 @@ ${result}`;
51408
51583
  annotations: WRITE_IDEMPOTENT,
51409
51584
  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.",
51410
51585
  inputSchema: {
51586
+ unset: unsetProperties,
51411
51587
  rule_id: string().describe('Rule id, e.g. "*3"'),
51412
51588
  action: _enum(ACTIONS).optional(),
51413
51589
  table: string().optional(),
@@ -51441,7 +51617,7 @@ ${result}`;
51441
51617
  cmd.set("comment", a.comment);
51442
51618
  if (a.disabled !== undefined)
51443
51619
  cmd.bool("disabled", a.disabled);
51444
- const built = cmd.build();
51620
+ const built = cmd.unset(a.unset).build();
51445
51621
  if (built === base)
51446
51622
  return "No updates specified.";
51447
51623
  const result = await executeMikrotikCommand(built, ctx);
@@ -51571,6 +51747,7 @@ ${details}`;
51571
51747
  annotations: WRITE_IDEMPOTENT,
51572
51748
  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.",
51573
51749
  inputSchema: {
51750
+ unset: unsetProperties,
51574
51751
  name: string().describe("Existing routing table name"),
51575
51752
  fib: boolean().optional().describe("Install routes into the FIB"),
51576
51753
  comment: string().optional(),
@@ -51585,7 +51762,7 @@ ${details}`;
51585
51762
  cmd.set("comment", a.comment);
51586
51763
  if (a.disabled !== undefined)
51587
51764
  cmd.bool("disabled", a.disabled);
51588
- const built = cmd.build();
51765
+ const built = cmd.unset(a.unset).build();
51589
51766
  if (built === base)
51590
51767
  return "No updates specified.";
51591
51768
  const result = await executeMikrotikCommand(built, ctx);
@@ -51642,7 +51819,7 @@ var safeModeTools = [
51642
51819
  name: "set_safe_mode_timeout",
51643
51820
  title: "Set Safe Mode Command Timeouts",
51644
51821
  annotations: WRITE,
51645
- 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.",
51822
+ 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.",
51646
51823
  inputSchema: {
51647
51824
  commandTimeoutMs: number().int().min(1000).max(600000).describe("Absolute command deadline in milliseconds."),
51648
51825
  idleTimeoutMs: number().int().min(1000).max(600000).describe("Maximum silence in milliseconds; must not exceed commandTimeoutMs.")
@@ -51655,7 +51832,7 @@ var safeModeTools = [
51655
51832
  name: "safe_mode_status",
51656
51833
  title: "Get Safe Mode Session Status",
51657
51834
  annotations: READ,
51658
- 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.",
51835
+ 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.",
51659
51836
  handler(_a, ctx) {
51660
51837
  const device = resolveDeviceName(ctx.device);
51661
51838
  ctx.info(`[${device}] Checking safe mode status`);
@@ -51670,7 +51847,10 @@ var safeModeTools = [
51670
51847
  async handler(_a, ctx) {
51671
51848
  const device = resolveDeviceName(ctx.device);
51672
51849
  ctx.info(`[${device}] Enabling MikroTik safe mode`);
51673
- return getSafeModeManager(device).enable();
51850
+ const result = await getSafeModeManager(device).enable();
51851
+ if (result.startsWith("Error"))
51852
+ throw new Error(result.replace(/^Error:\s*/, ""));
51853
+ return result;
51674
51854
  }
51675
51855
  }),
51676
51856
  defineTool({
@@ -51681,14 +51861,17 @@ var safeModeTools = [
51681
51861
  async handler(_a, ctx) {
51682
51862
  const device = resolveDeviceName(ctx.device);
51683
51863
  ctx.info(`[${device}] Committing safe mode changes`);
51684
- return (await getSafeModeManager(device).commit()).message;
51864
+ const result = await getSafeModeManager(device).commit();
51865
+ if (!result.ok)
51866
+ throw new Error(result.message);
51867
+ return result.message;
51685
51868
  }
51686
51869
  }),
51687
51870
  defineTool({
51688
51871
  name: "rollback_safe_mode",
51689
51872
  title: "Roll Back Safe Mode Changes",
51690
51873
  annotations: WRITE,
51691
- 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.",
51874
+ 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.",
51692
51875
  async handler(_a, ctx) {
51693
51876
  const device = resolveDeviceName(ctx.device);
51694
51877
  ctx.info(`[${device}] Rolling back safe mode changes`);
@@ -54488,7 +54671,7 @@ var riskByTool = null;
54488
54671
  async function riskIndex() {
54489
54672
  if (riskByTool)
54490
54673
  return riskByTool;
54491
- const { moduleCatalog } = await import("./cli-p3rfcsg3.js");
54674
+ const { moduleCatalog } = await import("./cli-rbe7s4mf.js");
54492
54675
  const index = new Map;
54493
54676
  for (const mod of moduleCatalog) {
54494
54677
  for (const tool of mod.tools)
@@ -59284,6 +59467,7 @@ ${result}`;
59284
59467
 
59285
59468
  ` + "Returns updated switch details on success.",
59286
59469
  inputSchema: {
59470
+ unset: unsetProperties,
59287
59471
  switch_id: string().describe("Switch name (e.g. 'switch1') or RouterOS '.id'"),
59288
59472
  name: string().optional().describe("Rename the switch"),
59289
59473
  cpu_flow_control: boolean().optional(),
@@ -59298,7 +59482,7 @@ ${result}`;
59298
59482
  const selector = a.switch_id.startsWith("*") ? `.id="${a.switch_id}"` : `name="${a.switch_id}"`;
59299
59483
  const base = `/interface ethernet switch set [find ${selector}]`;
59300
59484
  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);
59301
- const built = cmd.build();
59485
+ const built = cmd.unset(a.unset).build();
59302
59486
  if (built === base)
59303
59487
  return "No updates specified.";
59304
59488
  const result = await executeMikrotikCommand(built, ctx);
@@ -59371,6 +59555,7 @@ ${result}`;
59371
59555
  ` + ` 'always-strip', or 'add-if-missing'.
59372
59556
  ` + " default_vlan_id: PVID for untagged ingress ('auto', 'none', or a number).",
59373
59557
  inputSchema: {
59558
+ unset: unsetProperties,
59374
59559
  port_id: string().describe("Port name (e.g. 'ether1') or RouterOS '.id'"),
59375
59560
  default_vlan_id: string().optional().describe("PVID: 'auto', 'none', or a VLAN id number"),
59376
59561
  vlan_mode: VlanMode.optional(),
@@ -59382,7 +59567,7 @@ ${result}`;
59382
59567
  const selector = a.port_id.startsWith("*") ? `.id="${a.port_id}"` : `name="${a.port_id}"`;
59383
59568
  const base = `/interface ethernet switch port set [find ${selector}]`;
59384
59569
  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);
59385
- const built = cmd.build();
59570
+ const built = cmd.unset(a.unset).build();
59386
59571
  if (built === base)
59387
59572
  return "No updates specified.";
59388
59573
  const result = await executeMikrotikCommand(built, ctx);
@@ -59478,6 +59663,7 @@ ${result}`;
59478
59663
 
59479
59664
  ` + "Returns the entry's updated detail block.",
59480
59665
  inputSchema: {
59666
+ unset: unsetProperties,
59481
59667
  isolation_id: string().describe("Source port name or RouterOS '.id'"),
59482
59668
  forwarding_override_ports: string().optional().describe("Comma-separated allowed destination ports"),
59483
59669
  comment: string().optional()
@@ -59489,7 +59675,7 @@ ${result}`;
59489
59675
  const cmd = new Cmd(base).opt("forwarding-override-ports", a.forwarding_override_ports);
59490
59676
  if (a.comment !== undefined)
59491
59677
  cmd.raw(`comment=${quoteValue(a.comment)}`);
59492
- const built = cmd.build();
59678
+ const built = cmd.unset(a.unset).build();
59493
59679
  if (built === base)
59494
59680
  return "No updates specified.";
59495
59681
  const result = await executeMikrotikCommand(built, ctx);
@@ -59528,7 +59714,7 @@ ${details}`;
59528
59714
  // src/tools/switch-rule.ts
59529
59715
  async function updateSwitchRule(a, ctx) {
59530
59716
  ctx.info(`Updating switch rule: rule_id=${a.rule_id}`);
59531
- const updates = [];
59717
+ const updates = unsetFragments(a.unset);
59532
59718
  const put = (key, val) => {
59533
59719
  if (val === undefined)
59534
59720
  return;
@@ -59676,6 +59862,7 @@ ${result}`;
59676
59862
  annotations: WRITE_IDEMPOTENT,
59677
59863
  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.",
59678
59864
  inputSchema: {
59865
+ unset: unsetProperties,
59679
59866
  rule_id: string(),
59680
59867
  switch: string().optional(),
59681
59868
  ports: string().optional(),
@@ -60761,6 +60948,7 @@ ${redactSecrets(result)}`;
60761
60948
  annotations: WRITE_IDEMPOTENT,
60762
60949
  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.",
60763
60950
  inputSchema: {
60951
+ unset: unsetProperties,
60764
60952
  name: string().describe("Current name of the user to update"),
60765
60953
  new_name: string().optional(),
60766
60954
  password: string().optional(),
@@ -60774,8 +60962,8 @@ ${redactSecrets(result)}`;
60774
60962
  },
60775
60963
  async handler(a, ctx) {
60776
60964
  ctx.info(`Updating User Manager user: name=${a.name}`);
60777
- 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();
60778
- if (!cmd.includes("=", cmd.indexOf("]")))
60965
+ 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();
60966
+ if (!/[=!]/.test(cmd.slice(cmd.indexOf("]"))))
60779
60967
  return "No updates specified.";
60780
60968
  const result = await executeMikrotikCommand(cmd, ctx);
60781
60969
  if (commandUnsupported(result))
@@ -61962,6 +62150,7 @@ ${result}`;
61962
62150
  annotations: WRITE_IDEMPOTENT,
61963
62151
  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.",
61964
62152
  inputSchema: {
62153
+ unset: unsetProperties,
61965
62154
  name: string().describe("Current name of the VLAN interface to update"),
61966
62155
  new_name: interfaceName().optional().describe("Rename the interface to this (no spaces)."),
61967
62156
  vlan_id: number().int().min(1).max(4094).optional(),
@@ -61979,8 +62168,8 @@ ${result}`;
61979
62168
  },
61980
62169
  async handler(a, ctx) {
61981
62170
  ctx.info(`Updating VLAN interface: name=${a.name}`);
61982
- 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();
61983
- if (!cmd.includes("=", cmd.indexOf("]")))
62171
+ 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();
62172
+ if (!/[=!]/.test(cmd.slice(cmd.indexOf("]"))))
61984
62173
  return "No updates specified.";
61985
62174
  const result = await executeMikrotikCommand(cmd, ctx);
61986
62175
  if (looksLikeError(result))
@@ -62300,6 +62489,7 @@ ${peerBlock}`;
62300
62489
  annotations: WRITE_IDEMPOTENT,
62301
62490
  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.",
62302
62491
  inputSchema: {
62492
+ unset: unsetProperties,
62303
62493
  name: string(),
62304
62494
  new_name: interfaceName().optional().describe("Rename the interface to this (no spaces)."),
62305
62495
  listen_port: number().int().optional(),
@@ -62311,7 +62501,7 @@ ${peerBlock}`;
62311
62501
  async handler(a, ctx) {
62312
62502
  ctx.info(`Updating WireGuard interface: name=${a.name}`);
62313
62503
  const base = `/interface wireguard set [find name="${a.name}"]`;
62314
- 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();
62504
+ 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();
62315
62505
  if (cmd === base)
62316
62506
  return "No updates specified.";
62317
62507
  const result = await executeMikrotikCommand(cmd, ctx);
@@ -62476,6 +62666,7 @@ ${result}`;
62476
62666
  ` + ` persistent_keepalive: seconds as string e.g. "25"
62477
62667
  ` + ' Pass "" for endpoint_address or preshared_key to clear them.',
62478
62668
  inputSchema: {
62669
+ unset: unsetProperties,
62479
62670
  peer_id: string().describe('"*N" or "N" from list output e.g. "*2"'),
62480
62671
  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)."),
62481
62672
  allowed_address: string().optional(),
@@ -62501,7 +62692,7 @@ ${result}`;
62501
62692
  if (!id)
62502
62693
  return peerNotFound(a.peer_id);
62503
62694
  const base = `/interface wireguard peers set ${id}`;
62504
- 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();
62695
+ 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();
62505
62696
  if (cmd === base)
62506
62697
  return "No updates specified.";
62507
62698
  const result = await executeMikrotikCommand(cmd, ctx);
@@ -63204,6 +63395,7 @@ ${redactSecrets(result)}`;
63204
63395
  annotations: WRITE_IDEMPOTENT,
63205
63396
  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.",
63206
63397
  inputSchema: {
63398
+ unset: unsetProperties,
63207
63399
  name: string(),
63208
63400
  new_name: interfaceName().optional().describe("Rename the interface to this (no spaces)."),
63209
63401
  ssid: string().optional(),
@@ -63238,8 +63430,8 @@ ${redactSecrets(result)}`;
63238
63430
  const count = await executeMikrotikCommand(`${interfaceType} print count-only where name="${a.name}"`, ctx);
63239
63431
  if (count.trim() === "0")
63240
63432
  return `Wireless interface '${a.name}' not found.`;
63241
- 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();
63242
- if (!cmd.includes("=", cmd.indexOf("]")))
63433
+ 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();
63434
+ if (!/[=!]/.test(cmd.slice(cmd.indexOf("]"))))
63243
63435
  return "No updates specified.";
63244
63436
  const result = await executeMikrotikCommand(cmd, ctx);
63245
63437
  if (looksLikeError(result))