@akms/mcp-ssh 0.1.8 → 0.2.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/CHANGELOG.md +14 -0
- package/README.md +8 -0
- package/lib/cli.cjs +13 -11
- package/lib/cli.cjs.map +1 -1
- package/lib/cli.js +13 -10
- package/lib/cli.js.map +1 -1
- package/lib/index.cjs +13 -11
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +2 -1
- package/lib/index.d.ts +2 -1
- package/lib/index.js +13 -10
- package/lib/index.js.map +1 -1
- package/package.json +1 -1
package/lib/index.d.cts
CHANGED
|
@@ -171,6 +171,7 @@ declare class SshConnection {
|
|
|
171
171
|
get jumpHostKeyFingerprint(): string | null;
|
|
172
172
|
/** True when a connection was established and then lost, so shell state is gone. */
|
|
173
173
|
get wasDropped(): boolean;
|
|
174
|
+
private assertNotDisposed;
|
|
174
175
|
/**
|
|
175
176
|
* Opens the connection, or joins the in-flight attempt when one is already running.
|
|
176
177
|
*
|
|
@@ -532,7 +533,7 @@ declare const $logger: Logger;
|
|
|
532
533
|
/** Env var overriding the stderr log level ("debug" | "info" | "warn" | "error" | "silent"). */
|
|
533
534
|
declare const LOG_LEVEL_ENV = "SSH_MCP_LOG_LEVEL";
|
|
534
535
|
declare const SERVER_NAME = "akms-mcp-ssh";
|
|
535
|
-
declare const SERVER_VERSION = "0.
|
|
536
|
+
declare const SERVER_VERSION = "0.2.0";
|
|
536
537
|
|
|
537
538
|
/**
|
|
538
539
|
* Environment variables that define the host, one MCP server entry per host.
|
package/lib/index.d.ts
CHANGED
|
@@ -171,6 +171,7 @@ declare class SshConnection {
|
|
|
171
171
|
get jumpHostKeyFingerprint(): string | null;
|
|
172
172
|
/** True when a connection was established and then lost, so shell state is gone. */
|
|
173
173
|
get wasDropped(): boolean;
|
|
174
|
+
private assertNotDisposed;
|
|
174
175
|
/**
|
|
175
176
|
* Opens the connection, or joins the in-flight attempt when one is already running.
|
|
176
177
|
*
|
|
@@ -532,7 +533,7 @@ declare const $logger: Logger;
|
|
|
532
533
|
/** Env var overriding the stderr log level ("debug" | "info" | "warn" | "error" | "silent"). */
|
|
533
534
|
declare const LOG_LEVEL_ENV = "SSH_MCP_LOG_LEVEL";
|
|
534
535
|
declare const SERVER_NAME = "akms-mcp-ssh";
|
|
535
|
-
declare const SERVER_VERSION = "0.
|
|
536
|
+
declare const SERVER_VERSION = "0.2.0";
|
|
536
537
|
|
|
537
538
|
/**
|
|
538
539
|
* Environment variables that define the host, one MCP server entry per host.
|
package/lib/index.js
CHANGED
|
@@ -6,7 +6,6 @@ import { spawn } from 'child_process';
|
|
|
6
6
|
import { createHash } from 'crypto';
|
|
7
7
|
import { Duplex } from 'stream';
|
|
8
8
|
import { StringDecoder } from 'string_decoder';
|
|
9
|
-
import ssh2 from 'ssh2';
|
|
10
9
|
import { setInterval, clearInterval } from 'timers';
|
|
11
10
|
import { z } from 'zod';
|
|
12
11
|
|
|
@@ -25,7 +24,7 @@ var SESSION_SWEEP_INTERVAL_MS = 6e4;
|
|
|
25
24
|
var CWD_MARKER = "__AKMS_SSH_CWD__";
|
|
26
25
|
var MAX_DIRECTORY_ENTRIES = 1e3;
|
|
27
26
|
var SERVER_NAME = "akms-mcp-ssh";
|
|
28
|
-
var SERVER_VERSION = "0.
|
|
27
|
+
var SERVER_VERSION = "0.2.0";
|
|
29
28
|
|
|
30
29
|
// src/_defs/command-rules.ts
|
|
31
30
|
var CRITICAL_PATH_PATTERN = new RegExp(
|
|
@@ -1331,7 +1330,6 @@ var GuardRejectionError = class extends Error {
|
|
|
1331
1330
|
};
|
|
1332
1331
|
|
|
1333
1332
|
// src/modules/ssh/ssh-connection.ts
|
|
1334
|
-
var { Client } = ssh2;
|
|
1335
1333
|
var OUTPUT_HARD_CAP_MULTIPLIER = 4;
|
|
1336
1334
|
var PRIVATE_KEY_CACHE = /* @__PURE__ */ new Map();
|
|
1337
1335
|
var WINDOWS_AGENT_PIPE = "\\\\.\\pipe\\openssh-ssh-agent";
|
|
@@ -1473,7 +1471,7 @@ function openProxyCommand(profile, hop) {
|
|
|
1473
1471
|
}
|
|
1474
1472
|
};
|
|
1475
1473
|
}
|
|
1476
|
-
function openJumpTransport(profile, jump, proxy, onHostKeySeen) {
|
|
1474
|
+
function openJumpTransport(profile, jump, proxy, onHostKeySeen, Client) {
|
|
1477
1475
|
const label = `${profile.name} jump host`;
|
|
1478
1476
|
const endpoint = `${jump.username}@${jump.host}:${jump.port}`;
|
|
1479
1477
|
const _logger = $logger.child({ context: "openJumpTransport", profile: profile.name, jump_host: jump.host });
|
|
@@ -1538,7 +1536,7 @@ function openJumpTransport(profile, jump, proxy, onHostKeySeen) {
|
|
|
1538
1536
|
jumpClient.connect(jumpConfig);
|
|
1539
1537
|
});
|
|
1540
1538
|
}
|
|
1541
|
-
async function openTransport(profile, onJumpHostKeySeen) {
|
|
1539
|
+
async function openTransport(profile, onJumpHostKeySeen, Client) {
|
|
1542
1540
|
let proxy = null;
|
|
1543
1541
|
if (profile.proxyCommand != null) {
|
|
1544
1542
|
proxy = openProxyCommand(profile, profile.jump ?? profile);
|
|
@@ -1547,7 +1545,7 @@ async function openTransport(profile, onJumpHostKeySeen) {
|
|
|
1547
1545
|
return proxy;
|
|
1548
1546
|
}
|
|
1549
1547
|
try {
|
|
1550
|
-
const jumpTransport = await openJumpTransport(profile, profile.jump, proxy, onJumpHostKeySeen);
|
|
1548
|
+
const jumpTransport = await openJumpTransport(profile, profile.jump, proxy, onJumpHostKeySeen, Client);
|
|
1551
1549
|
return jumpTransport;
|
|
1552
1550
|
} catch (ex) {
|
|
1553
1551
|
proxy?.close();
|
|
@@ -1611,6 +1609,11 @@ var SshConnection = class {
|
|
|
1611
1609
|
get wasDropped() {
|
|
1612
1610
|
return this.droppedAfterReady;
|
|
1613
1611
|
}
|
|
1612
|
+
assertNotDisposed() {
|
|
1613
|
+
if (this.disposed == true) {
|
|
1614
|
+
throw new Error(`ssh connection for '${this.profile.name}' has been closed; open a new session`);
|
|
1615
|
+
}
|
|
1616
|
+
}
|
|
1614
1617
|
/**
|
|
1615
1618
|
* Opens the connection, or joins the in-flight attempt when one is already running.
|
|
1616
1619
|
*
|
|
@@ -1621,9 +1624,7 @@ var SshConnection = class {
|
|
|
1621
1624
|
* unreachable, the handshake times out, or the carrier cannot be opened.
|
|
1622
1625
|
*/
|
|
1623
1626
|
async connect(onProgress) {
|
|
1624
|
-
|
|
1625
|
-
throw new Error(`ssh connection for '${this.profile.name}' has been closed; open a new session`);
|
|
1626
|
-
}
|
|
1627
|
+
this.assertNotDisposed();
|
|
1627
1628
|
if (this.client != null) {
|
|
1628
1629
|
return;
|
|
1629
1630
|
}
|
|
@@ -1642,12 +1643,14 @@ var SshConnection = class {
|
|
|
1642
1643
|
this.observedFingerprint = fingerprint;
|
|
1643
1644
|
});
|
|
1644
1645
|
this.connecting = (async () => {
|
|
1646
|
+
const { default: { Client } } = await import('ssh2');
|
|
1647
|
+
this.assertNotDisposed();
|
|
1645
1648
|
if (this.profile.jump != null || this.profile.proxyCommand != null) {
|
|
1646
1649
|
onProgress?.("transport");
|
|
1647
1650
|
}
|
|
1648
1651
|
const transport = await openTransport(this.profile, (fingerprint) => {
|
|
1649
1652
|
this.observedJumpFingerprint = fingerprint;
|
|
1650
|
-
});
|
|
1653
|
+
}, Client);
|
|
1651
1654
|
if (this.disposed == true) {
|
|
1652
1655
|
transport?.close();
|
|
1653
1656
|
throw new Error(`ssh connection for '${this.profile.name}' was closed during the handshake`);
|