mcp-ssh-manager 3.1.0 → 3.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -5,6 +5,69 @@ 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.1.2] - 2026-02-09
9
+
10
+ ### Fixed
11
+
12
+ - **Windows compatibility**: Replace `process.env.HOME` with `os.homedir()` for cross-platform support ([#8](https://github.com/bvisible/mcp-ssh-manager/issues/8))
13
+ - `process.env.HOME` is undefined on Windows, causing crash at startup
14
+ - Fixed in `src/ssh-key-manager.js`, `src/index.js`, `src/ssh-manager.js`
15
+
16
+ ## [3.1.1] - 2025-11-15
17
+
18
+ ### 🔧 Stability & Performance Release
19
+
20
+ This release fixes critical issues causing Claude Code to crash or freeze during MCP tool execution, particularly with large command outputs.
21
+
22
+ ### Fixed
23
+
24
+ - **Claude Code crashes**: Automatic output truncation prevents context overflow
25
+ - All stdout/stderr outputs now limited to 10,000 characters (configurable)
26
+ - Clear truncation indicator showing how many characters were cut
27
+ - Prevents "Interrupted: What should Claude do instead?" errors
28
+
29
+ - **Timeout issues**: Default timeout increased from 30s to 2 minutes
30
+ - Maximum timeout raised to 5 minutes for long-running operations
31
+ - Prevents premature command termination
32
+
33
+ - **Standardized error responses**: Consistent JSON error format
34
+ - Better error handling and logging
35
+ - Improved debugging information
36
+
37
+ ### Added
38
+
39
+ - **Performance configuration** via environment variables:
40
+ - `MCP_SSH_MAX_OUTPUT_LENGTH`: Control output truncation (default: 10000)
41
+ - `MCP_SSH_DEFAULT_TIMEOUT`: Set default command timeout (default: 120000ms)
42
+ - `MCP_SSH_MAX_TIMEOUT`: Set maximum timeout limit (default: 300000ms)
43
+ - `MCP_SSH_COMPACT_JSON`: Enable compact JSON responses (default: false)
44
+ - `MCP_SSH_DEBUG`: Enable debug information (default: false)
45
+ - `MCP_SSH_CONNECTION_TIMEOUT`: Connection idle timeout (default: 1800000ms)
46
+ - `MCP_SSH_KEEPALIVE_INTERVAL`: Keepalive packet interval (default: 60000ms)
47
+
48
+ - **New configuration module** (`src/config.js`):
49
+ - Centralized configuration management
50
+ - Helper functions: `truncateOutput()`, `formatJSONResponse()`
51
+ - Environment variable parsing with defaults
52
+
53
+ - **Troubleshooting documentation**:
54
+ - Complete guide in `docs/TROUBLESHOOTING.md`
55
+ - Best practices for handling large outputs
56
+ - Performance optimization tips
57
+ - Debugging steps for common issues
58
+
59
+ ### Changed
60
+
61
+ - Updated `.env.example` with new performance configuration options
62
+ - Enhanced README with troubleshooting section for Claude Code crashes
63
+ - Improved error logging with detailed context
64
+
65
+ ### Documentation
66
+
67
+ - Added comprehensive troubleshooting guide
68
+ - Updated README with performance tuning section
69
+ - Added examples for handling large command outputs
70
+
8
71
  ## [3.0.0] - 2025-10-01
9
72
 
10
73
  ### 🎉 Major Release - Enterprise DevOps Features
package/README.md CHANGED
@@ -12,7 +12,7 @@ A powerful Model Context Protocol (MCP) server that enables **Claude Code** and
12
12
  [![npm downloads](https://img.shields.io/npm/dt/mcp-ssh-manager.svg?style=for-the-badge&logo=npm)](https://www.npmjs.com/package/mcp-ssh-manager)
13
13
  [![MCP SSH Server](https://img.shields.io/badge/MCP_SSH-Server-orange?style=for-the-badge)](https://github.com/bvisible/mcp-ssh-manager)
14
14
  [![SSH MCP](https://img.shields.io/badge/SSH_MCP-Compatible-blue?style=for-the-badge)](https://modelcontextprotocol.io)
15
- [![Version](https://img.shields.io/badge/Version-3.0.0-brightgreen?style=for-the-badge)](https://github.com/bvisible/mcp-ssh-manager/releases/tag/v3.0.0)
15
+ [![Version](https://img.shields.io/badge/Version-3.1.2-brightgreen?style=for-the-badge)](https://github.com/bvisible/mcp-ssh-manager/releases/tag/v3.1.2)
16
16
  [![Claude Code](https://img.shields.io/badge/Claude_Code-Compatible-5A67D8?style=for-the-badge&logo=anthropic)](https://claude.ai/code)
17
17
  [![OpenAI Codex](https://img.shields.io/badge/OpenAI_Codex-Compatible-00A67E?style=for-the-badge&logo=openai)](https://openai.com/codex)
18
18
  [![MCP](https://img.shields.io/badge/MCP-Server-orange?style=for-the-badge)](https://modelcontextprotocol.io)
@@ -22,13 +22,36 @@ A powerful Model Context Protocol (MCP) server that enables **Claude Code** and
22
22
  <img width="380" height="200" src="https://glama.ai/mcp/servers/@bvisible/mcp-ssh-manager/badge" alt="SSH Manager MCP server" />
23
23
  </a>
24
24
 
25
+ <br/>
26
+
27
+ <a href="https://mseep.ai/app/bvisible-mcp-ssh-manager">
28
+ <img src="https://mseep.net/pr/bvisible-mcp-ssh-manager-badge.png" alt="MseeP.ai Security Assessment Badge" />
29
+ </a>
30
+
25
31
  </div>
26
32
 
27
33
  ---
28
34
 
29
- ## 🎉 What's New in v3.0.0
35
+ ## 🎉 What's New in v3.1.2
30
36
 
31
- **Major Release - Enterprise DevOps Platform** (Released: October 1, 2025)
37
+ **Windows Compatibility Fix** (Released: February 9, 2026)
38
+
39
+ - **🪟 Windows support**: Fixed crash on Windows where `process.env.HOME` is undefined ([#8](https://github.com/bvisible/mcp-ssh-manager/issues/8))
40
+ - Now uses `os.homedir()` for cross-platform compatibility (Linux, macOS, Windows)
41
+
42
+ ---
43
+
44
+ ## Previous Releases
45
+
46
+ ### v3.1.0 - Tool Activation System (November 15, 2025)
47
+
48
+ ### 🎯 Context Usage Optimization
49
+ - **92% context reduction**: Enable only the tools you need (minimal mode: 5 tools vs all 37)
50
+ - **Tool management CLI**: `ssh-manager tools list/configure/enable/disable`
51
+ - **6 tool groups**: Core, Sessions, Monitoring, Backup, Database, Advanced
52
+ - **Auto-approval export**: Generate Claude Code auto-approval configs
53
+
54
+ ### v3.0.0 - Enterprise DevOps Platform (October 1, 2025)
32
55
 
33
56
  This release adds **12 new MCP tools** transforming SSH Manager into a comprehensive DevOps automation platform:
34
57
 
@@ -171,6 +194,7 @@ This is **the** MCP SSH Manager you've been searching for! 🎯
171
194
 
172
195
  - Node.js (v18 or higher)
173
196
  - npm (comes with Node.js)
197
+ - **Platforms**: Linux, macOS, Windows
174
198
  - **For Claude Code**: Claude Code CLI installed
175
199
  - **For OpenAI Codex**: Codex CLI configured
176
200
  - Bash 4.0+ (for CLI management tools)
@@ -596,6 +620,39 @@ claude mcp list
596
620
 
597
621
  ## 🐛 Troubleshooting
598
622
 
623
+ ### Claude Code Crashes / Interruptions
624
+
625
+ **Symptoms:**
626
+ - Claude shows "Interrupted: What should Claude do instead?"
627
+ - MCP tools execute but Claude stops working
628
+ - Commands succeed but Claude freezes
629
+
630
+ **Solution:** v3.1.1 includes automatic fixes:
631
+ - ✅ Output auto-truncated to prevent context overflow
632
+ - ✅ Timeout increased to 2 minutes (default), max 5 minutes
633
+ - ✅ Standardized error responses
634
+
635
+ **Performance Tuning** (add to `.env`):
636
+ ```bash
637
+ # Reduce output size (default: 10000 characters)
638
+ MCP_SSH_MAX_OUTPUT_LENGTH=5000
639
+
640
+ # Increase timeout for slow commands (default: 120000ms)
641
+ MCP_SSH_DEFAULT_TIMEOUT=180000
642
+
643
+ # Use compact JSON to save tokens (default: false)
644
+ MCP_SSH_COMPACT_JSON=true
645
+ ```
646
+
647
+ **For large outputs:**
648
+ ```bash
649
+ # Instead of: cat huge-log.txt
650
+ # Use: tail -n 100 huge-log.txt
651
+ # Or: grep ERROR huge-log.txt | tail -n 50
652
+ ```
653
+
654
+ See [docs/TROUBLESHOOTING.md](docs/TROUBLESHOOTING.md) for complete guide.
655
+
599
656
  ### MCP Tools Not Available
600
657
 
601
658
  1. Ensure MCP is installed: `claude mcp list`
@@ -604,7 +661,7 @@ claude mcp list
604
661
 
605
662
  ### Connection Failed
606
663
 
607
- 1. Test connection: `python tools/test-connection.py [server_name]`
664
+ 1. Test connection: `ssh-manager server test [server_name]`
608
665
  2. Verify network connectivity
609
666
  3. Check firewall rules
610
667
  4. Ensure SSH service is running on remote server
@@ -0,0 +1 @@
1
+ Server: production, Error: test-error
@@ -0,0 +1,385 @@
1
+ # Social Media Announcement - v3.1.0
2
+
3
+ ## Twitter/X Post
4
+
5
+ 🚀 NEW: MCP SSH Manager v3.1.0 - Tool Activation System!
6
+
7
+ Reduce context usage by 92% with intelligent tool activation. Enable only what you need:
8
+
9
+ ✅ 37 DevOps tools (SSH, Database, Backup, Monitoring)
10
+ ✅ 6 tool groups (Core → Advanced)
11
+ ✅ Compatible with Claude Code & OpenAI Codex
12
+ ✅ Auto-approval config export
13
+
14
+ Install: `npm i -g mcp-ssh-manager`
15
+
16
+ 📦 https://github.com/bvisible/mcp-ssh-manager
17
+ 🌟 Star if useful!
18
+
19
+ #MCP #ClaudeCode #DevOps #SSH #AI #Automation
20
+
21
+ ---
22
+
23
+ ## Reddit Post (r/ClaudeAI)
24
+
25
+ **Title:** MCP SSH Manager v3.1.0 - Comprehensive SSH automation with 92% context reduction
26
+
27
+ **Body:**
28
+
29
+ I've been working on MCP SSH Manager, a Model Context Protocol server that brings comprehensive SSH management to Claude Code (and OpenAI Codex).
30
+
31
+ **What is it?**
32
+
33
+ A complete DevOps automation platform with 37 MCP tools for managing remote SSH servers directly from Claude Code:
34
+
35
+ - 🔧 Core SSH operations (execute, upload, download, sync)
36
+ - 💾 Backup & restore (MySQL, PostgreSQL, MongoDB, files)
37
+ - 🏥 Health monitoring (CPU, RAM, disk, network, services)
38
+ - 🗄️ Database management (dumps, imports, queries)
39
+ - 🚇 SSH tunnels (local, remote, SOCKS)
40
+ - 📦 Advanced features (persistent sessions, server groups, profiles, hooks)
41
+
42
+ **What's new in v3.1.0?**
43
+
44
+ Tool activation system - reduce context usage by **92%**!
45
+
46
+ - Enable only the tools you need (minimal mode: 5 tools vs all 37)
47
+ - 6 tool groups: Core, Sessions, Monitoring, Backup, Database, Advanced
48
+ - CLI: `ssh-manager tools configure` for interactive setup
49
+ - Export auto-approval configs for Claude Code
50
+
51
+ **Why build this?**
52
+
53
+ Existing MCP SSH tools offer 2-4 basic operations. I needed enterprise DevOps features: automated backups, health monitoring, database operations, etc.
54
+
55
+ **Installation:**
56
+
57
+ ```bash
58
+ npm install -g mcp-ssh-manager
59
+ ```
60
+
61
+ **Configuration:**
62
+
63
+ Claude Code:
64
+ ```json
65
+ {
66
+ "mcpServers": {
67
+ "ssh-manager": {
68
+ "command": "node",
69
+ "args": ["/path/to/mcp-ssh-manager/src/index.js"]
70
+ }
71
+ }
72
+ }
73
+ ```
74
+
75
+ OpenAI Codex:
76
+ ```bash
77
+ ssh-manager codex setup
78
+ ```
79
+
80
+ **Links:**
81
+
82
+ - GitHub: https://github.com/bvisible/mcp-ssh-manager
83
+ - NPM: https://www.npmjs.com/package/mcp-ssh-manager
84
+ - Glama.ai: https://glama.ai/mcp/servers/@bvisible/mcp-ssh-manager
85
+ - Documentation: Full guides for all features
86
+
87
+ **Features I'm proud of:**
88
+
89
+ - Dual compatibility (Claude Code + OpenAI Codex)
90
+ - Profile system (default, docker, frappe, nodejs)
91
+ - Hooks for automation (pre-deploy, post-deploy, on-error)
92
+ - Command aliases (reduce typing)
93
+ - Comprehensive testing & CI/CD
94
+ - 92% context reduction with tool activation
95
+
96
+ Would love feedback! Star on GitHub if you find it useful ⭐
97
+
98
+ ---
99
+
100
+ ## Hacker News Post (Show HN)
101
+
102
+ **Title:** Show HN: MCP SSH Manager – 37 DevOps tools for Claude Code with 92% context reduction
103
+
104
+ **Body:**
105
+
106
+ Hi HN! I built MCP SSH Manager, a comprehensive Model Context Protocol server for SSH automation with Claude Code and OpenAI Codex.
107
+
108
+ **The problem:** Existing MCP SSH tools offer 2-4 basic operations (execute, upload, download). I needed enterprise DevOps features like automated backups, health monitoring, and database management - directly accessible from my AI assistant.
109
+
110
+ **What I built:**
111
+
112
+ 37 MCP tools organized into 6 groups:
113
+ - Core (5): SSH execute, upload, download, sync, sudo
114
+ - Sessions (4): Persistent SSH sessions
115
+ - Monitoring (6): Health checks, service status, process management
116
+ - Backup (4): MySQL/PostgreSQL/MongoDB/file backups with scheduling
117
+ - Database (4): Dumps, imports, queries, table listings
118
+ - Advanced (14): Tunnels, groups, profiles, hooks, aliases
119
+
120
+ **New in v3.1.0: Tool Activation System**
121
+
122
+ The biggest challenge was context usage - 37 tools consume ~43.5k tokens. Solution: intelligent tool activation.
123
+
124
+ - Users can enable only needed tool groups
125
+ - Minimal mode: 5 tools (~3.5k tokens) = 92% reduction
126
+ - Interactive CLI: `ssh-manager tools configure`
127
+ - Export auto-approval configs for Claude Code
128
+
129
+ **Technical details:**
130
+
131
+ - Built with @modelcontextprotocol/sdk + ssh2
132
+ - Dual config support: .env (Claude) + TOML (Codex)
133
+ - Profile system for different workflows (docker, nodejs, frappe)
134
+ - Hooks for automation (pre-deploy, post-deploy, on-error)
135
+ - Comprehensive testing with GitHub Actions CI/CD
136
+
137
+ **Stack:**
138
+
139
+ - Node.js 18+
140
+ - SSH2 for connections
141
+ - Zod for validation
142
+ - TOML parser for Codex configs
143
+
144
+ **Example use cases:**
145
+
146
+ 1. "Deploy my app to production server, create a database backup first"
147
+ 2. "Check health of all my servers and alert me if any are above 80% CPU"
148
+ 3. "Execute this command on all servers in the 'web' group sequentially"
149
+ 4. "Create a backup of the MySQL database and schedule it to run daily at 2am"
150
+
151
+ **Links:**
152
+
153
+ - Repo: https://github.com/bvisible/mcp-ssh-manager
154
+ - NPM: https://www.npmjs.com/package/mcp-ssh-manager
155
+ - Docs: https://github.com/bvisible/mcp-ssh-manager#readme
156
+
157
+ Would love HN's feedback! What other DevOps automation would you want accessible from your AI assistant?
158
+
159
+ ---
160
+
161
+ ## LinkedIn Post
162
+
163
+ 🚀 Excited to announce MCP SSH Manager v3.1.0!
164
+
165
+ After months of development, I'm releasing a comprehensive Model Context Protocol server that brings enterprise DevOps automation to Claude Code and OpenAI Codex.
166
+
167
+ **What does it do?**
168
+
169
+ Think of it as giving your AI assistant direct, controlled access to your SSH servers with 37 specialized tools:
170
+
171
+ ✅ Execute commands remotely
172
+ ✅ Automated database backups (MySQL, PostgreSQL, MongoDB)
173
+ ✅ Health monitoring (CPU, RAM, disk, network)
174
+ ✅ File transfers & synchronization
175
+ ✅ SSH tunnel management
176
+ ✅ Database operations
177
+ ✅ And much more...
178
+
179
+ **Key innovation in v3.1.0:**
180
+
181
+ Tool activation system reduces AI context usage by 92%. Enable only the tools you need - from 5 core tools to all 37 advanced features.
182
+
183
+ **Why this matters:**
184
+
185
+ DevOps teams spend hours on repetitive SSH tasks. With MCP SSH Manager, you can ask Claude Code:
186
+
187
+ "Deploy the app to production, backup the database first, and monitor the health metrics"
188
+
189
+ And it handles everything - safely and automatically.
190
+
191
+ **Enterprise-ready features:**
192
+
193
+ - Profile system for different workflows
194
+ - Automation hooks (pre-deploy, post-deploy, on-error)
195
+ - Server groups for batch operations
196
+ - Comprehensive audit logging
197
+ - Security-first design
198
+
199
+ Check it out: https://github.com/bvisible/mcp-ssh-manager
200
+
201
+ #DevOps #AI #Automation #ClaudeCode #SSH #EnterpriseIT #CloudComputing
202
+
203
+ ---
204
+
205
+ ## Dev.to / Medium Article Outline
206
+
207
+ **Title:** "Building an Enterprise DevOps Platform with Model Context Protocol: Lessons from MCP SSH Manager"
208
+
209
+ **Sections:**
210
+
211
+ 1. **Introduction**
212
+ - What is MCP?
213
+ - Why SSH automation?
214
+ - The gap in existing solutions
215
+
216
+ 2. **Architecture Overview**
217
+ - MCP SDK integration
218
+ - Tool design patterns
219
+ - Connection pooling
220
+ - Security considerations
221
+
222
+ 3. **The Tool Activation Challenge**
223
+ - Context token limits
224
+ - 37 tools = 43.5k tokens
225
+ - Solution: Dynamic tool activation
226
+ - 92% reduction achieved
227
+
228
+ 4. **Technical Deep Dives**
229
+ - Dual configuration support (.env + TOML)
230
+ - Profile system architecture
231
+ - Hooks and automation
232
+ - Testing strategy
233
+
234
+ 5. **Real-world Use Cases**
235
+ - Automated deployments
236
+ - Database backup workflows
237
+ - Health monitoring dashboards
238
+ - Multi-server management
239
+
240
+ 6. **Lessons Learned**
241
+ - Tool granularity vs. simplicity
242
+ - Security in AI-accessible systems
243
+ - Error handling for AI consumers
244
+ - Documentation for AI understanding
245
+
246
+ 7. **Future Directions**
247
+ - Community feedback
248
+ - Planned features
249
+ - MCP ecosystem growth
250
+
251
+ 8. **Getting Started**
252
+ - Installation guide
253
+ - Quick start examples
254
+ - Links to resources
255
+
256
+ ---
257
+
258
+ ## YouTube Video Script Outline
259
+
260
+ **Title:** "MCP SSH Manager v3.1.0 - Automate DevOps with Claude Code (92% Context Reduction)"
261
+
262
+ **Duration:** 8-10 minutes
263
+
264
+ **Outline:**
265
+
266
+ 1. **Intro (30 sec)**
267
+ - What we're building
268
+ - Why it matters
269
+
270
+ 2. **Problem Statement (1 min)**
271
+ - Manual SSH tasks
272
+ - Existing MCP tools limitations
273
+ - Context usage challenges
274
+
275
+ 3. **Demo: Basic Setup (2 min)**
276
+ - Install from npm
277
+ - Configure Claude Code
278
+ - First SSH command
279
+
280
+ 4. **Demo: Tool Activation (2 min)**
281
+ - Show all 37 tools
282
+ - Run `ssh-manager tools configure`
283
+ - Compare context usage
284
+
285
+ 5. **Demo: Real DevOps Workflow (3 min)**
286
+ - Deploy app
287
+ - Backup database
288
+ - Monitor health
289
+ - All from Claude Code
290
+
291
+ 6. **Feature Highlights (1.5 min)**
292
+ - Profiles
293
+ - Hooks
294
+ - Server groups
295
+ - OpenAI Codex support
296
+
297
+ 7. **Outro (30 sec)**
298
+ - Links
299
+ - Call to action (star on GitHub)
300
+ - What's next
301
+
302
+ ---
303
+
304
+ ## Instagram/Visual Content Ideas
305
+
306
+ 1. **Infographic: "37 DevOps Tools, 92% Less Context"**
307
+ - Visual comparison: All tools vs Minimal mode
308
+ - Token usage chart
309
+ - Tool group breakdown
310
+
311
+ 2. **Carousel: "From Manual SSH to AI-Powered DevOps"**
312
+ - Slide 1: Old way (terminal commands)
313
+ - Slide 2: MCP SSH Manager way (Claude Code)
314
+ - Slide 3: Results (time saved, errors reduced)
315
+ - Slide 4: Get started (GitHub link)
316
+
317
+ 3. **Short Video: "Deploy in 10 Seconds with Claude Code"**
318
+ - Screen recording of deployment workflow
319
+ - Before/after comparison
320
+ - Call to action
321
+
322
+ ---
323
+
324
+ ## Community Engagement Plan
325
+
326
+ **Week 1:**
327
+ - Post on Reddit r/ClaudeAI, r/devops, r/MachineLearning
328
+ - Share on Twitter/X with relevant hashtags
329
+ - Post on LinkedIn
330
+ - Submit to Hacker News
331
+
332
+ **Week 2:**
333
+ - Write Dev.to article
334
+ - Create YouTube demo video
335
+ - Engage with comments/questions
336
+ - Update Glama.ai listing
337
+
338
+ **Week 3:**
339
+ - Write Medium article (technical deep dive)
340
+ - Submit to awesome-mcp lists
341
+ - Answer Stack Overflow questions about MCP SSH
342
+ - Create comparison article
343
+
344
+ **Week 4:**
345
+ - Follow up on MCP official repo submission
346
+ - Collect user feedback
347
+ - Plan v3.2.0 based on feedback
348
+ - Create case studies
349
+
350
+ ---
351
+
352
+ ## Hashtags to Use
353
+
354
+ **General:**
355
+ #MCP #ModelContextProtocol #ClaudeCode #OpenAICodex #AI #Automation #DevOps
356
+
357
+ **Technical:**
358
+ #SSH #RemoteManagement #CloudComputing #Infrastructure #IaC #SRE #Platform
359
+
360
+ **AI-specific:**
361
+ #AITools #LLM #AIAgent #AIAssistant #Anthropic #OpenAI #Claude
362
+
363
+ **Community:**
364
+ #OpenSource #JavaScript #NodeJS #TypeScript #NPM #GitHub
365
+
366
+ ---
367
+
368
+ ## Key Messages to Emphasize
369
+
370
+ 1. **Most comprehensive** - 37 tools vs competitors' 2-4
371
+ 2. **Enterprise-ready** - Not just basic SSH, full DevOps platform
372
+ 3. **Efficient** - 92% context reduction with tool activation
373
+ 4. **Dual support** - Claude Code AND OpenAI Codex
374
+ 5. **Production-ready** - Extensive testing, CI/CD, documentation
375
+ 6. **Active development** - Regular updates, community-driven
376
+
377
+ ---
378
+
379
+ ## Call to Action Options
380
+
381
+ 1. **For developers:** "Star on GitHub if you find it useful!"
382
+ 2. **For users:** "Try it now: `npm install -g mcp-ssh-manager`"
383
+ 3. **For contributors:** "Issues and PRs welcome!"
384
+ 4. **For feedback:** "What DevOps features would you like to see next?"
385
+ 5. **For community:** "Join the discussion on GitHub Discussions"
@@ -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,6 +1,6 @@
1
1
  {
2
2
  "name": "mcp-ssh-manager",
3
- "version": "3.1.0",
3
+ "version": "3.1.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
  "type": "module",
package/src/config.js ADDED
@@ -0,0 +1,70 @@
1
+ // Configuration constants for MCP SSH Manager
2
+
3
+ // Output limits to prevent Claude Code crashes
4
+ export const OUTPUT_LIMITS = {
5
+ // Maximum length of stdout/stderr in responses (characters)
6
+ MAX_OUTPUT_LENGTH: process.env.MCP_SSH_MAX_OUTPUT_LENGTH
7
+ ? parseInt(process.env.MCP_SSH_MAX_OUTPUT_LENGTH)
8
+ : 10000,
9
+
10
+ // Maximum length for log file tailing
11
+ MAX_TAIL_LINES: process.env.MCP_SSH_MAX_TAIL_LINES
12
+ ? parseInt(process.env.MCP_SSH_MAX_TAIL_LINES)
13
+ : 100,
14
+
15
+ // Maximum length for rsync verbose output
16
+ MAX_RSYNC_OUTPUT: process.env.MCP_SSH_MAX_RSYNC_OUTPUT
17
+ ? parseInt(process.env.MCP_SSH_MAX_RSYNC_OUTPUT)
18
+ : 5000,
19
+ };
20
+
21
+ // Timeout configuration
22
+ export const TIMEOUTS = {
23
+ // Default command execution timeout (milliseconds)
24
+ DEFAULT_COMMAND_TIMEOUT: process.env.MCP_SSH_DEFAULT_TIMEOUT
25
+ ? parseInt(process.env.MCP_SSH_DEFAULT_TIMEOUT)
26
+ : 120000, // 2 minutes
27
+
28
+ // Maximum allowed command timeout (milliseconds)
29
+ MAX_COMMAND_TIMEOUT: process.env.MCP_SSH_MAX_TIMEOUT
30
+ ? parseInt(process.env.MCP_SSH_MAX_TIMEOUT)
31
+ : 300000, // 5 minutes
32
+
33
+ // Connection timeout (milliseconds)
34
+ CONNECTION_TIMEOUT: process.env.MCP_SSH_CONNECTION_TIMEOUT
35
+ ? parseInt(process.env.MCP_SSH_CONNECTION_TIMEOUT)
36
+ : 1800000, // 30 minutes
37
+
38
+ // Keepalive interval (milliseconds)
39
+ KEEPALIVE_INTERVAL: process.env.MCP_SSH_KEEPALIVE_INTERVAL
40
+ ? parseInt(process.env.MCP_SSH_KEEPALIVE_INTERVAL)
41
+ : 60000, // 1 minute
42
+ };
43
+
44
+ // Response formatting
45
+ export const RESPONSE_FORMAT = {
46
+ // Whether to use compact JSON (no formatting)
47
+ COMPACT_JSON: process.env.MCP_SSH_COMPACT_JSON === 'true',
48
+
49
+ // Whether to include debug information in responses
50
+ INCLUDE_DEBUG_INFO: process.env.MCP_SSH_DEBUG === 'true',
51
+ };
52
+
53
+ // Helper function to truncate output
54
+ export function truncateOutput(text, maxLength = OUTPUT_LIMITS.MAX_OUTPUT_LENGTH) {
55
+ if (!text) return '';
56
+
57
+ if (text.length <= maxLength) return text;
58
+
59
+ const truncated = text.length - maxLength;
60
+ return text.substring(0, maxLength) + `\n\n... [${truncated} characters truncated]`;
61
+ }
62
+
63
+ // Helper function to format JSON response
64
+ export function formatJSONResponse(data) {
65
+ return JSON.stringify(
66
+ data,
67
+ null,
68
+ RESPONSE_FORMAT.COMPACT_JSON ? 0 : 2
69
+ );
70
+ }
package/src/index.js CHANGED
@@ -7,6 +7,7 @@ import SSHManager from './ssh-manager.js';
7
7
  import * as dotenv from 'dotenv';
8
8
  import fs from 'fs';
9
9
  import path from 'path';
10
+ import os from 'os';
10
11
  import { fileURLToPath } from 'url';
11
12
  import { configLoader } from './config-loader.js';
12
13
  import {
@@ -27,6 +28,12 @@ import {
27
28
  listCommandAliases,
28
29
  suggestAliases
29
30
  } from './command-aliases.js';
31
+ import {
32
+ OUTPUT_LIMITS,
33
+ TIMEOUTS,
34
+ truncateOutput,
35
+ formatJSONResponse
36
+ } from './config.js';
30
37
  import {
31
38
  initializeHooks,
32
39
  executeHook,
@@ -445,10 +452,12 @@ registerToolConditional(
445
452
  server: z.string().describe('Server name from configuration'),
446
453
  command: z.string().describe('Command to execute'),
447
454
  cwd: z.string().optional().describe('Working directory (optional, uses default if configured)'),
448
- timeout: z.number().optional().describe('Command timeout in milliseconds (default: 30000)')
455
+ timeout: z.number().optional().describe('Command timeout in milliseconds (default: 120000, max: 300000)')
449
456
  }
450
457
  },
451
- async ({ server: serverName, command, cwd, timeout = 30000 }) => {
458
+ async ({ server: serverName, command, cwd, timeout = TIMEOUTS.DEFAULT_COMMAND_TIMEOUT }) => {
459
+ // Cap timeout at maximum allowed
460
+ const cappedTimeout = Math.min(timeout, TIMEOUTS.MAX_COMMAND_TIMEOUT);
452
461
  try {
453
462
  const ssh = await getConnection(serverName);
454
463
 
@@ -473,7 +482,7 @@ registerToolConditional(
473
482
  // Log command execution
474
483
  const startTime = logger.logCommand(serverName, fullCommand, workingDir);
475
484
 
476
- const result = await execCommandWithTimeout(ssh, fullCommand, {}, timeout);
485
+ const result = await execCommandWithTimeout(ssh, fullCommand, {}, cappedTimeout);
477
486
 
478
487
  // Log command result
479
488
  logger.logCommandResult(serverName, fullCommand, startTime, result);
@@ -487,29 +496,44 @@ registerToolConditional(
487
496
  });
488
497
  }
489
498
 
499
+ // Truncate output if too large to prevent Claude Code crashes
500
+ const stdout = truncateOutput(result.stdout);
501
+ const stderr = truncateOutput(result.stderr);
502
+
490
503
  return {
491
504
  content: [
492
505
  {
493
506
  type: 'text',
494
- text: JSON.stringify({
507
+ text: formatJSONResponse({
495
508
  server: serverName,
496
509
  command: fullCommand,
497
- stdout: result.stdout,
498
- stderr: result.stderr,
510
+ stdout: stdout,
511
+ stderr: stderr,
499
512
  code: result.code,
500
513
  success: result.code === 0,
501
- }, null, 2),
514
+ }),
502
515
  },
503
516
  ],
504
517
  };
505
518
  } catch (error) {
519
+ logger.error('ssh_execute failed', {
520
+ server: serverName,
521
+ error: error.message
522
+ });
523
+
506
524
  return {
507
525
  content: [
508
526
  {
509
527
  type: 'text',
510
- text: `❌ Error: ${error.message}`,
528
+ text: formatJSONResponse({
529
+ server: serverName,
530
+ success: false,
531
+ error: truncateOutput(error.message, 1000),
532
+ code: -1
533
+ }),
511
534
  },
512
535
  ],
536
+ isError: true
513
537
  };
514
538
  }
515
539
  }
@@ -730,7 +754,7 @@ registerToolConditional(
730
754
  sshOptions.push('-o StrictHostKeyChecking=accept-new'); // Accept new keys, reject changed ones
731
755
  sshOptions.push('-o ConnectTimeout=10'); // Connection timeout
732
756
 
733
- const keyPath = serverConfig.keypath.replace('~', process.env.HOME);
757
+ const keyPath = serverConfig.keypath.replace('~', os.homedir());
734
758
  sshOptions.push(`-i ${keyPath}`);
735
759
  } else {
736
760
  // With sshpass, we don't use BatchMode
@@ -1,12 +1,13 @@
1
1
  import { execSync, spawn } from 'child_process';
2
2
  import fs from 'fs';
3
3
  import path from 'path';
4
+ import os from 'os';
4
5
  import crypto from 'crypto';
5
6
  import { logger } from './logger.js';
6
7
 
7
8
  // Path to known_hosts file
8
- const KNOWN_HOSTS_PATH = path.join(process.env.HOME, '.ssh', 'known_hosts');
9
- const KNOWN_HOSTS_BACKUP = path.join(process.env.HOME, '.ssh', 'known_hosts.mcp-backup');
9
+ const KNOWN_HOSTS_PATH = path.join(os.homedir(), '.ssh', 'known_hosts');
10
+ const KNOWN_HOSTS_BACKUP = path.join(os.homedir(), '.ssh', 'known_hosts.mcp-backup');
10
11
 
11
12
  /**
12
13
  * Parse a known_hosts entry
@@ -1,5 +1,6 @@
1
1
  import { Client } from 'ssh2';
2
2
  import fs from 'fs';
3
+ import os from 'os';
3
4
  import { promisify } from 'util';
4
5
  import crypto from 'crypto';
5
6
  import { isHostKnown, getCurrentHostKey, addHostKey, updateHostKey } from './ssh-key-manager.js';
@@ -100,7 +101,7 @@ class SSHManager {
100
101
  // Add authentication (support both keyPath and keypath for compatibility)
101
102
  const keyPath = this.config.keyPath || this.config.keypath;
102
103
  if (keyPath) {
103
- const resolvedKeyPath = keyPath.replace('~', process.env.HOME);
104
+ const resolvedKeyPath = keyPath.replace('~', os.homedir());
104
105
  connConfig.privateKey = fs.readFileSync(resolvedKeyPath);
105
106
  } else if (this.config.password) {
106
107
  connConfig.password = this.config.password;