@pyrokine/mcp-ssh 1.2.0 → 1.2.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/file-ops.js +3 -1
- package/dist/session-manager.js +5 -1
- package/package.json +2 -2
- package/src/file-ops.ts +3 -1
- package/src/session-manager.ts +5 -1
package/dist/file-ops.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { execSync } from 'child_process';
|
|
5
5
|
import * as fs from 'fs';
|
|
6
|
+
import * as os from 'os';
|
|
6
7
|
import * as path from 'path';
|
|
7
8
|
import { sessionManager } from './session-manager.js';
|
|
8
9
|
// 文件类型 mode 常量
|
|
@@ -273,7 +274,8 @@ async function syncWithRsync(alias, localPath, remotePath, direction, options) {
|
|
|
273
274
|
// 检查本地是否有 rsync
|
|
274
275
|
let hasLocalRsync = false;
|
|
275
276
|
try {
|
|
276
|
-
|
|
277
|
+
const cmd = os.platform() === 'win32' ? 'where rsync' : 'which rsync';
|
|
278
|
+
execSync(cmd, { stdio: 'pipe' });
|
|
277
279
|
hasLocalRsync = true;
|
|
278
280
|
}
|
|
279
281
|
catch {
|
package/dist/session-manager.js
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
* - 会话持久化
|
|
9
9
|
*/
|
|
10
10
|
import * as fs from 'fs';
|
|
11
|
+
import * as os from 'os';
|
|
11
12
|
import * as path from 'path';
|
|
12
13
|
import { Client } from 'ssh2';
|
|
13
14
|
import { ForwardManager } from './forward-manager.js';
|
|
@@ -24,7 +25,7 @@ export class SessionManager {
|
|
|
24
25
|
defaultMaxOutputSize = 10 * 1024 * 1024; // 10MB
|
|
25
26
|
reconnectDelay = 5000; // 5秒
|
|
26
27
|
constructor(persistPath) {
|
|
27
|
-
this.persistPath = persistPath || path.join(
|
|
28
|
+
this.persistPath = persistPath || path.join(os.homedir(), '.ssh-mcp-pro', 'sessions.json');
|
|
28
29
|
this.ensurePersistDir();
|
|
29
30
|
}
|
|
30
31
|
/**
|
|
@@ -100,6 +101,9 @@ export class SessionManager {
|
|
|
100
101
|
const session = this.sessions.get(alias);
|
|
101
102
|
if (session && session.client === client) {
|
|
102
103
|
session.connected = false;
|
|
104
|
+
// 清理绑定旧 client 的 forward/PTY 资源
|
|
105
|
+
this.forwardManager.closeByAlias(alias);
|
|
106
|
+
this.ptyManager.closeByAlias(alias);
|
|
103
107
|
if (!session.manualClose) {
|
|
104
108
|
this.scheduleReconnect(alias);
|
|
105
109
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pyrokine/mcp-ssh",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.1",
|
|
4
4
|
"description": "A comprehensive SSH MCP Server for Claude Code",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"build": "tsc",
|
|
12
12
|
"start": "node dist/index.js",
|
|
13
13
|
"dev": "tsc && node dist/index.js",
|
|
14
|
-
"clean": "
|
|
14
|
+
"clean": "node -e \"require('fs').rmSync('dist',{recursive:true,force:true})\"",
|
|
15
15
|
"prepublishOnly": "npm run build"
|
|
16
16
|
},
|
|
17
17
|
"keywords": [
|
package/src/file-ops.ts
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
import {execSync} from 'child_process'
|
|
6
6
|
import * as fs from 'fs'
|
|
7
|
+
import * as os from 'os'
|
|
7
8
|
import * as path from 'path'
|
|
8
9
|
import {SFTPWrapper, Stats} from 'ssh2'
|
|
9
10
|
import {sessionManager} from './session-manager.js'
|
|
@@ -382,7 +383,8 @@ async function syncWithRsync(
|
|
|
382
383
|
// 检查本地是否有 rsync
|
|
383
384
|
let hasLocalRsync = false
|
|
384
385
|
try {
|
|
385
|
-
|
|
386
|
+
const cmd = os.platform() === 'win32' ? 'where rsync' : 'which rsync'
|
|
387
|
+
execSync(cmd, {stdio: 'pipe'})
|
|
386
388
|
hasLocalRsync = true
|
|
387
389
|
} catch {
|
|
388
390
|
}
|
package/src/session-manager.ts
CHANGED
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
import * as fs from 'fs'
|
|
12
|
+
import * as os from 'os'
|
|
12
13
|
import * as path from 'path'
|
|
13
14
|
import {Client, ClientChannel, ConnectConfig, SFTPWrapper} from 'ssh2'
|
|
14
15
|
import {ForwardManager} from './forward-manager.js'
|
|
@@ -48,7 +49,7 @@ export class SessionManager {
|
|
|
48
49
|
|
|
49
50
|
constructor(persistPath?: string) {
|
|
50
51
|
this.persistPath = persistPath || path.join(
|
|
51
|
-
|
|
52
|
+
os.homedir(),
|
|
52
53
|
'.ssh-mcp-pro',
|
|
53
54
|
'sessions.json',
|
|
54
55
|
)
|
|
@@ -140,6 +141,9 @@ export class SessionManager {
|
|
|
140
141
|
const session = this.sessions.get(alias)
|
|
141
142
|
if (session && session.client === client) {
|
|
142
143
|
session.connected = false
|
|
144
|
+
// 清理绑定旧 client 的 forward/PTY 资源
|
|
145
|
+
this.forwardManager.closeByAlias(alias)
|
|
146
|
+
this.ptyManager.closeByAlias(alias)
|
|
143
147
|
if (!session.manualClose) {
|
|
144
148
|
this.scheduleReconnect(alias)
|
|
145
149
|
}
|