@usex/mikrotik-mcp 6.15.0 → 6.17.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 (67) hide show
  1. package/dist/cli.js +2509 -614
  2. package/dist/index.d.ts +10 -1
  3. package/dist/index.js +24 -10
  4. package/dist/shared/{cli-b7rbwm6j.js → cli-87bbe6j5.js} +8 -2
  5. package/dist/shared/cli-a3wbtdan.js +15 -0
  6. package/dist/shared/{cli-9x2ne7hp.js → cli-fbt00t70.js} +1 -1
  7. package/dist/shared/{cli-4aqtcr9k.js → cli-gjbdvacq.js} +1 -1
  8. package/dist/shared/cli-p3kz2br3.js +9 -0
  9. package/dist/shared/{cli-4n039739.js → cli-qnd27b4y.js} +5167 -1927
  10. package/dist/shared/{cli-57nggfz3.js → cli-wzv67n8r.js} +1 -1
  11. package/dist/shared/{cli-5hgbedxa.js → cli-xbab17xp.js} +1 -1
  12. package/dist/shared/{library-1sy0ph9r.js → library-4esmr0zw.js} +1 -1
  13. package/dist/shared/{library-7qr2sc9x.js → library-941sa041.js} +4840 -1575
  14. package/dist/shared/{library-twpgma2r.js → library-d3zdg5db.js} +1 -1
  15. package/dist/shared/{library-28w0j1ny.js → library-xgfbc20h.js} +1 -1
  16. package/dist/shared/{library-nt9fygza.js → library-zntcre28.js} +1 -1
  17. package/dist/ui/observability.html +160 -191
  18. package/package.json +23 -19
  19. package/schemas/README.md +5 -5
  20. package/schemas/config.schema.json +274 -6
  21. package/schemas/devtools-manifest.json +301 -5
  22. package/schemas/tool-catalog.json +1116 -42
  23. package/schemas/tools/add_alert_rule.json +1 -1
  24. package/schemas/tools/apply_config_template.json +56 -0
  25. package/schemas/tools/apply_wireless_to_wifi_migration.json +30 -0
  26. package/schemas/tools/deploy_container_stack.json +112 -0
  27. package/schemas/tools/design_zone_firewall.json +81 -0
  28. package/schemas/tools/discover_unmanaged_devices.json +49 -0
  29. package/schemas/tools/enrol_device.json +56 -0
  30. package/schemas/tools/expire_wireguard_users.json +19 -0
  31. package/schemas/tools/export_logs.json +2 -1
  32. package/schemas/tools/find_tools.json +1 -1
  33. package/schemas/tools/firmware_check.json +0 -5
  34. package/schemas/tools/firmware_post_upgrade.json +29 -0
  35. package/schemas/tools/firmware_repo_fetch.json +30 -0
  36. package/schemas/tools/firmware_repo_list.json +7 -0
  37. package/schemas/tools/firmware_stage_from_repo.json +19 -0
  38. package/schemas/tools/follow_ipv6_prefix.json +51 -0
  39. package/schemas/tools/generate_hotspot_vouchers.json +37 -1
  40. package/schemas/tools/get_container_logs.json +20 -0
  41. package/schemas/tools/get_logs.json +2 -1
  42. package/schemas/tools/get_logs_by_severity.json +2 -1
  43. package/schemas/tools/get_logs_by_topic.json +2 -1
  44. package/schemas/tools/get_security_logs.json +2 -1
  45. package/schemas/tools/get_system_events.json +2 -1
  46. package/schemas/tools/list_config_templates.json +7 -0
  47. package/schemas/tools/list_voucher_batches.json +7 -0
  48. package/schemas/tools/list_wireguard_users.json +12 -0
  49. package/schemas/tools/onboard_wireguard_user.json +17 -2
  50. package/schemas/tools/plan_wireless_to_wifi_migration.json +14 -0
  51. package/schemas/tools/protect_hotspot_login.json +32 -0
  52. package/schemas/tools/remove_config_template.json +14 -0
  53. package/schemas/tools/remove_threat_feed.json +1 -0
  54. package/schemas/tools/remove_voucher_batch.json +24 -0
  55. package/schemas/tools/remove_zone_firewall.json +14 -0
  56. package/schemas/tools/revoke_wireguard_user.json +1 -0
  57. package/schemas/tools/run_routeros_command.json +6 -1
  58. package/schemas/tools/save_config_template.json +20 -0
  59. package/schemas/tools/search_logs.json +2 -1
  60. package/schemas/tools/subscribe_threat_feed.json +1 -0
  61. package/schemas/tools/test_alert_channel.json +1 -1
  62. package/schemas/tools/unfollow_ipv6_prefix.json +18 -0
  63. package/schemas/tools/unprotect_hotspot_login.json +7 -0
  64. package/schemas/tools/update_alert_rule.json +1 -1
  65. package/schemas/tools/upgrade_container_image.json +29 -0
  66. package/schemas/tools/validate_routeros_command.json +13 -0
  67. package/scripts/service.ts +2 -3
package/dist/index.d.ts CHANGED
@@ -77,7 +77,7 @@ interface ToolAccess {
77
77
  /** How a device command was actually carried. */
78
78
  type DeviceTransport = "ssh" | "rest" | "mac-telnet";
79
79
  type SendLog = (level: "info" | "error", message: string) => void;
80
- import { ClientChannel } from "ssh2";
80
+ import { ClientChannel, SFTPWrapper } from "ssh2";
81
81
  interface EndpointOptions {
82
82
  /** Evaluated at connect time, not at client construction. */
83
83
  hosts?: () => string[];
@@ -93,6 +93,10 @@ interface SSHClientOptions extends EndpointOptions {
93
93
  privateKey?: string;
94
94
  /** Passphrase for an encrypted private key. */
95
95
  keyPassphrase?: string;
96
+ /** Sign in with an SSH agent: `true` uses `SSH_AUTH_SOCK`, a string is the socket. */
97
+ agent?: boolean | string;
98
+ /** The pinned SHA-256 fingerprint of the host key (`SHA256:…`). */
99
+ hostKeySha256?: string;
96
100
  timeoutMs?: number;
97
101
  /**
98
102
  * Optional SSH jump host (bastion / ProxyJump). When set, `connect()` reaches
@@ -173,6 +177,11 @@ declare class MikroTikSSHClient {
173
177
  * contents; rejects with a clear reason on failure.
174
178
  */
175
179
  downloadFile(remotePath: string): Promise<Buffer>;
180
+ /**
181
+ * Open the SFTP subsystem and keep it open, for callers that list, stream or
182
+ * rename files (the dashboard Files page). The caller ends it.
183
+ */
184
+ sftp(): Promise<SFTPWrapper>;
176
185
  /** Open a persistent interactive shell channel (used by Safe Mode). */
177
186
  shell(opts?: {
178
187
  term?: string;
package/dist/index.js CHANGED
@@ -70,7 +70,7 @@ import {
70
70
  updateSummaryLine,
71
71
  allToolModules2,
72
72
  selectToolModules2
73
- } from "./shared/library-7qr2sc9x.js";
73
+ } from "./shared/library-941sa041.js";
74
74
 
75
75
  // node_modules/ajv/dist/compile/codegen/code.js
76
76
  var require_code = __commonJS(function(exports) {
@@ -9905,22 +9905,36 @@ function registerPrompts(server, opts = {}) {
9905
9905
  }
9906
9906
 
9907
9907
  // src/server.ts
9908
+ var AUTO_CORE_ABOVE = 100;
9909
+ function resolveSurface(setting, toolCount) {
9910
+ if (setting !== "auto")
9911
+ return setting;
9912
+ return toolCount > AUTO_CORE_ABOVE ? "core" : "full";
9913
+ }
9908
9914
  var INSTRUCTIONS = `MikroTik RouterOS management over SSH.
9909
9915
 
9916
+ RULE: a tool that is not in your tool list is NOT missing. Every tool of this
9917
+ server runs through \`invoke_tool\`. Call \`find_tools\` to get its name, then
9918
+ \`invoke_tool\`. Never tell the user that a tool is unavailable before
9919
+ \`find_tools\` returned nothing.
9920
+
9910
9921
  This server exposes RouterOS configuration as MCP tools grouped by subsystem:
9911
9922
  interfaces, IP addressing, DHCP, DNS, firewall (filter + NAT), routing, VLANs,
9912
9923
  wireless, WireGuard, queues/QoS, users, logs, backups, PoE, system, network
9913
9924
  tools, bridges, address-lists, scheduler/scripts and certificates.
9914
9925
 
9915
9926
  Tool discovery \u2014 MANDATORY workflow:
9916
- This server has several hundred dedicated tools, but the host only surfaces a
9917
- small subset at a time. You MUST follow this order:
9918
- 1. ALWAYS call \`find_tools\` FIRST \u2014 describe what you want to do and it
9919
- searches the full catalog for the best-matching dedicated tool.
9920
- 2. (Optional) Call \`describe_tool\` to get the exact parameter schema.
9921
- 3. Run it with the \`invoke_tool\` call that \`find_tools\` printed. Call a tool
9922
- by its own name only if it is in your tool list. \`invoke_tool\` applies the
9923
- same validation, risk checks and audit record as a direct call.
9927
+ This server has about a thousand dedicated tools. Your tool list holds only a
9928
+ few of them. You MUST follow this order:
9929
+ 1. ALWAYS call \`find_tools\` FIRST \u2014 describe what you want to do in your own
9930
+ words, in English (translate a request in another language first). It searches the full catalog by words and by meaning and returns
9931
+ tool names with one line each.
9932
+ 2. Call \`describe_tool\` with the name you picked to get its parameters.
9933
+ When \`find_tools\` is sure of the best match, it gives them at once.
9934
+ 3. Run it with \`invoke_tool\`. Call a tool by its own name only if it is in
9935
+ your tool list. \`invoke_tool\` applies the same validation, risk checks
9936
+ and audit record as a direct call, and an argument error returns the
9937
+ parameters so you can correct the call.
9924
9938
  4. ONLY if \`find_tools\` returned ZERO results, run a raw command with
9925
9939
  \`invoke_tool {"name":"run_routeros_command","arguments":{"command":"\u2026"}}\`.
9926
9940
  Dedicated tools have schema validation, structured output, and correct risk
@@ -10118,7 +10132,7 @@ ${note}`;
10118
10132
  deviceDirectory: deviceDirectory(),
10119
10133
  appViews: getConfig2().mcp.appViews,
10120
10134
  readOnly,
10121
- surface: getConfig2().mcp.toolSurface,
10135
+ surface: resolveSurface(getConfig2().mcp.toolSurface, toolModules.reduce((sum, module) => sum + module.length, 0)),
10122
10136
  coreTools: getConfig2().mcp.coreTools.split(",").map((name) => name.trim()).filter(Boolean)
10123
10137
  });
10124
10138
  const promptCount = registerPrompts(server, {
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  logger,
4
4
  UI_DIST_DIR
5
- } from "./cli-4n039739.js";
5
+ } from "./cli-qnd27b4y.js";
6
6
 
7
7
  // src/observability/remote.ts
8
8
  import { readFileSync } from "fs";
@@ -27,12 +27,16 @@ function upstreamUrl(origin, pathAndQuery, ws = false) {
27
27
  }
28
28
  function upstreamHeaders(incoming, token) {
29
29
  const out = new Headers(incoming);
30
- for (const name of ["host", "connection", "authorization", "accept-encoding"])
30
+ for (const name of ["host", "connection", "authorization", "accept-encoding", "origin"])
31
31
  out.delete(name);
32
32
  if (token)
33
33
  out.set("authorization", `Bearer ${token}`);
34
34
  return out;
35
35
  }
36
+ function crossOrigin(req) {
37
+ const origin = req.headers.get("origin");
38
+ return origin !== null && origin !== new URL(req.url).origin;
39
+ }
36
40
  function localPage(dir = UI_DIST_DIR) {
37
41
  try {
38
42
  return readFileSync(join(dir, "observability.html"), "utf8");
@@ -50,6 +54,8 @@ function runRemoteDashboard(options) {
50
54
  async fetch(req, srv) {
51
55
  const url = new URL(req.url);
52
56
  const path = url.pathname + url.search;
57
+ if (crossOrigin(req))
58
+ return new Response("Cross-origin operation denied", { status: 403 });
53
59
  if (req.headers.get("upgrade")?.toLowerCase() === "websocket") {
54
60
  const target = upstreamUrl(origin, path, true);
55
61
  return srv.upgrade(req, { data: { target } }) ? undefined : new Response("WebSocket upgrade failed", { status: 400 });
@@ -0,0 +1,15 @@
1
+ // @bun
2
+ import {
3
+ buildStatus2,
4
+ buildWaitMessage2,
5
+ startSemanticIndex2,
6
+ semanticRank2,
7
+ fuseRanks2
8
+ } from "./cli-qnd27b4y.js";
9
+ export {
10
+ buildStatus2 as buildStatus,
11
+ buildWaitMessage2 as buildWaitMessage,
12
+ fuseRanks2 as fuseRanks,
13
+ semanticRank2 as semanticRank,
14
+ startSemanticIndex2 as startSemanticIndex
15
+ };
@@ -4,7 +4,7 @@ import {
4
4
  allToolModules2,
5
5
  ALWAYS_ON_MODULES2,
6
6
  selectToolModules2
7
- } from "./cli-4n039739.js";
7
+ } from "./cli-qnd27b4y.js";
8
8
  export {
9
9
  ALWAYS_ON_MODULES2 as ALWAYS_ON_MODULES,
10
10
  allToolModules2 as allToolModules,
@@ -4,7 +4,7 @@ import {
4
4
  normalizeExport2,
5
5
  contentSha2,
6
6
  countLines2
7
- } from "./cli-4n039739.js";
7
+ } from "./cli-qnd27b4y.js";
8
8
  export {
9
9
  contentSha2 as contentSha,
10
10
  countLines2 as countLines,
@@ -0,0 +1,9 @@
1
+ // @bun
2
+ import {
3
+ semanticDocs2,
4
+ toolGatewayTools2
5
+ } from "./cli-qnd27b4y.js";
6
+ export {
7
+ semanticDocs2 as semanticDocs,
8
+ toolGatewayTools2 as toolGatewayTools
9
+ };