mcp-ssh-manager 3.7.0 → 3.8.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/CHANGELOG.md CHANGED
@@ -5,6 +5,38 @@ 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.8.0] - 2026-08-14
9
+
10
+ ### Security
11
+
12
+ - **`@modelcontextprotocol/sdk` floor raised to `^1.30.0`** — the declared range (`^1.17.2`) still allowed versions carrying three published advisories, one of them high: cross-client data leak through shared server/transport instance reuse, DNS rebinding protection off by default, and a ReDoS. It also dragged in vulnerable transitive express packages (`body-parser`, `path-to-regexp`, `qs`, `ajv`). `npm audit --omit=dev` now reports **0 vulnerabilities**. Behaviour verified against the real MCP stdio protocol: identical to 1.17.5 (37 tools registered, same negotiation, clean shutdown).
13
+
14
+ ### Added
15
+
16
+ - **Optional `group` field on server config** ([#56](https://github.com/bvisible/mcp-ssh-manager/pull/56) — contributed by [@ice616](https://github.com/ice616), requested in [#55](https://github.com/bvisible/mcp-ssh-manager/issues/55))
17
+ - A free-form label (`SSH_SERVER_<NAME>_GROUP` in `.env`, `group = "..."` in TOML) carried on the server entry itself, so a server's group membership can be read straight off its config when exporting to — or importing from — another tool, with no second file to ship. It round-trips through `exportToToml`/`exportToEnv` and is returned by `ssh_list_servers`.
18
+ - **The label is not just descriptive: it makes the group usable.** `ssh_execute_group` and `ssh_group_manage list` now resolve members from the `group` field as well, so tagging servers is enough to run a command across them — `.server-groups.json` is no longer required to have a working group.
19
+ - Membership is the **union** of both sources: the explicit list stored by `ssh_group_manage` (which keeps carrying strategy, delay and stop-on-error) plus every server tagged with that name. Group names are case-insensitive. Config-derived members are resolved at read time and never written to `.server-groups.json`, so they cannot go stale.
20
+ - A group that exists only through the config is read-only for `ssh_group_manage`; attempting to edit it now returns an error pointing at the server config instead of a bare "not found".
21
+ - The `ssh-manager` add-server wizard asks for an optional group.
22
+ - Tests: new `tests/test-server-groups.js` (14 checks) covers config-derived groups, the union with stored groups, case-insensitivity, read-only enforcement, persistence isolation, the dynamic-group reload regression and group execution; `tests/test-config-field-names.js` gains `group` coverage across the `.env` loader, the TOML loader, the forbidden-field guard and the export round-trip.
23
+ - **Static type-checking over the existing JavaScript** (`npm run typecheck`) — a `tsconfig.json` in `checkJs`/`noEmit` mode runs TypeScript as a linter over JSDoc annotations. **Nothing is compiled and nothing changes for users**: the package still ships plain JS straight from `src/`, with no build step and no `dist/`. Added as a hard gate in the Code Quality workflow.
24
+ - A `ServerConfig` typedef in `src/config-loader.js` documents the resolved server shape and makes its camelCase contract enforceable: reading `serverConfig.default_dir` — the exact issue #49 regression — is now a type error (*"Property 'default_dir' does not exist on type 'ServerConfig'. Did you mean 'defaultDir'?"*) instead of a silent `undefined`. `tests/test-config-field-names.js` keeps guarding the same contract at runtime.
25
+
26
+ ### Fixed
27
+
28
+ - **A tunnel on an already-used local port crashed the entire MCP server** — `net.Server#listen` never passes an error to its callback (a failed bind is emitted as an `'error'` event), yet `ssh_tunnel_create` used `listen(port, host, (err) => ...)` and registered no `'error'` listener. On `EADDRINUSE` — the everyday tunnel failure — Node rethrew the unhandled event and killed the process, taking every pooled SSH connection and session with it, while the awaited promise never settled. Binding now rejects properly and the tool returns an error. Guarded by `tests/test-tunnel-listen.js`.
29
+ - **`ssh_sync` always passed an explicit `-p 22` to rsync** — the guard read `serverConfig.port !== '22'`, comparing a number against a string, so it never matched. Harmless in effect, but the intent (omit the flag on the default port) never applied. Found by the new typecheck, along with a matching `parseInt(serverConfig.port || '22')` in `ssh_known_hosts` that only worked because `parseInt` stringifies its argument first.
30
+ - **`ssh_sync` treated native Windows local paths as remote rsync specifications** — a path such as `C:\project` was passed unchanged to MSYS2 rsync, which parsed `C:` as a remote host and attempted an SSH connection to `c`. Windows drive-letter, rooted, UNC, and extended-length paths are now resolved and converted only for the spawned rsync argument while Node keeps the native path for local filesystem checks and logging; relative paths keep their existing semantics with normalized separators. Trailing separators retain rsync's directory-content semantics. A path already written in MSYS2 form (`/c/project`, `//server/share`) — the shape Windows users adopted to work around this very bug — is passed through untouched instead of being mounted twice into `/c/c/project`. Guarded by `tests/test-rsync-path.js` (24 checks: conversion table, pass-through, invariants over every input, platform isolation, failure modes, and a static guard on the `ssh_sync` wiring) plus a real MSYS2 rsync dry run.
31
+ - **The MCP server announced itself as version `1.2.0`** — the `serverInfo` version sent to Claude Code / Codex was a hardcoded literal the release process never bumped, so it had drifted far behind the real package version (3.7.0). It is now derived from `package.json`, the same treatment the CLI banner got in 3.7.0. This matters more under the MCP `2026-07-28` spec, where servers identify themselves in the `_meta` of every result.
32
+ - **`exportToEnv` no longer truncates a `group` containing `#`** — the value is now quoted like `DESCRIPTION`, so a label such as `prod #eu west` survives an export/re-import instead of coming back as `prod`.
33
+ - **The dynamic `all` group now sees TOML-defined servers** — it enumerated `process.env` only, so `ssh_execute_group all` silently skipped every server declared in a TOML config. The group layer now reads the configuration actually loaded by `ConfigLoader`.
34
+ - **The `all` group no longer disappears after the first group edit** — dynamic groups are deliberately never persisted, so every `.server-groups.json` written by `ssh_group_manage` lacked `all`, and the next start loaded that file as the complete set: `ssh_execute_group all` then failed with `Group 'all' not found`. Dynamic groups are now re-injected when the file is read.
35
+
36
+ ### Changed
37
+
38
+ - **Dropped the `uuid` dependency** in favour of Node's built-in `crypto.randomUUID()` — available since Node 14.17, and this package already requires Node >= 18. Removes one runtime dependency and the last remaining advisory. Session and tunnel ID formats are unchanged.
39
+
8
40
  ## [3.7.0] - 2026-07-13
9
41
 
10
42
  ### Added
@@ -420,4 +452,4 @@ None. All existing tools remain fully compatible.
420
452
  - Interactive server configuration tool
421
453
  - Connection testing utility
422
454
  - Pre-commit hooks for code quality
423
- - GitHub Actions workflow for CI/CD
455
+ - GitHub Actions workflow for CI/CD
package/CLAUDE.md CHANGED
@@ -70,11 +70,20 @@ See [docs/TOOL_MANAGEMENT.md](docs/TOOL_MANAGEMENT.md) for complete guide.
70
70
  ### Development and Testing
71
71
  ```bash
72
72
  npm start # Start MCP server (requires stdin)
73
+ npm test # Run the full test suite
74
+ npm run typecheck # Type-check JSDoc with tsc (no build, nothing emitted)
75
+ npm run test:all # Tests + typecheck + validation
73
76
  ./scripts/validate.sh # Run all validation checks
74
77
  node --check src/index.js # Check JavaScript syntax
75
78
  python -m py_compile tools/*.py # Check Python syntax
76
79
  ```
77
80
 
81
+ **Typecheck**: `tsconfig.json` runs TypeScript in `checkJs`/`noEmit` mode over the plain JS —
82
+ this project ships JavaScript straight from `src/` with no build step, and that must stay true.
83
+ The baseline is 0 errors and CI enforces it, so add JSDoc annotations (or a narrow
84
+ `/** @type {...} */` cast) rather than leaving new errors. `typescript` is pinned to `^6`
85
+ because knip 5 declares `peer typescript ">=5.0.4 <7"` — bumping one requires bumping the other.
86
+
78
87
  ### Debug Tools (in `debug/` directory)
79
88
  ```bash
80
89
  ./debug/test-claude-code.sh # Test Claude Code integration
@@ -154,6 +163,7 @@ SSH_SERVER_[NAME]_PASSPHRASE=passphrase # Optional, for passphrase-protected
154
163
  SSH_SERVER_[NAME]_PORT=22 # Optional
155
164
  SSH_SERVER_[NAME]_DEFAULT_DIR=/path # Optional default working directory
156
165
  SSH_SERVER_[NAME]_SUDO_PASSWORD=pass # Optional for automated sudo
166
+ SSH_SERVER_[NAME]_GROUP=production # Optional, free-form label for grouping/import-export
157
167
  SSH_SERVER_[NAME]_PLATFORM=windows # Optional: "linux" (default) or "windows"
158
168
  SSH_SERVER_[NAME]_PROXYJUMP=bastion # Optional: name of another server to use as jump host
159
169
  SSH_SERVER_[NAME]_PROXYCOMMAND=command # Optional: custom proxy command (ncat, ssh -W, etc.)
@@ -171,6 +181,7 @@ passphrase = "key_passphrase" # Optional, for passphrase-protected
171
181
  port = 22 # Optional
172
182
  default_dir = "/path" # Optional default working directory
173
183
  sudo_password = "pass" # Optional for automated sudo
184
+ group = "production" # Optional, free-form label for grouping/import-export
174
185
  platform = "windows" # Optional: "linux" (default) or "windows"
175
186
  proxy_jump = "bastion" # Optional: name of another server to use as jump host
176
187
  proxy_command = "command" # Optional: custom proxy command (ncat, ssh -W, etc.)
@@ -191,6 +202,8 @@ forward_agent = true # Optional: forward local ssh-agent t
191
202
 
192
203
  6. **Proxy Command Support**: Custom proxy commands (SOCKS5, ssh -W, etc.) are executed locally to establish connections, with proper error handling and timeout management (src/index.js:389-432)
193
204
 
205
+ 7. **Server Groups**: Membership is the union of two sources — the explicit lists in `.server-groups.json` (created via `ssh_group_manage`, which also hold strategy/delay/stopOnError) and the per-server `group` field of the SSH config. Config-derived groups are resolved at read time, never written to `.server-groups.json`, and are read-only for `ssh_group_manage`. `src/index.js` injects the loaded config into the group layer via `setServerConfigProvider()`; without it the module can only see `.env` servers (src/server-groups.js)
206
+
194
207
  ## Security Considerations
195
208
 
196
209
  - Never commit `.env` files (included in .gitignore)
package/README.md CHANGED
@@ -6,12 +6,14 @@ 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.7.0-brightgreen?style=for-the-badge)](https://github.com/bvisible/mcp-ssh-manager/releases/tag/v3.7.0)
9
+ [![Version](https://img.shields.io/badge/Version-3.8.0-brightgreen?style=for-the-badge)](https://github.com/bvisible/mcp-ssh-manager/releases/tag/v3.8.0)
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)
13
13
  [![License](https://img.shields.io/badge/License-MIT-blue?style=for-the-badge)](LICENSE)
14
14
 
15
+ [![MCP Toplist](https://mcptoplist.com/badge/glama%2Fbvisible%2Fmcp-ssh-manager.svg)](https://mcptoplist.com/server/glama%2Fbvisible%2Fmcp-ssh-manager)
16
+
15
17
  </div>
16
18
 
17
19
  <p align="center">
@@ -20,24 +22,33 @@ A Model Context Protocol (MCP) server that enables **Claude Code** and **OpenAI
20
22
 
21
23
  ---
22
24
 
23
- ## 🎉 What's New in v3.7.0
25
+ ## 🎉 What's New in v3.8.0
24
26
 
25
- **🔗 Per-server SSH agent forwarding (`ForwardAgent`)** (Released: July 13, 2026)
27
+ **👥 Groups that live in your config, `ssh_sync` fixed on Windows, and a crash that took the whole server down** (Released: August 14, 2026)
26
28
 
27
- - **New opt-in `FORWARD_AGENT` / `forward_agent` option** ([#53](https://github.com/bvisible/mcp-ssh-manager/pull/53) — requested by [@raphaelbahat](https://github.com/raphaelbahat) in [#52](https://github.com/bvisible/mcp-ssh-manager/issues/52)) — enable the equivalent of OpenSSH's `ForwardAgent yes` per server, so processes on the remote host can authenticate to *other* SSH hosts using the keys in your **local** `ssh-agent` (e.g. `git clone` over SSH on a remote server using your local GitHub key), without copying any private key to the server.
28
- - **Safe by construction** — requires a running local agent (`SSH_AUTH_SOCK`); the flag is ignored when no agent is present, so it never breaks a connection. Boolean parsing treats only `true`/`1`/`yes`/`on` as enabled — `FORWARD_AGENT=false` stays off.
29
- - **⚠️ Defaults to `false`** — agent forwarding lets anyone with root on the remote host use your loaded keys for the life of the connection, so enable it only for servers you trust. See the new *SSH Agent Forwarding* section in the docs.
29
+ - **New optional `group` field per server** ([#56](https://github.com/bvisible/mcp-ssh-manager/pull/56) — contributed by [@ice616](https://github.com/ice616), requested in [#55](https://github.com/bvisible/mcp-ssh-manager/issues/55)) — tag a server with `group = "production"` and it *is* in that group: `ssh_execute_group` and `ssh_group_manage list` resolve members straight from your `.env`/TOML, so there is no `.server-groups.json` to maintain and the grouping travels with the config when you export it to another tool. Membership is the **union** of both sources, so groups you already store keep working untouched.
30
+ - **🪟 `ssh_sync` works from a Windows host** ([#59](https://github.com/bvisible/mcp-ssh-manager/pull/59) — contributed by [@2836603852](https://github.com/2836603852)) — a local path like `C:\project` reached MSYS2 rsync unchanged, which read `C:` as a remote host and tried to SSH into a machine named `c`. Drive-letter, UNC and extended-length paths are now converted for the rsync argument only, while Node keeps the native path for its filesystem checks.
31
+ - **💥 A tunnel on a busy port no longer kills the MCP server** — `ssh_tunnel_create` on an already-bound port hit an unhandled `'error'` event and took the entire process down with it, dropping every pooled SSH connection and open session. It now returns a normal error.
32
+ - **🔒 Security: `@modelcontextprotocol/sdk` floor raised to `^1.30.0`** — the previous range still allowed versions carrying three published advisories, one of them high. `npm audit` is clean, and the `uuid` dependency is gone in favour of Node's built-in `crypto.randomUUID()`.
33
+ - **🧪 JSDoc type-checking in CI** (`npm run typecheck`) — TypeScript now runs as a static checker over the plain JavaScript. **No build step, no `dist/`, nothing changes for users**; it found two of the bugs above on the day it landed.
30
34
 
31
35
  ```env
32
- SSH_SERVER_MYSERVER_FORWARD_AGENT=true
36
+ SSH_SERVER_WEB1_GROUP=production
33
37
  ```
34
38
 
35
- [Read full changelog →](CHANGELOG.md#370---2026-07-13)
39
+ [Read full changelog →](CHANGELOG.md#380---2026-08-14)
36
40
 
37
41
  ---
38
42
 
39
43
  ## Previous Releases
40
44
 
45
+ <details>
46
+ <summary><b>📜 Release history — v3.7.0 down to v1.0.0</b> (click to expand)</summary>
47
+
48
+ ### v3.7.0 - Per-server SSH agent forwarding (July 13, 2026)
49
+
50
+ - **🔗 New opt-in `FORWARD_AGENT` / `forward_agent` option** ([#53](https://github.com/bvisible/mcp-ssh-manager/pull/53) — requested by [@raphaelbahat](https://github.com/raphaelbahat) in [#52](https://github.com/bvisible/mcp-ssh-manager/issues/52)) — the equivalent of OpenSSH's `ForwardAgent yes`, per server: processes on the remote host authenticate to *other* SSH hosts with the keys in your local `ssh-agent`, without copying any private key. Requires a running agent and defaults to `false`. [Full changelog →](CHANGELOG.md#370---2026-07-13)
51
+
41
52
  ### v3.6.7 - Security: command injection fix in the database helpers (July 11, 2026)
42
53
 
43
54
  - **🔒 Every `ssh_db_*` argument is now shell-quoted** ([#51](https://github.com/bvisible/mcp-ssh-manager/pull/51) — responsibly disclosed by **Ugur Ozer, Aeon AI Risk Management** (http://airiskmanagement.ca), see [#48](https://github.com/bvisible/mcp-ssh-manager/issues/48)) — caller-controlled values (`ssh_db_list` most notably, which stayed allowed in `readonly`/`restricted` modes) were interpolated into shell-evaluated strings, allowing arbitrary command execution on the SSH target. A centralized `shellQuote()` now wraps every value across all 15 builders, guarded by a 648-combination injection test. [Full changelog →](CHANGELOG.md#367---2026-07-11)
@@ -178,6 +189,8 @@ This release adds **12 new MCP tools** transforming SSH Manager into a comprehen
178
189
 
179
190
  [Read Full Changelog →](CHANGELOG.md#300---2025-10-01)
180
191
 
192
+ </details>
193
+
181
194
  ---
182
195
 
183
196
  ## 📑 Table of Contents
@@ -447,6 +460,7 @@ key_path = "~/.ssh/id_rsa" # for SSH key auth (recommended)
447
460
  passphrase = "key_passphrase" # optional, for passphrase-protected keys
448
461
  port = 22
449
462
  default_dir = "/var/www"
463
+ group = "production" # optional, free-form label for grouping/import-export
450
464
  description = "Production server"
451
465
 
452
466
  [ssh_servers.staging]
@@ -676,6 +690,7 @@ SSH_SERVER_[NAME]_PASSPHRASE=key_passphrase # Optional, for passphrase-protecte
676
690
  SSH_SERVER_[NAME]_PORT=22 # Optional, defaults to 22
677
691
  SSH_SERVER_[NAME]_DEFAULT_DIR=/path/to/dir # Optional, default working directory
678
692
  SSH_SERVER_[NAME]_DESCRIPTION=Description # Optional
693
+ SSH_SERVER_[NAME]_GROUP=production # Optional, free-form label for grouping/import-export
679
694
  SSH_SERVER_[NAME]_PLATFORM=windows # Optional: "linux" (default) or "windows"
680
695
  SSH_SERVER_[NAME]_PROXYJUMP=bastion # Optional: name of another server to use as jump host
681
696
  SSH_SERVER_[NAME]_PROXYCOMMAND=command # Optional: custom proxy command (ncat, ssh -W, etc.)
@@ -893,6 +908,41 @@ proxy_command = "C:\\Windows\\System32\\OpenSSH\\ssh.exe -W %h:%p user@jump-host
893
908
 
894
909
  The proxy command must be a valid command that reads from stdin and writes to stdout, accepting `%h` and `%p` placeholders for host and port.
895
910
 
911
+ ### Server Groups
912
+
913
+ Tag a server with `group` and it becomes part of that group — no extra file to maintain. The label is free-form and travels with the server definition, so it survives an export to (or import from) another tool.
914
+
915
+ ```env
916
+ SSH_SERVER_WEB1_HOST=10.0.0.1
917
+ SSH_SERVER_WEB1_USER=deploy
918
+ SSH_SERVER_WEB1_GROUP=production
919
+
920
+ SSH_SERVER_WEB2_HOST=10.0.0.2
921
+ SSH_SERVER_WEB2_USER=deploy
922
+ SSH_SERVER_WEB2_GROUP=production
923
+ ```
924
+
925
+ Or in TOML:
926
+ ```toml
927
+ [ssh_servers.web1]
928
+ host = "10.0.0.1"
929
+ user = "deploy"
930
+ group = "production"
931
+ ```
932
+
933
+ Both servers are then reachable as a group:
934
+
935
+ ```
936
+ Run "uptime" on the production group → ssh_execute_group
937
+ List my server groups → ssh_group_manage (action: list)
938
+ ```
939
+
940
+ `ssh_list_servers` also reports the group of each server, so you can see membership without opening the config.
941
+
942
+ **How it combines with `ssh_group_manage`:** groups you create with `ssh_group_manage` live in `.server-groups.json` and carry execution settings (strategy, delay, stop-on-error). Groups implied by the `group` field carry membership only. When a name exists on both sides, **membership is the union** — the stored list plus every server tagged with that name — and the stored execution settings apply. Group names are case-insensitive.
943
+
944
+ A group that exists only through the `group` field is read-only for `ssh_group_manage`: to change who belongs to it, edit the servers' `group` in your `.env`/TOML. Creating a group of the same name with `ssh_group_manage` is still allowed and simply adds stored members and settings on top.
945
+
896
946
  ### Documentation
897
947
  - [DEPLOYMENT_GUIDE.md](docs/DEPLOYMENT_GUIDE.md) - Deployment strategies and permission handling
898
948
  - [ALIASES_AND_HOOKS.md](docs/ALIASES_AND_HOOKS.md) - Command aliases and automation hooks
@@ -1061,6 +1111,7 @@ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file
1061
1111
  ### SSH Sync (rsync)
1062
1112
  - Password authentication requires `sshpass` to be installed
1063
1113
  - SSH key authentication is recommended for better security and reliability
1114
+ - **Windows MCP hosts**: pass native local paths such as `local:C:\project` or `local:.\project`; `ssh_sync` converts drive-letter and UNC paths to MSYS2 format before launching rsync. Prefer native paths, since Node checks them on disk using Windows path semantics — a path already written as `/c/...` or `//server/share` is passed through to rsync untouched rather than converted twice.
1064
1115
  - Large file transfers may take time and appear to hang - be patient
1065
1116
 
1066
1117
  ### Connection Management
package/cli/install.sh CHANGED
@@ -69,6 +69,12 @@ echo "Copying CLI files to $CLI_HOME..."
69
69
  rm -rf "$CLI_HOME"
70
70
  cp -r "$SCRIPT_DIR" "$CLI_HOME"
71
71
 
72
+ # Bundle package.json next to the CLI so it can report the real build version
73
+ # (the CLI derives its version from package.json instead of a hardcoded string).
74
+ if [ -f "$SCRIPT_DIR/../package.json" ]; then
75
+ cp "$SCRIPT_DIR/../package.json" "$CLI_HOME/package.json"
76
+ fi
77
+
72
78
  # Create executable symlink
73
79
  $SUDO ln -sf "$CLI_HOME/ssh-manager" "$INSTALL_DIR/ssh-manager"
74
80
 
package/cli/lib/menu.sh CHANGED
@@ -177,7 +177,24 @@ wizard_add_server() {
177
177
  echo "Set a default directory for this server (optional)."
178
178
  echo "Example: /var/www/html, /home/user/app, /opt/services"
179
179
  prompt_input "Default directory" "" "default_dir"
180
-
180
+
181
+ local group
182
+ echo
183
+ echo "Assign this server to a group (optional)."
184
+ echo "Servers sharing a group can be targeted together with ssh_execute_group."
185
+ echo "Example: production, staging, customer-acme"
186
+ prompt_input "Group" "" "group"
187
+
188
+ local forward_agent="n"
189
+ echo
190
+ echo "Forward your local ssh-agent to this server (optional)."
191
+ echo "Lets remote processes use your local keys — e.g. git over SSH."
192
+ print_warning "Security: anyone with root on this host can use your loaded keys"
193
+ print_warning "for the life of the connection. Only enable for servers you trust."
194
+ if prompt_yes_no "Enable SSH agent forwarding?" "n"; then
195
+ forward_agent="y"
196
+ fi
197
+
181
198
  # Step 5: Review
182
199
  echo
183
200
  print_subheader "Step 5: Review Configuration"
@@ -198,18 +215,35 @@ wizard_add_server() {
198
215
  if [ -n "$default_dir" ]; then
199
216
  print_table_row "Default Dir:" "$default_dir"
200
217
  fi
201
-
218
+ if [ -n "$group" ]; then
219
+ print_table_row "Group:" "$group"
220
+ fi
221
+ if [ "$forward_agent" = "y" ]; then
222
+ print_table_row "Agent Forwarding:" "enabled"
223
+ fi
224
+
202
225
  echo
203
226
  if prompt_yes_no "Save this configuration?" "y"; then
204
227
  # Save to .env
205
228
  add_server_to_env "$server_name" "$host" "$user" "$auth_type" "$auth_value" "$port" "$description"
206
-
229
+
230
+ local name_upper="$(echo "$server_name" | tr '[:lower:]' '[:upper:]')"
231
+
207
232
  # Add default directory if specified
208
233
  if [ -n "$default_dir" ]; then
209
- local name_upper="$(echo "$server_name" | tr '[:lower:]' '[:upper:]')"
210
234
  echo "SSH_SERVER_${name_upper}_DEFAULT_DIR=$default_dir" >> "$SSH_MANAGER_ENV"
211
235
  fi
212
-
236
+
237
+ # Add group if specified (quoted: free-form text, may contain spaces)
238
+ if [ -n "$group" ]; then
239
+ echo "SSH_SERVER_${name_upper}_GROUP=\"$group\"" >> "$SSH_MANAGER_ENV"
240
+ fi
241
+
242
+ # Enable agent forwarding if opted in
243
+ if [ "$forward_agent" = "y" ]; then
244
+ echo "SSH_SERVER_${name_upper}_FORWARD_AGENT=true" >> "$SSH_MANAGER_ENV"
245
+ fi
246
+
213
247
  echo
214
248
  print_success "Server '$server_name' added successfully!"
215
249
 
package/cli/ssh-manager CHANGED
@@ -21,8 +21,24 @@ source "$SCRIPT_DIR/lib/menu.sh"
21
21
  source "$SCRIPT_DIR/commands/server.sh"
22
22
  source "$SCRIPT_DIR/commands/tools.sh"
23
23
 
24
- # Version
25
- VERSION="3.1.0"
24
+ # Version — derived from package.json so it always reflects the real build,
25
+ # never a hardcoded literal that drifts across releases. Works both in-repo
26
+ # (cli/../package.json) and from an installed copy (package.json bundled next
27
+ # to this script by install.sh). Uses sed only, so no jq dependency.
28
+ get_cli_version() {
29
+ local pkg ver
30
+ for pkg in "$SCRIPT_DIR/../package.json" "$SCRIPT_DIR/package.json"; do
31
+ if [ -f "$pkg" ]; then
32
+ ver="$(sed -n 's/.*"version"[[:space:]]*:[[:space:]]*"\([^"]*\)".*/\1/p' "$pkg" | head -n1)"
33
+ if [ -n "$ver" ]; then
34
+ echo "$ver"
35
+ return
36
+ fi
37
+ fi
38
+ done
39
+ echo "unknown"
40
+ }
41
+ VERSION="$(get_cli_version)"
26
42
 
27
43
  # Show version
28
44
  show_version() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mcp-ssh-manager",
3
- "version": "3.7.0",
3
+ "version": "3.8.0",
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:fieldnames && npm run test:agentforward && npm run test:lifecycle && npm run test:sync && npm run test:dbquoting && npm run test:dbinjection && 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:groups && npm run test:agentforward && npm run test:lifecycle && npm run test:tunnel && npm run test:sync && npm run test:sync-path && npm run test:dbquoting && npm run test:dbinjection && 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",
@@ -22,14 +22,18 @@
22
22
  "test:ping": "node tests/test-ssh-ping.js",
23
23
  "test:config": "node tests/test-server-config-manager.js",
24
24
  "test:fieldnames": "node tests/test-config-field-names.js",
25
+ "test:groups": "node tests/test-server-groups.js",
25
26
  "test:agentforward": "node tests/test-agent-forward.js",
26
27
  "test:lifecycle": "node tests/test-lifecycle.js",
28
+ "test:tunnel": "node tests/test-tunnel-listen.js",
27
29
  "test:sync": "node tests/test-sync-stats.js",
30
+ "test:sync-path": "node tests/test-rsync-path.js",
28
31
  "test:dbquoting": "node tests/test-database-query-quoting.js",
29
32
  "test:dbinjection": "node tests/test-database-injection.js",
30
33
  "test:dbrowcount": "node tests/test-database-row-count.js",
31
- "test:all": "npm test && ./scripts/validate.sh",
34
+ "test:all": "npm test && npm run typecheck && ./scripts/validate.sh",
32
35
  "validate": "./scripts/validate.sh",
36
+ "typecheck": "tsc -p tsconfig.json",
33
37
  "lint": "eslint src/*.js",
34
38
  "format": "prettier --write 'src/**/*.js' 'tests/**/*.js'"
35
39
  },
@@ -84,16 +88,16 @@
84
88
  "homepage": "https://github.com/bvisible/mcp-ssh-manager#readme",
85
89
  "dependencies": {
86
90
  "@iarna/toml": "^2.2.5",
87
- "@modelcontextprotocol/sdk": "^1.17.2",
91
+ "@modelcontextprotocol/sdk": "^1.30.0",
88
92
  "dotenv": "^16.4.5",
89
93
  "ssh2": "^1.17.0",
90
- "uuid": "^11.1.0",
91
94
  "zod": "^3.25.76"
92
95
  },
93
96
  "devDependencies": {
94
97
  "eslint": "^8.56.0",
95
98
  "knip": "^5.0.0",
96
- "prettier": "^3.2.4"
99
+ "prettier": "^3.2.4",
100
+ "typescript": "^6.0.3"
97
101
  },
98
102
  "engines": {
99
103
  "node": ">=18.0.0"
@@ -419,7 +419,7 @@ export function parseBackupsList(output) {
419
419
  }
420
420
 
421
421
  // Sort by created_at descending
422
- return backups.sort((a, b) => new Date(b.created_at) - new Date(a.created_at));
422
+ return backups.sort((a, b) => new Date(b.created_at).getTime() - new Date(a.created_at).getTime());
423
423
  }
424
424
 
425
425
  /**
@@ -6,6 +6,40 @@ import os from 'os';
6
6
  import { logger } from './logger.js';
7
7
  import { VALID_MODES } from './policy.js';
8
8
 
9
+ /**
10
+ * A resolved SSH server configuration, as produced by this loader and consumed
11
+ * by every handler. **Field names are camelCase, always** — the `.env` keys
12
+ * (`SUDO_PASSWORD`) and TOML keys (`sudo_password`) are source syntax and are
13
+ * mapped here; they never survive into a resolved config.
14
+ *
15
+ * This is the contract that broke in issue #49: handlers kept reading the
16
+ * pre-v3.0.0 snake_case names, which silently evaluated to `undefined`. Anything
17
+ * typed as a `ServerConfig` now makes that a type error rather than a runtime
18
+ * no-op. `tests/test-config-field-names.js` guards the same contract at runtime.
19
+ *
20
+ * @typedef {Object} ServerConfig
21
+ * @property {string} name Normalized (lowercased) server name.
22
+ * @property {string} host Hostname or IP address.
23
+ * @property {string} [user] SSH user.
24
+ * @property {string} [password] Password for password authentication.
25
+ * @property {string} [keyPath] Path to the private key (`KEYPATH` / `key_path`).
26
+ * @property {string} [passphrase] Passphrase for a protected private key.
27
+ * @property {number} [port] TCP port; defaults to 22.
28
+ * @property {string} [defaultDir] Working directory used when a tool omits `cwd`.
29
+ * @property {string} [sudoPassword] Password piped to `sudo -S`.
30
+ * @property {string} [description] Free-form description.
31
+ * @property {string} [group] Free-form group label; also feeds server groups.
32
+ * @property {string} [platform] `'linux'` (default) or `'windows'`.
33
+ * @property {string} [proxyJump] Name of another configured server to jump through.
34
+ * @property {string} [proxyCommand] Custom proxy command (`%h` / `%p` placeholders).
35
+ * @property {boolean} [forwardAgent] Forward the local ssh-agent to this server.
36
+ * @property {string} [mode] Security mode: `unrestricted`, `readonly` or `restricted`.
37
+ * @property {string[]} [allowPatterns] Regex sources allowed in `restricted` mode.
38
+ * @property {string[]} [denyPatterns] Regex sources always refused.
39
+ * @property {string} [auditLog] Path to a per-server audit log.
40
+ * @property {'env'|'toml'} [source] Which configuration source won for this server.
41
+ */
42
+
9
43
  // Parse a `;`-separated list of regex pattern strings. Empty entries are dropped.
10
44
  // We do NOT compile here — that happens lazily in policy.js so config-loader stays
11
45
  // free of regex error handling.
@@ -44,7 +78,9 @@ function parseBool(raw) {
44
78
 
45
79
  export class ConfigLoader {
46
80
  constructor() {
81
+ /** @type {Map<string, ServerConfig>} */
47
82
  this.servers = new Map();
83
+ /** @type {string|null} */
48
84
  this.configSource = null;
49
85
  }
50
86
 
@@ -53,6 +89,8 @@ export class ConfigLoader {
53
89
  * 1. Environment variables (highest priority)
54
90
  * 2. .env file
55
91
  * 3. TOML config file (lowest priority)
92
+ *
93
+ * @returns {Promise<Map<string, ServerConfig>>}
56
94
  */
57
95
  async load(options = {}) {
58
96
  const {
@@ -145,6 +183,7 @@ export class ConfigLoader {
145
183
  defaultDir: serverConfig.default_dir || serverConfig.default_directory || serverConfig.cwd,
146
184
  sudoPassword: serverConfig.sudo_password,
147
185
  description: serverConfig.description,
186
+ group: serverConfig.group,
148
187
  platform: serverConfig.platform ? serverConfig.platform.toLowerCase() : undefined,
149
188
  proxyJump: serverConfig.proxy_jump,
150
189
  proxyCommand: serverConfig.proxy_command || serverConfig.proxycommand,
@@ -205,6 +244,7 @@ export class ConfigLoader {
205
244
  );
206
245
  }
207
246
 
247
+ /** @type {ServerConfig} */
208
248
  const server = {
209
249
  name: serverName,
210
250
  host: value,
@@ -216,6 +256,7 @@ export class ConfigLoader {
216
256
  defaultDir: env[`SSH_SERVER_${match[1]}_DEFAULT_DIR`],
217
257
  sudoPassword: env[`SSH_SERVER_${match[1]}_SUDO_PASSWORD`],
218
258
  description: env[`SSH_SERVER_${match[1]}_DESCRIPTION`],
259
+ group: env[`SSH_SERVER_${match[1]}_GROUP`],
219
260
  platform: (env[`SSH_SERVER_${match[1]}_PLATFORM`] || '').toLowerCase() || undefined,
220
261
  proxyJump: env[`SSH_SERVER_${match[1]}_PROXYJUMP`],
221
262
  proxyCommand: env[`SSH_SERVER_${match[1]}_PROXYCOMMAND`],
@@ -235,6 +276,9 @@ export class ConfigLoader {
235
276
 
236
277
  /**
237
278
  * Get server configuration by name
279
+ *
280
+ * @param {string} name
281
+ * @returns {ServerConfig|undefined}
238
282
  */
239
283
  getServer(name) {
240
284
  return this.servers.get(name.toLowerCase());
@@ -242,6 +286,8 @@ export class ConfigLoader {
242
286
 
243
287
  /**
244
288
  * Get all server configurations
289
+ *
290
+ * @returns {ServerConfig[]}
245
291
  */
246
292
  getAllServers() {
247
293
  return Array.from(this.servers.values());
@@ -275,6 +321,7 @@ export class ConfigLoader {
275
321
  if (server.defaultDir) serverConfig.default_dir = server.defaultDir;
276
322
  if (server.sudoPassword) serverConfig.sudo_password = server.sudoPassword;
277
323
  if (server.description) serverConfig.description = server.description;
324
+ if (server.group) serverConfig.group = server.group;
278
325
  if (server.platform) serverConfig.platform = server.platform;
279
326
  if (server.proxyJump) serverConfig.proxy_jump = server.proxyJump;
280
327
  if (server.proxyCommand) serverConfig.proxy_command = server.proxyCommand;
@@ -317,6 +364,9 @@ export class ConfigLoader {
317
364
  if (server.defaultDir) lines.push(`SSH_SERVER_${upperName}_DEFAULT_DIR=${server.defaultDir}`);
318
365
  if (server.sudoPassword) lines.push(`SSH_SERVER_${upperName}_SUDO_PASSWORD="${server.sudoPassword}"`);
319
366
  if (server.description) lines.push(`SSH_SERVER_${upperName}_DESCRIPTION="${server.description}"`);
367
+ // Quoted like DESCRIPTION: free-form text, so an unquoted value would be
368
+ // truncated at the first ` #` when the generated file is read back.
369
+ if (server.group) lines.push(`SSH_SERVER_${upperName}_GROUP="${server.group}"`);
320
370
  if (server.platform) lines.push(`SSH_SERVER_${upperName}_PLATFORM=${server.platform}`);
321
371
  if (server.proxyJump) lines.push(`SSH_SERVER_${upperName}_PROXYJUMP=${server.proxyJump}`);
322
372
  if (server.proxyCommand) lines.push(`SSH_SERVER_${upperName}_PROXYCOMMAND=${server.proxyCommand}`);
@@ -342,6 +392,7 @@ export class ConfigLoader {
342
392
  * Save configuration to Codex TOML format
343
393
  */
344
394
  async saveToCodexConfig(codexConfigPath = path.join(os.homedir(), '.codex', 'config.toml')) {
395
+ /** @type {Record<string, any>} */
345
396
  let config = {};
346
397
 
347
398
  // Load existing config if it exists
@@ -378,10 +378,11 @@ export function buildMongoDBListCollectionsCommand(options) {
378
378
  * so the pipeline is passed via `options.pipeline` and emitted as `<<'DELIM' | awk ...`.
379
379
  *
380
380
  * @param body Text fed to the command's stdin (e.g. a SQL statement). Passed verbatim.
381
- * @param options.delimiter Heredoc terminator. Must not appear as a standalone line in
382
- * `body`, otherwise the heredoc would end early; this is rejected defensively.
383
- * @param options.pipeline Shell pipeline appended after the heredoc marker on the
384
- * opening line (e.g. `"| awk '...'"`). Omit for a plain stdin redirect.
381
+ * @param {object} [options]
382
+ * @param {string} [options.delimiter] Heredoc terminator. Must not appear as a standalone
383
+ * line in `body`, otherwise the heredoc would end early; this is rejected defensively.
384
+ * @param {string} [options.pipeline] Shell pipeline appended after the heredoc marker on
385
+ * the opening line (e.g. `"| awk '...'"`). Omit for a plain stdin redirect.
385
386
  * @returns The redirection fragment to append after a command, ending with the
386
387
  * terminator on its own line.
387
388
  * @throws {Error} If a line of `body` equals `delimiter`.