mcp-ssh-manager 3.6.0 → 3.6.2

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,24 @@ 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.2] - 2026-06-09
9
+
10
+ ### Changed
11
+
12
+ - **All 37 tool descriptions rewritten for clarity and agent reliability.** Every MCP tool now documents its real behavior — side effects, destructive vs read-only nature, idempotency, sudo/auth requirements, security-mode gating, and parameter semantics (mutually-exclusive params, defaults, edge cases) — instead of a 4-to-10-word summary. Average description length went from ~6 words to ~70, with no weak outliers (shortest is now 55 words).
13
+ - Improves real tool-calling: agents now know the consequences before invoking a tool — e.g. that `ssh_db_import` and `ssh_backup_restore` are destructive (DROP/overwrite), that `ssh_db_query` is strictly SELECT-only, that `ssh_upload`/`ssh_sync`/`ssh_deploy` are blocked on `readonly` servers, and which parameters are mutually exclusive.
14
+ - Also raises the Glama "Tool Definition Quality" score (previously C — average 3.1/5, lowest 2.1/5).
15
+ - **No behavioral change**: only `description` strings were edited; all logic, parameters, and tool names are unchanged. All test suites pass unmodified.
16
+
17
+ ## [3.6.1] - 2026-06-09
18
+
19
+ ### Fixed
20
+
21
+ - **Module-level monitor/cleanup intervals pinned the Node event loop** (follow-up to [#41](https://github.com/bvisible/mcp-ssh-manager/pull/41))
22
+ - `tunnel-manager.js` (`monitorTunnels`, every 30 s) and `session-manager.js` (inactive-session cleanup, every 5 min) registered module-level `setInterval` timers that were never `unref()`'d, so importing either module kept the event loop alive on its own.
23
+ - Both are now `unref()`'d, matching the keepalive and cleanup timers fixed in #41. The forced-exit added in #41 already made these harmless for the orphan-process bug; this restores proper teardown hygiene so process lifetime tracks the stdio transport, not a background timer.
24
+ - Verified: before, importing either module never exits on its own; after, both exit naturally. Full `npm test` (including `test:lifecycle`) stays green.
25
+
8
26
  ## [3.6.0] - 2026-06-09
9
27
 
10
28
  ### Added
package/README.md CHANGED
@@ -20,21 +20,29 @@ 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.0
23
+ ## 🎉 What's New in v3.6.2
24
24
 
25
- **Live config hot reload + stdio lifecycle fix (no more orphaned processes)** (Released: June 9, 2026)
25
+ **Richer tool descriptions — better AI tool-calling** (Released: June 9, 2026)
26
26
 
27
- - **♻️ Configuration hot reload** ([#40](https://github.com/bvisible/mcp-ssh-manager/pull/40) — thanks [@EnjoySR](https://github.com/EnjoySR))
28
- - Add or edit a server in your `.env`/TOML and the running MCP server picks it up on the next call — `ssh_list_servers` sees it **without a restart**. A new `ServerConfigManager` reloads **lazily** when a file's signature (path + `mtime` + size) changes; if a reload fails (malformed mid-edit), the last known-good config is kept. Real `process.env` vars keep top priority. No watcher, no polling.
29
- - **🔌 No more orphaned stdio processes** ([#41](https://github.com/bvisible/mcp-ssh-manager/pull/41) — thanks [@LegendaryGatz](https://github.com/LegendaryGatz))
30
- - A stdio MCP server is torn down by stdin EOF / SIGTERM, not SIGINT. With only a `SIGINT` handler, every session leaked a ~83 MB node process (reparented to init). Shutdown is now idempotent across `SIGINT`/`SIGTERM`/`SIGHUP`/stdin-close, keepalive & cleanup timers are `unref()`'d, and the process exits cleanly **~10 ms** after teardown instead of never.
27
+ - **📝 All 37 tool descriptions rewritten** — every MCP tool now states its real behavior: side effects, destructive vs read-only nature, idempotency, sudo/auth needs, security-mode gating, and parameter semantics (mutually-exclusive params, defaults, edge cases). Average description length went from ~6 words to ~70, with no weak outliers.
28
+ - Agents now know the consequences **before** calling a tool — e.g. `ssh_db_import` and `ssh_backup_restore` are destructive, `ssh_db_query` is SELECT-only, and `ssh_upload`/`ssh_deploy` are blocked on `readonly` servers.
29
+ - **No behavioral change** — only `description` strings changed; logic, parameters, and tool names are identical. All tests pass unmodified.
31
30
 
32
- [Read full changelog →](CHANGELOG.md#360---2026-06-09)
31
+ [Read full changelog →](CHANGELOG.md#362---2026-06-09)
33
32
 
34
33
  ---
35
34
 
36
35
  ## Previous Releases
37
36
 
37
+ ### v3.6.1 - Teardown hygiene follow-up (June 9, 2026)
38
+
39
+ - **🔌 Module-level timers no longer pin the event loop** (follow-up to [#41](https://github.com/bvisible/mcp-ssh-manager/pull/41)) — `tunnel-manager.js` and `session-manager.js` registered module-level `setInterval`s that were never `unref()`'d, so importing either module kept Node's event loop alive. Both are now `unref()`'d. [Full changelog →](CHANGELOG.md#361---2026-06-09)
40
+
41
+ ### v3.6.0 - Live config hot reload + stdio lifecycle fix (June 9, 2026)
42
+
43
+ - **♻️ Configuration hot reload** ([#40](https://github.com/bvisible/mcp-ssh-manager/pull/40) — thanks [@EnjoySR](https://github.com/EnjoySR)) — add or edit a server in your `.env`/TOML and the running MCP server picks it up on the next call, no restart. A `ServerConfigManager` reloads lazily on file-signature change (path + `mtime` + size); a failed reload keeps the last known-good config; real `process.env` vars keep top priority. No watcher, no polling.
44
+ - **🔌 No more orphaned stdio processes** ([#41](https://github.com/bvisible/mcp-ssh-manager/pull/41) — thanks [@LegendaryGatz](https://github.com/LegendaryGatz)) — a stdio MCP server is torn down by stdin EOF / SIGTERM, not SIGINT; with only a `SIGINT` handler every session leaked a ~83 MB node process. Shutdown is now idempotent across `SIGINT`/`SIGTERM`/`SIGHUP`/stdin-close, timers are `unref()`'d, and the process exits **~10 ms** after teardown instead of never. [Full changelog →](CHANGELOG.md#360---2026-06-09)
45
+
38
46
  ### v3.5.1 - Robust SSH ping health-check on Windows/OpenSSH (May 26, 2026)
39
47
 
40
48
  - **🪟 Healthy Windows sessions no longer reported as `Dead`** ([#39](https://github.com/bvisible/mcp-ssh-manager/pull/39) — thanks [@username77](https://github.com/username77)) — the liveness probe ran `echo "ping"` and `cmd.exe` echoed the quotes literally, failing a strict `=== 'ping'` check and needlessly rebuilding live connections. Now uses `echo ping` parsed by a null-safe `isPingAlive(stdout)` helper (CRLF/quote/case-normalized), covered by `tests/test-ssh-ping.js`. [Full changelog →](CHANGELOG.md#351---2026-05-26)
@@ -1030,10 +1038,4 @@ Made with ❤️ for the Claude Code community
1030
1038
  <img width="380" height="200" src="https://glama.ai/mcp/servers/@bvisible/mcp-ssh-manager/badge" alt="SSH Manager MCP server" />
1031
1039
  </a>
1032
1040
 
1033
- <br/>
1034
-
1035
- <a href="https://mseep.ai/app/bvisible-mcp-ssh-manager">
1036
- <img src="https://mseep.net/pr/bvisible-mcp-ssh-manager-badge.png" alt="MseeP.ai Security Assessment Badge" />
1037
- </a>
1038
-
1039
1041
  </div>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mcp-ssh-manager",
3
- "version": "3.6.0",
3
+ "version": "3.6.2",
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": {
package/src/index.js CHANGED
@@ -662,7 +662,7 @@ function registerToolConditional(toolName, schema, handler) {
662
662
  registerToolConditional(
663
663
  'ssh_execute',
664
664
  {
665
- description: 'Execute command on remote SSH server',
665
+ description: 'Runs a shell command over SSH on a named configured server and returns stdout, stderr, and exit code. Mutates remote state depending on the command; not read-only. Expands command aliases before running. Uses the cwd parameter or, if omitted, the server configured default directory; adapts syntax for Linux versus Windows PowerShell targets. Timeout defaults to 120000 ms and is capped at 300000 ms. Under readonly mode destructive commands like rm or dd are refused; under restricted mode the command must match allow patterns. Output is truncated when very large.',
666
666
  inputSchema: {
667
667
  server: z.string().describe('Server name from configuration'),
668
668
  command: z.string().describe('Command to execute'),
@@ -784,7 +784,7 @@ registerToolConditional(
784
784
  registerToolConditional(
785
785
  'ssh_upload',
786
786
  {
787
- description: 'Upload file to remote SSH server',
787
+ description: 'Uploads one local file to a remote destination path over SFTP on the named server, overwriting any existing remote file at that path. Mutates remote state and is not idempotent beyond replacing the target. Creates no backup. Requires the local file to exist. Does not use sudo, so the remote path must be writable by the configured SSH user. This tool is blocked entirely on servers set to readonly or restricted security mode. For directory trees use ssh_sync instead.',
788
788
  inputSchema: {
789
789
  server: z.string().describe('Server name'),
790
790
  localPath: z.string().describe('Local file path'),
@@ -844,7 +844,7 @@ registerToolConditional(
844
844
  registerToolConditional(
845
845
  'ssh_download',
846
846
  {
847
- description: 'Download file from remote SSH server',
847
+ description: 'Downloads one remote file from the named server to a local destination path over SFTP, overwriting any existing local file at that path. Affects only the local filesystem and is read-only on the remote side, so it stays allowed even on servers in readonly or restricted security mode. Reads the remote file using the configured SSH user, which must have permission to read it. Handles single files only; use ssh_sync for directories.',
848
848
  inputSchema: {
849
849
  server: z.string().describe('Server name'),
850
850
  remotePath: z.string().describe('Remote file path'),
@@ -895,7 +895,7 @@ registerToolConditional(
895
895
  registerToolConditional(
896
896
  'ssh_sync',
897
897
  {
898
- description: 'Synchronize files/folders between local and remote via rsync',
898
+ description: 'Synchronizes files or directories between local and remote using rsync over SSH on the named server. Each of source and destination must carry a local: or remote: prefix and one side must be local and the other remote; with no prefix it assumes a push from local to remote. Mutates the destination. Setting delete true removes destination files absent from source, which is destructive; dryRun true previews without changing anything. Compression is on by default. Password authentication requires sshpass installed locally. Blocked on readonly or restricted servers. Timeout defaults to 30000 ms.',
899
899
  inputSchema: {
900
900
  server: z.string().describe('Server name from configuration'),
901
901
  source: z.string().describe('Source path (use "local:" or "remote:" prefix)'),
@@ -1241,7 +1241,7 @@ registerToolConditional(
1241
1241
  registerToolConditional(
1242
1242
  'ssh_tail',
1243
1243
  {
1244
- description: 'Tail remote log files in real-time',
1244
+ description: 'Reads the tail of a remote log file on the named server, optionally filtered by a grep pattern. Read-only; it does not modify remote state. Behavior depends on follow, which defaults to true: in follow mode it starts a streaming tail whose output is written to the server process stderr rather than returned, and the response only reports a session note, so to capture content directly set follow to false to get the last N lines back. The lines parameter defaults to 10.',
1245
1245
  inputSchema: {
1246
1246
  server: z.string().describe('Server name from configuration'),
1247
1247
  file: z.string().describe('Path to the log file to tail'),
@@ -1342,7 +1342,7 @@ registerToolConditional(
1342
1342
  registerToolConditional(
1343
1343
  'ssh_monitor',
1344
1344
  {
1345
- description: 'Monitor system resources (CPU, RAM, disk) on remote server',
1345
+ description: 'Collects a read-only snapshot of system resources on the named Linux server by running inspection commands such as top, free, df, ss, and ps. The type parameter selects the view and defaults to overview; other values are cpu, memory, disk, network, and process. Does not change remote state and needs no sudo. The interval and duration parameters are accepted for continuous monitoring intent but a single snapshot is gathered. Targets Linux tooling, so output may be empty on Windows hosts.',
1346
1346
  inputSchema: {
1347
1347
  server: z.string().describe('Server name from configuration'),
1348
1348
  type: z.enum(['overview', 'cpu', 'memory', 'disk', 'network', 'process']).optional().describe('Type of monitoring (default: overview)'),
@@ -1515,7 +1515,7 @@ registerToolConditional(
1515
1515
  registerToolConditional(
1516
1516
  'ssh_history',
1517
1517
  {
1518
- description: 'View SSH command history',
1518
+ description: 'Returns the in-memory log of SSH commands previously run through this server process during the current session, formatted with timestamps, server, duration, and success status. Purely local and read-only: it opens no SSH connection and does not persist across restarts. Optional filters narrow the results by server name, by success or failure, and by a search substring in the command text; limit defaults to 20 most recent entries. Does not expose command output, only the commands and their outcomes.',
1519
1519
  inputSchema: {
1520
1520
  limit: z.number().optional().describe('Number of commands to show (default: 20)'),
1521
1521
  server: z.string().optional().describe('Filter by server name'),
@@ -1619,7 +1619,7 @@ registerToolConditional(
1619
1619
  registerToolConditional(
1620
1620
  'ssh_session_start',
1621
1621
  {
1622
- description: 'Start a persistent SSH session that maintains state and context',
1622
+ description: 'Opens a new persistent interactive shell on the named configured server and returns a generated session ID. Stateful and side-effecting: it establishes (or reuses pooled) SSH connection and keeps an open shell that preserves working directory, environment, and command history across later ssh_session_send calls, unlike one-shot ssh_execute. The optional name is only a human label. The session stays open and consumes a remote shell until ssh_session_close is called.',
1623
1623
  inputSchema: {
1624
1624
  server: z.string().describe('Server name from configuration'),
1625
1625
  name: z.string().optional().describe('Optional session name for identification')
@@ -1667,7 +1667,7 @@ registerToolConditional(
1667
1667
  registerToolConditional(
1668
1668
  'ssh_session_send',
1669
1669
  {
1670
- description: 'Send a command to an existing SSH session',
1670
+ description: 'Runs one command inside an already-open session identified by its session ID, reusing the persisted working directory, environment, and history of that shell. Mutates remote state like any shell command and is not idempotent; cd and export update the saved context for subsequent calls. Commands run through a bash-style shell (Unix-oriented). The security policy of the underlying server is enforced, so readonly or restricted servers may refuse. Default timeout is 30000 ms.',
1671
1671
  inputSchema: {
1672
1672
  session: z.string().describe('Session ID from ssh_session_start'),
1673
1673
  command: z.string().describe('Command to execute in the session'),
@@ -1741,7 +1741,7 @@ registerToolConditional(
1741
1741
  registerToolConditional(
1742
1742
  'ssh_session_list',
1743
1743
  {
1744
- description: 'List all active SSH sessions',
1744
+ description: 'Lists currently active SSH sessions with their ID, server, state, working directory, command count, age, idle time, and any defined variables. Read-only: it inspects in-memory session state and changes nothing on remote hosts or local config. The optional server argument is a case-insensitive substring filter on server name; omit it to list every active session. Closed sessions are excluded from the results.',
1745
1745
  inputSchema: {
1746
1746
  server: z.string().optional().describe('Filter by server name')
1747
1747
  }
@@ -1819,7 +1819,7 @@ registerToolConditional(
1819
1819
  registerToolConditional(
1820
1820
  'ssh_session_close',
1821
1821
  {
1822
- description: 'Close an SSH session',
1822
+ description: 'Terminates an open SSH session given its session ID, writing exit to the remote shell, ending it, and discarding its in-memory history and context; the session ID becomes unusable afterward. Destructive to session state but does not delete remote files. Passing the literal value all closes every active session at once, ignoring individual close errors. It does not drop the pooled underlying connection, only the interactive shell.',
1823
1823
  inputSchema: {
1824
1824
  session: z.string().describe('Session ID to close (or "all" to close all sessions)')
1825
1825
  }
@@ -1896,7 +1896,7 @@ function formatDuration(seconds) {
1896
1896
  registerToolConditional(
1897
1897
  'ssh_execute_group',
1898
1898
  {
1899
- description: 'Execute command on a group of servers',
1899
+ description: 'Runs one command on every server belonging to the named group and returns a per-server success or failure report. Mutates remote state on each member and is not idempotent. Best-effort: the security policy of each server is evaluated independently, so readonly or restricted members are reported as failed without aborting the rest unless stopOnError is set. Strategy may be parallel, sequential, or rolling (delay applies between servers). Per-server timeout is 30000 ms; cwd defaults to the default_dir of each server.',
1900
1900
  inputSchema: {
1901
1901
  group: z.string().describe('Group name (e.g., "production", "staging", "all")'),
1902
1902
  command: z.string().describe('Command to execute'),
@@ -2023,7 +2023,7 @@ registerToolConditional(
2023
2023
  registerToolConditional(
2024
2024
  'ssh_group_manage',
2025
2025
  {
2026
- description: 'Manage server groups (create, update, delete, list)',
2026
+ description: 'Creates, updates, deletes, and inspects named server groups used by ssh_execute_group, persisting changes to local configuration only with no remote side effects. The action selects the operation: create, update, delete, add-servers, remove-servers, or list. Every action except list requires name; add-servers and remove-servers also require a non-empty servers array. list is read-only. Optional strategy, delay, and stopOnError set default group execution behavior.',
2027
2027
  inputSchema: {
2028
2028
  action: z.enum(['create', 'update', 'delete', 'list', 'add-servers', 'remove-servers']).describe('Action to perform'),
2029
2029
  name: z.string().optional().describe('Group name'),
@@ -2157,7 +2157,7 @@ registerToolConditional(
2157
2157
  registerToolConditional(
2158
2158
  'ssh_list_servers',
2159
2159
  {
2160
- description: 'List all configured SSH servers',
2160
+ description: 'Lists all SSH servers defined in the loaded configuration, returning for each the name, host, user, port, authentication type (password or key), default directory, and description. Read-only and local: it reads configuration only and opens no SSH connections. Deliberately omits secrets, so no passwords, key paths, passphrases, or sudo passwords are returned. Takes no parameters. Useful as a first call to discover which server names other tools accept.',
2161
2161
  inputSchema: {}
2162
2162
  },
2163
2163
  async () => {
@@ -2187,7 +2187,7 @@ registerToolConditional(
2187
2187
  registerToolConditional(
2188
2188
  'ssh_deploy',
2189
2189
  {
2190
- description: 'Deploy files to remote server with automatic permission handling',
2190
+ description: 'Deploys a list of local files to remote paths on the named server, uploading each to a temporary location first and then moving it into place. Mutates remote state. By default it backs up any existing target file before overwriting; backup can be disabled per call. Options can set owner and permissions, supply a sudo password, and name a single service to restart afterward. Detects sensible owner and permission defaults from the remote path. Runs pre and post deploy hooks. Blocked entirely on servers in readonly or restricted security mode.',
2191
2191
  inputSchema: {
2192
2192
  server: z.string().describe('Server name or alias'),
2193
2193
  files: z.array(z.object({
@@ -2296,7 +2296,7 @@ registerToolConditional(
2296
2296
  registerToolConditional(
2297
2297
  'ssh_execute_sudo',
2298
2298
  {
2299
- description: 'Execute command with sudo on remote server',
2299
+ description: 'Runs a command with elevated privileges via sudo on the named server and returns the exit code and output. Prepends sudo when absent. If a password is given, or a sudo password is configured for the server, it is piped to sudo -S and masked in the returned output. Mutates remote state and can be destructive. Honors the cwd parameter or the server default directory and adapts to Linux or Windows. Timeout defaults to 30000 ms. Blocked entirely in readonly mode; in restricted mode the command must satisfy the allow and deny patterns.',
2300
2300
  inputSchema: {
2301
2301
  server: z.string().describe('Server name or alias'),
2302
2302
  command: z.string().describe('Command to execute with sudo'),
@@ -2382,7 +2382,7 @@ registerToolConditional(
2382
2382
  registerToolConditional(
2383
2383
  'ssh_command_alias',
2384
2384
  {
2385
- description: 'Manage command aliases for frequently used commands',
2385
+ description: 'Manages local shorthand aliases that map a short name to a full command string, stored in local config with no remote execution or side effects. The action selects behavior: add (requires both alias and command), remove (requires alias), list to show all aliases tagged as profile or custom, or suggest to return existing aliases matching a search term passed in the command field. Adding an existing alias overwrites it.',
2386
2386
  inputSchema: {
2387
2387
  action: z.enum(['add', 'remove', 'list', 'suggest']).describe('Action to perform'),
2388
2388
  alias: z.string().optional().describe('Alias name (for add/remove)'),
@@ -2483,7 +2483,7 @@ registerToolConditional(
2483
2483
  registerToolConditional(
2484
2484
  'ssh_hooks',
2485
2485
  {
2486
- description: 'Manage automation hooks for SSH operations',
2486
+ description: 'Manages automation hooks that fire around SSH operations such as pre-deploy, toggling them on or off in local configuration only with no immediate remote action. The action selects behavior: list shows each hook with its enabled state, description, and action count; enable and disable flip a hook and both require the hook name; status summarizes which hooks are currently enabled versus disabled. Toggling persists and affects later operations.',
2487
2487
  inputSchema: {
2488
2488
  action: z.enum(['list', 'enable', 'disable', 'status']).describe('Action to perform'),
2489
2489
  hook: z.string().optional().describe('Hook name (for enable/disable)')
@@ -2575,7 +2575,7 @@ registerToolConditional(
2575
2575
  registerToolConditional(
2576
2576
  'ssh_profile',
2577
2577
  {
2578
- description: 'Manage SSH Manager profiles for different project types',
2578
+ description: 'Manages SSH Manager profiles that bundle command aliases and hooks for different project types, affecting local configuration only with no remote side effects. The action selects behavior: list shows available profiles and the active one, current shows the active profile details, and switch activates a named profile and requires the profile argument. A successful switch reports that Claude Code must be restarted before the new profile takes effect.',
2579
2579
  inputSchema: {
2580
2580
  action: z.enum(['list', 'switch', 'current']).describe('Action to perform'),
2581
2581
  profile: z.string().optional().describe('Profile name (for switch)')
@@ -2655,7 +2655,7 @@ registerToolConditional(
2655
2655
  registerToolConditional(
2656
2656
  'ssh_connection_status',
2657
2657
  {
2658
- description: 'Check status of SSH connections and manage connection pool',
2658
+ description: 'Inspects and manages the pooled SSH connections held by this server process; affects only local in-memory connections, never remote state. The action parameter selects: status lists active connections with age and keepalive (read-only); reconnect closes then reopens one connection; disconnect closes one connection; cleanup drops aged-out and dead connections. The server parameter is required for reconnect and disconnect and ignored otherwise.',
2659
2659
  inputSchema: {
2660
2660
  action: z.enum(['status', 'reconnect', 'disconnect', 'cleanup']).describe('Action to perform'),
2661
2661
  server: z.string().optional().describe('Server name (for reconnect/disconnect)')
@@ -2772,7 +2772,7 @@ registerToolConditional(
2772
2772
  registerToolConditional(
2773
2773
  'ssh_tunnel_create',
2774
2774
  {
2775
- description: 'Create SSH tunnel (port forwarding or SOCKS proxy)',
2775
+ description: 'Opens a new SSH connection to the named server and starts a port-forwarding or SOCKS proxy tunnel that keeps running until closed. The type parameter selects local forward, remote forward, or dynamic SOCKS5 proxy. localPort is always required; remoteHost and remotePort are required for local and remote types but ignored for dynamic. localHost defaults to 127.0.0.1. Returns a tunnel ID used later to close it.',
2776
2776
  inputSchema: {
2777
2777
  server: z.string().describe('Server name or alias'),
2778
2778
  type: z.enum(['local', 'remote', 'dynamic']).describe('Tunnel type'),
@@ -2855,7 +2855,7 @@ registerToolConditional(
2855
2855
  registerToolConditional(
2856
2856
  'ssh_tunnel_list',
2857
2857
  {
2858
- description: 'List active SSH tunnels',
2858
+ description: 'Lists currently active SSH tunnels tracked by this process, showing each tunnel ID, server, type, state, local and remote endpoints, active and total connection counts, bytes transferred, error count, and timestamps. Read-only: it does not create, modify, or close anything. The optional server parameter filters results to one server; omit it to list every active tunnel across all servers.',
2859
2859
  inputSchema: {
2860
2860
  server: z.string().optional().describe('Filter by server name')
2861
2861
  }
@@ -2937,7 +2937,7 @@ registerToolConditional(
2937
2937
  registerToolConditional(
2938
2938
  'ssh_tunnel_close',
2939
2939
  {
2940
- description: 'Close an SSH tunnel',
2940
+ description: 'Tears down active SSH tunnels created earlier, freeing the bound local ports; this affects only local tunnel state, not the remote host. Exactly one of tunnelId or server must be supplied: tunnelId closes that single tunnel, while server closes every tunnel for the named server and reports how many were closed. Supplying neither raises an error. Closing is final and cannot be undone.',
2941
2941
  inputSchema: {
2942
2942
  tunnelId: z.string().optional().describe('Tunnel ID to close'),
2943
2943
  server: z.string().optional().describe('Close all tunnels for this server')
@@ -3001,7 +3001,7 @@ registerToolConditional(
3001
3001
  registerToolConditional(
3002
3002
  'ssh_key_manage',
3003
3003
  {
3004
- description: 'Manage SSH host keys for security verification',
3004
+ description: 'Manages SSH host key fingerprints in your local known_hosts file for the named server. The action parameter selects: verify, check, and list are read-only comparisons or listings; accept adds or updates the host key in known_hosts; remove deletes it. accept and remove mutate local state and are blocked on servers configured as readonly. server is required for every action except list. autoAccept defaults to false and should be used with caution.',
3005
3005
  inputSchema: {
3006
3006
  action: z.enum(['verify', 'accept', 'remove', 'list', 'check']).describe('Action to perform'),
3007
3007
  server: z.string().optional().describe('Server name (required for most actions)'),
@@ -3253,7 +3253,7 @@ registerToolConditional(
3253
3253
  registerToolConditional(
3254
3254
  'ssh_alias',
3255
3255
  {
3256
- description: 'Manage server aliases for easier access',
3256
+ description: 'Manages local name aliases that let you reference a configured server by a shorter or alternative name. The action parameter selects add, remove, or list. add creates an alias pointing to an existing server and requires both alias and server; remove deletes an alias and requires alias; list shows all aliases (read-only). add and remove persist the alias mapping locally. The target server must already exist for add to succeed.',
3257
3257
  inputSchema: {
3258
3258
  action: z.enum(['add', 'remove', 'list']).describe('Action to perform'),
3259
3259
  alias: z.string().optional().describe('Alias name (for add/remove)'),
@@ -3343,7 +3343,7 @@ registerToolConditional(
3343
3343
  registerToolConditional(
3344
3344
  'ssh_backup_create',
3345
3345
  {
3346
- description: 'Create backup of database or files on remote server',
3346
+ description: 'Creates a database or file backup on the remote server over SSH, writing a compressed archive plus a JSON metadata file into backupDir. Supports mysql, postgresql, mongodb, and files (full is not yet implemented and errors). Database types require database; files requires paths. After writing it prunes backups older than retention days (default 7); compress defaults to true. Runs pre-backup and post-backup hooks.',
3347
3347
  inputSchema: {
3348
3348
  server: z.string().describe('Server name'),
3349
3349
  type: z.enum(['mysql', 'postgresql', 'mongodb', 'files', 'full'])
@@ -3566,7 +3566,7 @@ registerToolConditional(
3566
3566
  registerToolConditional(
3567
3567
  'ssh_backup_list',
3568
3568
  {
3569
- description: 'List available backups on remote server',
3569
+ description: 'Lists existing backups found in backupDir on the remote server, returning each backup id, type, database or paths, size, compression, retention, status, and creation time parsed from stored metadata. Read-only: it inspects the filesystem and mutates nothing. Optional type filters results to mysql, postgresql, mongodb, files, or full. backupDir defaults to the configured backup directory.',
3570
3570
  inputSchema: {
3571
3571
  server: z.string().describe('Server name'),
3572
3572
  type: z.enum(['mysql', 'postgresql', 'mongodb', 'files', 'full']).optional()
@@ -3638,7 +3638,7 @@ registerToolConditional(
3638
3638
  registerToolConditional(
3639
3639
  'ssh_backup_restore',
3640
3640
  {
3641
- description: 'Restore from a backup on remote server',
3641
+ description: 'Restores a previously created backup identified by backupId, reading its metadata to pick the engine. This is destructive and overwrites the target: PostgreSQL runs pg_restore with --clean --if-exists which DROPs existing objects, MongoDB runs mongorestore --drop, and MySQL pipes the dump into the live database replacing matching objects. Supports mysql, postgresql, mongodb, and files. Runs pre-restore and post-restore hooks.',
3642
3642
  inputSchema: {
3643
3643
  server: z.string().describe('Server name'),
3644
3644
  backupId: z.string().describe('Backup ID to restore'),
@@ -3762,7 +3762,7 @@ registerToolConditional(
3762
3762
  registerToolConditional(
3763
3763
  'ssh_backup_schedule',
3764
3764
  {
3765
- description: 'Schedule automatic backups using cron',
3765
+ description: 'Schedules a recurring backup on the remote server by writing an executable bash script to /usr/local/bin/ssh-manager-backup-NAME.sh and installing a crontab entry for the given cron expression. Mutates the remote filesystem and crontab, and typically needs root to write that path. Supports mysql, postgresql, mongodb, and files; the generated script also deletes backups older than retention days (default 7).',
3766
3766
  inputSchema: {
3767
3767
  server: z.string().describe('Server name'),
3768
3768
  schedule: z.string().describe('Cron schedule (e.g., "0 2 * * *" for daily at 2 AM)'),
@@ -3888,7 +3888,7 @@ registerToolConditional(
3888
3888
  registerToolConditional(
3889
3889
  'ssh_health_check',
3890
3890
  {
3891
- description: 'Perform comprehensive health check on remote server',
3891
+ description: 'Runs a comprehensive read-only health check on the named server by executing diagnostic shell commands over SSH, then returns parsed JSON with overall status, CPU, memory, disk usage, and uptime. It only reads metrics and changes nothing on the remote host. Set detailed to true to additionally include load average and network metrics; it defaults to false. Critical CPU, memory, or disk conditions are surfaced in a critical_issues list.',
3892
3892
  inputSchema: {
3893
3893
  server: z.string().describe('Server name'),
3894
3894
  detailed: z.boolean().optional()
@@ -3983,7 +3983,7 @@ registerToolConditional(
3983
3983
  registerToolConditional(
3984
3984
  'ssh_service_status',
3985
3985
  {
3986
- description: 'Check status of services on remote server',
3986
+ description: 'Checks the running state of the named system services on a remote server by querying each one over SSH, returning JSON per service plus running and stopped counts and an aggregate health rating. Read-only: it inspects status without starting, stopping, or restarting anything. The services array parameter is required and lists the service names to check, for example nginx, mysql, or docker; common names are resolved to their actual unit names automatically.',
3987
3987
  inputSchema: {
3988
3988
  server: z.string().describe('Server name'),
3989
3989
  services: z.array(z.string())
@@ -4062,7 +4062,7 @@ registerToolConditional(
4062
4062
  registerToolConditional(
4063
4063
  'ssh_process_manager',
4064
4064
  {
4065
- description: 'List, monitor, or kill processes on remote server',
4065
+ description: 'Lists, inspects, or terminates processes on a remote server over SSH. The action parameter selects: list returns top processes (read-only), info returns details for one process (read-only), and kill sends a signal to terminate a process and mutates remote state. pid is required for kill and info. kill is blocked on servers configured as readonly. signal defaults to TERM, sortBy defaults to cpu, and limit defaults to 20; filter narrows the list by name or command.',
4066
4066
  inputSchema: {
4067
4067
  server: z.string().describe('Server name'),
4068
4068
  action: z.enum(['list', 'kill', 'info'])
@@ -4217,7 +4217,7 @@ registerToolConditional(
4217
4217
  registerToolConditional(
4218
4218
  'ssh_alert_setup',
4219
4219
  {
4220
- description: 'Configure health monitoring alerts and thresholds',
4220
+ description: 'Configures and evaluates CPU, memory, and disk usage alert thresholds for a remote server. The action parameter selects: set writes the threshold config to /etc/ssh-manager-alerts.json on the remote host (mutating, may need write access to /etc, and is blocked on readonly servers); get reads back that config; check reads current metrics and compares them to stored thresholds. get and check are read-only. enabled defaults to true; check errors if no config exists yet.',
4221
4221
  inputSchema: {
4222
4222
  server: z.string().describe('Server name'),
4223
4223
  action: z.enum(['set', 'get', 'check'])
@@ -4406,7 +4406,7 @@ registerToolConditional(
4406
4406
  registerToolConditional(
4407
4407
  'ssh_db_dump',
4408
4408
  {
4409
- description: 'Dump database to file (MySQL, PostgreSQL, MongoDB)',
4409
+ description: 'Dumps a database to a file on the remote server over SSH; it reads data only and does not modify the database. Supports mysql (using --single-transaction --routines --triggers), postgresql (custom format with --clean --if-exists, restorable via pg_restore), and mongodb. compress defaults to true and gzips the output. The optional tables list applies to MySQL and PostgreSQL only and is ignored for MongoDB.',
4410
4410
  inputSchema: {
4411
4411
  server: z.string().describe('Server name'),
4412
4412
  type: z.enum(['mysql', 'postgresql', 'mongodb'])
@@ -4521,7 +4521,7 @@ registerToolConditional(
4521
4521
  registerToolConditional(
4522
4522
  'ssh_db_import',
4523
4523
  {
4524
- description: 'Import database from SQL file (MySQL, PostgreSQL, MongoDB)',
4524
+ description: 'Imports a dump file into a target database on the remote server and is destructive to existing data. PostgreSQL uses pg_restore --clean --if-exists which DROPs existing objects before loading; MongoDB uses mongorestore with --drop controlled by the drop flag (default true); MySQL pipes the file into the live database, replacing objects defined in it. Supports mysql, postgresql, mongodb. Compressed .gz inputs are decompressed automatically.',
4525
4525
  inputSchema: {
4526
4526
  server: z.string().describe('Server name'),
4527
4527
  type: z.enum(['mysql', 'postgresql', 'mongodb'])
@@ -4626,7 +4626,7 @@ registerToolConditional(
4626
4626
  registerToolConditional(
4627
4627
  'ssh_db_list',
4628
4628
  {
4629
- description: 'List databases or tables/collections',
4629
+ description: 'Lists database objects on the remote server for the given engine without modifying anything. When database is provided it lists the tables (SQL) or collections (MongoDB) of that database; when omitted it lists all databases with common system databases filtered out. Supports mysql, postgresql, and mongodb. Returns the items and a count. Read-only and safe to call repeatedly.',
4630
4630
  inputSchema: {
4631
4631
  server: z.string().describe('Server name'),
4632
4632
  type: z.enum(['mysql', 'postgresql', 'mongodb'])
@@ -4751,7 +4751,7 @@ registerToolConditional(
4751
4751
  registerToolConditional(
4752
4752
  'ssh_db_query',
4753
4753
  {
4754
- description: 'Execute SELECT query on database (read-only, SELECT queries only)',
4754
+ description: 'Runs a read-only query against a remote database. For mysql and postgresql it is strictly limited to SELECT: the query must begin with SELECT and any insert, update, delete, drop, create, alter, truncate, grant, revoke, or exec keyword is rejected before execution. For mongodb it runs a find() and requires the collection parameter. Returns the raw command output as text.',
4755
4755
  inputSchema: {
4756
4756
  server: z.string().describe('Server name'),
4757
4757
  type: z.enum(['mysql', 'postgresql', 'mongodb'])
@@ -393,13 +393,16 @@ export function cleanupSessions(maxAge = 30 * 60 * 1000) { // 30 minutes default
393
393
  return cleanedCount;
394
394
  }
395
395
 
396
- // Periodic cleanup of inactive sessions
397
- setInterval(() => {
396
+ // Periodic cleanup of inactive sessions.
397
+ // unref() so this interval never keeps the process alive on its own (a stdio MCP
398
+ // server must exit when its transport closes, not be pinned by a background timer).
399
+ const sessionCleanup = setInterval(() => {
398
400
  const cleaned = cleanupSessions();
399
401
  if (cleaned > 0) {
400
402
  logger.info(`Cleaned up ${cleaned} inactive sessions`);
401
403
  }
402
404
  }, 5 * 60 * 1000); // Every 5 minutes
405
+ if (typeof sessionCleanup.unref === 'function') sessionCleanup.unref();
403
406
 
404
407
  export default {
405
408
  createSession,
@@ -562,8 +562,12 @@ export function monitorTunnels() {
562
562
  }
563
563
  }
564
564
 
565
- // Monitor tunnels periodically
566
- setInterval(monitorTunnels, 30 * 1000); // Every 30 seconds
565
+ // Monitor tunnels periodically.
566
+ // unref() so this interval never keeps the process alive on its own: as part of
567
+ // a stdio MCP server we must exit when the transport closes, not stay pinned by
568
+ // a background timer.
569
+ const tunnelMonitor = setInterval(monitorTunnels, 30 * 1000); // Every 30 seconds
570
+ if (typeof tunnelMonitor.unref === 'function') tunnelMonitor.unref();
567
571
 
568
572
  export default {
569
573
  createTunnel,