@yawlabs/ssh-mcp 0.3.0 → 0.5.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/README.md +43 -5
- package/dist/index.js +597 -228
- package/dist/server.d.ts +81 -17
- package/dist/server.js +446 -59
- package/package.json +2 -1
package/dist/server.d.ts
CHANGED
|
@@ -1,7 +1,55 @@
|
|
|
1
1
|
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
-
import { Client } from 'ssh2';
|
|
2
|
+
import { ConnectConfig, Client } from 'ssh2';
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
interface SSHConfig {
|
|
5
|
+
host: string;
|
|
6
|
+
port?: number;
|
|
7
|
+
username?: string;
|
|
8
|
+
privateKeyPath?: string;
|
|
9
|
+
password?: string;
|
|
10
|
+
agent?: string;
|
|
11
|
+
}
|
|
12
|
+
interface ExecResult {
|
|
13
|
+
stdout: string;
|
|
14
|
+
stderr: string;
|
|
15
|
+
code: number;
|
|
16
|
+
}
|
|
17
|
+
interface ResolvedConfig {
|
|
18
|
+
connectConfig: ConnectConfig;
|
|
19
|
+
proxyJump?: string;
|
|
20
|
+
}
|
|
21
|
+
declare function resolveConfig(config: SSHConfig): ResolvedConfig;
|
|
22
|
+
declare function formatDiagnostics(host: string): string;
|
|
23
|
+
declare function connectRaw(connectConfig: ConnectConfig): Promise<Client>;
|
|
24
|
+
declare function connectWithProxy(resolved: ResolvedConfig): Promise<Client>;
|
|
25
|
+
declare function connect(config: SSHConfig): Promise<Client>;
|
|
26
|
+
declare function exec(client: Client, command: string, timeoutMs?: number): Promise<ExecResult>;
|
|
27
|
+
declare function readFile(client: Client, remotePath: string): Promise<string>;
|
|
28
|
+
declare function writeFile(client: Client, remotePath: string, content: string): Promise<void>;
|
|
29
|
+
declare function uploadFile(client: Client, localPath: string, remotePath: string): Promise<void>;
|
|
30
|
+
declare function downloadFile(client: Client, remotePath: string, localPath: string): Promise<void>;
|
|
31
|
+
declare function listDir(client: Client, remotePath: string): Promise<string[]>;
|
|
32
|
+
|
|
33
|
+
interface PoolOptions {
|
|
34
|
+
/** Milliseconds before an idle connection is closed. Default: 60000 (60s) */
|
|
35
|
+
idleTtlMs?: number;
|
|
36
|
+
}
|
|
37
|
+
declare class ConnectionPool {
|
|
38
|
+
private entries;
|
|
39
|
+
private idleTtlMs;
|
|
40
|
+
constructor(options?: PoolOptions);
|
|
41
|
+
acquire(config: SSHConfig): Promise<Client>;
|
|
42
|
+
release(client: Client): void;
|
|
43
|
+
withConnection<T>(config: SSHConfig, fn: (client: Client) => Promise<T>): Promise<T>;
|
|
44
|
+
drain(): void;
|
|
45
|
+
get size(): number;
|
|
46
|
+
get stats(): {
|
|
47
|
+
active: number;
|
|
48
|
+
idle: number;
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
declare function registerTools(server: McpServer, pool?: ConnectionPool): void;
|
|
5
53
|
|
|
6
54
|
interface DiagnosticResult {
|
|
7
55
|
status: "ok" | "warning" | "error";
|
|
@@ -21,26 +69,42 @@ declare function checkConnectivity(host: string, port?: number): DiagnosticResul
|
|
|
21
69
|
declare function checkSshConfig(host: string): DiagnosticResult;
|
|
22
70
|
declare function diagnose(host: string, port?: number): DiagnosticReport;
|
|
23
71
|
|
|
24
|
-
interface
|
|
72
|
+
interface MultiExecResult {
|
|
73
|
+
host: string;
|
|
74
|
+
stdout: string;
|
|
75
|
+
stderr: string;
|
|
76
|
+
code: number;
|
|
77
|
+
error?: string;
|
|
78
|
+
}
|
|
79
|
+
interface MultiExecHost {
|
|
25
80
|
host: string;
|
|
26
81
|
port?: number;
|
|
27
82
|
username?: string;
|
|
28
83
|
privateKeyPath?: string;
|
|
29
84
|
password?: string;
|
|
30
|
-
agent?: string;
|
|
31
85
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
86
|
+
declare function multiExec(pool: ConnectionPool, hosts: MultiExecHost[], command: string, timeoutMs?: number): Promise<MultiExecResult[]>;
|
|
87
|
+
interface FindOptions {
|
|
88
|
+
path: string;
|
|
89
|
+
name?: string;
|
|
90
|
+
type?: "f" | "d" | "l";
|
|
91
|
+
maxdepth?: number;
|
|
92
|
+
minsize?: string;
|
|
93
|
+
maxsize?: string;
|
|
94
|
+
newer?: string;
|
|
36
95
|
}
|
|
37
|
-
declare function
|
|
38
|
-
declare function
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
96
|
+
declare function find(client: Client, options: FindOptions, timeoutMs?: number): Promise<string[]>;
|
|
97
|
+
declare function tail(client: Client, path: string, lines?: number, grep?: string, timeoutMs?: number): Promise<string>;
|
|
98
|
+
interface ServiceStatus {
|
|
99
|
+
name: string;
|
|
100
|
+
active: boolean;
|
|
101
|
+
status: string;
|
|
102
|
+
description?: string;
|
|
103
|
+
since?: string;
|
|
104
|
+
pid?: number;
|
|
105
|
+
raw: string;
|
|
106
|
+
}
|
|
107
|
+
declare function serviceStatus(client: Client, serviceName: string, timeoutMs?: number): Promise<ServiceStatus>;
|
|
44
108
|
|
|
45
109
|
interface KeyInfo {
|
|
46
110
|
name: string;
|
|
@@ -95,6 +159,6 @@ declare function testConnection(host: string, port?: number): {
|
|
|
95
159
|
message: string;
|
|
96
160
|
};
|
|
97
161
|
|
|
98
|
-
declare function createServer(): McpServer;
|
|
162
|
+
declare function createServer(pool?: ConnectionPool): McpServer;
|
|
99
163
|
|
|
100
|
-
export { type AgentResult, type ConfigLookupResult, type DiagnosticReport, type DiagnosticResult, type ExecResult, type KeyInfo, type SSHConfig, checkConnectivity, checkGitSsh, checkKnownHosts, checkSshAgent, checkSshConfig, checkSshKeys, configLookup, connect, createServer, diagnose, downloadFile, ensureAgent, exec, fixKnownHosts, listDir, listSshKeys, loadKey, readFile, registerTools, testConnection, uploadFile, writeFile };
|
|
164
|
+
export { type AgentResult, type ConfigLookupResult, ConnectionPool, type DiagnosticReport, type DiagnosticResult, type ExecResult, type FindOptions, type KeyInfo, type MultiExecHost, type MultiExecResult, type PoolOptions, type ResolvedConfig, type SSHConfig, type ServiceStatus, checkConnectivity, checkGitSsh, checkKnownHosts, checkSshAgent, checkSshConfig, checkSshKeys, configLookup, connect, connectRaw, connectWithProxy, createServer, diagnose, downloadFile, ensureAgent, exec, find, fixKnownHosts, formatDiagnostics, listDir, listSshKeys, loadKey, multiExec, readFile, registerTools, resolveConfig, serviceStatus, tail, testConnection, uploadFile, writeFile };
|