@usex/mikrotik-mcp 3.38.0 → 3.39.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.
package/dist/cli.js CHANGED
@@ -84,7 +84,7 @@ import {
84
84
  toggleAaaEntity,
85
85
  updateAaaEntity,
86
86
  writeBackup
87
- } from "./shared/cli-e484wzek.js";
87
+ } from "./shared/cli-ksdjs84m.js";
88
88
 
89
89
  // src/cli.ts
90
90
  import { existsSync as existsSync2 } from "fs";
@@ -2242,7 +2242,7 @@ function registerPrompts(server) {
2242
2242
  // package.json
2243
2243
  var package_default = {
2244
2244
  name: "@usex/mikrotik-mcp",
2245
- version: "3.38.0",
2245
+ version: "3.39.0",
2246
2246
  description: "MCP server for MikroTik RouterOS \u2014 660+ tools over SSH for firewall, NAT, routing, DHCP, DNS, WireGuard, wireless, QoS and more.",
2247
2247
  keywords: [
2248
2248
  "ai",
package/dist/index.js CHANGED
@@ -21,7 +21,7 @@ import {
21
21
  resolveDeviceName,
22
22
  selectToolModules,
23
23
  setConfig
24
- } from "./shared/library-nxh3rb8t.js";
24
+ } from "./shared/library-pvb7kh40.js";
25
25
  // src/server.ts
26
26
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
27
27
  import { ListToolsRequestSchema } from "@modelcontextprotocol/sdk/types.js";
@@ -131,7 +131,7 @@ function registerPrompts(server) {
131
131
  // package.json
132
132
  var package_default = {
133
133
  name: "@usex/mikrotik-mcp",
134
- version: "3.38.0",
134
+ version: "3.39.0",
135
135
  description: "MCP server for MikroTik RouterOS \u2014 660+ tools over SSH for firewall, NAT, routing, DHCP, DNS, WireGuard, wireless, QoS and more.",
136
136
  keywords: [
137
137
  "ai",
@@ -4,7 +4,7 @@ import {
4
4
  allToolModules,
5
5
  moduleCatalog,
6
6
  selectToolModules
7
- } from "./cli-e484wzek.js";
7
+ } from "./cli-ksdjs84m.js";
8
8
  export {
9
9
  selectToolModules,
10
10
  moduleCatalog,
@@ -3212,24 +3212,24 @@ ${fileDetails}` : `Section export '${name}.rsc' created successfully.`;
3212
3212
  }),
3213
3213
  defineTool({
3214
3214
  name: "download_file",
3215
- title: "Download File as Base64",
3215
+ title: "Download File from Device",
3216
3216
  annotations: READ,
3217
- description: "Attempts to read a file from the device filesystem via `/file print file=<filename>` and" + " returns the RouterOS API text response base64-encoded as `FILE_CONTENT_BASE64:<data>`." + " NOTE: this is a simplified implementation. RouterOS has no file-content-read API over SSH;" + " `/file print file=<name>` saves the directory-listing output to a file named `<name>` rather" + " than streaming an existing file's bytes. The returned base64 payload is the RouterOS text" + " response to that command \u2014 not the actual file contents. Binary `.backup` files cannot be" + " reliably retrieved this way. Verifies file existence first" + " (`/file print count-only where name=<filename>`); returns a not-found message if absent." + " To list available files use `list_backups`; for file metadata only use `backup_info`.",
3217
+ description: "Downloads a file from the device filesystem over SFTP and returns its raw bytes base64-encoded" + " as `FILE_CONTENT_BASE64:<data>`. Works for any file type \u2014 `.backup`, `.rsc`, `.p12`" + " certificates, keys, etc. Verifies file existence first (`/file print count-only`). The SSH" + " user MUST have the `read` policy (and `sensitive` for `.backup` / certificate files) on" + " RouterOS for SFTP downloads to work. NOT available on MAC-Telnet devices (Layer-2 has no" + " file transfer). To list available files use `list_backups`; for file metadata use" + " `backup_info`; to push a file onto the device use `upload_file`.",
3218
3218
  inputSchema: {
3219
- filename: z5.string(),
3220
- file_type: z5.enum(["backup", "export"]).default("backup")
3219
+ filename: z5.string().describe("Name of the file on the device, e.g. 'cert.p12' or 'backup.backup'")
3221
3220
  },
3222
3221
  async handler(a, ctx) {
3223
- ctx.info(`Downloading file: filename=${a.filename}, type=${a.file_type}`);
3222
+ ctx.info(`Downloading file: filename=${a.filename}`);
3224
3223
  const count = await executeMikrotikCommand(`/file print count-only where name=${a.filename}`, ctx);
3225
3224
  if (count.trim() === "0")
3226
- return `File '${a.filename}' not found.`;
3227
- const content = await executeMikrotikCommand(`/file print file=${a.filename}`, ctx);
3228
- if (content) {
3229
- const encoded = Buffer.from(content, "utf8").toString("base64");
3225
+ return `File '${a.filename}' not found on the device.`;
3226
+ try {
3227
+ const data = await downloadFileFromDevice(ctx.device, a.filename);
3228
+ const encoded = data.toString("base64");
3230
3229
  return `FILE_CONTENT_BASE64:${encoded}`;
3230
+ } catch (e) {
3231
+ return `Failed to download '${a.filename}': ${e instanceof Error ? e.message : String(e)}. ` + "Ensure the SSH user has the 'read' and 'sensitive' policies on RouterOS.";
3231
3232
  }
3232
- return `Failed to download file '${a.filename}'.`;
3233
3233
  }
3234
3234
  }),
3235
3235
  defineTool({
@@ -6141,7 +6141,7 @@ var cache = null;
6141
6141
  async function gateway() {
6142
6142
  if (cache)
6143
6143
  return cache;
6144
- const { moduleCatalog } = await import("./cli-h0gydx8r.js");
6144
+ const { moduleCatalog } = await import("./cli-17657c2v.js");
6145
6145
  const forIndex = [];
6146
6146
  const byName = new Map;
6147
6147
  for (const mod of moduleCatalog) {
@@ -4,7 +4,7 @@ import {
4
4
  allToolModules,
5
5
  moduleCatalog,
6
6
  selectToolModules
7
- } from "./library-nxh3rb8t.js";
7
+ } from "./library-pvb7kh40.js";
8
8
  export {
9
9
  selectToolModules,
10
10
  moduleCatalog,
@@ -3188,24 +3188,24 @@ ${fileDetails}` : `Section export '${name}.rsc' created successfully.`;
3188
3188
  }),
3189
3189
  defineTool({
3190
3190
  name: "download_file",
3191
- title: "Download File as Base64",
3191
+ title: "Download File from Device",
3192
3192
  annotations: READ,
3193
- description: "Attempts to read a file from the device filesystem via `/file print file=<filename>` and" + " returns the RouterOS API text response base64-encoded as `FILE_CONTENT_BASE64:<data>`." + " NOTE: this is a simplified implementation. RouterOS has no file-content-read API over SSH;" + " `/file print file=<name>` saves the directory-listing output to a file named `<name>` rather" + " than streaming an existing file's bytes. The returned base64 payload is the RouterOS text" + " response to that command \u2014 not the actual file contents. Binary `.backup` files cannot be" + " reliably retrieved this way. Verifies file existence first" + " (`/file print count-only where name=<filename>`); returns a not-found message if absent." + " To list available files use `list_backups`; for file metadata only use `backup_info`.",
3193
+ description: "Downloads a file from the device filesystem over SFTP and returns its raw bytes base64-encoded" + " as `FILE_CONTENT_BASE64:<data>`. Works for any file type \u2014 `.backup`, `.rsc`, `.p12`" + " certificates, keys, etc. Verifies file existence first (`/file print count-only`). The SSH" + " user MUST have the `read` policy (and `sensitive` for `.backup` / certificate files) on" + " RouterOS for SFTP downloads to work. NOT available on MAC-Telnet devices (Layer-2 has no" + " file transfer). To list available files use `list_backups`; for file metadata use" + " `backup_info`; to push a file onto the device use `upload_file`.",
3194
3194
  inputSchema: {
3195
- filename: z5.string(),
3196
- file_type: z5.enum(["backup", "export"]).default("backup")
3195
+ filename: z5.string().describe("Name of the file on the device, e.g. 'cert.p12' or 'backup.backup'")
3197
3196
  },
3198
3197
  async handler(a, ctx) {
3199
- ctx.info(`Downloading file: filename=${a.filename}, type=${a.file_type}`);
3198
+ ctx.info(`Downloading file: filename=${a.filename}`);
3200
3199
  const count = await executeMikrotikCommand(`/file print count-only where name=${a.filename}`, ctx);
3201
3200
  if (count.trim() === "0")
3202
- return `File '${a.filename}' not found.`;
3203
- const content = await executeMikrotikCommand(`/file print file=${a.filename}`, ctx);
3204
- if (content) {
3205
- const encoded = Buffer.from(content, "utf8").toString("base64");
3201
+ return `File '${a.filename}' not found on the device.`;
3202
+ try {
3203
+ const data = await downloadFileFromDevice(ctx.device, a.filename);
3204
+ const encoded = data.toString("base64");
3206
3205
  return `FILE_CONTENT_BASE64:${encoded}`;
3206
+ } catch (e) {
3207
+ return `Failed to download '${a.filename}': ${e instanceof Error ? e.message : String(e)}. ` + "Ensure the SSH user has the 'read' and 'sensitive' policies on RouterOS.";
3207
3208
  }
3208
- return `Failed to download file '${a.filename}'.`;
3209
3209
  }
3210
3210
  }),
3211
3211
  defineTool({
@@ -6117,7 +6117,7 @@ var cache = null;
6117
6117
  async function gateway() {
6118
6118
  if (cache)
6119
6119
  return cache;
6120
- const { moduleCatalog } = await import("./library-q0q3kf6m.js");
6120
+ const { moduleCatalog } = await import("./library-dhx14y24.js");
6121
6121
  const forIndex = [];
6122
6122
  const byName = new Map;
6123
6123
  for (const mod of moduleCatalog) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@usex/mikrotik-mcp",
3
- "version": "3.38.0",
3
+ "version": "3.39.0",
4
4
  "description": "MCP server for MikroTik RouterOS — 660+ tools over SSH for firewall, NAT, routing, DHCP, DNS, WireGuard, wireless, QoS and more.",
5
5
  "keywords": [
6
6
  "ai",