mcp-ssh-manager 3.6.2 → 3.6.3

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.3] - 2026-06-18
9
+
10
+ ### Fixed
11
+
12
+ - **`ssh_sync` falsely reported "No files needed to be transferred" even when files were synced** ([#42](https://github.com/bvisible/mcp-ssh-manager/pull/42) — thanks [@MakksSh](https://github.com/MakksSh))
13
+ - Two bugs in the rsync `--stats` scraper kept `filesTransferred` at `0`: `--stats` was only passed when `verbose` was enabled (so rsync produced no statistics lines at all), and the count regex only matched rsync 2.x wording (`Number of files transferred`) while rsync 3.x — standard on modern distros — emits `Number of regular files transferred`. Agents would mistrust the result, run redundant checks, or retry the sync.
14
+ - `--stats` is now always passed, and the count regex matches both rsync 2.x and 3.x.
15
+ - **`totalSize` stayed `0` on macOS, and locale-formatted numbers were mis-parsed** (follow-up hardening)
16
+ - openrsync (the default `/usr/bin/rsync` on recent macOS) suffixes byte counts with `B`, not `bytes`, so the size regex never matched. Both suffixes are now accepted — openrsync keeps raw byte counts even for large files (verified at 5 MB), so no `K/M/G` handling is needed.
17
+ - Numbers grouped with locale-specific separators (`,` or `.` for thousands, the opposite char for the decimal) are now parsed correctly for the file count, transferred size, and speed, instead of only stripping commas.
18
+ - The `--stats` parsing was extracted into `src/rsync-stats.js` so it is unit-testable without booting the MCP server.
19
+
20
+ ### Tests
21
+
22
+ - **New `tests/test-sync-stats.js`** (wired into `npm test` as `test:sync`) — 46 assertions covering openrsync output captured from a live macOS run, GNU rsync 3.x/2.x, US/EU locale number formats, the zero-files case, and a missing `--stats` block.
23
+
8
24
  ## [3.6.2] - 2026-06-09
9
25
 
10
26
  ### Changed
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.5.1-brightgreen?style=for-the-badge)](https://github.com/bvisible/mcp-ssh-manager/releases/tag/v3.5.1)
9
+ [![Version](https://img.shields.io/badge/Version-3.6.3-brightgreen?style=for-the-badge)](https://github.com/bvisible/mcp-ssh-manager/releases/tag/v3.6.3)
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,20 +20,23 @@ 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.2
23
+ ## 🎉 What's New in v3.6.3
24
24
 
25
- **Richer tool descriptions — better AI tool-calling** (Released: June 9, 2026)
25
+ **`ssh_sync` now reports the real transfer count** (Released: June 18, 2026)
26
26
 
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.
27
+ - **📊 No more false "No files needed to be transferred"** ([#42](https://github.com/bvisible/mcp-ssh-manager/pull/42) — thanks [@MakksSh](https://github.com/MakksSh)) — `ssh_sync` scraped rsync's `--stats` block incorrectly: stats were only requested in `verbose` mode and the regex only matched rsync 2.x wording, so `filesTransferred` stayed `0` and agents kept re-verifying or retrying a sync that had actually succeeded. Now `--stats` is always passed and both rsync 2.x and 3.x output is parsed.
28
+ - **🍏 Correct on macOS and in any locale** — openrsync (the default `/usr/bin/rsync` on recent macOS) writes byte counts as `B`, not `bytes`, and locale-formatted numbers use `,`/`.` as thousands separators; both are handled now. Parsing was extracted to `src/rsync-stats.js` and covered by 46 new assertions in `tests/test-sync-stats.js`.
30
29
 
31
- [Read full changelog →](CHANGELOG.md#362---2026-06-09)
30
+ [Read full changelog →](CHANGELOG.md#363---2026-06-18)
32
31
 
33
32
  ---
34
33
 
35
34
  ## Previous Releases
36
35
 
36
+ ### v3.6.2 - Richer tool descriptions (June 9, 2026)
37
+
38
+ - **📝 All 37 tool descriptions rewritten** — every MCP tool now documents its real behavior (side effects, destructive vs read-only nature, idempotency, sudo/auth requirements, security-mode gating, parameter semantics) instead of a 4-to-10-word summary. Agents now know the consequences before invoking a tool; no behavioral change — only `description` strings changed. [Full changelog →](CHANGELOG.md#362---2026-06-09)
39
+
37
40
  ### v3.6.1 - Teardown hygiene follow-up (June 9, 2026)
38
41
 
39
42
  - **🔌 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)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mcp-ssh-manager",
3
- "version": "3.6.2",
3
+ "version": "3.6.3",
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",
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",
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,6 +22,7 @@
22
22
  "test:ping": "node tests/test-ssh-ping.js",
23
23
  "test:config": "node tests/test-server-config-manager.js",
24
24
  "test:lifecycle": "node tests/test-lifecycle.js",
25
+ "test:sync": "node tests/test-sync-stats.js",
25
26
  "test:all": "npm test && ./scripts/validate.sh",
26
27
  "validate": "./scripts/validate.sh",
27
28
  "lint": "eslint src/*.js",
package/src/index.js CHANGED
@@ -47,6 +47,7 @@ import {
47
47
  getActiveProfileName
48
48
  } from './profile-loader.js';
49
49
  import { logger } from './logger.js';
50
+ import { parseRsyncStats } from './rsync-stats.js';
50
51
  import {
51
52
  createSession,
52
53
  getSession,
@@ -973,10 +974,8 @@ registerToolConditional(
973
974
  rsyncOptions.push('--dry-run');
974
975
  }
975
976
 
976
- if (verbose || logger.verbose) {
977
- // Only add stats, not progress to avoid blocking with too much output
978
- rsyncOptions.push('--stats');
979
- }
977
+ // Always include --stats so we can parse transfer counts
978
+ rsyncOptions.push('--stats');
980
979
 
981
980
  // Add exclude patterns
982
981
  exclude.forEach(pattern => {
@@ -1153,21 +1152,9 @@ registerToolConditional(
1153
1152
  return;
1154
1153
  }
1155
1154
 
1156
- // Parse rsync output for statistics
1157
- let stats = {
1158
- filesTransferred: 0,
1159
- totalSize: 0,
1160
- totalTime: duration
1161
- };
1162
-
1163
- // Extract statistics from rsync output
1164
- const filesMatch = output.match(/Number of files transferred: (\d+)/);
1165
- const sizeMatch = output.match(/Total transferred file size: ([\d,]+) bytes/);
1166
- const speedMatch = output.match(/([\d.]+) bytes\/sec/);
1167
-
1168
- if (filesMatch) stats.filesTransferred = parseInt(filesMatch[1]);
1169
- if (sizeMatch) stats.totalSize = parseInt(sizeMatch[1].replace(/,/g, ''));
1170
- if (speedMatch) stats.speed = parseFloat(speedMatch[1]);
1155
+ // Parse rsync output for statistics. Handles rsync 2.x/3.x wording,
1156
+ // GNU "bytes" vs openrsync "B" suffixes, and locale separators.
1157
+ const stats = parseRsyncStats(output, duration);
1171
1158
 
1172
1159
  logger.info(`Rsync ${direction} completed`, {
1173
1160
  server: serverName,
@@ -0,0 +1,72 @@
1
+ // Parsing helpers for `rsync --stats` output.
2
+ //
3
+ // `ssh_sync` runs rsync with `--stats` and scrapes the summary block to report
4
+ // how many files were transferred. Three things make that scraping fragile, and
5
+ // all three are handled here so the tool never falsely claims "no files
6
+ // transferred" when a sync actually moved data:
7
+ //
8
+ // 1. rsync 2.x prints "Number of files transferred: N" while rsync 3.x prints
9
+ // "Number of regular files transferred: N" (the word "regular" was added).
10
+ // 2. Byte counts carry an implementation-specific unit suffix: GNU rsync
11
+ // writes "... bytes", openrsync (the default on recent macOS) writes
12
+ // "... B". Both keep raw byte counts even for large files (no K/M/G).
13
+ // 3. Depending on the rsync host locale the numbers may use "," or "." as a
14
+ // thousands separator (and the opposite char as the decimal separator).
15
+ //
16
+ // Keeping this in its own module makes it unit-testable without booting the MCP
17
+ // server (importing src/index.js starts the stdio server as a side effect).
18
+
19
+ // Parse a number rsync may have grouped with locale-specific separators.
20
+ // Counts and sizes are integers (raw bytes); speed carries an optional
21
+ // fractional part, so `allowDecimal` says whether the last separator may be a
22
+ // decimal point rather than a thousands group.
23
+ export function parseGroupedNumber(raw, { allowDecimal = false } = {}) {
24
+ const separators = raw.match(/[.,]/g) || [];
25
+ if (separators.length === 0) return Number(raw);
26
+
27
+ const distinctSeparators = new Set(separators);
28
+ const lastChar = separators[separators.length - 1];
29
+ const lastIndex = raw.lastIndexOf(lastChar);
30
+ const digitsAfterLast = raw.length - lastIndex - 1;
31
+
32
+ // The last separator is a decimal point only when a fractional part is allowed
33
+ // and it cannot be a thousands group:
34
+ // - two distinct separators ("1.234,56" / "1,234.56") => the last is decimal
35
+ // - a single separator repeated ("1.234.567") => all are thousands groups
36
+ // - a single separator with exactly 3 trailing digits ("1,234") => thousands
37
+ const repeated = separators.length > 1;
38
+ const twoTypes = distinctSeparators.size === 2;
39
+ const isDecimal = allowDecimal && (twoTypes || (!repeated && digitsAfterLast !== 3));
40
+
41
+ if (!isDecimal) {
42
+ // Every separator just groups thousands; strip them all.
43
+ return Number(raw.replace(/[.,]/g, ''));
44
+ }
45
+ const integerPart = raw.slice(0, lastIndex).replace(/[.,]/g, '');
46
+ const fractionPart = raw.slice(lastIndex + 1);
47
+ return Number(`${integerPart}.${fractionPart}`);
48
+ }
49
+
50
+ // Extract the statistics ssh_sync reports from a full rsync stdout capture.
51
+ // Counts default to 0 (never null) when the matching line is absent — e.g. an
52
+ // rsync build that produced no --stats block — so callers can use the result
53
+ // directly. `speed` is only set when present, matching the optional output line.
54
+ export function parseRsyncStats(output, totalTime) {
55
+ const stats = {
56
+ filesTransferred: 0,
57
+ totalSize: 0,
58
+ totalTime,
59
+ };
60
+
61
+ // rsync 2.x: "Number of files transferred", rsync 3.x: "... regular files ...".
62
+ const filesMatch = output.match(/Number of (?:regular )?files transferred:\s*([\d,.]+)/);
63
+ // GNU rsync suffixes byte counts with "bytes", openrsync with "B".
64
+ const sizeMatch = output.match(/Total transferred file size:\s*([\d,.]+)\s*(?:bytes|B)\b/);
65
+ const speedMatch = output.match(/([\d,.]+)\s*bytes\/sec/);
66
+
67
+ if (filesMatch) stats.filesTransferred = parseGroupedNumber(filesMatch[1]);
68
+ if (sizeMatch) stats.totalSize = parseGroupedNumber(sizeMatch[1]);
69
+ if (speedMatch) stats.speed = parseGroupedNumber(speedMatch[1], { allowDecimal: true });
70
+
71
+ return stats;
72
+ }