ssh-mcp 1.0.8 → 1.0.9

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.
Files changed (2) hide show
  1. package/build/index.js +16 -10
  2. package/package.json +13 -5
package/build/index.js CHANGED
@@ -16,7 +16,8 @@ function parseArgv() {
16
16
  }
17
17
  return config;
18
18
  }
19
- const argvConfig = parseArgv();
19
+ const isCliEnabled = process.env.SSH_MCP_DISABLE_MAIN !== '1';
20
+ const argvConfig = isCliEnabled ? parseArgv() : {};
20
21
  const HOST = argvConfig.host;
21
22
  const PORT = argvConfig.port ? parseInt(argvConfig.port) : 22;
22
23
  const USER = argvConfig.user;
@@ -35,9 +36,11 @@ function validateConfig(config) {
35
36
  throw new Error('Configuration error:\n' + errors.join('\n'));
36
37
  }
37
38
  }
38
- validateConfig(argvConfig);
39
+ if (isCliEnabled) {
40
+ validateConfig(argvConfig);
41
+ }
39
42
  // Command sanitization and validation
40
- function sanitizeCommand(command) {
43
+ export function sanitizeCommand(command) {
41
44
  if (typeof command !== 'string') {
42
45
  throw new McpError(ErrorCode.InvalidParams, 'Command must be a string');
43
46
  }
@@ -52,13 +55,13 @@ function sanitizeCommand(command) {
52
55
  return trimmedCommand;
53
56
  }
54
57
  // Escape command for use in shell contexts (like pkill)
55
- function escapeCommandForShell(command) {
58
+ export function escapeCommandForShell(command) {
56
59
  // Replace single quotes with escaped single quotes
57
60
  return command.replace(/'/g, "'\"'\"'");
58
61
  }
59
62
  const server = new McpServer({
60
63
  name: 'SSH MCP Server',
61
- version: '1.0.7',
64
+ version: '1.0.9',
62
65
  capabilities: {
63
66
  resources: {},
64
67
  tools: {},
@@ -92,7 +95,7 @@ server.tool("exec", "Execute a shell command on the remote SSH server and return
92
95
  throw new McpError(ErrorCode.InternalError, `Unexpected error: ${err?.message || err}`);
93
96
  }
94
97
  });
95
- async function execSshCommand(sshConfig, command) {
98
+ export async function execSshCommand(sshConfig, command) {
96
99
  return new Promise((resolve, reject) => {
97
100
  const conn = new SSHClient();
98
101
  let timeoutId;
@@ -175,7 +178,10 @@ async function main() {
175
178
  await server.connect(transport);
176
179
  console.error("SSH MCP Server running on stdio");
177
180
  }
178
- main().catch((error) => {
179
- console.error("Fatal error in main():", error);
180
- process.exit(1);
181
- });
181
+ if (process.env.SSH_MCP_DISABLE_MAIN !== '1') {
182
+ main().catch((error) => {
183
+ console.error("Fatal error in main():", error);
184
+ process.exit(1);
185
+ });
186
+ }
187
+ export { parseArgv, validateConfig };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "ssh-mcp",
3
3
  "license": "MIT",
4
- "version": "1.0.8",
4
+ "version": "1.0.9",
5
5
  "description": "MCP server exposing SSH control for Linux and Windows systems via Model Context Protocol.",
6
6
  "type": "module",
7
7
  "bin": {
@@ -10,7 +10,10 @@
10
10
  "scripts": {
11
11
  "prepare": "npm run build",
12
12
  "build": "tsc && shx chmod +x build/*.js",
13
- "inspect": "npx @modelcontextprotocol/inspector node build/index.js"
13
+ "inspect": "npx @modelcontextprotocol/inspector node build/index.js",
14
+ "test": "cross-env SSH_MCP_DISABLE_MAIN=1 vitest --run",
15
+ "test:watch": "cross-env SSH_MCP_DISABLE_MAIN=1 vitest",
16
+ "coverage": "cross-env SSH_MCP_DISABLE_MAIN=1 vitest --run --coverage"
14
17
  },
15
18
  "files": [
16
19
  "build"
@@ -18,13 +21,18 @@
18
21
  "dependencies": {
19
22
  "@modelcontextprotocol/sdk": "^1.17.5",
20
23
  "ssh2": "^1.17.0",
21
- "zod": "^4.1.5"
24
+ "zod": "3.23.8"
22
25
  },
23
26
  "devDependencies": {
24
- "@types/node": "^24.3.0",
27
+ "@types/node": "^24.5.2",
25
28
  "@types/ssh2": "^1.15.5",
29
+ "cross-env": "^7.0.3",
26
30
  "shx": "^0.4.0",
27
- "typescript": "^5.9.2"
31
+ "testcontainers": "^11.7.0",
32
+ "ts-node": "^10.9.2",
33
+ "tsx": "^4.20.6",
34
+ "typescript": "^5.9.2",
35
+ "vitest": "^3.2.4"
28
36
  },
29
37
  "homepage": "https://github.com/tufantunc/ssh-mcp#readme",
30
38
  "repository": {