mcp-ssh-manager 3.0.0 → 3.1.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/.claude/settings.local.json +10 -1
- package/CHANGELOG.md +63 -0
- package/CLAUDE.md +16 -0
- package/README.md +117 -4
- package/cli/commands/server.sh +27 -5
- package/cli/commands/tools.sh +603 -0
- package/cli/lib/config.sh +104 -14
- package/cli/lib/menu.sh +124 -0
- package/cli/ssh-manager +17 -7
- package/context-test.txt +1 -0
- package/docs/SOCIAL_MEDIA_ANNOUNCEMENT.md +385 -0
- package/docs/TOOL_MANAGEMENT.md +473 -0
- package/docs/TROUBLESHOOTING.md +143 -0
- package/package.json +5 -4
- package/scripts/validate.sh +12 -0
- package/src/backup-manager.js +12 -12
- package/src/command-aliases.js +16 -16
- package/src/config-loader.js +1 -1
- package/src/config.js +70 -0
- package/src/database-manager.js +38 -40
- package/src/deploy-helper.js +12 -13
- package/src/health-monitor.js +26 -26
- package/src/hooks-system.js +43 -43
- package/src/index.js +899 -841
- package/src/logger.js +53 -53
- package/src/profile-loader.js +14 -14
- package/src/server-aliases.js +11 -11
- package/src/server-groups.js +98 -97
- package/src/session-manager.js +59 -58
- package/src/ssh-key-manager.js +4 -3
- package/src/ssh-manager.js +46 -24
- package/src/tool-config-manager.js +434 -0
- package/src/tool-registry.js +196 -0
- package/src/tunnel-manager.js +98 -98
|
@@ -0,0 +1,473 @@
|
|
|
1
|
+
# Tool Management Guide
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
MCP SSH Manager provides **37 tools** organized into **6 functional groups**. You can enable or disable tool groups to customize your experience and reduce context usage in Claude Code.
|
|
6
|
+
|
|
7
|
+
### Why Manage Tools?
|
|
8
|
+
|
|
9
|
+
- **Reduce Context Usage**: By default, all 37 tools consume ~43.5k tokens in Claude Code. Minimal mode uses only ~3.5k tokens (92% reduction)
|
|
10
|
+
- **Fewer Approval Prompts**: Only enabled tools require approval in Claude Code
|
|
11
|
+
- **Faster Loading**: Less tools mean faster MCP server startup
|
|
12
|
+
- **Cleaner Interface**: Only see the tools you actually use
|
|
13
|
+
|
|
14
|
+
## Quick Start
|
|
15
|
+
|
|
16
|
+
### View Current Configuration
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
ssh-manager tools list
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
### Interactive Configuration Wizard
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
ssh-manager tools configure
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Choose from three modes:
|
|
29
|
+
1. **All tools** (37 tools) - Full feature set, recommended for most users
|
|
30
|
+
2. **Minimal** (5 tools) - Only core operations, maximum efficiency
|
|
31
|
+
3. **Custom** - Pick which groups to enable
|
|
32
|
+
|
|
33
|
+
### Enable/Disable Specific Groups
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
# Enable a group
|
|
37
|
+
ssh-manager tools enable monitoring
|
|
38
|
+
|
|
39
|
+
# Disable a group
|
|
40
|
+
ssh-manager tools disable backup
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### Reset to Defaults
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
ssh-manager tools reset
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### Export Auto-Approval Configuration
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
ssh-manager tools export-claude
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
This generates configuration for Claude Code to auto-approve your enabled tools.
|
|
56
|
+
|
|
57
|
+
## Tool Groups
|
|
58
|
+
|
|
59
|
+
### Core (5 tools) ✨ Always Enabled
|
|
60
|
+
|
|
61
|
+
Essential SSH operations for basic functionality:
|
|
62
|
+
|
|
63
|
+
- `ssh_list_servers` - List all configured SSH servers
|
|
64
|
+
- `ssh_execute` - Execute commands on remote servers
|
|
65
|
+
- `ssh_upload` - Upload files to remote servers
|
|
66
|
+
- `ssh_download` - Download files from remote servers
|
|
67
|
+
- `ssh_sync` - Bidirectional file synchronization with rsync
|
|
68
|
+
|
|
69
|
+
**When to use**: Always enabled. These are the minimum tools needed for SSH operations.
|
|
70
|
+
|
|
71
|
+
### Sessions (4 tools)
|
|
72
|
+
|
|
73
|
+
Persistent SSH session management:
|
|
74
|
+
|
|
75
|
+
- `ssh_session_start` - Start a persistent SSH session
|
|
76
|
+
- `ssh_session_send` - Send command to an existing session
|
|
77
|
+
- `ssh_session_list` - List all active sessions
|
|
78
|
+
- `ssh_session_close` - Close a persistent session
|
|
79
|
+
|
|
80
|
+
**When to use**: Enable if you need to maintain state across multiple commands or run interactive sessions.
|
|
81
|
+
|
|
82
|
+
### Monitoring (6 tools)
|
|
83
|
+
|
|
84
|
+
System health checks and monitoring:
|
|
85
|
+
|
|
86
|
+
- `ssh_health_check` - Comprehensive server health check (CPU, RAM, disk, network)
|
|
87
|
+
- `ssh_service_status` - Check status of services (nginx, mysql, docker, etc.)
|
|
88
|
+
- `ssh_process_manager` - List, monitor, or kill processes
|
|
89
|
+
- `ssh_monitor` - Real-time system resource monitoring
|
|
90
|
+
- `ssh_tail` - Tail log files in real-time
|
|
91
|
+
- `ssh_alert_setup` - Configure health monitoring alerts and thresholds
|
|
92
|
+
|
|
93
|
+
**When to use**: Enable for server administration, DevOps work, or troubleshooting.
|
|
94
|
+
|
|
95
|
+
### Backup (4 tools)
|
|
96
|
+
|
|
97
|
+
Automated backup and restore:
|
|
98
|
+
|
|
99
|
+
- `ssh_backup_create` - Create database or file backups
|
|
100
|
+
- `ssh_backup_list` - List all available backups
|
|
101
|
+
- `ssh_backup_restore` - Restore from previous backups
|
|
102
|
+
- `ssh_backup_schedule` - Schedule automatic backups using cron
|
|
103
|
+
|
|
104
|
+
**Supports**: MySQL, PostgreSQL, MongoDB, files
|
|
105
|
+
|
|
106
|
+
**When to use**: Enable for database administration or when managing production servers.
|
|
107
|
+
|
|
108
|
+
### Database (4 tools)
|
|
109
|
+
|
|
110
|
+
Database operations:
|
|
111
|
+
|
|
112
|
+
- `ssh_db_dump` - Create database dumps
|
|
113
|
+
- `ssh_db_import` - Import SQL dumps or restore databases
|
|
114
|
+
- `ssh_db_list` - List databases or tables/collections
|
|
115
|
+
- `ssh_db_query` - Execute read-only SELECT queries
|
|
116
|
+
|
|
117
|
+
**Supports**: MySQL, PostgreSQL, MongoDB
|
|
118
|
+
|
|
119
|
+
**When to use**: Enable for database administration or data migration tasks.
|
|
120
|
+
|
|
121
|
+
### Advanced (14 tools)
|
|
122
|
+
|
|
123
|
+
Advanced features for power users:
|
|
124
|
+
|
|
125
|
+
- `ssh_deploy` - Smart deployment with automatic permission handling
|
|
126
|
+
- `ssh_execute_sudo` - Execute commands with sudo privileges
|
|
127
|
+
- `ssh_alias` - Manage server aliases (shortcuts)
|
|
128
|
+
- `ssh_command_alias` - Manage command aliases
|
|
129
|
+
- `ssh_hooks` - Automation hooks system
|
|
130
|
+
- `ssh_profile` - Profile management
|
|
131
|
+
- `ssh_connection_status` - Connection management and pooling
|
|
132
|
+
- `ssh_tunnel_create` - Create SSH tunnels (local/remote/SOCKS)
|
|
133
|
+
- `ssh_tunnel_list` - List active tunnels
|
|
134
|
+
- `ssh_tunnel_close` - Close SSH tunnels
|
|
135
|
+
- `ssh_key_manage` - SSH host key management
|
|
136
|
+
- `ssh_execute_group` - Execute commands on server groups
|
|
137
|
+
- `ssh_group_manage` - Manage server groups
|
|
138
|
+
- `ssh_history` - View command history
|
|
139
|
+
|
|
140
|
+
**When to use**: Enable for advanced automation, deployment workflows, or managing multiple servers.
|
|
141
|
+
|
|
142
|
+
## Configuration Modes
|
|
143
|
+
|
|
144
|
+
### All Tools Mode
|
|
145
|
+
|
|
146
|
+
```json
|
|
147
|
+
{
|
|
148
|
+
"mode": "all",
|
|
149
|
+
"groups": {
|
|
150
|
+
"core": { "enabled": true },
|
|
151
|
+
"sessions": { "enabled": true },
|
|
152
|
+
"monitoring": { "enabled": true },
|
|
153
|
+
"backup": { "enabled": true },
|
|
154
|
+
"database": { "enabled": true },
|
|
155
|
+
"advanced": { "enabled": true }
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
- **Enabled tools**: 37/37
|
|
161
|
+
- **Context usage**: ~43.5k tokens
|
|
162
|
+
- **Best for**: Users who need all features
|
|
163
|
+
|
|
164
|
+
### Minimal Mode
|
|
165
|
+
|
|
166
|
+
```json
|
|
167
|
+
{
|
|
168
|
+
"mode": "minimal",
|
|
169
|
+
"groups": {
|
|
170
|
+
"core": { "enabled": true },
|
|
171
|
+
"sessions": { "enabled": false },
|
|
172
|
+
"monitoring": { "enabled": false },
|
|
173
|
+
"backup": { "enabled": false },
|
|
174
|
+
"database": { "enabled": false },
|
|
175
|
+
"advanced": { "enabled": false }
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
- **Enabled tools**: 5/37
|
|
181
|
+
- **Context usage**: ~3.5k tokens
|
|
182
|
+
- **Context savings**: 92% reduction (~40k tokens saved)
|
|
183
|
+
- **Best for**: Simple SSH operations, file transfers, basic command execution
|
|
184
|
+
|
|
185
|
+
### Custom Mode
|
|
186
|
+
|
|
187
|
+
```json
|
|
188
|
+
{
|
|
189
|
+
"mode": "custom",
|
|
190
|
+
"groups": {
|
|
191
|
+
"core": { "enabled": true },
|
|
192
|
+
"sessions": { "enabled": true },
|
|
193
|
+
"monitoring": { "enabled": true },
|
|
194
|
+
"backup": { "enabled": false },
|
|
195
|
+
"database": { "enabled": false },
|
|
196
|
+
"advanced": { "enabled": false }
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
- **Enabled tools**: Custom (5-37 tools)
|
|
202
|
+
- **Context usage**: Varies based on selection
|
|
203
|
+
- **Best for**: Tailoring to specific workflows
|
|
204
|
+
|
|
205
|
+
## Configuration File
|
|
206
|
+
|
|
207
|
+
### Location
|
|
208
|
+
|
|
209
|
+
- **User-global**: `~/.ssh-manager/tools-config.json`
|
|
210
|
+
|
|
211
|
+
### Structure
|
|
212
|
+
|
|
213
|
+
```json
|
|
214
|
+
{
|
|
215
|
+
"version": "1.0",
|
|
216
|
+
"mode": "minimal|all|custom",
|
|
217
|
+
"groups": {
|
|
218
|
+
"core": { "enabled": true },
|
|
219
|
+
"sessions": { "enabled": false },
|
|
220
|
+
"monitoring": { "enabled": false },
|
|
221
|
+
"backup": { "enabled": false },
|
|
222
|
+
"database": { "enabled": false },
|
|
223
|
+
"advanced": { "enabled": false }
|
|
224
|
+
},
|
|
225
|
+
"tools": {
|
|
226
|
+
"ssh_session_start": true // Individual tool override
|
|
227
|
+
},
|
|
228
|
+
"_comment": "Tool configuration for MCP SSH Manager"
|
|
229
|
+
}
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
### Individual Tool Overrides
|
|
233
|
+
|
|
234
|
+
You can override group settings for specific tools:
|
|
235
|
+
|
|
236
|
+
```json
|
|
237
|
+
{
|
|
238
|
+
"mode": "minimal",
|
|
239
|
+
"groups": {
|
|
240
|
+
"sessions": { "enabled": false }
|
|
241
|
+
},
|
|
242
|
+
"tools": {
|
|
243
|
+
"ssh_session_start": true // Enable this tool despite group being disabled
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
## Use Cases
|
|
249
|
+
|
|
250
|
+
### Scenario 1: Web Developer (Basic SSH)
|
|
251
|
+
|
|
252
|
+
**Need**: Upload files, run build commands, restart services
|
|
253
|
+
|
|
254
|
+
**Recommended**: Minimal mode + monitoring
|
|
255
|
+
|
|
256
|
+
```bash
|
|
257
|
+
ssh-manager tools configure # Choose "2) Minimal"
|
|
258
|
+
ssh-manager tools enable monitoring
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
**Result**: 11 tools (5 core + 6 monitoring) = ~7k tokens
|
|
262
|
+
|
|
263
|
+
### Scenario 2: DevOps Engineer
|
|
264
|
+
|
|
265
|
+
**Need**: Full server management, monitoring, backups
|
|
266
|
+
|
|
267
|
+
**Recommended**: All tools mode
|
|
268
|
+
|
|
269
|
+
```bash
|
|
270
|
+
ssh-manager tools configure # Choose "1) All tools"
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
**Result**: 37 tools = ~43.5k tokens
|
|
274
|
+
|
|
275
|
+
### Scenario 3: Database Administrator
|
|
276
|
+
|
|
277
|
+
**Need**: Database operations, backups, monitoring
|
|
278
|
+
|
|
279
|
+
**Recommended**: Custom mode
|
|
280
|
+
|
|
281
|
+
```bash
|
|
282
|
+
ssh-manager tools configure # Choose "3) Custom"
|
|
283
|
+
# Enable: monitoring, backup, database
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
**Result**: 19 tools (5 core + 6 monitoring + 4 backup + 4 database) = ~15k tokens
|
|
287
|
+
|
|
288
|
+
### Scenario 4: Security-Conscious User
|
|
289
|
+
|
|
290
|
+
**Need**: Minimal attack surface, only essential tools
|
|
291
|
+
|
|
292
|
+
**Recommended**: Minimal mode only
|
|
293
|
+
|
|
294
|
+
```bash
|
|
295
|
+
ssh-manager tools configure # Choose "2) Minimal"
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
**Result**: 5 tools = ~3.5k tokens (minimum possible)
|
|
299
|
+
|
|
300
|
+
## Claude Code Integration
|
|
301
|
+
|
|
302
|
+
### Auto-Approval Configuration
|
|
303
|
+
|
|
304
|
+
After configuring your tools, export the auto-approval configuration:
|
|
305
|
+
|
|
306
|
+
```bash
|
|
307
|
+
ssh-manager tools export-claude
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
This generates a JSON snippet like:
|
|
311
|
+
|
|
312
|
+
```json
|
|
313
|
+
{
|
|
314
|
+
"autoApprove": {
|
|
315
|
+
"tools": [
|
|
316
|
+
"mcp__ssh-manager__ssh_list_servers",
|
|
317
|
+
"mcp__ssh-manager__ssh_execute",
|
|
318
|
+
"mcp__ssh-manager__ssh_upload",
|
|
319
|
+
"mcp__ssh-manager__ssh_download",
|
|
320
|
+
"mcp__ssh-manager__ssh_sync"
|
|
321
|
+
]
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
```
|
|
325
|
+
|
|
326
|
+
### Adding to Claude Code Config
|
|
327
|
+
|
|
328
|
+
1. Open `~/.config/claude-code/claude_code_config.json`
|
|
329
|
+
2. Add or merge the `autoApprove` section
|
|
330
|
+
3. Save and restart Claude Code
|
|
331
|
+
|
|
332
|
+
Example complete config:
|
|
333
|
+
|
|
334
|
+
```json
|
|
335
|
+
{
|
|
336
|
+
"mcpServers": {
|
|
337
|
+
"ssh-manager": {
|
|
338
|
+
"command": "node",
|
|
339
|
+
"args": ["/absolute/path/to/mcp-ssh-manager/src/index.js"]
|
|
340
|
+
}
|
|
341
|
+
},
|
|
342
|
+
"autoApprove": {
|
|
343
|
+
"tools": [
|
|
344
|
+
"mcp__ssh-manager__ssh_list_servers",
|
|
345
|
+
"mcp__ssh-manager__ssh_execute",
|
|
346
|
+
"mcp__ssh-manager__ssh_upload",
|
|
347
|
+
"mcp__ssh-manager__ssh_download",
|
|
348
|
+
"mcp__ssh-manager__ssh_sync"
|
|
349
|
+
]
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
```
|
|
353
|
+
|
|
354
|
+
## Troubleshooting
|
|
355
|
+
|
|
356
|
+
### Tools Not Disabled After Configuration
|
|
357
|
+
|
|
358
|
+
**Cause**: MCP server is still running with old configuration
|
|
359
|
+
|
|
360
|
+
**Solution**: Restart Claude Code or run `claude mcp restart`
|
|
361
|
+
|
|
362
|
+
### Config File Not Found
|
|
363
|
+
|
|
364
|
+
**Cause**: No configuration file exists yet
|
|
365
|
+
|
|
366
|
+
**Solution**: Run `ssh-manager tools configure` to create one
|
|
367
|
+
|
|
368
|
+
### Can't Disable Core Group
|
|
369
|
+
|
|
370
|
+
**Cause**: Core tools are required for basic functionality
|
|
371
|
+
|
|
372
|
+
**Solution**: Core group cannot be disabled. Consider minimal mode if you want the absolute minimum tools.
|
|
373
|
+
|
|
374
|
+
### Changes Not Reflected in Claude Code
|
|
375
|
+
|
|
376
|
+
**Cause**: Claude Code caches MCP server configuration
|
|
377
|
+
|
|
378
|
+
**Solution**:
|
|
379
|
+
1. Restart Claude Code
|
|
380
|
+
2. Or use Claude Code's MCP server management commands
|
|
381
|
+
3. Verify with `ssh-manager tools list`
|
|
382
|
+
|
|
383
|
+
## Best Practices
|
|
384
|
+
|
|
385
|
+
### 1. Start with Minimal, Enable as Needed
|
|
386
|
+
|
|
387
|
+
Begin with minimal mode and enable groups as you discover you need them:
|
|
388
|
+
|
|
389
|
+
```bash
|
|
390
|
+
ssh-manager tools configure # Choose minimal
|
|
391
|
+
# ... later when you need monitoring ...
|
|
392
|
+
ssh-manager tools enable monitoring
|
|
393
|
+
```
|
|
394
|
+
|
|
395
|
+
### 2. Use Tool List Regularly
|
|
396
|
+
|
|
397
|
+
Check what's enabled before starting work:
|
|
398
|
+
|
|
399
|
+
```bash
|
|
400
|
+
ssh-manager tools list
|
|
401
|
+
```
|
|
402
|
+
|
|
403
|
+
### 3. Different Configs for Different Projects
|
|
404
|
+
|
|
405
|
+
While MCP SSH Manager uses a single user-global config, you can:
|
|
406
|
+
- Create shell aliases for different profiles
|
|
407
|
+
- Manually switch configs for different projects
|
|
408
|
+
- Use the CLI to quickly enable/disable groups
|
|
409
|
+
|
|
410
|
+
### 4. Export Auto-Approval After Changes
|
|
411
|
+
|
|
412
|
+
Whenever you modify tool configuration, update your Claude Code auto-approval:
|
|
413
|
+
|
|
414
|
+
```bash
|
|
415
|
+
ssh-manager tools enable backup
|
|
416
|
+
ssh-manager tools export-claude
|
|
417
|
+
# Copy the output to claude_code_config.json
|
|
418
|
+
```
|
|
419
|
+
|
|
420
|
+
### 5. Document Your Configuration
|
|
421
|
+
|
|
422
|
+
Add comments to your config file to remember why you enabled specific groups:
|
|
423
|
+
|
|
424
|
+
```json
|
|
425
|
+
{
|
|
426
|
+
"_comment": "Custom config for web development projects. Monitoring enabled for debugging deployment issues. Backup disabled as we use external backup solutions."
|
|
427
|
+
}
|
|
428
|
+
```
|
|
429
|
+
|
|
430
|
+
## FAQ
|
|
431
|
+
|
|
432
|
+
### Q: Will existing users see any changes?
|
|
433
|
+
|
|
434
|
+
**A**: No. If no configuration file exists, all 37 tools are enabled by default (current behavior).
|
|
435
|
+
|
|
436
|
+
### Q: Can I enable individual tools without enabling the whole group?
|
|
437
|
+
|
|
438
|
+
**A**: Yes! Use the `tools` object in the config file for individual overrides.
|
|
439
|
+
|
|
440
|
+
### Q: What happens to new tools in future updates?
|
|
441
|
+
|
|
442
|
+
**A**: New tools default to enabled unless you've explicitly disabled their group.
|
|
443
|
+
|
|
444
|
+
### Q: Can I have different configs for different servers?
|
|
445
|
+
|
|
446
|
+
**A**: Currently, tool configuration is user-global. Server-specific tool configs may be added in a future version.
|
|
447
|
+
|
|
448
|
+
### Q: Does this affect the Node.js API?
|
|
449
|
+
|
|
450
|
+
**A**: Only if you're using the MCP server. Direct use of the Node.js SSH Manager class is unaffected.
|
|
451
|
+
|
|
452
|
+
### Q: How much does minimal mode actually save?
|
|
453
|
+
|
|
454
|
+
**A**: Minimal mode (5 tools) uses ~3.5k tokens vs all tools (37 tools) at ~43.5k tokens. That's a **92% reduction** or **~40k tokens saved**.
|
|
455
|
+
|
|
456
|
+
## Command Reference
|
|
457
|
+
|
|
458
|
+
| Command | Description |
|
|
459
|
+
|---------|-------------|
|
|
460
|
+
| `ssh-manager tools list` | Show all tools and their current status |
|
|
461
|
+
| `ssh-manager tools configure` | Interactive configuration wizard |
|
|
462
|
+
| `ssh-manager tools enable <group>` | Enable a tool group |
|
|
463
|
+
| `ssh-manager tools disable <group>` | Disable a tool group |
|
|
464
|
+
| `ssh-manager tools reset` | Reset to defaults (all tools enabled) |
|
|
465
|
+
| `ssh-manager tools show` | Display raw configuration file |
|
|
466
|
+
| `ssh-manager tools export-claude` | Generate Claude Code auto-approval config |
|
|
467
|
+
|
|
468
|
+
## See Also
|
|
469
|
+
|
|
470
|
+
- [README.md](../README.md) - Main project documentation
|
|
471
|
+
- [CLAUDE.md](../CLAUDE.md) - Instructions for Claude Code AI
|
|
472
|
+
- [Tool Registry Source](../src/tool-registry.js) - Tool group definitions
|
|
473
|
+
- [Config Manager Source](../src/tool-config-manager.js) - Configuration logic
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
# Troubleshooting Guide
|
|
2
|
+
|
|
3
|
+
## Claude Code Crashes / Interruptions
|
|
4
|
+
|
|
5
|
+
### Symptoms
|
|
6
|
+
- Claude Code shows "Interrupted: What should Claude do instead?"
|
|
7
|
+
- MCP tool responses cause Claude to stop working
|
|
8
|
+
- Commands execute successfully but Claude crashes
|
|
9
|
+
|
|
10
|
+
### Root Causes
|
|
11
|
+
|
|
12
|
+
1. **Large Output Responses**
|
|
13
|
+
- Long stdout/stderr outputs overwhelm Claude's context window
|
|
14
|
+
- JSON responses with thousands of characters
|
|
15
|
+
- Solution: Output is now automatically truncated to prevent crashes
|
|
16
|
+
|
|
17
|
+
2. **Timeout Issues**
|
|
18
|
+
- Default 30s timeout too short for some operations
|
|
19
|
+
- Commands killed prematurely
|
|
20
|
+
- Solution: Default timeout increased to 2 minutes, max 5 minutes
|
|
21
|
+
|
|
22
|
+
3. **Unstructured Error Responses**
|
|
23
|
+
- Inconsistent error formatting
|
|
24
|
+
- Solution: Standardized JSON error responses
|
|
25
|
+
|
|
26
|
+
### Configuration
|
|
27
|
+
|
|
28
|
+
You can customize limits via environment variables in your `.env` file:
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
# Maximum output length (default: 10000 characters)
|
|
32
|
+
MCP_SSH_MAX_OUTPUT_LENGTH=10000
|
|
33
|
+
|
|
34
|
+
# Default command timeout (default: 120000ms = 2 minutes)
|
|
35
|
+
MCP_SSH_DEFAULT_TIMEOUT=120000
|
|
36
|
+
|
|
37
|
+
# Maximum command timeout (default: 300000ms = 5 minutes)
|
|
38
|
+
MCP_SSH_MAX_TIMEOUT=300000
|
|
39
|
+
|
|
40
|
+
# Use compact JSON responses (no formatting, saves tokens)
|
|
41
|
+
MCP_SSH_COMPACT_JSON=true
|
|
42
|
+
|
|
43
|
+
# Enable debug information in responses
|
|
44
|
+
MCP_SSH_DEBUG=true
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### Best Practices
|
|
48
|
+
|
|
49
|
+
1. **For Long-Running Commands**
|
|
50
|
+
- Specify a custom timeout when calling `ssh_execute`:
|
|
51
|
+
```json
|
|
52
|
+
{
|
|
53
|
+
"server": "myserver",
|
|
54
|
+
"command": "long-running-task",
|
|
55
|
+
"timeout": 300000
|
|
56
|
+
}
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
2. **For Commands with Large Output**
|
|
60
|
+
- Redirect output to a file on the server
|
|
61
|
+
- Use grep/awk to filter output before returning
|
|
62
|
+
- Example:
|
|
63
|
+
```bash
|
|
64
|
+
# Instead of: cat huge-log.txt
|
|
65
|
+
# Use: tail -n 100 huge-log.txt
|
|
66
|
+
# Or: grep ERROR huge-log.txt | tail -n 50
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
3. **Monitor Resource Usage**
|
|
70
|
+
- Use `ssh_monitor` tool for system metrics
|
|
71
|
+
- Check disk space before operations
|
|
72
|
+
- Monitor process memory usage
|
|
73
|
+
|
|
74
|
+
### Debugging Steps
|
|
75
|
+
|
|
76
|
+
1. **Check MCP Server Logs**
|
|
77
|
+
```bash
|
|
78
|
+
# Server logs to stderr
|
|
79
|
+
# Check Claude Code console for detailed errors
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
2. **Test Connection**
|
|
83
|
+
```bash
|
|
84
|
+
ssh-manager server test <server-name>
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
3. **Verify Configuration**
|
|
88
|
+
```bash
|
|
89
|
+
ssh-manager server show <server-name>
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
4. **Test Direct SSH**
|
|
93
|
+
```bash
|
|
94
|
+
ssh user@host "command"
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### Known Issues
|
|
98
|
+
|
|
99
|
+
1. **Commands with Interactive Prompts**
|
|
100
|
+
- SSH sessions don't support interactive input
|
|
101
|
+
- Solution: Use non-interactive flags or pre-configure
|
|
102
|
+
|
|
103
|
+
2. **Supervisor Not Running**
|
|
104
|
+
- Some deployments expect supervisor
|
|
105
|
+
- Check: `supervisorctl status`
|
|
106
|
+
- Solution: Start supervisor or use alternative process manager
|
|
107
|
+
|
|
108
|
+
3. **Permission Denied**
|
|
109
|
+
- SSH user lacks permissions
|
|
110
|
+
- Solution: Configure sudo password in server config or use `ssh_execute_sudo`
|
|
111
|
+
|
|
112
|
+
### Recovery Steps
|
|
113
|
+
|
|
114
|
+
If Claude Code crashes:
|
|
115
|
+
|
|
116
|
+
1. Restart Claude Code
|
|
117
|
+
2. Check last command in logs
|
|
118
|
+
3. Re-run with lower timeout or filtered output
|
|
119
|
+
4. Report issue with error message
|
|
120
|
+
|
|
121
|
+
### Performance Optimization
|
|
122
|
+
|
|
123
|
+
1. **Reduce Token Usage**
|
|
124
|
+
- Set `MCP_SSH_COMPACT_JSON=true`
|
|
125
|
+
- Limit output with grep/head/tail
|
|
126
|
+
- Use specific queries instead of broad commands
|
|
127
|
+
|
|
128
|
+
2. **Connection Pooling**
|
|
129
|
+
- Server maintains persistent connections
|
|
130
|
+
- Connections auto-close after 30 minutes idle
|
|
131
|
+
- Manual disconnect: use `ssh_connection_manage` tool
|
|
132
|
+
|
|
133
|
+
3. **Batch Operations**
|
|
134
|
+
- Use `ssh_group_execute` for multiple servers
|
|
135
|
+
- Combine commands with `&&` or `;`
|
|
136
|
+
- Example: `cd /app && git pull && npm install`
|
|
137
|
+
|
|
138
|
+
### Getting Help
|
|
139
|
+
|
|
140
|
+
1. Check logs: `~/.config/claude-code/logs/`
|
|
141
|
+
2. Test manually: `node src/index.js` (requires stdin)
|
|
142
|
+
3. Open issue: https://github.com/yourusername/mcp-ssh-manager/issues
|
|
143
|
+
4. Include: error message, command executed, server type
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mcp-ssh-manager",
|
|
3
|
-
"version": "3.
|
|
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",
|
|
3
|
+
"version": "3.1.2",
|
|
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
|
"type": "module",
|
|
7
7
|
"scripts": {
|
|
@@ -9,10 +9,11 @@
|
|
|
9
9
|
"setup": "npm install && pip install -r tools/requirements.txt",
|
|
10
10
|
"configure": "python tools/server-manager.py",
|
|
11
11
|
"test-connection": "python tools/test-connection.py",
|
|
12
|
-
"test": "npm run test:profiles && npm run test:aliases && npm run test:hooks",
|
|
12
|
+
"test": "npm run test:profiles && npm run test:aliases && npm run test:hooks && npm run test:tools",
|
|
13
13
|
"test:profiles": "node tests/test-profiles.js",
|
|
14
14
|
"test:aliases": "node tests/test-command-aliases.js",
|
|
15
15
|
"test:hooks": "node tests/test-hooks.js",
|
|
16
|
+
"test:tools": "node tests/test-tool-registry.js",
|
|
16
17
|
"test:all": "npm test && ./scripts/validate.sh",
|
|
17
18
|
"validate": "./scripts/validate.sh",
|
|
18
19
|
"lint": "eslint src/*.js",
|
|
@@ -61,7 +62,7 @@
|
|
|
61
62
|
"license": "MIT",
|
|
62
63
|
"repository": {
|
|
63
64
|
"type": "git",
|
|
64
|
-
"url": "https://github.com/bvisible/mcp-ssh-manager.git"
|
|
65
|
+
"url": "git+https://github.com/bvisible/mcp-ssh-manager.git"
|
|
65
66
|
},
|
|
66
67
|
"bugs": {
|
|
67
68
|
"url": "https://github.com/bvisible/mcp-ssh-manager/issues"
|
package/scripts/validate.sh
CHANGED
|
@@ -65,6 +65,18 @@ else
|
|
|
65
65
|
fi
|
|
66
66
|
fi
|
|
67
67
|
|
|
68
|
+
# Test password special characters handling
|
|
69
|
+
echo "📋 Testing password special character handling..."
|
|
70
|
+
if [ -f "debug/test_password_special_chars.sh" ]; then
|
|
71
|
+
if bash debug/test_password_special_chars.sh > /dev/null 2>&1; then
|
|
72
|
+
echo " ✅ Password special characters handled correctly"
|
|
73
|
+
else
|
|
74
|
+
echo " ⚠️ Password test requires local dependencies (skipping in CI)"
|
|
75
|
+
fi
|
|
76
|
+
else
|
|
77
|
+
echo " ⚠️ Password test script not found (skipping)"
|
|
78
|
+
fi
|
|
79
|
+
|
|
68
80
|
echo ""
|
|
69
81
|
echo "====================================="
|
|
70
82
|
if [ $ERRORS -eq 0 ]; then
|
package/src/backup-manager.js
CHANGED
|
@@ -207,16 +207,16 @@ export function buildFilesBackupCommand(options) {
|
|
|
207
207
|
*/
|
|
208
208
|
export function buildRestoreCommand(backupType, backupFile, options = {}) {
|
|
209
209
|
switch (backupType) {
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
210
|
+
case BACKUP_TYPES.MYSQL:
|
|
211
|
+
return buildMySQLRestoreCommand(backupFile, options);
|
|
212
|
+
case BACKUP_TYPES.POSTGRESQL:
|
|
213
|
+
return buildPostgreSQLRestoreCommand(backupFile, options);
|
|
214
|
+
case BACKUP_TYPES.MONGODB:
|
|
215
|
+
return buildMongoDBRestoreCommand(backupFile, options);
|
|
216
|
+
case BACKUP_TYPES.FILES:
|
|
217
|
+
return buildFilesRestoreCommand(backupFile, options);
|
|
218
|
+
default:
|
|
219
|
+
throw new Error(`Unknown backup type: ${backupType}`);
|
|
220
220
|
}
|
|
221
221
|
}
|
|
222
222
|
|
|
@@ -379,7 +379,7 @@ export function createBackupMetadata(backupId, type, options = {}) {
|
|
|
379
379
|
export function buildSaveMetadataCommand(metadata, metadataPath) {
|
|
380
380
|
const jsonData = JSON.stringify(metadata, null, 2);
|
|
381
381
|
// Escape single quotes in JSON for shell
|
|
382
|
-
const escapedJson = jsonData.replace(/'/g,
|
|
382
|
+
const escapedJson = jsonData.replace(/'/g, '\'\\\'\'');
|
|
383
383
|
return `echo '${escapedJson}' > "${metadataPath}"`;
|
|
384
384
|
}
|
|
385
385
|
|
|
@@ -394,7 +394,7 @@ export function buildListBackupsCommand(backupDir = DEFAULT_BACKUP_DIR, type = n
|
|
|
394
394
|
}
|
|
395
395
|
|
|
396
396
|
// Read and parse each metadata file
|
|
397
|
-
command +=
|
|
397
|
+
command += ' | while read -r file; do cat "$file"; echo "---"; done';
|
|
398
398
|
|
|
399
399
|
return command;
|
|
400
400
|
}
|