ssh-agent-workspace 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +319 -0
- package/dist/__tests__/SSHManager.test.d.ts +2 -0
- package/dist/__tests__/SSHManager.test.d.ts.map +1 -0
- package/dist/__tests__/SSHManager.test.js +134 -0
- package/dist/__tests__/SSHManager.test.js.map +1 -0
- package/dist/__tests__/SessionManager.test.d.ts +2 -0
- package/dist/__tests__/SessionManager.test.d.ts.map +1 -0
- package/dist/__tests__/SessionManager.test.js +141 -0
- package/dist/__tests__/SessionManager.test.js.map +1 -0
- package/dist/__tests__/StorageManager.test.d.ts +2 -0
- package/dist/__tests__/StorageManager.test.d.ts.map +1 -0
- package/dist/__tests__/StorageManager.test.js +171 -0
- package/dist/__tests__/StorageManager.test.js.map +1 -0
- package/dist/__tests__/ansi.test.d.ts +2 -0
- package/dist/__tests__/ansi.test.d.ts.map +1 -0
- package/dist/__tests__/ansi.test.js +41 -0
- package/dist/__tests__/ansi.test.js.map +1 -0
- package/dist/__tests__/security.test.d.ts +2 -0
- package/dist/__tests__/security.test.d.ts.map +1 -0
- package/dist/__tests__/security.test.js +87 -0
- package/dist/__tests__/security.test.js.map +1 -0
- package/dist/__tests__/validation.test.d.ts +2 -0
- package/dist/__tests__/validation.test.d.ts.map +1 -0
- package/dist/__tests__/validation.test.js +23 -0
- package/dist/__tests__/validation.test.js.map +1 -0
- package/dist/core/HostSecurityManager.d.ts +25 -0
- package/dist/core/HostSecurityManager.d.ts.map +1 -0
- package/dist/core/HostSecurityManager.js +76 -0
- package/dist/core/HostSecurityManager.js.map +1 -0
- package/dist/core/SSHManager.d.ts +48 -0
- package/dist/core/SSHManager.d.ts.map +1 -0
- package/dist/core/SSHManager.js +288 -0
- package/dist/core/SSHManager.js.map +1 -0
- package/dist/core/SessionManager.d.ts +15 -0
- package/dist/core/SessionManager.d.ts.map +1 -0
- package/dist/core/SessionManager.js +96 -0
- package/dist/core/SessionManager.js.map +1 -0
- package/dist/core/StorageManager.d.ts +27 -0
- package/dist/core/StorageManager.d.ts.map +1 -0
- package/dist/core/StorageManager.js +87 -0
- package/dist/core/StorageManager.js.map +1 -0
- package/dist/core/TmuxManager.d.ts +21 -0
- package/dist/core/TmuxManager.d.ts.map +1 -0
- package/dist/core/TmuxManager.js +110 -0
- package/dist/core/TmuxManager.js.map +1 -0
- package/dist/core/ToolConfigManager.d.ts +15 -0
- package/dist/core/ToolConfigManager.d.ts.map +1 -0
- package/dist/core/ToolConfigManager.js +57 -0
- package/dist/core/ToolConfigManager.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +169 -0
- package/dist/index.js.map +1 -0
- package/dist/server.d.ts +44 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +152 -0
- package/dist/server.js.map +1 -0
- package/dist/tools/backup.d.ts +74 -0
- package/dist/tools/backup.d.ts.map +1 -0
- package/dist/tools/backup.js +152 -0
- package/dist/tools/backup.js.map +1 -0
- package/dist/tools/connect.d.ts +46 -0
- package/dist/tools/connect.d.ts.map +1 -0
- package/dist/tools/connect.js +235 -0
- package/dist/tools/connect.js.map +1 -0
- package/dist/tools/connection_status.d.ts +39 -0
- package/dist/tools/connection_status.d.ts.map +1 -0
- package/dist/tools/connection_status.js +67 -0
- package/dist/tools/connection_status.js.map +1 -0
- package/dist/tools/db_query.d.ts +103 -0
- package/dist/tools/db_query.d.ts.map +1 -0
- package/dist/tools/db_query.js +194 -0
- package/dist/tools/db_query.js.map +1 -0
- package/dist/tools/deploy.d.ts +127 -0
- package/dist/tools/deploy.d.ts.map +1 -0
- package/dist/tools/deploy.js +201 -0
- package/dist/tools/deploy.js.map +1 -0
- package/dist/tools/disconnect.d.ts +46 -0
- package/dist/tools/disconnect.d.ts.map +1 -0
- package/dist/tools/disconnect.js +77 -0
- package/dist/tools/disconnect.js.map +1 -0
- package/dist/tools/exec.d.ts +69 -0
- package/dist/tools/exec.d.ts.map +1 -0
- package/dist/tools/exec.js +188 -0
- package/dist/tools/exec.js.map +1 -0
- package/dist/tools/group_exec.d.ts +80 -0
- package/dist/tools/group_exec.d.ts.map +1 -0
- package/dist/tools/group_exec.js +150 -0
- package/dist/tools/group_exec.js.map +1 -0
- package/dist/tools/health_check.d.ts +38 -0
- package/dist/tools/health_check.d.ts.map +1 -0
- package/dist/tools/health_check.js +161 -0
- package/dist/tools/health_check.js.map +1 -0
- package/dist/tools/host_security.d.ts +52 -0
- package/dist/tools/host_security.d.ts.map +1 -0
- package/dist/tools/host_security.js +127 -0
- package/dist/tools/host_security.js.map +1 -0
- package/dist/tools/index.d.ts +24 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +24 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/interrupt.d.ts +47 -0
- package/dist/tools/interrupt.d.ts.map +1 -0
- package/dist/tools/interrupt.js +77 -0
- package/dist/tools/interrupt.js.map +1 -0
- package/dist/tools/list_hosts.d.ts +15 -0
- package/dist/tools/list_hosts.d.ts.map +1 -0
- package/dist/tools/list_hosts.js +18 -0
- package/dist/tools/list_hosts.js.map +1 -0
- package/dist/tools/list_sessions.d.ts +16 -0
- package/dist/tools/list_sessions.d.ts.map +1 -0
- package/dist/tools/list_sessions.js +20 -0
- package/dist/tools/list_sessions.js.map +1 -0
- package/dist/tools/read_output.d.ts +46 -0
- package/dist/tools/read_output.d.ts.map +1 -0
- package/dist/tools/read_output.js +73 -0
- package/dist/tools/read_output.js.map +1 -0
- package/dist/tools/reconnect_to_tmux.d.ts +53 -0
- package/dist/tools/reconnect_to_tmux.d.ts.map +1 -0
- package/dist/tools/reconnect_to_tmux.js +199 -0
- package/dist/tools/reconnect_to_tmux.js.map +1 -0
- package/dist/tools/send_input.d.ts +45 -0
- package/dist/tools/send_input.d.ts.map +1 -0
- package/dist/tools/send_input.js +83 -0
- package/dist/tools/send_input.js.map +1 -0
- package/dist/tools/sftp_download.d.ts +52 -0
- package/dist/tools/sftp_download.d.ts.map +1 -0
- package/dist/tools/sftp_download.js +90 -0
- package/dist/tools/sftp_download.js.map +1 -0
- package/dist/tools/sftp_list.d.ts +46 -0
- package/dist/tools/sftp_list.d.ts.map +1 -0
- package/dist/tools/sftp_list.js +93 -0
- package/dist/tools/sftp_list.js.map +1 -0
- package/dist/tools/sftp_upload.d.ts +52 -0
- package/dist/tools/sftp_upload.d.ts.map +1 -0
- package/dist/tools/sftp_upload.js +98 -0
- package/dist/tools/sftp_upload.js.map +1 -0
- package/dist/tools/ssh_tunnel.d.ts +116 -0
- package/dist/tools/ssh_tunnel.d.ts.map +1 -0
- package/dist/tools/ssh_tunnel.js +282 -0
- package/dist/tools/ssh_tunnel.js.map +1 -0
- package/dist/tools/sync.d.ts +71 -0
- package/dist/tools/sync.d.ts.map +1 -0
- package/dist/tools/sync.js +310 -0
- package/dist/tools/sync.js.map +1 -0
- package/dist/tools/tail_log.d.ts +61 -0
- package/dist/tools/tail_log.d.ts.map +1 -0
- package/dist/tools/tail_log.js +111 -0
- package/dist/tools/tail_log.js.map +1 -0
- package/dist/tools/tools_config.d.ts +34 -0
- package/dist/tools/tools_config.d.ts.map +1 -0
- package/dist/tools/tools_config.js +98 -0
- package/dist/tools/tools_config.js.map +1 -0
- package/dist/types/index.d.ts +21 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +2 -0
- package/dist/types/index.js.map +1 -0
- package/dist/utils/ansi.d.ts +2 -0
- package/dist/utils/ansi.d.ts.map +1 -0
- package/dist/utils/ansi.js +7 -0
- package/dist/utils/ansi.js.map +1 -0
- package/dist/utils/logger.d.ts +3 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +8 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/utils/security.d.ts +7 -0
- package/dist/utils/security.d.ts.map +1 -0
- package/dist/utils/security.js +58 -0
- package/dist/utils/security.js.map +1 -0
- package/dist/utils/ssh.d.ts +4 -0
- package/dist/utils/ssh.d.ts.map +1 -0
- package/dist/utils/ssh.js +29 -0
- package/dist/utils/ssh.js.map +1 -0
- package/dist/utils/sshConfig.d.ts +4 -0
- package/dist/utils/sshConfig.d.ts.map +1 -0
- package/dist/utils/sshConfig.js +85 -0
- package/dist/utils/sshConfig.js.map +1 -0
- package/dist/utils/validation.d.ts +4 -0
- package/dist/utils/validation.d.ts.map +1 -0
- package/dist/utils/validation.js +12 -0
- package/dist/utils/validation.js.map +1 -0
- package/docs/SECURITY.md +213 -0
- package/docs/TOOLS.md +425 -0
- package/keygen.bat +325 -0
- package/package.json +48 -0
- package/test_check.bat +9 -0
- package/test_delayed.bat +12 -0
- package/vitest.config.ts +14 -0
package/docs/TOOLS.md
ADDED
|
@@ -0,0 +1,425 @@
|
|
|
1
|
+
# Tool Reference
|
|
2
|
+
|
|
3
|
+
Complete reference for all 25 MCP tools.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Session Management
|
|
8
|
+
|
|
9
|
+
### `list_hosts`
|
|
10
|
+
|
|
11
|
+
List all SSH host aliases from `~/.ssh/config`. Wildcard entries are ignored.
|
|
12
|
+
|
|
13
|
+
| Parameter | Type | Required |
|
|
14
|
+
|---|---|---|
|
|
15
|
+
| _(none)_ | — | — |
|
|
16
|
+
|
|
17
|
+
**Returns:** Array of host alias strings.
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
### `connect`
|
|
22
|
+
|
|
23
|
+
Connect to a remote host via SSH and create a persistent tmux-backed shell session. Supports bash and zsh only. Session survives MCP restarts and SSH drops.
|
|
24
|
+
|
|
25
|
+
| Parameter | Type | Required | Description |
|
|
26
|
+
|---|---|---|---|
|
|
27
|
+
| `host` | string | **Yes** | SSH config host alias |
|
|
28
|
+
| `proxy_jump` | string | No | Bastion host alias for proxy jump |
|
|
29
|
+
|
|
30
|
+
**Returns:** `{ session_id, host, tmux_session, shell }`
|
|
31
|
+
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
### `reconnect_to_tmux`
|
|
35
|
+
|
|
36
|
+
Reconnect to an existing tmux session on a remote host. Use after MCP restart or SSH disconnection to recover a session.
|
|
37
|
+
|
|
38
|
+
| Parameter | Type | Required | Description |
|
|
39
|
+
|---|---|---|---|
|
|
40
|
+
| `host` | string | **Yes** | SSH config host alias |
|
|
41
|
+
| `tmux_session` | string | **Yes** | Tmux session name (e.g., `mcp_prod_abc12345`) |
|
|
42
|
+
| `proxy_jump` | string | No | Bastion host alias |
|
|
43
|
+
|
|
44
|
+
**Returns:** `{ session_id, host, tmux_session }`
|
|
45
|
+
|
|
46
|
+
---
|
|
47
|
+
|
|
48
|
+
### `exec`
|
|
49
|
+
|
|
50
|
+
Execute a command in a tmux session with prompt stabilization. Sends the command, waits for the deterministic PS1 prompt to appear, then captures output.
|
|
51
|
+
|
|
52
|
+
| Parameter | Type | Required | Description |
|
|
53
|
+
|---|---|---|---|
|
|
54
|
+
| `session_id` | string | **Yes** | Session ID from connect |
|
|
55
|
+
| `command` | string | **Yes** | Shell command to execute |
|
|
56
|
+
| `wait_ms` | number | No | Min wait before prompt detection (default: 200, max: 60000) |
|
|
57
|
+
| `max_wait_ms` | number | No | Max total wait for prompt (default: 10000, max: 300000) |
|
|
58
|
+
| `lines` | number | No | Max output lines to return (default: 200, max: 5000) |
|
|
59
|
+
|
|
60
|
+
**Returns:** `{ output, command }`
|
|
61
|
+
|
|
62
|
+
**Blocked when:** Read-only mode, per-host read-only, command in denylist.
|
|
63
|
+
|
|
64
|
+
---
|
|
65
|
+
|
|
66
|
+
### `send_input`
|
|
67
|
+
|
|
68
|
+
Send raw input into a tmux session. Preserves shell state (cwd, env, history). Non-blocking — no prompt wait.
|
|
69
|
+
|
|
70
|
+
| Parameter | Type | Required | Description |
|
|
71
|
+
|---|---|---|---|
|
|
72
|
+
| `session_id` | string | **Yes** | Session ID |
|
|
73
|
+
| `input` | string | **Yes** | Raw input text |
|
|
74
|
+
|
|
75
|
+
**Blocked when:** Read-only mode, per-host read-only.
|
|
76
|
+
|
|
77
|
+
---
|
|
78
|
+
|
|
79
|
+
### `read_output`
|
|
80
|
+
|
|
81
|
+
Capture recent terminal output from a tmux session pane.
|
|
82
|
+
|
|
83
|
+
| Parameter | Type | Required | Description |
|
|
84
|
+
|---|---|---|---|
|
|
85
|
+
| `session_id` | string | **Yes** | Session ID |
|
|
86
|
+
| `lines` | number | No | Number of lines to capture (default: 50) |
|
|
87
|
+
|
|
88
|
+
**Always allowed** (read-only operation).
|
|
89
|
+
|
|
90
|
+
---
|
|
91
|
+
|
|
92
|
+
### `interrupt`
|
|
93
|
+
|
|
94
|
+
Send an interrupt or termination signal to the active process in a tmux session.
|
|
95
|
+
|
|
96
|
+
| Parameter | Type | Required | Description |
|
|
97
|
+
|---|---|---|---|
|
|
98
|
+
| `session_id` | string | **Yes** | Session ID |
|
|
99
|
+
| `signal` | string | No | `SIGINT` (Ctrl-C, default) or `SIGTERM` (Ctrl-D) |
|
|
100
|
+
|
|
101
|
+
**Always allowed.**
|
|
102
|
+
|
|
103
|
+
---
|
|
104
|
+
|
|
105
|
+
### `disconnect`
|
|
106
|
+
|
|
107
|
+
Close a session. Optionally kills the remote tmux session or leaves it running for later reconnection.
|
|
108
|
+
|
|
109
|
+
| Parameter | Type | Required | Description |
|
|
110
|
+
|---|---|---|---|
|
|
111
|
+
| `session_id` | string | **Yes** | Session ID |
|
|
112
|
+
| `preserve_tmux` | boolean | No | Keep tmux session alive on remote (default: false) |
|
|
113
|
+
|
|
114
|
+
**Always allowed.**
|
|
115
|
+
|
|
116
|
+
---
|
|
117
|
+
|
|
118
|
+
### `list_sessions`
|
|
119
|
+
|
|
120
|
+
List all active MCP SSH sessions with host, connection time, last activity, and tmux session name.
|
|
121
|
+
|
|
122
|
+
| Parameter | Type | Required |
|
|
123
|
+
|---|---|---|
|
|
124
|
+
| _(none)_ | — | — |
|
|
125
|
+
|
|
126
|
+
**Returns:** Array of `{ id, host, tmuxSession, connectedAt, lastActivity, shell }`.
|
|
127
|
+
|
|
128
|
+
---
|
|
129
|
+
|
|
130
|
+
## File Transfer
|
|
131
|
+
|
|
132
|
+
### `sftp_upload`
|
|
133
|
+
|
|
134
|
+
Upload a local file to a remote host via SFTP.
|
|
135
|
+
|
|
136
|
+
| Parameter | Type | Required | Description |
|
|
137
|
+
|---|---|---|---|
|
|
138
|
+
| `session_id` | string | **Yes** | Session ID |
|
|
139
|
+
| `local_path` | string | **Yes** | Absolute local file path |
|
|
140
|
+
| `remote_path` | string | **Yes** | Absolute remote destination path |
|
|
141
|
+
|
|
142
|
+
**Blocked when:** Read-only mode, per-host read-only.
|
|
143
|
+
|
|
144
|
+
---
|
|
145
|
+
|
|
146
|
+
### `sftp_download`
|
|
147
|
+
|
|
148
|
+
Download a file from a remote host via SFTP.
|
|
149
|
+
|
|
150
|
+
| Parameter | Type | Required | Description |
|
|
151
|
+
|---|---|---|---|
|
|
152
|
+
| `session_id` | string | **Yes** | Session ID |
|
|
153
|
+
| `remote_path` | string | **Yes** | Absolute remote file path |
|
|
154
|
+
| `local_path` | string | **Yes** | Absolute local destination path |
|
|
155
|
+
|
|
156
|
+
**Blocked when:** Read-only mode, per-host read-only.
|
|
157
|
+
|
|
158
|
+
---
|
|
159
|
+
|
|
160
|
+
### `sftp_list`
|
|
161
|
+
|
|
162
|
+
List files and directories on a remote host via SFTP.
|
|
163
|
+
|
|
164
|
+
| Parameter | Type | Required | Description |
|
|
165
|
+
|---|---|---|---|
|
|
166
|
+
| `session_id` | string | **Yes** | Session ID |
|
|
167
|
+
| `path` | string | No | Remote path (default: home directory) |
|
|
168
|
+
|
|
169
|
+
**Always allowed** (read-only operation). Returns file/directory listing with name, size, permissions, mtime.
|
|
170
|
+
|
|
171
|
+
---
|
|
172
|
+
|
|
173
|
+
## Health & Monitoring
|
|
174
|
+
|
|
175
|
+
### `connection_status`
|
|
176
|
+
|
|
177
|
+
Check the health of an active session: SSH connection liveness and tmux session existence.
|
|
178
|
+
|
|
179
|
+
| Parameter | Type | Required | Description |
|
|
180
|
+
|---|---|---|---|
|
|
181
|
+
| `session_id` | string | **Yes** | Session ID |
|
|
182
|
+
|
|
183
|
+
**Returns:** `{ alive: boolean, tmux_exists: boolean, tmux_session: string }`
|
|
184
|
+
|
|
185
|
+
**Always allowed.**
|
|
186
|
+
|
|
187
|
+
---
|
|
188
|
+
|
|
189
|
+
### `health_check`
|
|
190
|
+
|
|
191
|
+
Run a system health check via SSH exec channel (non-interactive — does not touch the tmux session). Returns structured system metrics.
|
|
192
|
+
|
|
193
|
+
| Parameter | Type | Required | Description |
|
|
194
|
+
|---|---|---|---|
|
|
195
|
+
| `session_id` | string | **Yes** | Session ID |
|
|
196
|
+
|
|
197
|
+
**Returns:**
|
|
198
|
+
```json
|
|
199
|
+
{
|
|
200
|
+
"host": "prod",
|
|
201
|
+
"cpu": { "model": "Intel...", "cores": 8, "usage": 23.5 },
|
|
202
|
+
"memory": { "total": "16G", "used": "8.2G", "usage": 51.2 },
|
|
203
|
+
"disk": [{ "mount": "/", "total": "100G", "used": "45G", "usage": 45 }],
|
|
204
|
+
"load": { "1m": 0.5, "5m": 0.8, "15m": 1.1 },
|
|
205
|
+
"uptime": "5 days 3 hours"
|
|
206
|
+
}
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
**Always allowed.**
|
|
210
|
+
|
|
211
|
+
---
|
|
212
|
+
|
|
213
|
+
### `tail_log`
|
|
214
|
+
|
|
215
|
+
Read the last N lines of a remote log file via SSH exec channel. Optionally follow (poll) for new output.
|
|
216
|
+
|
|
217
|
+
| Parameter | Type | Required | Description |
|
|
218
|
+
|---|---|---|---|
|
|
219
|
+
| `session_id` | string | **Yes** | Session ID |
|
|
220
|
+
| `file_path` | string | **Yes** | Absolute remote file path |
|
|
221
|
+
| `lines` | number | No | Lines to read (default: 50, max: 5000) |
|
|
222
|
+
| `follow_ms` | number | No | Follow duration in ms (max: 30000) |
|
|
223
|
+
|
|
224
|
+
**Always allowed.** Follow mode polls every 500ms and returns new lines.
|
|
225
|
+
|
|
226
|
+
---
|
|
227
|
+
|
|
228
|
+
## DevOps
|
|
229
|
+
|
|
230
|
+
### `deploy`
|
|
231
|
+
|
|
232
|
+
Deploy files to a remote host. Full pipeline per file:
|
|
233
|
+
|
|
234
|
+
```
|
|
235
|
+
pre_deploy_cmd → backup (.bak) → upload → chmod → chown → post_deploy_cmd → restart_service
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
| Parameter | Type | Required | Description |
|
|
239
|
+
|---|---|---|---|
|
|
240
|
+
| `session_id` | string | **Yes** | Session ID |
|
|
241
|
+
| `files` | array | **Yes** | `[{ local, remote }]` — file mappings |
|
|
242
|
+
| `chmod` | string | No | Permission mode (e.g., `"755"`) |
|
|
243
|
+
| `chown` | string | No | Owner:group (e.g., `"www-data:www-data"`) |
|
|
244
|
+
| `backup` | boolean | No | Create .bak before overwrite (default: true) |
|
|
245
|
+
| `restart_service` | string | No | Service name to restart via systemctl |
|
|
246
|
+
| `pre_deploy_cmd` | string | No | Command to run before deployment |
|
|
247
|
+
| `post_deploy_cmd` | string | No | Command to run after deployment |
|
|
248
|
+
|
|
249
|
+
**Returns:** Per-file result with status and any errors. Errors are isolated per file — one failure doesn't stop others.
|
|
250
|
+
|
|
251
|
+
**Blocked when:** Read-only mode, per-host read-only.
|
|
252
|
+
|
|
253
|
+
---
|
|
254
|
+
|
|
255
|
+
### `backup`
|
|
256
|
+
|
|
257
|
+
Create a compressed tar.gz archive of remote paths and download it locally.
|
|
258
|
+
|
|
259
|
+
| Parameter | Type | Required | Description |
|
|
260
|
+
|---|---|---|---|
|
|
261
|
+
| `session_id` | string | **Yes** | Session ID |
|
|
262
|
+
| `paths` | array | **Yes** | Remote paths to backup (e.g., `["/etc/nginx", "/var/log"]`) |
|
|
263
|
+
| `local_dest` | string | **Yes** | Local directory for the downloaded archive |
|
|
264
|
+
| `exclude` | array | No | Path patterns to exclude |
|
|
265
|
+
| `remove_remote_archive` | boolean | No | Clean up archive on remote after download (default: true) |
|
|
266
|
+
|
|
267
|
+
**Returns:** `{ archive, size, local_path, files_backup }`
|
|
268
|
+
|
|
269
|
+
**Blocked when:** Read-only mode, per-host read-only.
|
|
270
|
+
|
|
271
|
+
---
|
|
272
|
+
|
|
273
|
+
### `sync`
|
|
274
|
+
|
|
275
|
+
Bidirectional rsync-like sync between local and remote directories via SFTP. Compares files by mtime and size, transfers only changed or new files.
|
|
276
|
+
|
|
277
|
+
| Parameter | Type | Required | Description |
|
|
278
|
+
|---|---|---|---|
|
|
279
|
+
| `session_id` | string | **Yes** | Session ID |
|
|
280
|
+
| `local_path` | string | **Yes** | Absolute local directory path |
|
|
281
|
+
| `remote_path` | string | **Yes** | Absolute remote directory path |
|
|
282
|
+
| `direction` | string | No | `"upload"`, `"download"`, or `"bidirectional"` (default) |
|
|
283
|
+
| `dry_run` | boolean | No | Preview changes without applying (default: false) |
|
|
284
|
+
| `max_depth` | number | No | Max recursion depth (default: 10) |
|
|
285
|
+
|
|
286
|
+
**Returns:** `{ files_uploaded, files_downloaded, skipped, errors }`
|
|
287
|
+
|
|
288
|
+
**Blocked when:** Read-only mode, per-host read-only.
|
|
289
|
+
|
|
290
|
+
---
|
|
291
|
+
|
|
292
|
+
## SSH Tunnels
|
|
293
|
+
|
|
294
|
+
### `ssh_tunnel_open`
|
|
295
|
+
|
|
296
|
+
Open an SSH tunnel (local port forwarding or SOCKS5 proxy). Creates a dedicated SSH connection separate from the session.
|
|
297
|
+
|
|
298
|
+
| Parameter | Type | Required | Description |
|
|
299
|
+
|---|---|---|---|
|
|
300
|
+
| `session_id` | string | **Yes** | Session ID |
|
|
301
|
+
| `type` | string | **Yes** | `"local"` or `"socks5"` |
|
|
302
|
+
| `local_port` | number | **Yes** | Local port to bind |
|
|
303
|
+
| `remote_host` | string | **Yes** | Remote target host |
|
|
304
|
+
| `remote_port` | number | **Yes** | Remote target port |
|
|
305
|
+
|
|
306
|
+
**Returns:** `{ tunnel_id, type, local_port, remote_host, remote_port }`
|
|
307
|
+
|
|
308
|
+
**SOCKS5:** Implements no-auth CONNECT protocol. Sufficient for AI agent use.
|
|
309
|
+
|
|
310
|
+
**Blocked when:** Read-only mode, per-host read-only.
|
|
311
|
+
|
|
312
|
+
---
|
|
313
|
+
|
|
314
|
+
### `ssh_tunnel_list`
|
|
315
|
+
|
|
316
|
+
List all active SSH tunnels.
|
|
317
|
+
|
|
318
|
+
| Parameter | Type | Required |
|
|
319
|
+
|---|---|---|
|
|
320
|
+
| _(none)_ | — | — |
|
|
321
|
+
|
|
322
|
+
**Returns:** Array of `{ tunnel_id, type, local_port, remote_host, remote_port }`.
|
|
323
|
+
|
|
324
|
+
**Always allowed.**
|
|
325
|
+
|
|
326
|
+
---
|
|
327
|
+
|
|
328
|
+
### `ssh_tunnel_close`
|
|
329
|
+
|
|
330
|
+
Close and clean up an active SSH tunnel. Frees the local port and disconnects the dedicated SSH connection.
|
|
331
|
+
|
|
332
|
+
| Parameter | Type | Required | Description |
|
|
333
|
+
|---|---|---|---|
|
|
334
|
+
| `tunnel_id` | string | **Yes** | Tunnel ID from `ssh_tunnel_open` |
|
|
335
|
+
|
|
336
|
+
**Always allowed.**
|
|
337
|
+
|
|
338
|
+
---
|
|
339
|
+
|
|
340
|
+
## Multi-Session & Database
|
|
341
|
+
|
|
342
|
+
### `group_exec`
|
|
343
|
+
|
|
344
|
+
Execute the same command across multiple tmux sessions simultaneously (parallel) or one-by-one (sequential). Each session runs independently with its own prompt stabilization.
|
|
345
|
+
|
|
346
|
+
| Parameter | Type | Required | Description |
|
|
347
|
+
|---|---|---|---|
|
|
348
|
+
| `session_ids` | array | **Yes** | Up to 20 session IDs |
|
|
349
|
+
| `command` | string | **Yes** | Shell command to execute |
|
|
350
|
+
| `wait_ms` | number | No | Min wait before prompt detection (default: 200) |
|
|
351
|
+
| `max_wait_ms` | number | No | Max total wait (default: 10000) |
|
|
352
|
+
| `lines` | number | No | Max output lines per session (default: 200) |
|
|
353
|
+
| `parallel` | boolean | No | Run all at once (default: true) |
|
|
354
|
+
|
|
355
|
+
**Returns:** Array of `{ session_id, host, status, output, error? }`.
|
|
356
|
+
|
|
357
|
+
**Blocked when:** Read-only mode (per-session check — read-only hosts are skipped with error).
|
|
358
|
+
|
|
359
|
+
---
|
|
360
|
+
|
|
361
|
+
### `db_query`
|
|
362
|
+
|
|
363
|
+
Execute a read-only database query on a remote host via SSH exec channel. Supports MySQL, PostgreSQL, and MongoDB. Returns structured JSON rows.
|
|
364
|
+
|
|
365
|
+
| Parameter | Type | Required | Description |
|
|
366
|
+
|---|---|---|---|
|
|
367
|
+
| `session_id` | string | **Yes** | Session ID |
|
|
368
|
+
| `type` | string | **Yes** | `"mysql"`, `"postgres"`, or `"mongodb"` |
|
|
369
|
+
| `database` | string | **Yes** | Database name |
|
|
370
|
+
| `query` | string | **Yes** | SQL query or Mongo find query (JSON string) |
|
|
371
|
+
| `db_user` | string | No | Database user (falls back to session user) |
|
|
372
|
+
| `db_password` | string | No | Database password |
|
|
373
|
+
| `db_host` | string | No | Database host (default: localhost) |
|
|
374
|
+
| `db_port` | number | No | Database port (default: MySQL 3306, PG 5432, Mongo 27017) |
|
|
375
|
+
| `collection` | string | No | MongoDB collection name |
|
|
376
|
+
| `timeout_ms` | number | No | Query timeout (default: 30000, max: 120000) |
|
|
377
|
+
|
|
378
|
+
**Returns:** Array of JSON row objects.
|
|
379
|
+
|
|
380
|
+
**SQL enforcement:** Only `SELECT`, `SHOW`, `EXPLAIN`, `DESCRIBE`, and `WITH` queries allowed. All mutation keywords rejected.
|
|
381
|
+
|
|
382
|
+
**MongoDB enforcement:** Only `find`, `aggregate`, `countDocuments`, `estimatedDocumentCount`, `distinct`, `listCollections` allowed.
|
|
383
|
+
|
|
384
|
+
**Blocked when:** Read-only mode, per-host read-only.
|
|
385
|
+
|
|
386
|
+
---
|
|
387
|
+
|
|
388
|
+
## Security Management
|
|
389
|
+
|
|
390
|
+
### `tools_config`
|
|
391
|
+
|
|
392
|
+
Manage tool enable/disable state. Disable unused tools to reduce token overhead in the MCP tool list. Config persists at `~/.dynamic-ssh-mcp/tools.json`.
|
|
393
|
+
|
|
394
|
+
| Parameter | Type | Required | Description |
|
|
395
|
+
|---|---|---|---|
|
|
396
|
+
| `action` | string | **Yes** | `"list"`, `"enable"`, `"disable"`, `"reset"` |
|
|
397
|
+
| `tool` | string | Conditional | Tool name (required for enable/disable) |
|
|
398
|
+
|
|
399
|
+
**Self-protection:** `tools_config` cannot be disabled — it always remains enabled.
|
|
400
|
+
|
|
401
|
+
**Always allowed.**
|
|
402
|
+
|
|
403
|
+
---
|
|
404
|
+
|
|
405
|
+
### `host_security`
|
|
406
|
+
|
|
407
|
+
Manage per-host security settings: read-only mode, command allowlist, and command denylist. Settings persist at `~/.dynamic-ssh-mcp/host_security.json` and override global `MCP_SSH_READONLY` per host.
|
|
408
|
+
|
|
409
|
+
| Parameter | Type | Required | Description |
|
|
410
|
+
|---|---|---|---|
|
|
411
|
+
| `action` | string | **Yes** | `"get"`, `"set"`, `"remove"` |
|
|
412
|
+
| `host` | string | Conditional | Host alias (required for set/remove) |
|
|
413
|
+
| `readonly` | boolean | No | Force read-only for this host (set only) |
|
|
414
|
+
| `allow_commands` | array | No | Command allowlist patterns (set only) |
|
|
415
|
+
| `deny_commands` | array | No | Command denylist patterns (set only) |
|
|
416
|
+
|
|
417
|
+
**Examples:**
|
|
418
|
+
```
|
|
419
|
+
host_security action=get host=prod
|
|
420
|
+
host_security action=set host=prod readonly=true
|
|
421
|
+
host_security action=set host=staging deny_commands=["shutdown", "reboot"]
|
|
422
|
+
host_security action=remove host=prod
|
|
423
|
+
```
|
|
424
|
+
|
|
425
|
+
**Always allowed.**
|