mcp-ssh-manager 3.6.5 → 3.6.6

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 CHANGED
@@ -5,6 +5,22 @@ All notable changes to MCP SSH Manager will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [3.6.6] - 2026-07-11
9
+
10
+ ### Fixed
11
+
12
+ - **Handlers read stale snake_case config fields that `ConfigLoader` no longer produces** ([#49](https://github.com/bvisible/mcp-ssh-manager/issues/49) — thanks [@egoan82](https://github.com/egoan82) for the excellent root-cause report; fixed in [#50](https://github.com/bvisible/mcp-ssh-manager/pull/50))
13
+ - Since the v3.0.0 ConfigLoader refactor, resolved server configs expose **camelCase** fields (`sudoPassword`, `defaultDir`, `keyPath`), but several handlers still read the pre-3.0 snake_case/lowercase names — always `undefined`, so their fallback branches silently never ran:
14
+ - `ssh_execute_sudo` ignored the configured `SUDO_PASSWORD` → `sudo: a terminal is required to authenticate` on hosts without a TTY on the exec channel
15
+ - `ssh_execute` / `ssh_group_execute` / `ssh_execute_sudo` ignored `DEFAULT_DIR` — commands silently ran in `$HOME`
16
+ - `ssh_list_servers` always reported an empty `defaultDir`
17
+ - `ssh_sync` never passed the configured SSH key to rsync (`-i` / `BatchMode=yes`), falling back to whatever default key the agent offered
18
+ - No configuration change required: `.env`/TOML source keys (`SUDO_PASSWORD`, `default_dir`, `key_path`, …) are unchanged — existing configs simply start working again.
19
+
20
+ ### Added
21
+
22
+ - Regression test `tests/test-config-field-names.js` (`npm run test:fieldnames`, part of `npm test`): locks the ConfigLoader's output field names from both `.env` and TOML sources, and statically forbids stale `.sudo_password` / `.default_dir` / `.keypath` access in `src/`.
23
+
8
24
  ## [3.6.5] - 2026-06-30
9
25
 
10
26
  ### Security
package/README.md CHANGED
@@ -6,7 +6,7 @@ A Model Context Protocol (MCP) server that enables **Claude Code** and **OpenAI
6
6
 
7
7
  [![npm version](https://img.shields.io/npm/v/mcp-ssh-manager.svg?style=for-the-badge&logo=npm)](https://www.npmjs.com/package/mcp-ssh-manager)
8
8
  [![npm downloads](https://img.shields.io/npm/dt/mcp-ssh-manager.svg?style=for-the-badge&logo=npm)](https://www.npmjs.com/package/mcp-ssh-manager)
9
- [![Version](https://img.shields.io/badge/Version-3.6.5-brightgreen?style=for-the-badge)](https://github.com/bvisible/mcp-ssh-manager/releases/tag/v3.6.5)
9
+ [![Version](https://img.shields.io/badge/Version-3.6.6-brightgreen?style=for-the-badge)](https://github.com/bvisible/mcp-ssh-manager/releases/tag/v3.6.6)
10
10
  [![Claude Code](https://img.shields.io/badge/Claude_Code-Compatible-5A67D8?style=for-the-badge&logo=anthropic)](https://claude.ai/code)
11
11
  [![OpenAI Codex](https://img.shields.io/badge/OpenAI_Codex-Compatible-00A67E?style=for-the-badge&logo=openai)](https://openai.com/codex)
12
12
  [![MCP](https://img.shields.io/badge/MCP-Server-orange?style=for-the-badge)](https://modelcontextprotocol.io)
@@ -20,19 +20,25 @@ A Model Context Protocol (MCP) server that enables **Claude Code** and **OpenAI
20
20
 
21
21
  ---
22
22
 
23
- ## 🎉 What's New in v3.6.5
23
+ ## 🎉 What's New in v3.6.6
24
24
 
25
- **Security fix: `ssh_db_query` shell injection + a row-count fix** (Released: June 30, 2026)
25
+ **Bugfix: per-server `SUDO_PASSWORD`, `DEFAULT_DIR` and `ssh_sync` key auth work again** (Released: July 11, 2026)
26
26
 
27
- - **🔒 `ssh_db_query` no longer lets the remote shell parse your query** ([#44](https://github.com/bvisible/mcp-ssh-manager/pull/44) — thanks [@technophile77](https://github.com/technophile77)) — the builders interpolated the query into a double-quoted shell string (`mysql -e "${query}"`, `psql -c "${query}"`, `mongo --eval "${query}"`), so the remote shell evaluated backticks and `$(…)` **before** the database saw it. That both **corrupted** backtick identifiers (hyphenated DB names, cross-DB joins → empty results, no error) **and** let the "SELECT-only" tool **run arbitrary shell commands** on the host. The query is now delivered on **stdin via a single-quoted heredoc**, so only the database engine ever interprets it.
28
- - **🔢 `ssh_db_query` reports the real `row_count`** ([#45](https://github.com/bvisible/mcp-ssh-manager/pull/45) — thanks [@technophile77](https://github.com/technophile77)) — it used to count the cosmetic JSON-wrapper line (1 row → `2`, 0 rows → `2`); it now derives the count from each engine's actual output (MySQL JSON entries, psql's `(N rows)` footer, MongoDB documents).
27
+ - **🔑 `ssh_execute_sudo` respects the configured `SSH_SERVER_<NAME>_SUDO_PASSWORD` again** ([#49](https://github.com/bvisible/mcp-ssh-manager/issues/49) — thanks [@egoan82](https://github.com/egoan82) for the excellent root-cause report) — since the v3.0.0 ConfigLoader refactor, resolved server configs expose **camelCase** fields (`sudoPassword`), but the handler still read the pre-3.0 snake_case name (`sudo_password`), which is always `undefined`. Non-interactive sudo therefore failed with `sudo: a terminal is required to authenticate` unless the password was passed explicitly on every call.
28
+ - **📁 Same mismatch, same fix for `DEFAULT_DIR` and `ssh_sync` key auth** ([#50](https://github.com/bvisible/mcp-ssh-manager/pull/50)) — `ssh_execute`, `ssh_group_execute` and `ssh_execute_sudo` silently ignored the configured default directory (commands ran in `$HOME`), `ssh_list_servers` always reported an empty `defaultDir`, and `ssh_sync` never passed the configured SSH key to rsync (`-i` / `BatchMode=yes`).
29
+ - **🧪 Regression-proofed** — a new test locks the ConfigLoader's output field names (from both `.env` and TOML) and statically forbids stale snake_case field access in `src/`.
30
+ - **No configuration change required** — your `.env`/TOML keys are unchanged; existing configs simply start working again.
29
31
 
30
- [Read full changelog →](CHANGELOG.md#365---2026-06-30)
32
+ [Read full changelog →](CHANGELOG.md#366---2026-07-11)
31
33
 
32
34
  ---
33
35
 
34
36
  ## Previous Releases
35
37
 
38
+ ### v3.6.5 - `ssh_db_query` shell-injection security fix + real row_count (June 30, 2026)
39
+
40
+ - **🔒 Queries are delivered on stdin via a single-quoted heredoc** ([#44](https://github.com/bvisible/mcp-ssh-manager/pull/44), [#45](https://github.com/bvisible/mcp-ssh-manager/pull/45) — thanks [@technophile77](https://github.com/technophile77)) — the remote shell no longer parses backticks/`$(…)` inside queries (which corrupted backtick identifiers **and** let the "SELECT-only" tool run arbitrary shell commands), and `row_count` now reflects each engine's real output instead of counting wrapper lines. [Full changelog →](CHANGELOG.md#365---2026-06-30)
41
+
36
42
  ### v3.6.4 - Internal cleanup + a dead-code quality gate (June 18, 2026)
37
43
 
38
44
  - **🧹 Dead-code removal (−343 lines), zero behavioral change** — removed 27 unused exports and 2 duplicate exports; the MCP server and CLI behave identically (command builders/parsers byte-identical, all 37 tools verified end-to-end). A calibrated `knip.json` plus a **blocking** `knip` CI step keep unused code from creeping back. [Full changelog →](CHANGELOG.md#364---2026-06-18)
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mcp-ssh-manager",
3
- "version": "3.6.5",
3
+ "version": "3.6.6",
4
4
  "description": "MCP SSH Manager: Model Context Protocol server for SSH remote server management. Control SSH connections from Claude Code and OpenAI Codex - execute commands, transfer files, database operations, backups, health monitoring, and DevOps automation. NEW: Tool activation system reduces context usage by 92%",
5
5
  "main": "src/index.js",
6
6
  "bin": {
@@ -13,7 +13,7 @@
13
13
  "setup": "npm install && pip install -r tools/requirements.txt",
14
14
  "configure": "python tools/server-manager.py",
15
15
  "test-connection": "python tools/test-connection.py",
16
- "test": "npm run test:profiles && npm run test:aliases && npm run test:hooks && npm run test:tools && npm run test:policy && npm run test:ping && npm run test:config && npm run test:lifecycle && npm run test:sync && npm run test:dbquoting && npm run test:dbrowcount",
16
+ "test": "npm run test:profiles && npm run test:aliases && npm run test:hooks && npm run test:tools && npm run test:policy && npm run test:ping && npm run test:config && npm run test:fieldnames && npm run test:lifecycle && npm run test:sync && npm run test:dbquoting && npm run test:dbrowcount",
17
17
  "test:profiles": "node tests/test-profiles.js",
18
18
  "test:aliases": "node tests/test-command-aliases.js",
19
19
  "test:hooks": "node tests/test-hooks.js",
@@ -21,6 +21,7 @@
21
21
  "test:policy": "node tests/test-policy.js",
22
22
  "test:ping": "node tests/test-ssh-ping.js",
23
23
  "test:config": "node tests/test-server-config-manager.js",
24
+ "test:fieldnames": "node tests/test-config-field-names.js",
24
25
  "test:lifecycle": "node tests/test-lifecycle.js",
25
26
  "test:sync": "node tests/test-sync-stats.js",
26
27
  "test:dbquoting": "node tests/test-database-query-quoting.js",
package/src/index.js CHANGED
@@ -672,10 +672,10 @@ registerToolConditional(
672
672
  });
673
673
  }
674
674
 
675
- // Use provided cwd, or default_dir from config, or no cwd
675
+ // Use provided cwd, or the server's configured defaultDir, or no cwd
676
676
  const servers = await loadServerConfig();
677
677
  const serverConfig = servers[serverName.toLowerCase()];
678
- const workingDir = cwd || serverConfig?.default_dir;
678
+ const workingDir = cwd || serverConfig?.defaultDir;
679
679
  const platform = serverConfig?.platform || 'linux';
680
680
 
681
681
  // Build cwd-prefixed command using platform-appropriate syntax
@@ -898,7 +898,7 @@ registerToolConditional(
898
898
  const serverConfig = servers[serverName.toLowerCase()];
899
899
 
900
900
  // Check if sshpass is available for password authentication
901
- if (!serverConfig.keypath && serverConfig.password) {
901
+ if (!serverConfig.keyPath && serverConfig.password) {
902
902
  // Check if sshpass is installed
903
903
  try {
904
904
  const { execSync } = await import('child_process');
@@ -980,12 +980,12 @@ registerToolConditional(
980
980
  const sshOptions = [];
981
981
 
982
982
  // Different options based on authentication method
983
- if (serverConfig.keypath) {
983
+ if (serverConfig.keyPath) {
984
984
  sshOptions.push('-o BatchMode=yes'); // No password prompts
985
985
  sshOptions.push('-o StrictHostKeyChecking=accept-new'); // Accept new keys, reject changed ones
986
986
  sshOptions.push('-o ConnectTimeout=10'); // Connection timeout
987
987
 
988
- const keyPath = serverConfig.keypath.replace('~', os.homedir());
988
+ const keyPath = serverConfig.keyPath.replace('~', os.homedir());
989
989
  sshOptions.push(`-i ${keyPath}`);
990
990
  } else {
991
991
  // With sshpass, we don't use BatchMode
@@ -1893,7 +1893,7 @@ registerToolConditional(
1893
1893
  // does not support `cd && `) vs cd && for Linux/macOS.
1894
1894
  const servers = await loadServerConfig();
1895
1895
  const serverConfig = servers[serverName.toLowerCase()];
1896
- const workingDir = cwd || serverConfig?.default_dir;
1896
+ const workingDir = cwd || serverConfig?.defaultDir;
1897
1897
  const platform = serverConfig?.platform || 'linux';
1898
1898
  let fullCommand;
1899
1899
  if (workingDir) {
@@ -2133,7 +2133,7 @@ registerToolConditional(
2133
2133
  user: config.user,
2134
2134
  port: config.port || '22',
2135
2135
  auth: config.password ? 'password' : 'key',
2136
- defaultDir: config.default_dir || '',
2136
+ defaultDir: config.defaultDir || '',
2137
2137
  description: config.description || ''
2138
2138
  }));
2139
2139
 
@@ -2294,9 +2294,9 @@ registerToolConditional(
2294
2294
  // Add password if provided
2295
2295
  if (password) {
2296
2296
  fullCommand = `echo "${password}" | sudo -S ${command.replace(/^sudo /, '')}`;
2297
- } else if (serverConfig?.sudo_password) {
2297
+ } else if (serverConfig?.sudoPassword) {
2298
2298
  // Use configured sudo password if available
2299
- fullCommand = `echo "${serverConfig.sudo_password}" | sudo -S ${command.replace(/^sudo /, '')}`;
2299
+ fullCommand = `echo "${serverConfig.sudoPassword}" | sudo -S ${command.replace(/^sudo /, '')}`;
2300
2300
  }
2301
2301
 
2302
2302
  // Add working directory if specified
@@ -2308,12 +2308,12 @@ registerToolConditional(
2308
2308
  } else {
2309
2309
  fullCommand = `cd ${cwd} && ${fullCommand}`;
2310
2310
  }
2311
- } else if (serverConfig?.default_dir) {
2311
+ } else if (serverConfig?.defaultDir) {
2312
2312
  if (platform === 'windows') {
2313
- const escapedDir = serverConfig.default_dir.replace(/'/g, '\'\'');
2313
+ const escapedDir = serverConfig.defaultDir.replace(/'/g, '\'\'');
2314
2314
  fullCommand = `Set-Location '${escapedDir}'; ${fullCommand}`;
2315
2315
  } else {
2316
- fullCommand = `cd ${serverConfig.default_dir} && ${fullCommand}`;
2316
+ fullCommand = `cd ${serverConfig.defaultDir} && ${fullCommand}`;
2317
2317
  }
2318
2318
  }
2319
2319