@usex/mikrotik-mcp 5.18.0 → 5.20.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/README.md +213 -5
- package/dist/cli.js +3242 -835
- package/dist/index.js +169 -28
- package/dist/shared/{cli-97csvm6f.js → cli-426pkqe9.js} +8 -0
- package/dist/shared/{library-552hdvw2.js → library-73y8qdjr.js} +2619 -537
- package/dist/shared/{library-xbg1d52n.js → library-76naf20r.js} +1 -1
- package/dist/shared/{library-w5tyng4c.js → library-81amv3az.js} +1 -1
- package/dist/shared/{library-08g0pwc9.js → library-krajvnj9.js} +1 -1
- package/dist/shared/{library-gmx9pzx3.js → library-y9tt30y1.js} +11 -1
- package/dist/ui/aaa.html +8 -8
- package/dist/ui/connected-devices.html +8 -8
- package/dist/ui/dashboard.html +16 -16
- package/dist/ui/fabric.html +11 -11
- package/dist/ui/firewall-audit.html +8 -8
- package/dist/ui/firewall.html +9 -9
- package/dist/ui/interfaces.html +8 -8
- package/dist/ui/investigations.html +11 -11
- package/dist/ui/observability.html +77 -75
- package/dist/ui/operations.html +11 -11
- package/dist/ui/records.html +12 -12
- package/dist/ui/reports.html +11 -11
- package/dist/ui/round-trip.html +11 -11
- package/dist/ui/service-health.html +11 -11
- package/package.json +22 -22
- package/prompts/audit-routeros-containers.md +27 -0
- package/prompts/audit-vlan-segmentation.md +31 -0
- package/prompts/setup-guest-wifi.md +23 -24
- package/prompts/setup-routeros-container.md +36 -0
- package/prompts/setup-v2ray-container-proxy.md +68 -194
- package/prompts/setup-vlan-network.md +27 -33
- package/schemas/README.md +1 -1
- package/schemas/devtools-manifest.json +358 -16
- package/schemas/tool-catalog.json +1133 -144
- package/schemas/tools/add_container.json +42 -30
- package/schemas/tools/add_container_env.json +3 -4
- package/schemas/tools/add_container_mount.json +10 -4
- package/schemas/tools/apply_service_routing.json +23 -0
- package/schemas/tools/arm_service_routing.json +23 -0
- package/schemas/tools/configure_flight_recorder.json +30 -0
- package/schemas/tools/confirm_mcp_settings.json +19 -0
- package/schemas/tools/create_service_routing.json +78 -0
- package/schemas/tools/design_network_segment.json +22 -6
- package/schemas/tools/destroy_recovery_lab.json +18 -0
- package/schemas/tools/export_network_incident.json +14 -0
- package/schemas/tools/freeze_network_incident.json +14 -0
- package/schemas/tools/get_container.json +11 -4
- package/schemas/tools/get_flight_recorder.json +7 -0
- package/schemas/tools/get_mcp_settings.json +7 -0
- package/schemas/tools/get_mcp_settings_schema.json +7 -0
- package/schemas/tools/get_recovery_lab.json +7 -0
- package/schemas/tools/get_routeros_container_guide.json +22 -0
- package/schemas/tools/get_vlan_segmentation_guide.json +14 -0
- package/schemas/tools/list_container_envs.json +1 -1
- package/schemas/tools/list_container_mounts.json +7 -2
- package/schemas/tools/list_containers.json +2 -4
- package/schemas/tools/list_service_routing.json +7 -0
- package/schemas/tools/poll_recovery_lab.json +14 -0
- package/schemas/tools/prepare_recovery_lab.json +23 -0
- package/schemas/tools/preview_mcp_settings.json +94 -0
- package/schemas/tools/preview_service_routing.json +23 -0
- package/schemas/tools/probe_service_routing.json +14 -0
- package/schemas/tools/recovery_lab_inventory.json +7 -0
- package/schemas/tools/remove_container.json +11 -4
- package/schemas/tools/remove_container_env.json +7 -3
- package/schemas/tools/remove_container_mount.json +18 -2
- package/schemas/tools/rollback_mcp_settings.json +19 -0
- package/schemas/tools/service_routing_inventory.json +7 -0
- package/schemas/tools/set_container_config.json +4 -6
- package/schemas/tools/start_container.json +11 -4
- package/schemas/tools/start_recovery_lab.json +18 -0
- package/schemas/tools/stop_container.json +11 -4
- package/schemas/tools/update_container.json +46 -6
- package/schemas/tools/update_mcp_settings.json +110 -0
- /package/dist/shared/{cli-3zrj182m.js → cli-6wdstvdq.js} +0 -0
- /package/dist/shared/{cli-s423xk9v.js → cli-cvt06346.js} +0 -0
- /package/dist/shared/{cli-ff6yww2e.js → cli-z1kavk0z.js} +0 -0
package/dist/index.js
CHANGED
|
@@ -52,6 +52,14 @@ import {
|
|
|
52
52
|
registerTools2,
|
|
53
53
|
PROMPTS_DIR,
|
|
54
54
|
registerUiResources,
|
|
55
|
+
VLAN_GUIDE_URI,
|
|
56
|
+
getVlanSegmentationGuide,
|
|
57
|
+
VLAN_INSTRUCTIONS,
|
|
58
|
+
vlanPromptGuidance,
|
|
59
|
+
CONTAINER_GUIDE_URI,
|
|
60
|
+
getRouterosContainerGuide,
|
|
61
|
+
CONTAINER_INSTRUCTIONS,
|
|
62
|
+
containerPromptGuidance,
|
|
55
63
|
VERSION2,
|
|
56
64
|
WEBSITE_URL,
|
|
57
65
|
LOGO_URL,
|
|
@@ -62,7 +70,7 @@ import {
|
|
|
62
70
|
updateSummaryLine,
|
|
63
71
|
allToolModules2,
|
|
64
72
|
selectToolModules2
|
|
65
|
-
} from "./shared/library-
|
|
73
|
+
} from "./shared/library-73y8qdjr.js";
|
|
66
74
|
|
|
67
75
|
// node_modules/ajv/dist/compile/codegen/code.js
|
|
68
76
|
var require_code = __commonJS(function(exports) {
|
|
@@ -12838,6 +12846,9 @@ class Protocol {
|
|
|
12838
12846
|
this.setRequestHandler(GetTaskPayloadRequestSchema, async (request, extra) => {
|
|
12839
12847
|
const handleTaskResult = async () => {
|
|
12840
12848
|
const taskId = request.params.taskId;
|
|
12849
|
+
if (!await this._taskStore.getTask(taskId, extra.sessionId)) {
|
|
12850
|
+
throw new McpError(ErrorCode.InvalidParams, `Task not found: ${taskId}`);
|
|
12851
|
+
}
|
|
12841
12852
|
if (this._taskMessageQueue) {
|
|
12842
12853
|
let queuedMessage;
|
|
12843
12854
|
while (queuedMessage = await this._taskMessageQueue.dequeue(taskId, extra.sessionId)) {
|
|
@@ -12868,12 +12879,12 @@ class Protocol {
|
|
|
12868
12879
|
throw new McpError(ErrorCode.InvalidParams, `Task not found: ${taskId}`);
|
|
12869
12880
|
}
|
|
12870
12881
|
if (!isTerminal(task.status)) {
|
|
12871
|
-
await this._waitForTaskUpdate(taskId, extra.signal);
|
|
12882
|
+
await this._waitForTaskUpdate(taskId, extra.signal, extra.sessionId);
|
|
12872
12883
|
return await handleTaskResult();
|
|
12873
12884
|
}
|
|
12874
12885
|
if (isTerminal(task.status)) {
|
|
12875
12886
|
const result = await this._taskStore.getTaskResult(taskId, extra.sessionId);
|
|
12876
|
-
this._clearTaskQueue(taskId);
|
|
12887
|
+
this._clearTaskQueue(taskId, extra.sessionId);
|
|
12877
12888
|
return {
|
|
12878
12889
|
...result,
|
|
12879
12890
|
_meta: {
|
|
@@ -12910,7 +12921,7 @@ class Protocol {
|
|
|
12910
12921
|
throw new McpError(ErrorCode.InvalidParams, `Cannot cancel task in terminal status: ${task.status}`);
|
|
12911
12922
|
}
|
|
12912
12923
|
await this._taskStore.updateTaskStatus(request.params.taskId, "cancelled", "Client cancelled task execution.", extra.sessionId);
|
|
12913
|
-
this._clearTaskQueue(request.params.taskId);
|
|
12924
|
+
this._clearTaskQueue(request.params.taskId, extra.sessionId);
|
|
12914
12925
|
const cancelledTask = await this._taskStore.getTask(request.params.taskId, extra.sessionId);
|
|
12915
12926
|
if (!cancelledTask) {
|
|
12916
12927
|
throw new McpError(ErrorCode.InvalidParams, `Task not found after cancellation: ${request.params.taskId}`);
|
|
@@ -13033,6 +13044,19 @@ class Protocol {
|
|
|
13033
13044
|
const handler = this._requestHandlers.get(request.method) ?? this.fallbackRequestHandler;
|
|
13034
13045
|
const capturedTransport = this._transport;
|
|
13035
13046
|
const relatedTaskId = request.params?._meta?.[RELATED_TASK_META_KEY]?.taskId;
|
|
13047
|
+
const sessionId = capturedTransport?.sessionId;
|
|
13048
|
+
const store = this._taskStore;
|
|
13049
|
+
let relatedTaskFound = true;
|
|
13050
|
+
let relatedTaskLookup;
|
|
13051
|
+
if (relatedTaskId && store && this._taskMessageQueue && sessionId !== undefined) {
|
|
13052
|
+
relatedTaskFound = false;
|
|
13053
|
+
relatedTaskLookup = (async () => {
|
|
13054
|
+
if (!await store.getTask(relatedTaskId, sessionId)) {
|
|
13055
|
+
throw new McpError(ErrorCode.InvalidParams, `Task not found: ${relatedTaskId}`);
|
|
13056
|
+
}
|
|
13057
|
+
relatedTaskFound = true;
|
|
13058
|
+
})();
|
|
13059
|
+
}
|
|
13036
13060
|
if (handler === undefined) {
|
|
13037
13061
|
const errorResponse = {
|
|
13038
13062
|
jsonrpc: "2.0",
|
|
@@ -13042,7 +13066,10 @@ class Protocol {
|
|
|
13042
13066
|
message: "Method not found"
|
|
13043
13067
|
}
|
|
13044
13068
|
};
|
|
13045
|
-
if (relatedTaskId &&
|
|
13069
|
+
if (relatedTaskId && relatedTaskLookup) {
|
|
13070
|
+
const queuedError = { type: "error", message: errorResponse, timestamp: Date.now() };
|
|
13071
|
+
relatedTaskLookup.then(() => this._enqueueTaskMessage(relatedTaskId, queuedError, sessionId), () => capturedTransport?.send(errorResponse)).catch((error) => this._onerror(new Error(`Failed to send an error response: ${error}`)));
|
|
13072
|
+
} else if (relatedTaskId && this._taskMessageQueue) {
|
|
13046
13073
|
this._enqueueTaskMessage(relatedTaskId, {
|
|
13047
13074
|
type: "error",
|
|
13048
13075
|
message: errorResponse,
|
|
@@ -13093,7 +13120,10 @@ class Protocol {
|
|
|
13093
13120
|
closeSSEStream: extra?.closeSSEStream,
|
|
13094
13121
|
closeStandaloneSSEStream: extra?.closeStandaloneSSEStream
|
|
13095
13122
|
};
|
|
13096
|
-
Promise.resolve().then(() => {
|
|
13123
|
+
(relatedTaskLookup ?? Promise.resolve()).then(() => {
|
|
13124
|
+
if (relatedTaskLookup && abortController.signal.aborted) {
|
|
13125
|
+
throw new McpError(ErrorCode.ConnectionClosed, "Request was cancelled");
|
|
13126
|
+
}
|
|
13097
13127
|
if (taskCreationParams) {
|
|
13098
13128
|
this.assertTaskHandlerCapability(request.method);
|
|
13099
13129
|
}
|
|
@@ -13128,7 +13158,7 @@ class Protocol {
|
|
|
13128
13158
|
...error["data"] !== undefined && { data: error["data"] }
|
|
13129
13159
|
}
|
|
13130
13160
|
};
|
|
13131
|
-
if (relatedTaskId && this._taskMessageQueue) {
|
|
13161
|
+
if (relatedTaskId && this._taskMessageQueue && relatedTaskFound) {
|
|
13132
13162
|
await this._enqueueTaskMessage(relatedTaskId, {
|
|
13133
13163
|
type: "error",
|
|
13134
13164
|
message: errorResponse,
|
|
@@ -13516,7 +13546,7 @@ class Protocol {
|
|
|
13516
13546
|
throw new Error("Cannot enqueue task message: taskStore and taskMessageQueue are not configured");
|
|
13517
13547
|
}
|
|
13518
13548
|
const maxQueueSize = this._options?.maxTaskQueueSize;
|
|
13519
|
-
await this._taskMessageQueue.enqueue(taskId, message, sessionId, maxQueueSize);
|
|
13549
|
+
await this._taskMessageQueue.enqueue(taskId, message, sessionId ?? this._transport?.sessionId, maxQueueSize);
|
|
13520
13550
|
}
|
|
13521
13551
|
async _clearTaskQueue(taskId, sessionId) {
|
|
13522
13552
|
if (this._taskMessageQueue) {
|
|
@@ -13535,10 +13565,10 @@ class Protocol {
|
|
|
13535
13565
|
}
|
|
13536
13566
|
}
|
|
13537
13567
|
}
|
|
13538
|
-
async _waitForTaskUpdate(taskId, signal) {
|
|
13568
|
+
async _waitForTaskUpdate(taskId, signal, sessionId) {
|
|
13539
13569
|
let interval = this._options?.defaultTaskPollInterval ?? 1000;
|
|
13540
13570
|
try {
|
|
13541
|
-
const task = await this._taskStore?.getTask(taskId);
|
|
13571
|
+
const task = await this._taskStore?.getTask(taskId, sessionId);
|
|
13542
13572
|
if (task?.pollInterval) {
|
|
13543
13573
|
interval = task.pollInterval;
|
|
13544
13574
|
}
|
|
@@ -14206,6 +14236,43 @@ class ExperimentalMcpServerTasks {
|
|
|
14206
14236
|
}
|
|
14207
14237
|
|
|
14208
14238
|
// node_modules/@modelcontextprotocol/sdk/dist/esm/server/mcp.js
|
|
14239
|
+
function toolInputElementCount(value, max) {
|
|
14240
|
+
let count = 0;
|
|
14241
|
+
const stack = [value];
|
|
14242
|
+
while (stack.length > 0) {
|
|
14243
|
+
const node = stack.pop();
|
|
14244
|
+
if (node === null || typeof node !== "object")
|
|
14245
|
+
continue;
|
|
14246
|
+
if (Array.isArray(node)) {
|
|
14247
|
+
for (const child of node) {
|
|
14248
|
+
if (++count > max)
|
|
14249
|
+
return count;
|
|
14250
|
+
if (child !== null && typeof child === "object")
|
|
14251
|
+
stack.push(child);
|
|
14252
|
+
}
|
|
14253
|
+
} else {
|
|
14254
|
+
for (const key in node) {
|
|
14255
|
+
if (!Object.prototype.hasOwnProperty.call(node, key))
|
|
14256
|
+
continue;
|
|
14257
|
+
if (++count > max)
|
|
14258
|
+
return count;
|
|
14259
|
+
const child = node[key];
|
|
14260
|
+
if (child !== null && typeof child === "object")
|
|
14261
|
+
stack.push(child);
|
|
14262
|
+
}
|
|
14263
|
+
}
|
|
14264
|
+
}
|
|
14265
|
+
return count;
|
|
14266
|
+
}
|
|
14267
|
+
function resolveMaxToolInputElements(value) {
|
|
14268
|
+
if (value === undefined || value === Infinity)
|
|
14269
|
+
return;
|
|
14270
|
+
if (typeof value !== "number" || Number.isNaN(value) || value < 1) {
|
|
14271
|
+
throw new RangeError(`maxToolInputElements must be a number of at least 1, or Infinity, got ${String(value)}`);
|
|
14272
|
+
}
|
|
14273
|
+
return value;
|
|
14274
|
+
}
|
|
14275
|
+
|
|
14209
14276
|
class McpServer {
|
|
14210
14277
|
constructor(serverInfo, options) {
|
|
14211
14278
|
this._registeredResources = {};
|
|
@@ -14217,6 +14284,7 @@ class McpServer {
|
|
|
14217
14284
|
this._resourceHandlersInitialized = false;
|
|
14218
14285
|
this._promptHandlersInitialized = false;
|
|
14219
14286
|
this.server = new Server(serverInfo, options);
|
|
14287
|
+
this._maxToolInputElements = resolveMaxToolInputElements(options?.maxToolInputElements);
|
|
14220
14288
|
}
|
|
14221
14289
|
get experimental() {
|
|
14222
14290
|
if (!this._experimental) {
|
|
@@ -14323,12 +14391,15 @@ class McpServer {
|
|
|
14323
14391
|
};
|
|
14324
14392
|
}
|
|
14325
14393
|
async validateToolInput(tool, args, toolName) {
|
|
14394
|
+
if (this._maxToolInputElements !== undefined && toolInputElementCount(args, this._maxToolInputElements) > this._maxToolInputElements) {
|
|
14395
|
+
throw new McpError(ErrorCode.InvalidParams, `Invalid arguments for tool ${toolName}: arguments contain more than the maximum of ${this._maxToolInputElements} elements`);
|
|
14396
|
+
}
|
|
14326
14397
|
if (!tool.inputSchema) {
|
|
14327
14398
|
return;
|
|
14328
14399
|
}
|
|
14329
14400
|
const inputObj = normalizeObjectSchema(tool.inputSchema);
|
|
14330
14401
|
const schemaToParse = inputObj ?? tool.inputSchema;
|
|
14331
|
-
const parseResult = await safeParseAsync2(schemaToParse, args);
|
|
14402
|
+
const parseResult = await safeParseAsync2(schemaToParse, args ?? {});
|
|
14332
14403
|
if (!parseResult.success) {
|
|
14333
14404
|
const error = "error" in parseResult ? parseResult.error : "Unknown error";
|
|
14334
14405
|
const errorMessage = getParseErrorMessage(error);
|
|
@@ -14553,7 +14624,7 @@ class McpServer {
|
|
|
14553
14624
|
}
|
|
14554
14625
|
if (prompt.argsSchema) {
|
|
14555
14626
|
const argsObj = normalizeObjectSchema(prompt.argsSchema);
|
|
14556
|
-
const parseResult = await safeParseAsync2(argsObj, request.params.arguments);
|
|
14627
|
+
const parseResult = await safeParseAsync2(argsObj, request.params.arguments ?? {});
|
|
14557
14628
|
if (!parseResult.success) {
|
|
14558
14629
|
const error = "error" in parseResult ? parseResult.error : "Unknown error";
|
|
14559
14630
|
const errorMessage = getParseErrorMessage(error);
|
|
@@ -14931,6 +15002,28 @@ var EMPTY_COMPLETION_RESULT = {
|
|
|
14931
15002
|
}
|
|
14932
15003
|
};
|
|
14933
15004
|
|
|
15005
|
+
// src/core/vlan-resource.ts
|
|
15006
|
+
function registerVlanKnowledgeResource(server) {
|
|
15007
|
+
server.registerResource("vlan-segmentation-guide", VLAN_GUIDE_URI, {
|
|
15008
|
+
title: "RouterOS VLAN segmentation guide",
|
|
15009
|
+
description: "Read-only VLAN design, dual-stack isolation, management safety and validation guidance. No live device data.",
|
|
15010
|
+
mimeType: "text/markdown"
|
|
15011
|
+
}, (uri) => ({
|
|
15012
|
+
contents: [{ uri: uri.href, mimeType: "text/markdown", text: getVlanSegmentationGuide() }]
|
|
15013
|
+
}));
|
|
15014
|
+
}
|
|
15015
|
+
|
|
15016
|
+
// src/core/container-resource.ts
|
|
15017
|
+
function registerContainerKnowledgeResource(server) {
|
|
15018
|
+
server.registerResource("routeros-container-guide", CONTAINER_GUIDE_URI, {
|
|
15019
|
+
title: "RouterOS container operations guide",
|
|
15020
|
+
description: "Version-aware container discovery, deployment, isolation and lifecycle safety. Reference only, no live device data.",
|
|
15021
|
+
mimeType: "text/markdown"
|
|
15022
|
+
}, (uri) => ({
|
|
15023
|
+
contents: [{ uri: uri.href, mimeType: "text/markdown", text: getRouterosContainerGuide() }]
|
|
15024
|
+
}));
|
|
15025
|
+
}
|
|
15026
|
+
|
|
14934
15027
|
// src/prompts/index.ts
|
|
14935
15028
|
import { readFileSync, readdirSync } from "fs";
|
|
14936
15029
|
import { join } from "path";
|
|
@@ -15004,7 +15097,11 @@ function substitutePrompt(body, vars) {
|
|
|
15004
15097
|
const value = Object.hasOwn(vars, key) ? vars[key] : undefined;
|
|
15005
15098
|
if (value === undefined || value === null || value === "")
|
|
15006
15099
|
return whole;
|
|
15007
|
-
|
|
15100
|
+
if (typeof value === "string")
|
|
15101
|
+
return value;
|
|
15102
|
+
if (typeof value === "number" || typeof value === "boolean" || typeof value === "bigint")
|
|
15103
|
+
return String(value);
|
|
15104
|
+
return JSON.stringify(value) ?? whole;
|
|
15008
15105
|
});
|
|
15009
15106
|
}
|
|
15010
15107
|
|
|
@@ -15056,7 +15153,7 @@ function parseFrontmatter(raw) {
|
|
|
15056
15153
|
title: meta.title ?? meta.name,
|
|
15057
15154
|
description: meta.description ?? "",
|
|
15058
15155
|
arguments: args,
|
|
15059
|
-
body: transactionPromptGuidance(meta.name, body.trim())
|
|
15156
|
+
body: containerPromptGuidance(meta.name, vlanPromptGuidance(meta.name, transactionPromptGuidance(meta.name, body.trim())))
|
|
15060
15157
|
};
|
|
15061
15158
|
}
|
|
15062
15159
|
function deviceArgDescription(directory) {
|
|
@@ -15100,17 +15197,27 @@ function registerPrompts(server, opts = {}) {
|
|
|
15100
15197
|
if (multiDevice && !hasOwnDevice) {
|
|
15101
15198
|
argsSchema.device = _enum(selectorNames).optional().describe(deviceArgDescription(opts.deviceDirectory));
|
|
15102
15199
|
}
|
|
15103
|
-
server.registerPrompt(parsed.name, { title: parsed.title, description: parsed.description, argsSchema }, (args) =>
|
|
15104
|
-
|
|
15105
|
-
|
|
15106
|
-
|
|
15107
|
-
|
|
15108
|
-
type: "text",
|
|
15109
|
-
text: substitutePrompt(parsed.body, args)
|
|
15110
|
-
}
|
|
15200
|
+
server.registerPrompt(parsed.name, { title: parsed.title, description: parsed.description, argsSchema }, (args) => {
|
|
15201
|
+
const values = { ...args };
|
|
15202
|
+
for (const arg of parsed.arguments) {
|
|
15203
|
+
if (!arg.required && (typeof values[arg.name] !== "string" || !String(values[arg.name]).trim())) {
|
|
15204
|
+
values[arg.name] = "(not specified; ask if needed)";
|
|
15111
15205
|
}
|
|
15112
|
-
|
|
15113
|
-
|
|
15206
|
+
}
|
|
15207
|
+
return {
|
|
15208
|
+
messages: [
|
|
15209
|
+
{
|
|
15210
|
+
role: "user",
|
|
15211
|
+
content: {
|
|
15212
|
+
type: "text",
|
|
15213
|
+
text: (multiDevice && !hasOwnDevice && typeof args.device === "string" ? `Target device (configured MCP key or label): ${JSON.stringify(args.device)}. Resolve this exact device; do not substitute the default.
|
|
15214
|
+
|
|
15215
|
+
` : "") + substitutePrompt(parsed.body, values)
|
|
15216
|
+
}
|
|
15217
|
+
}
|
|
15218
|
+
]
|
|
15219
|
+
};
|
|
15220
|
+
});
|
|
15114
15221
|
count++;
|
|
15115
15222
|
}
|
|
15116
15223
|
return count;
|
|
@@ -15140,10 +15247,12 @@ Tool discovery \u2014 MANDATORY workflow:
|
|
|
15140
15247
|
Safety model \u2014 tools are annotated by risk:
|
|
15141
15248
|
\u2022 readOnlyHint \u2192 inspection only, no changes
|
|
15142
15249
|
\u2022 destructiveHint \u2192 removes or replaces configuration
|
|
15143
|
-
Before a single-device batch of risky changes,
|
|
15144
|
-
|
|
15145
|
-
|
|
15146
|
-
|
|
15250
|
+
Before a single-device batch of risky changes, assess enable_safe_mode and an
|
|
15251
|
+
independent management recovery path. RouterOS can roll back eligible uncommitted
|
|
15252
|
+
changes after session loss, but Safe Mode has limits and is NOT a backup or a
|
|
15253
|
+
universal rollback guarantee. Use only your own session; inspect uncertain writes
|
|
15254
|
+
instead of replaying them. Commit only an approved, verified plan; otherwise use
|
|
15255
|
+
the agreed rollback/recovery path. Prefer filtered list_* reads to keep output small.
|
|
15147
15256
|
|
|
15148
15257
|
Change workflow \u2014 ALWAYS take a restore point before a plan. Before calling
|
|
15149
15258
|
plan_changes or apply_plan (or any batch of write/destructive tools), first call
|
|
@@ -15237,6 +15346,20 @@ function createServer(opts = {}) {
|
|
|
15237
15346
|
const toolModules = selectToolModules2(getConfig2().tools);
|
|
15238
15347
|
const availableTools = new Set(toolModules.flatMap((mod) => mod.map((tool) => tool.name)));
|
|
15239
15348
|
let instructions = names.length > 1 ? INSTRUCTIONS + MULTI_DEVICE_INSTRUCTIONS.replace("{{names}}", names.join(", ")).replace("{{default}}", defaultDevice) : INSTRUCTIONS;
|
|
15349
|
+
instructions += `
|
|
15350
|
+
|
|
15351
|
+
${VLAN_INSTRUCTIONS}`;
|
|
15352
|
+
instructions += `
|
|
15353
|
+
|
|
15354
|
+
${CONTAINER_INSTRUCTIONS}`;
|
|
15355
|
+
if (availableTools.has("get_routeros_container_guide")) {
|
|
15356
|
+
instructions += `
|
|
15357
|
+
Container tool-only clients: discover get_routeros_container_guide with find_tools; this reference does not contact a router.`;
|
|
15358
|
+
}
|
|
15359
|
+
if (availableTools.has("get_vlan_segmentation_guide")) {
|
|
15360
|
+
instructions += `
|
|
15361
|
+
Tool-only clients: discover get_vlan_segmentation_guide with find_tools; topic=all returns the full guide without router I/O.`;
|
|
15362
|
+
}
|
|
15240
15363
|
const sshParticipants = names.filter((name) => !getConfig2().devices[name]?.mac);
|
|
15241
15364
|
if (!readOnly && sshParticipants.length > 1 && TRANSACTION_TOOL_NAMES.every((name) => availableTools.has(name))) {
|
|
15242
15365
|
instructions += `
|
|
@@ -15245,6 +15368,22 @@ ${TRANSACTION_WORKFLOW}`;
|
|
|
15245
15368
|
}
|
|
15246
15369
|
if (getConfig2().memory.enabled)
|
|
15247
15370
|
instructions += MEMORY_INSTRUCTIONS;
|
|
15371
|
+
if (!readOnly && availableTools.has("update_mcp_settings")) {
|
|
15372
|
+
instructions += `
|
|
15373
|
+
|
|
15374
|
+
MCP host settings (not RouterOS configuration):
|
|
15375
|
+
Use get_mcp_settings_schema, then get_mcp_settings and preview_mcp_settings.
|
|
15376
|
+
Show changed fields and restart requirements; apply only explicit user-approved
|
|
15377
|
+
changes with update_mcp_settings, the preview revision and confirm=true.
|
|
15378
|
+
Read back with get_mcp_settings; confirm_mcp_settings before the deadline or
|
|
15379
|
+
rollback_mcp_settings. The tool creates a local config backup automatically;
|
|
15380
|
+
no router snapshot or device argument is needed. Never restart while pending:
|
|
15381
|
+
the rollback timer only runs while this process is alive. Configured values do
|
|
15382
|
+
not prove startup-only components are active; restart separately after confirmation.
|
|
15383
|
+
Protected settings (devices, credentials, listeners, paths, access, readOnly,
|
|
15384
|
+
tool restrictions and probe allowlists) require the operator, not a workaround.
|
|
15385
|
+
If another workflow owns a pending change, finish it there before applying.`;
|
|
15386
|
+
}
|
|
15248
15387
|
if (!getConfig2().disableUpdateCheck) {
|
|
15249
15388
|
const cached = loadFileCacheSync();
|
|
15250
15389
|
if (cached) {
|
|
@@ -15292,6 +15431,8 @@ ${note}`;
|
|
|
15292
15431
|
deviceDirectory: deviceDirectory()
|
|
15293
15432
|
});
|
|
15294
15433
|
const uiViewCount = registerUiResources(server);
|
|
15434
|
+
registerVlanKnowledgeResource(server);
|
|
15435
|
+
registerContainerKnowledgeResource(server);
|
|
15295
15436
|
installToolPagination(server, getConfig2().mcp.toolPageSize);
|
|
15296
15437
|
return { server, toolCount, promptCount, uiViewCount, readOnly };
|
|
15297
15438
|
}
|
|
@@ -4,7 +4,11 @@ import {
|
|
|
4
4
|
DEFAULT_SNAPSHOT_DB2,
|
|
5
5
|
DEFAULT_BACKUP_DIR2,
|
|
6
6
|
DEFAULT_CONFIG_HISTORY_DIR2,
|
|
7
|
+
McpServerSettingsSchema2,
|
|
7
8
|
DeviceConfigSchema2,
|
|
9
|
+
DashboardConfigSchema2,
|
|
10
|
+
MemoryConfigSchema2,
|
|
11
|
+
SSHConfigSchema2,
|
|
8
12
|
ToolFilterSchema2,
|
|
9
13
|
AccessConfigSchema2,
|
|
10
14
|
MikrotikConfigSchema2,
|
|
@@ -17,8 +21,12 @@ export {
|
|
|
17
21
|
DEFAULT_CONFIG_HISTORY_DIR2 as DEFAULT_CONFIG_HISTORY_DIR,
|
|
18
22
|
DEFAULT_DASHBOARD_DB2 as DEFAULT_DASHBOARD_DB,
|
|
19
23
|
DEFAULT_SNAPSHOT_DB2 as DEFAULT_SNAPSHOT_DB,
|
|
24
|
+
DashboardConfigSchema2 as DashboardConfigSchema,
|
|
20
25
|
DeviceConfigSchema2 as DeviceConfigSchema,
|
|
26
|
+
McpServerSettingsSchema2 as McpServerSettingsSchema,
|
|
27
|
+
MemoryConfigSchema2 as MemoryConfigSchema,
|
|
21
28
|
MikrotikConfigSchema2 as MikrotikConfigSchema,
|
|
29
|
+
SSHConfigSchema2 as SSHConfigSchema,
|
|
22
30
|
ToolFilterSchema2 as ToolFilterSchema,
|
|
23
31
|
getConfigSource2 as getConfigSource,
|
|
24
32
|
loadConfig2 as loadConfig
|