@usex/mikrotik-mcp 6.11.0 → 6.13.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 +42 -5361
- package/dist/index.d.ts +76 -3
- package/dist/index.js +858 -6179
- package/dist/shared/{cli-xkhmxe9c.js → cli-1vn2bbpy.js} +6033 -398
- package/dist/shared/{cli-xgyy9he1.js → cli-4xzq2n6j.js} +1 -1
- package/dist/shared/{cli-p3rfcsg3.js → cli-r1ng5cjy.js} +1 -1
- package/dist/shared/{cli-vrfw477g.js → cli-rcx7e9h4.js} +1 -1
- package/dist/shared/{cli-n6heg9q6.js → cli-w6km895r.js} +1 -1
- package/dist/shared/{library-qx9hax3s.js → library-0qn06vwr.js} +1 -1
- package/dist/shared/{library-dc9pv2hm.js → library-1nhmbsv0.js} +1 -1
- package/dist/shared/{library-zwdxcca2.js → library-1swafsvq.js} +1 -1
- package/dist/shared/{library-w2eyfdqz.js → library-2wd7mt3g.js} +6033 -399
- package/dist/shared/{library-y783969c.js → library-jpmbkkz7.js} +1 -1
- package/dist/ui/observability.html +69 -69
- package/package.json +20 -16
- package/schemas/config.schema.json +13 -0
- package/schemas/devtools-manifest.json +3 -3
- package/schemas/tool-catalog.json +383 -10
- package/schemas/tools/apply_plan.json +6 -1
- package/schemas/tools/update_bfd_configuration.json +8 -0
- package/schemas/tools/update_bgp_connection.json +8 -0
- package/schemas/tools/update_bridge.json +8 -0
- package/schemas/tools/update_dns_static.json +8 -0
- package/schemas/tools/update_dot1x_client.json +8 -0
- package/schemas/tools/update_dot1x_server.json +8 -0
- package/schemas/tools/update_filter_rule.json +8 -0
- package/schemas/tools/update_igmp_proxy_interface.json +8 -0
- package/schemas/tools/update_ip_pool.json +8 -0
- package/schemas/tools/update_ipsec_peer.json +8 -0
- package/schemas/tools/update_ipsec_profile.json +8 -0
- package/schemas/tools/update_ipsec_proposal.json +8 -0
- package/schemas/tools/update_ipv6_filter_rule.json +8 -0
- package/schemas/tools/update_ipv6_mangle_rule.json +8 -0
- package/schemas/tools/update_ipv6_nat_rule.json +8 -0
- package/schemas/tools/update_ipv6_nd.json +8 -0
- package/schemas/tools/update_ipv6_pool.json +8 -0
- package/schemas/tools/update_ipv6_raw_rule.json +8 -0
- package/schemas/tools/update_mangle_rule.json +8 -0
- package/schemas/tools/update_nat_rule.json +8 -0
- package/schemas/tools/update_ospf_instance.json +8 -0
- package/schemas/tools/update_ovpn_server.json +8 -0
- package/schemas/tools/update_ppp_profile.json +8 -0
- package/schemas/tools/update_ppp_secret.json +8 -0
- package/schemas/tools/update_queue_interface.json +8 -0
- package/schemas/tools/update_queue_tree.json +8 -0
- package/schemas/tools/update_queue_type.json +8 -0
- package/schemas/tools/update_radius_server.json +8 -0
- package/schemas/tools/update_rip_instance.json +8 -0
- package/schemas/tools/update_route.json +8 -0
- package/schemas/tools/update_routing_filter_rule.json +8 -0
- package/schemas/tools/update_routing_id.json +8 -0
- package/schemas/tools/update_routing_rule.json +8 -0
- package/schemas/tools/update_routing_table.json +8 -0
- package/schemas/tools/update_rpki_session.json +8 -0
- package/schemas/tools/update_simple_queue.json +8 -0
- package/schemas/tools/update_switch.json +8 -0
- package/schemas/tools/update_switch_port.json +8 -0
- package/schemas/tools/update_switch_port_isolation.json +8 -0
- package/schemas/tools/update_switch_rule.json +8 -0
- package/schemas/tools/update_traffic_monitor.json +8 -0
- package/schemas/tools/update_user_manager_user.json +8 -0
- package/schemas/tools/update_vlan_interface.json +8 -0
- package/schemas/tools/update_wireguard_interface.json +8 -0
- package/schemas/tools/update_wireguard_peer.json +8 -0
- package/schemas/tools/update_wireless_interface.json +8 -0
- package/scripts/service.ts +618 -0
- package/scripts/upgrade.ts +7 -0
package/dist/index.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ type DeviceConfig = z.infer<typeof DeviceConfigSchema>;
|
|
|
4
4
|
declare const MikrotikConfigSchema: unknown;
|
|
5
5
|
type MikrotikConfig = z.infer<typeof MikrotikConfigSchema>;
|
|
6
6
|
declare function loadConfig(argv?: string[]): MikrotikConfig;
|
|
7
|
+
import { CallToolResult } from "@modelcontextprotocol/sdk/types.js";
|
|
7
8
|
interface ToolContext {
|
|
8
9
|
/** Correlates this invocation with its result and saved activity record. */
|
|
9
10
|
callId?: string;
|
|
@@ -35,6 +36,43 @@ interface ToolContext {
|
|
|
35
36
|
* simply never being enabled.
|
|
36
37
|
*/
|
|
37
38
|
restFallback?: string;
|
|
39
|
+
/**
|
|
40
|
+
* Risk preset of the tool that owns this call (set by the registry). The
|
|
41
|
+
* connector uses it to keep READ tools out of an open Safe Mode shell.
|
|
42
|
+
* Unset for internal callers (samplers, dashboard routes).
|
|
43
|
+
*/
|
|
44
|
+
risk?: "READ" | "WRITE" | "WRITE_IDEMPOTENT" | "DESTRUCTIVE" | "DANGEROUS";
|
|
45
|
+
/**
|
|
46
|
+
* The tools bound to the MCP server this call arrived on (set by the
|
|
47
|
+
* registry). The tool gateway uses it to run, describe and point at other
|
|
48
|
+
* tools without a second code path. Unset for internal callers.
|
|
49
|
+
*/
|
|
50
|
+
tools?: ToolAccess;
|
|
51
|
+
/** Set by the registry when this call returned another tool's finished result. */
|
|
52
|
+
delegated?: boolean;
|
|
53
|
+
/** Set by the registry when the handler opted out of the reachability hint line. */
|
|
54
|
+
noHint?: boolean;
|
|
55
|
+
}
|
|
56
|
+
/** Access to the other tools of the same MCP server, for the tool gateway. */
|
|
57
|
+
interface ToolAccess {
|
|
58
|
+
/**
|
|
59
|
+
* Run a tool through the SAME pipeline as a direct `tools/call`: device and
|
|
60
|
+
* `reason` handling, access policy, guards, audit record. `undefined` when
|
|
61
|
+
* the tool is not available on this server (unknown, read-only mode,
|
|
62
|
+
* filtered out).
|
|
63
|
+
*/
|
|
64
|
+
run(name: string, args: Record<string, unknown>): Promise<CallToolResult> | undefined;
|
|
65
|
+
/** The Zod shape a direct call is validated against (with `device` / `reason`). */
|
|
66
|
+
shape(name: string): Record<string, unknown> | undefined;
|
|
67
|
+
/** The JSON Schema exactly as `tools/list` publishes it for this tool. */
|
|
68
|
+
schema(name: string): Record<string, unknown> | undefined;
|
|
69
|
+
/**
|
|
70
|
+
* True when a hint may tell the client to call the tool by name. In `core`
|
|
71
|
+
* surface mode that is every listed tool. In `full` mode only the pinned
|
|
72
|
+
* core set: the rest is listed too, but a host with a large catalog may not
|
|
73
|
+
* have loaded it, so hints must give an `invoke_tool` call for those.
|
|
74
|
+
*/
|
|
75
|
+
direct(name: string): boolean;
|
|
38
76
|
}
|
|
39
77
|
/** How a device command was actually carried. */
|
|
40
78
|
type DeviceTransport = "ssh" | "rest" | "mac-telnet";
|
|
@@ -55,7 +93,7 @@ declare function executeMikrotikCommand(command: string, ctx: ToolContext, opts?
|
|
|
55
93
|
maxMs?: number;
|
|
56
94
|
}): Promise<string>;
|
|
57
95
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
58
|
-
import { ToolAnnotations } from "@modelcontextprotocol/sdk/types.js";
|
|
96
|
+
import { CallToolResult as CallToolResult2, ToolAnnotations } from "@modelcontextprotocol/sdk/types.js";
|
|
59
97
|
import { ZodRawShape } from "zod";
|
|
60
98
|
/** Links a tool to an MCP App view resource. */
|
|
61
99
|
interface UiLink {
|
|
@@ -130,6 +168,14 @@ interface ToolRequires {
|
|
|
130
168
|
}
|
|
131
169
|
/** Options threaded into every tool registration. */
|
|
132
170
|
interface RegisterOptions {
|
|
171
|
+
/**
|
|
172
|
+
* `full` (default) lists every tool. `core` lists only {@link PINNED_TOOLS}
|
|
173
|
+
* plus `coreTools`; every other tool stays bound and runs through
|
|
174
|
+
* `invoke_tool`. Use `core` for hosts that load only part of a large list.
|
|
175
|
+
*/
|
|
176
|
+
surface?: "full" | "core";
|
|
177
|
+
/** Extra tool names to list in `core` surface mode. */
|
|
178
|
+
coreTools?: string[];
|
|
133
179
|
sendLog?: SendLog;
|
|
134
180
|
/** Configured device KEYS; when more than one, a `device` selector is injected. */
|
|
135
181
|
deviceNames?: string[];
|
|
@@ -172,6 +218,17 @@ interface ToolResult {
|
|
|
172
218
|
structuredContent?: Record<string, unknown>;
|
|
173
219
|
/** Explicit outcome for evidence readers whose successful output can quote historical errors. */
|
|
174
220
|
isError?: boolean;
|
|
221
|
+
/**
|
|
222
|
+
* A finished result of ANOTHER tool's direct-call pipeline, returned as is.
|
|
223
|
+
* Only the tool gateway sets it: that call was already guarded, recorded and
|
|
224
|
+
* given its own Tool call ID, so this call must not record or stamp it again.
|
|
225
|
+
*/
|
|
226
|
+
passthrough?: CallToolResult2;
|
|
227
|
+
/**
|
|
228
|
+
* `false` = do not append the "not in your tool list" hint line. For a
|
|
229
|
+
* result whose text already says how to run every tool it names.
|
|
230
|
+
*/
|
|
231
|
+
hint?: false;
|
|
175
232
|
}
|
|
176
233
|
type HandlerOutput = string | ToolResult;
|
|
177
234
|
interface ToolDef<Shape extends ZodRawShape> {
|
|
@@ -207,6 +264,13 @@ interface ToolDef<Shape extends ZodRawShape> {
|
|
|
207
264
|
* returns a clear reason instead of a RouterOS parser error.
|
|
208
265
|
*/
|
|
209
266
|
requires?: ToolRequires;
|
|
267
|
+
/**
|
|
268
|
+
* True for `invoke_tool` only. The access policy is then evaluated for the
|
|
269
|
+
* delegated tool (its own risk and device) instead of for the dispatcher,
|
|
270
|
+
* so a read-only scope can still read through the gateway and a write is
|
|
271
|
+
* still judged as the write it is.
|
|
272
|
+
*/
|
|
273
|
+
dispatcher?: boolean;
|
|
210
274
|
/** Handler returning the result shown to the model (text, or text + structured data). */
|
|
211
275
|
handler: (args: any, ctx: ToolContext) => Promise<HandlerOutput> | HandlerOutput;
|
|
212
276
|
}
|
|
@@ -222,6 +286,8 @@ interface RegisterableTool {
|
|
|
222
286
|
ui?: UiLink;
|
|
223
287
|
/** Device requirements, if the tool declared any. */
|
|
224
288
|
requires?: ToolRequires;
|
|
289
|
+
/** True for `invoke_tool`: guards apply to the delegated tool. */
|
|
290
|
+
dispatcher?: boolean;
|
|
225
291
|
/**
|
|
226
292
|
* The raw handler (pre-`device`-injection, pre-validation). Exposed so the
|
|
227
293
|
* tool-gateway dispatcher (`invoke_tool`) can run any tool by name through its
|
|
@@ -369,8 +435,8 @@ declare class SafeModeManager {
|
|
|
369
435
|
* instead of a reassuring false success. Cleared on the next enable().
|
|
370
436
|
*/
|
|
371
437
|
private droppedUnexpectedly;
|
|
372
|
-
/**
|
|
373
|
-
private
|
|
438
|
+
/** Why the last session was closed automatically; shown by status() only. */
|
|
439
|
+
private lastClosure;
|
|
374
440
|
/** Distinguish each mode probe from delayed output of an earlier round trip. */
|
|
375
441
|
private probeSequence;
|
|
376
442
|
/** Serializes channel access so concurrent tool calls don't interleave I/O. */
|
|
@@ -382,7 +448,14 @@ declare class SafeModeManager {
|
|
|
382
448
|
/** The device this Safe Mode session belongs to (a configured device name). */
|
|
383
449
|
constructor(deviceName: string);
|
|
384
450
|
get isActive(): boolean;
|
|
451
|
+
/**
|
|
452
|
+
* True after the shell dropped by itself, until that is reported ONCE (by the
|
|
453
|
+
* next write, commit, rollback or enable). It never blocks reads and never
|
|
454
|
+
* needs a restart to clear.
|
|
455
|
+
*/
|
|
385
456
|
get requiresRecovery(): boolean;
|
|
457
|
+
/** Close the session after a failure and remember why, for status(). */
|
|
458
|
+
private closeAfterFailure;
|
|
386
459
|
/** Run `fn` exclusively — the persistent channel must not be shared mid-command. */
|
|
387
460
|
private lock;
|
|
388
461
|
/** Open a persistent SSH shell and activate MikroTik Safe Mode. */
|