@usex/mikrotik-mcp 5.8.0 → 5.9.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/index.d.ts CHANGED
@@ -212,6 +212,8 @@ interface RegisterableTool {
212
212
  annotations: ToolAnnotations;
213
213
  inputSchema?: ZodRawShape;
214
214
  description: string;
215
+ /** Server-only tools do not participate in device access checks. */
216
+ noDevice?: boolean;
215
217
  /** Present when the tool renders an MCP App view. */
216
218
  ui?: UiLink;
217
219
  /** Device requirements, if the tool declared any. */
package/dist/index.js CHANGED
@@ -62,7 +62,7 @@ import {
62
62
  updateSummaryLine,
63
63
  allToolModules2,
64
64
  selectToolModules2
65
- } from "./shared/library-srhzw8ym.js";
65
+ } from "./shared/library-dyeaqzj6.js";
66
66
 
67
67
  // node_modules/ajv/dist/compile/codegen/code.js
68
68
  var require_code = __commonJS(function(exports) {
@@ -11089,6 +11089,12 @@ function toolUiMeta(ui) {
11089
11089
  return meta;
11090
11090
  }
11091
11091
 
11092
+ // src/core/tool-pattern.ts
11093
+ function globMatch(pattern, name) {
11094
+ const rx = new RegExp(`^${pattern.toLowerCase().replace(/[.+?^${}()|[\]\\]/g, "\\$&").replace(/\*/g, ".*")}$`);
11095
+ return rx.test(name.toLowerCase());
11096
+ }
11097
+
11092
11098
  // src/core/access.ts
11093
11099
  var RISK_ORDER = [
11094
11100
  "READ",
@@ -11104,10 +11110,6 @@ var RISK_RANK = {
11104
11110
  DESTRUCTIVE: 2,
11105
11111
  DANGEROUS: 3
11106
11112
  };
11107
- function globMatch(pattern, name) {
11108
- const rx = new RegExp(`^${pattern.toLowerCase().replace(/[.+?^${}()|[\]\\]/g, "\\$&").replace(/\*/g, ".*")}$`);
11109
- return rx.test(name.toLowerCase());
11110
- }
11111
11113
  function matchesAny(patterns, name) {
11112
11114
  return (patterns ?? []).some((p) => globMatch(p, name));
11113
11115
  }
@@ -11137,7 +11139,20 @@ function evaluateAccess(policy, req) {
11137
11139
  reason: `Tool '${req.tool}' is outside the active access scope${where}. ` + `Allowed: ${s.tools.join(", ")}.`
11138
11140
  };
11139
11141
  }
11142
+ if ((s.toolAllowGroups ?? []).some((group) => !matchesAny(group, req.tool))) {
11143
+ return {
11144
+ allowed: false,
11145
+ rule: "tool",
11146
+ reason: `Tool '${req.tool}' does not satisfy every configured and session tool allow-list${where}.`
11147
+ };
11148
+ }
11140
11149
  if (req.device !== undefined) {
11150
+ if (s.noDevices)
11151
+ return {
11152
+ allowed: false,
11153
+ rule: "device",
11154
+ reason: `No devices remain in the intersection of the configured and session access scopes${where}.`
11155
+ };
11141
11156
  if ((s.denyDevices ?? []).some((d) => d.toLowerCase() === req.device.toLowerCase())) {
11142
11157
  return {
11143
11158
  allowed: false,
@@ -11176,7 +11191,14 @@ function narrowScope(base, requested) {
11176
11191
  return b.filter((x) => lower.has(x.toLowerCase()));
11177
11192
  };
11178
11193
  out.devices = intersect(base.devices, requested.devices);
11194
+ if (base.noDevices || requested.noDevices || base.devices?.length && requested.devices?.length && !out.devices?.length)
11195
+ out.noDevices = true;
11179
11196
  out.tools = requested.tools && requested.tools.length > 0 ? requested.tools : base.tools;
11197
+ const groups = [...base.toolAllowGroups ?? [], ...requested.toolAllowGroups ?? []];
11198
+ if (base.tools?.length && requested.tools?.length)
11199
+ groups.push(base.tools);
11200
+ if (groups.length)
11201
+ out.toolAllowGroups = [...new Map(groups.map((g) => [JSON.stringify(g), g])).values()];
11180
11202
  out.denyDevices = [...new Set([...base.denyDevices ?? [], ...requested.denyDevices ?? []])];
11181
11203
  out.denyTools = [...new Set([...base.denyTools ?? [], ...requested.denyTools ?? []])];
11182
11204
  if (out.denyDevices.length === 0)
@@ -11211,14 +11233,17 @@ function adoptConfiguredPolicy() {
11211
11233
  }
11212
11234
  onConfigChanged(adoptConfiguredPolicy);
11213
11235
  adoptConfiguredPolicy();
11214
- function getAccessPolicy() {
11236
+ function previewAccessPolicy(policy) {
11215
11237
  if (!sessionNarrowing)
11216
- return basePolicy;
11238
+ return policy;
11217
11239
  return {
11218
11240
  enabled: true,
11219
- scope: narrowScope(basePolicy.scope, sessionNarrowing)
11241
+ scope: narrowScope(policy.scope, sessionNarrowing)
11220
11242
  };
11221
11243
  }
11244
+ function getAccessPolicy() {
11245
+ return previewAccessPolicy(basePolicy);
11246
+ }
11222
11247
  function narrowSession(requested) {
11223
11248
  sessionNarrowing = sessionNarrowing ? narrowScope(sessionNarrowing, requested) : narrowScope(basePolicy.scope, requested);
11224
11249
  return getAccessPolicy().scope;
@@ -12466,6 +12491,7 @@ function defineTool2(def) {
12466
12491
  description: def.description,
12467
12492
  annotations: def.annotations,
12468
12493
  inputSchema: def.inputSchema,
12494
+ noDevice: def.noDevice,
12469
12495
  ui: def.ui,
12470
12496
  requires: def.requires,
12471
12497
  handler: def.handler,
@@ -22843,7 +22869,7 @@ var cache2 = null;
22843
22869
  async function gateway() {
22844
22870
  if (cache2)
22845
22871
  return cache2;
22846
- const { moduleCatalog } = await import("./library-hsq1a106.js");
22872
+ const { moduleCatalog } = await import("./library-rkr0yp3t.js");
22847
22873
  const forIndex = [];
22848
22874
  const byName = new Map;
22849
22875
  for (const mod of moduleCatalog) {
@@ -34258,7 +34284,7 @@ ${DATASET_NOTE}`;
34258
34284
  function renderScope(scope) {
34259
34285
  const lines = [];
34260
34286
  lines.push(` max risk : ${scope.maxRisk ?? "(no ceiling)"}`);
34261
- lines.push(` devices : ${scope.devices && scope.devices.length > 0 ? scope.devices.join(", ") : "(all configured)"}`);
34287
+ lines.push(` devices : ${scope.noDevices ? "(none: scopes do not overlap)" : scope.devices && scope.devices.length > 0 ? scope.devices.join(", ") : "(all configured)"}`);
34262
34288
  if (scope.denyDevices && scope.denyDevices.length > 0) {
34263
34289
  lines.push(` denied devs : ${scope.denyDevices.join(", ")}`);
34264
34290
  }
@@ -34266,6 +34292,8 @@ function renderScope(scope) {
34266
34292
  if (scope.denyTools && scope.denyTools.length > 0) {
34267
34293
  lines.push(` denied tools: ${scope.denyTools.join(", ")}`);
34268
34294
  }
34295
+ for (const group of scope.toolAllowGroups ?? [])
34296
+ lines.push(` also match : ${group.join(", ")}`);
34269
34297
  lines.push(` expires : ${scope.expiresAt ? new Date(scope.expiresAt).toISOString() : "(never)"}`);
34270
34298
  if (scope.label)
34271
34299
  lines.push(` label : ${scope.label}`);
@@ -44819,7 +44847,7 @@ var riskByTool = null;
44819
44847
  async function riskIndex() {
44820
44848
  if (riskByTool)
44821
44849
  return riskByTool;
44822
- const { moduleCatalog } = await import("./library-hsq1a106.js");
44850
+ const { moduleCatalog } = await import("./library-rkr0yp3t.js");
44823
44851
  const index = new Map;
44824
44852
  for (const mod of moduleCatalog) {
44825
44853
  for (const tool of mod.tools)
@@ -3,7 +3,7 @@ import {
3
3
  moduleCatalog2,
4
4
  allToolModules2,
5
5
  selectToolModules2
6
- } from "./library-srhzw8ym.js";
6
+ } from "./library-dyeaqzj6.js";
7
7
  export {
8
8
  allToolModules2 as allToolModules,
9
9
  moduleCatalog2 as moduleCatalog,