mcp-ssh-manager 3.6.1 → 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 +25 -0
- package/README.md +14 -5
- package/package.json +3 -2
- package/src/index.js +43 -56
- package/src/rsync-stats.js +72 -0
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,31 @@ 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
|
+
|
|
24
|
+
## [3.6.2] - 2026-06-09
|
|
25
|
+
|
|
26
|
+
### Changed
|
|
27
|
+
|
|
28
|
+
- **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).
|
|
29
|
+
- 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.
|
|
30
|
+
- Also raises the Glama "Tool Definition Quality" score (previously C — average 3.1/5, lowest 2.1/5).
|
|
31
|
+
- **No behavioral change**: only `description` strings were edited; all logic, parameters, and tool names are unchanged. All test suites pass unmodified.
|
|
32
|
+
|
|
8
33
|
## [3.6.1] - 2026-06-09
|
|
9
34
|
|
|
10
35
|
### Fixed
|
package/README.md
CHANGED
|
@@ -6,7 +6,7 @@ A Model Context Protocol (MCP) server that enables **Claude Code** and **OpenAI
|
|
|
6
6
|
|
|
7
7
|
[](https://www.npmjs.com/package/mcp-ssh-manager)
|
|
8
8
|
[](https://www.npmjs.com/package/mcp-ssh-manager)
|
|
9
|
-
[](https://github.com/bvisible/mcp-ssh-manager/releases/tag/v3.6.3)
|
|
10
10
|
[](https://claude.ai/code)
|
|
11
11
|
[](https://openai.com/codex)
|
|
12
12
|
[](https://modelcontextprotocol.io)
|
|
@@ -20,18 +20,27 @@ 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.
|
|
23
|
+
## 🎉 What's New in v3.6.3
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
**`ssh_sync` now reports the real transfer count** (Released: June 18, 2026)
|
|
26
26
|
|
|
27
|
-
-
|
|
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`.
|
|
28
29
|
|
|
29
|
-
[Read full changelog →](CHANGELOG.md#
|
|
30
|
+
[Read full changelog →](CHANGELOG.md#363---2026-06-18)
|
|
30
31
|
|
|
31
32
|
---
|
|
32
33
|
|
|
33
34
|
## Previous Releases
|
|
34
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
|
+
|
|
40
|
+
### v3.6.1 - Teardown hygiene follow-up (June 9, 2026)
|
|
41
|
+
|
|
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)
|
|
43
|
+
|
|
35
44
|
### v3.6.0 - Live config hot reload + stdio lifecycle fix (June 9, 2026)
|
|
36
45
|
|
|
37
46
|
- **♻️ 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.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mcp-ssh-manager",
|
|
3
|
-
"version": "3.6.
|
|
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,
|
|
@@ -662,7 +663,7 @@ function registerToolConditional(toolName, schema, handler) {
|
|
|
662
663
|
registerToolConditional(
|
|
663
664
|
'ssh_execute',
|
|
664
665
|
{
|
|
665
|
-
description: '
|
|
666
|
+
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
667
|
inputSchema: {
|
|
667
668
|
server: z.string().describe('Server name from configuration'),
|
|
668
669
|
command: z.string().describe('Command to execute'),
|
|
@@ -784,7 +785,7 @@ registerToolConditional(
|
|
|
784
785
|
registerToolConditional(
|
|
785
786
|
'ssh_upload',
|
|
786
787
|
{
|
|
787
|
-
description: '
|
|
788
|
+
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
789
|
inputSchema: {
|
|
789
790
|
server: z.string().describe('Server name'),
|
|
790
791
|
localPath: z.string().describe('Local file path'),
|
|
@@ -844,7 +845,7 @@ registerToolConditional(
|
|
|
844
845
|
registerToolConditional(
|
|
845
846
|
'ssh_download',
|
|
846
847
|
{
|
|
847
|
-
description: '
|
|
848
|
+
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
849
|
inputSchema: {
|
|
849
850
|
server: z.string().describe('Server name'),
|
|
850
851
|
remotePath: z.string().describe('Remote file path'),
|
|
@@ -895,7 +896,7 @@ registerToolConditional(
|
|
|
895
896
|
registerToolConditional(
|
|
896
897
|
'ssh_sync',
|
|
897
898
|
{
|
|
898
|
-
description: '
|
|
899
|
+
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
900
|
inputSchema: {
|
|
900
901
|
server: z.string().describe('Server name from configuration'),
|
|
901
902
|
source: z.string().describe('Source path (use "local:" or "remote:" prefix)'),
|
|
@@ -973,10 +974,8 @@ registerToolConditional(
|
|
|
973
974
|
rsyncOptions.push('--dry-run');
|
|
974
975
|
}
|
|
975
976
|
|
|
976
|
-
|
|
977
|
-
|
|
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
|
-
|
|
1158
|
-
|
|
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,
|
|
@@ -1241,7 +1228,7 @@ registerToolConditional(
|
|
|
1241
1228
|
registerToolConditional(
|
|
1242
1229
|
'ssh_tail',
|
|
1243
1230
|
{
|
|
1244
|
-
description: '
|
|
1231
|
+
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
1232
|
inputSchema: {
|
|
1246
1233
|
server: z.string().describe('Server name from configuration'),
|
|
1247
1234
|
file: z.string().describe('Path to the log file to tail'),
|
|
@@ -1342,7 +1329,7 @@ registerToolConditional(
|
|
|
1342
1329
|
registerToolConditional(
|
|
1343
1330
|
'ssh_monitor',
|
|
1344
1331
|
{
|
|
1345
|
-
description: '
|
|
1332
|
+
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
1333
|
inputSchema: {
|
|
1347
1334
|
server: z.string().describe('Server name from configuration'),
|
|
1348
1335
|
type: z.enum(['overview', 'cpu', 'memory', 'disk', 'network', 'process']).optional().describe('Type of monitoring (default: overview)'),
|
|
@@ -1515,7 +1502,7 @@ registerToolConditional(
|
|
|
1515
1502
|
registerToolConditional(
|
|
1516
1503
|
'ssh_history',
|
|
1517
1504
|
{
|
|
1518
|
-
description: '
|
|
1505
|
+
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
1506
|
inputSchema: {
|
|
1520
1507
|
limit: z.number().optional().describe('Number of commands to show (default: 20)'),
|
|
1521
1508
|
server: z.string().optional().describe('Filter by server name'),
|
|
@@ -1619,7 +1606,7 @@ registerToolConditional(
|
|
|
1619
1606
|
registerToolConditional(
|
|
1620
1607
|
'ssh_session_start',
|
|
1621
1608
|
{
|
|
1622
|
-
description: '
|
|
1609
|
+
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
1610
|
inputSchema: {
|
|
1624
1611
|
server: z.string().describe('Server name from configuration'),
|
|
1625
1612
|
name: z.string().optional().describe('Optional session name for identification')
|
|
@@ -1667,7 +1654,7 @@ registerToolConditional(
|
|
|
1667
1654
|
registerToolConditional(
|
|
1668
1655
|
'ssh_session_send',
|
|
1669
1656
|
{
|
|
1670
|
-
description: '
|
|
1657
|
+
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
1658
|
inputSchema: {
|
|
1672
1659
|
session: z.string().describe('Session ID from ssh_session_start'),
|
|
1673
1660
|
command: z.string().describe('Command to execute in the session'),
|
|
@@ -1741,7 +1728,7 @@ registerToolConditional(
|
|
|
1741
1728
|
registerToolConditional(
|
|
1742
1729
|
'ssh_session_list',
|
|
1743
1730
|
{
|
|
1744
|
-
description: '
|
|
1731
|
+
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
1732
|
inputSchema: {
|
|
1746
1733
|
server: z.string().optional().describe('Filter by server name')
|
|
1747
1734
|
}
|
|
@@ -1819,7 +1806,7 @@ registerToolConditional(
|
|
|
1819
1806
|
registerToolConditional(
|
|
1820
1807
|
'ssh_session_close',
|
|
1821
1808
|
{
|
|
1822
|
-
description: '
|
|
1809
|
+
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
1810
|
inputSchema: {
|
|
1824
1811
|
session: z.string().describe('Session ID to close (or "all" to close all sessions)')
|
|
1825
1812
|
}
|
|
@@ -1896,7 +1883,7 @@ function formatDuration(seconds) {
|
|
|
1896
1883
|
registerToolConditional(
|
|
1897
1884
|
'ssh_execute_group',
|
|
1898
1885
|
{
|
|
1899
|
-
description: '
|
|
1886
|
+
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
1887
|
inputSchema: {
|
|
1901
1888
|
group: z.string().describe('Group name (e.g., "production", "staging", "all")'),
|
|
1902
1889
|
command: z.string().describe('Command to execute'),
|
|
@@ -2023,7 +2010,7 @@ registerToolConditional(
|
|
|
2023
2010
|
registerToolConditional(
|
|
2024
2011
|
'ssh_group_manage',
|
|
2025
2012
|
{
|
|
2026
|
-
description: '
|
|
2013
|
+
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
2014
|
inputSchema: {
|
|
2028
2015
|
action: z.enum(['create', 'update', 'delete', 'list', 'add-servers', 'remove-servers']).describe('Action to perform'),
|
|
2029
2016
|
name: z.string().optional().describe('Group name'),
|
|
@@ -2157,7 +2144,7 @@ registerToolConditional(
|
|
|
2157
2144
|
registerToolConditional(
|
|
2158
2145
|
'ssh_list_servers',
|
|
2159
2146
|
{
|
|
2160
|
-
description: '
|
|
2147
|
+
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
2148
|
inputSchema: {}
|
|
2162
2149
|
},
|
|
2163
2150
|
async () => {
|
|
@@ -2187,7 +2174,7 @@ registerToolConditional(
|
|
|
2187
2174
|
registerToolConditional(
|
|
2188
2175
|
'ssh_deploy',
|
|
2189
2176
|
{
|
|
2190
|
-
description: '
|
|
2177
|
+
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
2178
|
inputSchema: {
|
|
2192
2179
|
server: z.string().describe('Server name or alias'),
|
|
2193
2180
|
files: z.array(z.object({
|
|
@@ -2296,7 +2283,7 @@ registerToolConditional(
|
|
|
2296
2283
|
registerToolConditional(
|
|
2297
2284
|
'ssh_execute_sudo',
|
|
2298
2285
|
{
|
|
2299
|
-
description: '
|
|
2286
|
+
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
2287
|
inputSchema: {
|
|
2301
2288
|
server: z.string().describe('Server name or alias'),
|
|
2302
2289
|
command: z.string().describe('Command to execute with sudo'),
|
|
@@ -2382,7 +2369,7 @@ registerToolConditional(
|
|
|
2382
2369
|
registerToolConditional(
|
|
2383
2370
|
'ssh_command_alias',
|
|
2384
2371
|
{
|
|
2385
|
-
description: '
|
|
2372
|
+
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
2373
|
inputSchema: {
|
|
2387
2374
|
action: z.enum(['add', 'remove', 'list', 'suggest']).describe('Action to perform'),
|
|
2388
2375
|
alias: z.string().optional().describe('Alias name (for add/remove)'),
|
|
@@ -2483,7 +2470,7 @@ registerToolConditional(
|
|
|
2483
2470
|
registerToolConditional(
|
|
2484
2471
|
'ssh_hooks',
|
|
2485
2472
|
{
|
|
2486
|
-
description: '
|
|
2473
|
+
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
2474
|
inputSchema: {
|
|
2488
2475
|
action: z.enum(['list', 'enable', 'disable', 'status']).describe('Action to perform'),
|
|
2489
2476
|
hook: z.string().optional().describe('Hook name (for enable/disable)')
|
|
@@ -2575,7 +2562,7 @@ registerToolConditional(
|
|
|
2575
2562
|
registerToolConditional(
|
|
2576
2563
|
'ssh_profile',
|
|
2577
2564
|
{
|
|
2578
|
-
description: '
|
|
2565
|
+
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
2566
|
inputSchema: {
|
|
2580
2567
|
action: z.enum(['list', 'switch', 'current']).describe('Action to perform'),
|
|
2581
2568
|
profile: z.string().optional().describe('Profile name (for switch)')
|
|
@@ -2655,7 +2642,7 @@ registerToolConditional(
|
|
|
2655
2642
|
registerToolConditional(
|
|
2656
2643
|
'ssh_connection_status',
|
|
2657
2644
|
{
|
|
2658
|
-
description: '
|
|
2645
|
+
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
2646
|
inputSchema: {
|
|
2660
2647
|
action: z.enum(['status', 'reconnect', 'disconnect', 'cleanup']).describe('Action to perform'),
|
|
2661
2648
|
server: z.string().optional().describe('Server name (for reconnect/disconnect)')
|
|
@@ -2772,7 +2759,7 @@ registerToolConditional(
|
|
|
2772
2759
|
registerToolConditional(
|
|
2773
2760
|
'ssh_tunnel_create',
|
|
2774
2761
|
{
|
|
2775
|
-
description: '
|
|
2762
|
+
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
2763
|
inputSchema: {
|
|
2777
2764
|
server: z.string().describe('Server name or alias'),
|
|
2778
2765
|
type: z.enum(['local', 'remote', 'dynamic']).describe('Tunnel type'),
|
|
@@ -2855,7 +2842,7 @@ registerToolConditional(
|
|
|
2855
2842
|
registerToolConditional(
|
|
2856
2843
|
'ssh_tunnel_list',
|
|
2857
2844
|
{
|
|
2858
|
-
description: '
|
|
2845
|
+
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
2846
|
inputSchema: {
|
|
2860
2847
|
server: z.string().optional().describe('Filter by server name')
|
|
2861
2848
|
}
|
|
@@ -2937,7 +2924,7 @@ registerToolConditional(
|
|
|
2937
2924
|
registerToolConditional(
|
|
2938
2925
|
'ssh_tunnel_close',
|
|
2939
2926
|
{
|
|
2940
|
-
description: '
|
|
2927
|
+
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
2928
|
inputSchema: {
|
|
2942
2929
|
tunnelId: z.string().optional().describe('Tunnel ID to close'),
|
|
2943
2930
|
server: z.string().optional().describe('Close all tunnels for this server')
|
|
@@ -3001,7 +2988,7 @@ registerToolConditional(
|
|
|
3001
2988
|
registerToolConditional(
|
|
3002
2989
|
'ssh_key_manage',
|
|
3003
2990
|
{
|
|
3004
|
-
description: '
|
|
2991
|
+
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
2992
|
inputSchema: {
|
|
3006
2993
|
action: z.enum(['verify', 'accept', 'remove', 'list', 'check']).describe('Action to perform'),
|
|
3007
2994
|
server: z.string().optional().describe('Server name (required for most actions)'),
|
|
@@ -3253,7 +3240,7 @@ registerToolConditional(
|
|
|
3253
3240
|
registerToolConditional(
|
|
3254
3241
|
'ssh_alias',
|
|
3255
3242
|
{
|
|
3256
|
-
description: '
|
|
3243
|
+
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
3244
|
inputSchema: {
|
|
3258
3245
|
action: z.enum(['add', 'remove', 'list']).describe('Action to perform'),
|
|
3259
3246
|
alias: z.string().optional().describe('Alias name (for add/remove)'),
|
|
@@ -3343,7 +3330,7 @@ registerToolConditional(
|
|
|
3343
3330
|
registerToolConditional(
|
|
3344
3331
|
'ssh_backup_create',
|
|
3345
3332
|
{
|
|
3346
|
-
description: '
|
|
3333
|
+
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
3334
|
inputSchema: {
|
|
3348
3335
|
server: z.string().describe('Server name'),
|
|
3349
3336
|
type: z.enum(['mysql', 'postgresql', 'mongodb', 'files', 'full'])
|
|
@@ -3566,7 +3553,7 @@ registerToolConditional(
|
|
|
3566
3553
|
registerToolConditional(
|
|
3567
3554
|
'ssh_backup_list',
|
|
3568
3555
|
{
|
|
3569
|
-
description: '
|
|
3556
|
+
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
3557
|
inputSchema: {
|
|
3571
3558
|
server: z.string().describe('Server name'),
|
|
3572
3559
|
type: z.enum(['mysql', 'postgresql', 'mongodb', 'files', 'full']).optional()
|
|
@@ -3638,7 +3625,7 @@ registerToolConditional(
|
|
|
3638
3625
|
registerToolConditional(
|
|
3639
3626
|
'ssh_backup_restore',
|
|
3640
3627
|
{
|
|
3641
|
-
description: '
|
|
3628
|
+
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
3629
|
inputSchema: {
|
|
3643
3630
|
server: z.string().describe('Server name'),
|
|
3644
3631
|
backupId: z.string().describe('Backup ID to restore'),
|
|
@@ -3762,7 +3749,7 @@ registerToolConditional(
|
|
|
3762
3749
|
registerToolConditional(
|
|
3763
3750
|
'ssh_backup_schedule',
|
|
3764
3751
|
{
|
|
3765
|
-
description: '
|
|
3752
|
+
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
3753
|
inputSchema: {
|
|
3767
3754
|
server: z.string().describe('Server name'),
|
|
3768
3755
|
schedule: z.string().describe('Cron schedule (e.g., "0 2 * * *" for daily at 2 AM)'),
|
|
@@ -3888,7 +3875,7 @@ registerToolConditional(
|
|
|
3888
3875
|
registerToolConditional(
|
|
3889
3876
|
'ssh_health_check',
|
|
3890
3877
|
{
|
|
3891
|
-
description: '
|
|
3878
|
+
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
3879
|
inputSchema: {
|
|
3893
3880
|
server: z.string().describe('Server name'),
|
|
3894
3881
|
detailed: z.boolean().optional()
|
|
@@ -3983,7 +3970,7 @@ registerToolConditional(
|
|
|
3983
3970
|
registerToolConditional(
|
|
3984
3971
|
'ssh_service_status',
|
|
3985
3972
|
{
|
|
3986
|
-
description: '
|
|
3973
|
+
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
3974
|
inputSchema: {
|
|
3988
3975
|
server: z.string().describe('Server name'),
|
|
3989
3976
|
services: z.array(z.string())
|
|
@@ -4062,7 +4049,7 @@ registerToolConditional(
|
|
|
4062
4049
|
registerToolConditional(
|
|
4063
4050
|
'ssh_process_manager',
|
|
4064
4051
|
{
|
|
4065
|
-
description: '
|
|
4052
|
+
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
4053
|
inputSchema: {
|
|
4067
4054
|
server: z.string().describe('Server name'),
|
|
4068
4055
|
action: z.enum(['list', 'kill', 'info'])
|
|
@@ -4217,7 +4204,7 @@ registerToolConditional(
|
|
|
4217
4204
|
registerToolConditional(
|
|
4218
4205
|
'ssh_alert_setup',
|
|
4219
4206
|
{
|
|
4220
|
-
description: '
|
|
4207
|
+
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
4208
|
inputSchema: {
|
|
4222
4209
|
server: z.string().describe('Server name'),
|
|
4223
4210
|
action: z.enum(['set', 'get', 'check'])
|
|
@@ -4406,7 +4393,7 @@ registerToolConditional(
|
|
|
4406
4393
|
registerToolConditional(
|
|
4407
4394
|
'ssh_db_dump',
|
|
4408
4395
|
{
|
|
4409
|
-
description: '
|
|
4396
|
+
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
4397
|
inputSchema: {
|
|
4411
4398
|
server: z.string().describe('Server name'),
|
|
4412
4399
|
type: z.enum(['mysql', 'postgresql', 'mongodb'])
|
|
@@ -4521,7 +4508,7 @@ registerToolConditional(
|
|
|
4521
4508
|
registerToolConditional(
|
|
4522
4509
|
'ssh_db_import',
|
|
4523
4510
|
{
|
|
4524
|
-
description: '
|
|
4511
|
+
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
4512
|
inputSchema: {
|
|
4526
4513
|
server: z.string().describe('Server name'),
|
|
4527
4514
|
type: z.enum(['mysql', 'postgresql', 'mongodb'])
|
|
@@ -4626,7 +4613,7 @@ registerToolConditional(
|
|
|
4626
4613
|
registerToolConditional(
|
|
4627
4614
|
'ssh_db_list',
|
|
4628
4615
|
{
|
|
4629
|
-
description: '
|
|
4616
|
+
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
4617
|
inputSchema: {
|
|
4631
4618
|
server: z.string().describe('Server name'),
|
|
4632
4619
|
type: z.enum(['mysql', 'postgresql', 'mongodb'])
|
|
@@ -4751,7 +4738,7 @@ registerToolConditional(
|
|
|
4751
4738
|
registerToolConditional(
|
|
4752
4739
|
'ssh_db_query',
|
|
4753
4740
|
{
|
|
4754
|
-
description: '
|
|
4741
|
+
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
4742
|
inputSchema: {
|
|
4756
4743
|
server: z.string().describe('Server name'),
|
|
4757
4744
|
type: z.enum(['mysql', 'postgresql', 'mongodb'])
|
|
@@ -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
|
+
}
|