@usex/mikrotik-mcp 6.12.0 → 6.14.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 +61 -1
- package/dist/index.js +858 -6179
- package/dist/shared/{cli-cbs63p0r.js → cli-1vn2bbpy.js} +5746 -303
- package/dist/shared/{cli-zhfcf33s.js → cli-4xzq2n6j.js} +1 -1
- package/dist/shared/{cli-rbe7s4mf.js → cli-r1ng5cjy.js} +1 -1
- package/dist/shared/{cli-frg1ynaw.js → cli-rcx7e9h4.js} +1 -1
- package/dist/shared/{cli-s9k59ne8.js → cli-w6km895r.js} +1 -1
- package/dist/shared/{library-vtet3w1h.js → library-0qn06vwr.js} +1 -1
- package/dist/shared/{library-je5saqvp.js → library-1nhmbsv0.js} +1 -1
- package/dist/shared/{library-5qaxx124.js → library-1swafsvq.js} +1 -1
- package/dist/shared/{library-he7xy22v.js → library-2wd7mt3g.js} +5798 -355
- package/dist/shared/{library-9sjsjtd1.js → library-jpmbkkz7.js} +1 -1
- package/package.json +1 -1
- package/schemas/config.schema.json +13 -0
- package/schemas/devtools-manifest.json +3 -3
- package/schemas/tool-catalog.json +3 -3
- package/scripts/service.ts +561 -63
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;
|
|
@@ -41,6 +42,37 @@ interface ToolContext {
|
|
|
41
42
|
* Unset for internal callers (samplers, dashboard routes).
|
|
42
43
|
*/
|
|
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;
|
|
44
76
|
}
|
|
45
77
|
/** How a device command was actually carried. */
|
|
46
78
|
type DeviceTransport = "ssh" | "rest" | "mac-telnet";
|
|
@@ -61,7 +93,7 @@ declare function executeMikrotikCommand(command: string, ctx: ToolContext, opts?
|
|
|
61
93
|
maxMs?: number;
|
|
62
94
|
}): Promise<string>;
|
|
63
95
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
64
|
-
import { ToolAnnotations } from "@modelcontextprotocol/sdk/types.js";
|
|
96
|
+
import { CallToolResult as CallToolResult2, ToolAnnotations } from "@modelcontextprotocol/sdk/types.js";
|
|
65
97
|
import { ZodRawShape } from "zod";
|
|
66
98
|
/** Links a tool to an MCP App view resource. */
|
|
67
99
|
interface UiLink {
|
|
@@ -136,6 +168,14 @@ interface ToolRequires {
|
|
|
136
168
|
}
|
|
137
169
|
/** Options threaded into every tool registration. */
|
|
138
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[];
|
|
139
179
|
sendLog?: SendLog;
|
|
140
180
|
/** Configured device KEYS; when more than one, a `device` selector is injected. */
|
|
141
181
|
deviceNames?: string[];
|
|
@@ -178,6 +218,17 @@ interface ToolResult {
|
|
|
178
218
|
structuredContent?: Record<string, unknown>;
|
|
179
219
|
/** Explicit outcome for evidence readers whose successful output can quote historical errors. */
|
|
180
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;
|
|
181
232
|
}
|
|
182
233
|
type HandlerOutput = string | ToolResult;
|
|
183
234
|
interface ToolDef<Shape extends ZodRawShape> {
|
|
@@ -213,6 +264,13 @@ interface ToolDef<Shape extends ZodRawShape> {
|
|
|
213
264
|
* returns a clear reason instead of a RouterOS parser error.
|
|
214
265
|
*/
|
|
215
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;
|
|
216
274
|
/** Handler returning the result shown to the model (text, or text + structured data). */
|
|
217
275
|
handler: (args: any, ctx: ToolContext) => Promise<HandlerOutput> | HandlerOutput;
|
|
218
276
|
}
|
|
@@ -228,6 +286,8 @@ interface RegisterableTool {
|
|
|
228
286
|
ui?: UiLink;
|
|
229
287
|
/** Device requirements, if the tool declared any. */
|
|
230
288
|
requires?: ToolRequires;
|
|
289
|
+
/** True for `invoke_tool`: guards apply to the delegated tool. */
|
|
290
|
+
dispatcher?: boolean;
|
|
231
291
|
/**
|
|
232
292
|
* The raw handler (pre-`device`-injection, pre-validation). Exposed so the
|
|
233
293
|
* tool-gateway dispatcher (`invoke_tool`) can run any tool by name through its
|