@mgsoftwarebv/mg-dashboard-mcp 3.10.0 → 3.10.1

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.js CHANGED
@@ -3627,43 +3627,47 @@ ${result.stderr}`);
3627
3627
  if (containers.length === 0) {
3628
3628
  return { content: [{ type: "text", text: "Error: no valid containerName provided" }] };
3629
3629
  }
3630
- const tail = Number(a.tail) > 0 ? Number(a.tail) : Number(a.lines) > 0 ? Number(a.lines) : 100;
3630
+ const followSeconds = Math.max(0, Math.min(300, Number(a.followSeconds) || 0));
3631
+ const userTail = a.tail !== void 0 ? Number(a.tail) : a.lines !== void 0 ? Number(a.lines) : void 0;
3632
+ const tailArg = userTail !== void 0 && Number.isFinite(userTail) && userTail >= 0 ? userTail : followSeconds > 0 ? 0 : 100;
3631
3633
  const sinceRaw = typeof a.since === "string" ? a.since.trim() : "";
3632
3634
  const grepRaw = typeof a.grep === "string" ? a.grep : "";
3633
- const followSeconds = Math.max(0, Math.min(300, Number(a.followSeconds) || 0));
3634
3635
  if (sinceRaw && !/^\d+[smhd]$/i.test(sinceRaw) && !/^\d{4}-\d{2}-\d{2}/.test(sinceRaw)) {
3635
3636
  return { content: [{ type: "text", text: 'Error: invalid `since` format (expected e.g. "10m", "2h", or ISO timestamp)' }] };
3636
3637
  }
3637
3638
  const sinceArg = sinceRaw ? ` --since ${posixQuote(sinceRaw)}` : "";
3638
3639
  const grepSuffix = grepRaw ? ` | grep -i -E ${posixQuote(grepRaw)} --line-buffered` : "";
3639
- const followTail = a.tail !== void 0 || a.lines !== void 0 ? tail : 0;
3640
- const tailArg = followSeconds > 0 ? followTail : tail;
3641
3640
  const { conn, proxy } = await getServerConnection(String(a.serverId));
3642
- if (followSeconds > 0) conn.timeout = (followSeconds + 10) * 1e3;
3641
+ const wallSeconds = followSeconds > 0 ? followSeconds : 30;
3642
+ conn.timeout = (wallSeconds + 10) * 1e3;
3643
3643
  const followFlag = followSeconds > 0 ? " -f" : "";
3644
3644
  if (containers.length === 1) {
3645
3645
  const c = containers[0];
3646
- const inner2 = `docker logs${followFlag} --tail ${tailArg}${sinceArg} ${c} 2>&1${grepSuffix}`;
3647
- const cmd2 = followSeconds > 0 ? `timeout --signal=INT ${followSeconds} sh -c ${posixQuote(inner2)}` : inner2;
3646
+ const inner = `docker logs${followFlag} --tail ${tailArg}${sinceArg} ${c} 2>&1${grepSuffix}`;
3647
+ const cmd2 = `timeout --signal=INT ${wallSeconds} sh -c ${posixQuote(inner)}`;
3648
3648
  const result2 = await sshExec(conn, cmd2, proxy);
3649
- const acceptable2 = followSeconds > 0 ? result2.exitCode === 0 || result2.exitCode === 124 || result2.exitCode === 130 : result2.exitCode === 0 || grepRaw && result2.exitCode === 1;
3650
- if (!acceptable2) {
3651
- return { content: [{ type: "text", text: `Error (exit ${result2.exitCode}): ${result2.stderr || result2.stdout}` }] };
3649
+ const acceptable2 = result2.exitCode === 0 || result2.exitCode === 124 || result2.exitCode === 130 || result2.exitCode === 143 || !!grepRaw && result2.exitCode === 1;
3650
+ if (!acceptable2 && !result2.stdout) {
3651
+ return { content: [{ type: "text", text: `Error (exit ${result2.exitCode}): ${result2.stderr || "(no output)"}` }] };
3652
3652
  }
3653
- return { content: [{ type: "text", text: result2.stdout || "(no log lines matched)" }] };
3653
+ const note2 = result2.exitCode === 124 ? `
3654
+ (note: command exceeded ${wallSeconds}s wall budget; partial output)` : "";
3655
+ return { content: [{ type: "text", text: (result2.stdout || "(no log lines matched)") + note2 }] };
3654
3656
  }
3655
3657
  const subShells = containers.map((c) => {
3656
- const inner2 = `docker logs${followFlag} --tail ${tailArg}${sinceArg} ${c} 2>&1${grepSuffix}`;
3657
- return `(${inner2} | sed -u -e ${posixQuote(`s/^/[${c}] /`)})`;
3658
+ const inner = `docker logs${followFlag} --tail ${tailArg}${sinceArg} ${c} 2>&1${grepSuffix}`;
3659
+ return `(${inner} | sed -u -e ${posixQuote(`s/^/[${c}] /`)})`;
3658
3660
  });
3659
- const inner = followSeconds > 0 ? subShells.join(" & ") + " & wait" : subShells.join("; ");
3660
- const cmd = followSeconds > 0 ? `timeout --signal=INT ${followSeconds} sh -c ${posixQuote(inner)}` : inner;
3661
+ const innerCmd = subShells.join(" & ") + " & wait";
3662
+ const cmd = `timeout --signal=INT ${wallSeconds} sh -c ${posixQuote(innerCmd)}`;
3661
3663
  const result = await sshExec(conn, cmd, proxy);
3662
- const acceptable = followSeconds > 0 ? result.exitCode === 0 || result.exitCode === 124 || result.exitCode === 130 || result.exitCode === 143 : result.exitCode === 0 || grepRaw && result.exitCode === 1;
3663
- if (!acceptable) {
3664
- return { content: [{ type: "text", text: `Error (exit ${result.exitCode}): ${result.stderr || result.stdout}` }] };
3664
+ const acceptable = result.exitCode === 0 || result.exitCode === 124 || result.exitCode === 130 || result.exitCode === 143 || !!grepRaw && result.exitCode === 1;
3665
+ if (!acceptable && !result.stdout) {
3666
+ return { content: [{ type: "text", text: `Error (exit ${result.exitCode}): ${result.stderr || "(no output)"}` }] };
3665
3667
  }
3666
- return { content: [{ type: "text", text: result.stdout || "(no log lines matched)" }] };
3668
+ const note = result.exitCode === 124 ? `
3669
+ (note: one or more containers exceeded ${wallSeconds}s wall budget; partial output)` : "";
3670
+ return { content: [{ type: "text", text: (result.stdout || "(no log lines matched)") + note }] };
3667
3671
  }
3668
3672
  case "docker-exec": {
3669
3673
  const container = String(a.container).replace(/[^a-zA-Z0-9._-]/g, "");