@yawlabs/ssh-mcp 0.9.2 → 0.9.3

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
@@ -343,6 +343,13 @@ function ensureAgent() {
343
343
  if (process.platform === "win32") {
344
344
  const result = probeAgent("\\\\.\\pipe\\openssh-ssh-agent", "Windows OpenSSH agent");
345
345
  if (result) return result;
346
+ return {
347
+ running: false,
348
+ reachable: false,
349
+ keys: [],
350
+ started: false,
351
+ message: "Windows OpenSSH agent not running. Start it: Get-Service ssh-agent | Set-Service -StartupType Automatic; Start-Service ssh-agent"
352
+ };
346
353
  }
347
354
  const { stdout, ok } = runArgs("ssh-agent", ["-s"]);
348
355
  if (ok) {
@@ -370,7 +377,7 @@ function ensureAgent() {
370
377
  reachable: false,
371
378
  keys: [],
372
379
  started: false,
373
- message: process.platform === "win32" ? "Windows OpenSSH agent not running. Start it: Get-Service ssh-agent | Set-Service -StartupType Automatic; Start-Service ssh-agent" : 'Could not start ssh-agent. Run manually: eval "$(ssh-agent -s)"'
380
+ message: 'Could not start ssh-agent. Run manually: eval "$(ssh-agent -s)"'
374
381
  };
375
382
  }
376
383
  function detectKeyType(filePath, fileName) {
@@ -1220,6 +1227,7 @@ async function serviceStatus(client, serviceName, timeoutMs = 3e4) {
1220
1227
  const descMatch = raw.match(/^\s+.*?-\s+(.+)$/m);
1221
1228
  const pidMatch = raw.match(/Main PID:\s+(\d+)/);
1222
1229
  const sinceMatch = raw.match(/since\s+(.+?);/);
1230
+ const unknown = !activeMatch && result.code !== 0;
1223
1231
  const fallbackStatus = result.code === 0 ? "active" : "inactive";
1224
1232
  return {
1225
1233
  name: serviceName,
@@ -1228,7 +1236,8 @@ async function serviceStatus(client, serviceName, timeoutMs = 3e4) {
1228
1236
  description: descMatch?.[1]?.trim(),
1229
1237
  since: sinceMatch?.[1]?.trim(),
1230
1238
  pid: pidMatch ? Number.parseInt(pidMatch[1], 10) : void 0,
1231
- raw
1239
+ raw,
1240
+ unknown
1232
1241
  };
1233
1242
  }
1234
1243
 
@@ -1265,6 +1274,7 @@ function registerTools(server, pool) {
1265
1274
  if (result.stdout) parts.push(result.stdout);
1266
1275
  if (result.stderr) parts.push(`[stderr]
1267
1276
  ${result.stderr}`);
1277
+ if (result.signal) parts.push(`[signal: ${result.signal}]`);
1268
1278
  parts.push(`[exit code: ${result.code}]`);
1269
1279
  return { content: [{ type: "text", text: parts.join("\n") }] };
1270
1280
  });
@@ -1601,7 +1611,7 @@ ${files.join("\n")}` }] };
1601
1611
  if (status.since) lines.push(`Since: ${status.since}`);
1602
1612
  lines.push("");
1603
1613
  lines.push(status.raw);
1604
- return { content: [{ type: "text", text: lines.join("\n") }] };
1614
+ return { content: [{ type: "text", text: lines.join("\n") }], isError: status.unknown };
1605
1615
  });
1606
1616
  }
1607
1617
  );
package/dist/server.d.ts CHANGED
@@ -175,6 +175,13 @@ interface ServiceStatus {
175
175
  since?: string;
176
176
  pid?: number;
177
177
  raw: string;
178
+ /**
179
+ * True when systemctl could not report on the unit at all: no `Active:` line
180
+ * parseable AND non-zero exit. Typical causes: typo'd unit name, unit file
181
+ * doesn't exist, systemd unreachable. Distinct from "service exists but is
182
+ * stopped" (active=false but unknown=false).
183
+ */
184
+ unknown: boolean;
178
185
  }
179
186
  declare function serviceStatus(client: Client, serviceName: string, timeoutMs?: number): Promise<ServiceStatus>;
180
187
 
package/dist/server.js CHANGED
@@ -339,6 +339,13 @@ function ensureAgent() {
339
339
  if (process.platform === "win32") {
340
340
  const result = probeAgent("\\\\.\\pipe\\openssh-ssh-agent", "Windows OpenSSH agent");
341
341
  if (result) return result;
342
+ return {
343
+ running: false,
344
+ reachable: false,
345
+ keys: [],
346
+ started: false,
347
+ message: "Windows OpenSSH agent not running. Start it: Get-Service ssh-agent | Set-Service -StartupType Automatic; Start-Service ssh-agent"
348
+ };
342
349
  }
343
350
  const { stdout, ok } = runArgs("ssh-agent", ["-s"]);
344
351
  if (ok) {
@@ -366,7 +373,7 @@ function ensureAgent() {
366
373
  reachable: false,
367
374
  keys: [],
368
375
  started: false,
369
- message: process.platform === "win32" ? "Windows OpenSSH agent not running. Start it: Get-Service ssh-agent | Set-Service -StartupType Automatic; Start-Service ssh-agent" : 'Could not start ssh-agent. Run manually: eval "$(ssh-agent -s)"'
376
+ message: 'Could not start ssh-agent. Run manually: eval "$(ssh-agent -s)"'
370
377
  };
371
378
  }
372
379
  function detectKeyType(filePath, fileName) {
@@ -1031,6 +1038,7 @@ async function serviceStatus(client, serviceName, timeoutMs = 3e4) {
1031
1038
  const descMatch = raw.match(/^\s+.*?-\s+(.+)$/m);
1032
1039
  const pidMatch = raw.match(/Main PID:\s+(\d+)/);
1033
1040
  const sinceMatch = raw.match(/since\s+(.+?);/);
1041
+ const unknown = !activeMatch && result.code !== 0;
1034
1042
  const fallbackStatus = result.code === 0 ? "active" : "inactive";
1035
1043
  return {
1036
1044
  name: serviceName,
@@ -1039,7 +1047,8 @@ async function serviceStatus(client, serviceName, timeoutMs = 3e4) {
1039
1047
  description: descMatch?.[1]?.trim(),
1040
1048
  since: sinceMatch?.[1]?.trim(),
1041
1049
  pid: pidMatch ? Number.parseInt(pidMatch[1], 10) : void 0,
1042
- raw
1050
+ raw,
1051
+ unknown
1043
1052
  };
1044
1053
  }
1045
1054
 
@@ -1270,6 +1279,7 @@ function registerTools(server, pool) {
1270
1279
  if (result.stdout) parts.push(result.stdout);
1271
1280
  if (result.stderr) parts.push(`[stderr]
1272
1281
  ${result.stderr}`);
1282
+ if (result.signal) parts.push(`[signal: ${result.signal}]`);
1273
1283
  parts.push(`[exit code: ${result.code}]`);
1274
1284
  return { content: [{ type: "text", text: parts.join("\n") }] };
1275
1285
  });
@@ -1606,7 +1616,7 @@ ${files.join("\n")}` }] };
1606
1616
  if (status.since) lines.push(`Since: ${status.since}`);
1607
1617
  lines.push("");
1608
1618
  lines.push(status.raw);
1609
- return { content: [{ type: "text", text: lines.join("\n") }] };
1619
+ return { content: [{ type: "text", text: lines.join("\n") }], isError: status.unknown };
1610
1620
  });
1611
1621
  }
1612
1622
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yawlabs/ssh-mcp",
3
- "version": "0.9.2",
3
+ "version": "0.9.3",
4
4
  "description": "MCP server for SSH operations with built-in diagnostics",
5
5
  "type": "module",
6
6
  "bin": {