ssh-mcp 1.0.9 → 1.1.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 +7 -1
- package/build/index.js +23 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -48,6 +48,10 @@
|
|
|
48
48
|
- Timeout is configured via command line argument `--timeout` (in milliseconds)
|
|
49
49
|
- Default timeout: 60000ms (1 minute)
|
|
50
50
|
- When a command times out, the server automatically attempts to abort the running process before closing the connection
|
|
51
|
+
- **Max Command Length Configuration:**
|
|
52
|
+
- Max command characters are configured via `--maxChars`
|
|
53
|
+
- Default: `1000`
|
|
54
|
+
- No-limit mode: set `--maxChars=none` or any `<= 0` value (e.g. `--maxChars=0`)
|
|
51
55
|
|
|
52
56
|
## Installation
|
|
53
57
|
|
|
@@ -74,6 +78,7 @@ You can configure Claude Desktop to use this MCP Server.
|
|
|
74
78
|
- `password`: SSH password (or use `key` for key-based auth)
|
|
75
79
|
- `key`: Path to private SSH key
|
|
76
80
|
- `timeout`: Command execution timeout in milliseconds (default: 60000ms = 1 minute)
|
|
81
|
+
- `maxChars`: Maximum allowed characters for the `command` input (default: 1000). Use `none` or `0` to disable the limit.
|
|
77
82
|
|
|
78
83
|
|
|
79
84
|
```commandline
|
|
@@ -90,7 +95,8 @@ You can configure Claude Desktop to use this MCP Server.
|
|
|
90
95
|
"--user=root",
|
|
91
96
|
"--password=pass",
|
|
92
97
|
"--key=path/to/key",
|
|
93
|
-
"--timeout=30000"
|
|
98
|
+
"--timeout=30000",
|
|
99
|
+
"--maxChars=none"
|
|
94
100
|
]
|
|
95
101
|
}
|
|
96
102
|
}
|
package/build/index.js
CHANGED
|
@@ -24,6 +24,27 @@ const USER = argvConfig.user;
|
|
|
24
24
|
const PASSWORD = argvConfig.password;
|
|
25
25
|
const KEY = argvConfig.key;
|
|
26
26
|
const DEFAULT_TIMEOUT = argvConfig.timeout ? parseInt(argvConfig.timeout) : 60000; // 60 seconds default timeout
|
|
27
|
+
// Max characters configuration:
|
|
28
|
+
// - Default: 1000 characters
|
|
29
|
+
// - When set via --maxChars:
|
|
30
|
+
// * a positive integer enforces that limit
|
|
31
|
+
// * 0 or a negative value disables the limit (no max)
|
|
32
|
+
// * the string "none" (case-insensitive) disables the limit (no max)
|
|
33
|
+
const MAX_CHARS_RAW = argvConfig.maxChars;
|
|
34
|
+
const MAX_CHARS = (() => {
|
|
35
|
+
if (typeof MAX_CHARS_RAW === 'string') {
|
|
36
|
+
const lowered = MAX_CHARS_RAW.toLowerCase();
|
|
37
|
+
if (lowered === 'none')
|
|
38
|
+
return Infinity;
|
|
39
|
+
const parsed = parseInt(MAX_CHARS_RAW);
|
|
40
|
+
if (isNaN(parsed))
|
|
41
|
+
return 1000;
|
|
42
|
+
if (parsed <= 0)
|
|
43
|
+
return Infinity;
|
|
44
|
+
return parsed;
|
|
45
|
+
}
|
|
46
|
+
return 1000;
|
|
47
|
+
})();
|
|
27
48
|
function validateConfig(config) {
|
|
28
49
|
const errors = [];
|
|
29
50
|
if (!config.host)
|
|
@@ -49,8 +70,8 @@ export function sanitizeCommand(command) {
|
|
|
49
70
|
throw new McpError(ErrorCode.InvalidParams, 'Command cannot be empty');
|
|
50
71
|
}
|
|
51
72
|
// Length check
|
|
52
|
-
if (trimmedCommand.length >
|
|
53
|
-
throw new McpError(ErrorCode.InvalidParams,
|
|
73
|
+
if (Number.isFinite(MAX_CHARS) && trimmedCommand.length > MAX_CHARS) {
|
|
74
|
+
throw new McpError(ErrorCode.InvalidParams, `Command is too long (max ${MAX_CHARS} characters)`);
|
|
54
75
|
}
|
|
55
76
|
return trimmedCommand;
|
|
56
77
|
}
|