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
package/cli/lib/config.sh
CHANGED
|
@@ -106,14 +106,34 @@ get_server_config() {
|
|
|
106
106
|
local server="$1"
|
|
107
107
|
local field="$2"
|
|
108
108
|
local server_upper="$(echo "$server" | tr '[:lower:]' '[:upper:]')"
|
|
109
|
-
|
|
109
|
+
|
|
110
110
|
if [ ! -f "$SSH_MANAGER_ENV" ]; then
|
|
111
111
|
return 1
|
|
112
112
|
fi
|
|
113
|
-
|
|
113
|
+
|
|
114
114
|
local field_upper="$(echo "$field" | tr '[:lower:]' '[:upper:]')"
|
|
115
115
|
local key="SSH_SERVER_${server_upper}_${field_upper}"
|
|
116
|
-
|
|
116
|
+
|
|
117
|
+
# Read value using IFS to preserve all special characters including quotes
|
|
118
|
+
local value=""
|
|
119
|
+
while IFS="=" read -r k v; do
|
|
120
|
+
if [[ "$k" == "$key" ]]; then
|
|
121
|
+
value="$v"
|
|
122
|
+
break
|
|
123
|
+
fi
|
|
124
|
+
done < <(grep "^${key}=" "$SSH_MANAGER_ENV" 2>/dev/null)
|
|
125
|
+
|
|
126
|
+
# Return error if no value found
|
|
127
|
+
if [ -z "$value" ]; then
|
|
128
|
+
return 1
|
|
129
|
+
fi
|
|
130
|
+
|
|
131
|
+
# Only remove surrounding quotes if they exist, preserve quotes within the value
|
|
132
|
+
if [[ "$value" =~ ^\"(.*)\"$ ]]; then
|
|
133
|
+
printf '%s' "${BASH_REMATCH[1]}"
|
|
134
|
+
else
|
|
135
|
+
printf '%s' "$value"
|
|
136
|
+
fi
|
|
117
137
|
}
|
|
118
138
|
|
|
119
139
|
# Add server to .env
|
|
@@ -159,6 +179,62 @@ add_server_to_env() {
|
|
|
159
179
|
print_success "Server '$name' added successfully"
|
|
160
180
|
}
|
|
161
181
|
|
|
182
|
+
# Update server in .env
|
|
183
|
+
update_server_in_env() {
|
|
184
|
+
local name="$1"
|
|
185
|
+
local host="$2"
|
|
186
|
+
local user="$3"
|
|
187
|
+
local auth_type="$4"
|
|
188
|
+
local auth_value="$5"
|
|
189
|
+
local port="${6:-22}"
|
|
190
|
+
local description="${7:-}"
|
|
191
|
+
local default_dir="${8:-}"
|
|
192
|
+
|
|
193
|
+
local name_upper="$(echo "$name" | tr '[:lower:]' '[:upper:]')"
|
|
194
|
+
|
|
195
|
+
# Check if server exists
|
|
196
|
+
if ! grep -q "^SSH_SERVER_${name_upper}_HOST=" "$SSH_MANAGER_ENV" 2>/dev/null; then
|
|
197
|
+
print_error "Server '$name' not found"
|
|
198
|
+
return 1
|
|
199
|
+
fi
|
|
200
|
+
|
|
201
|
+
# Backup .env file
|
|
202
|
+
cp "$SSH_MANAGER_ENV" "$SSH_MANAGER_ENV.bak"
|
|
203
|
+
|
|
204
|
+
# Remove old server configuration (all lines including comments and old auth methods)
|
|
205
|
+
local temp=$(mktemp)
|
|
206
|
+
# Remove server config lines and the comment line before them
|
|
207
|
+
sed "/^# Server: $name$/d; /^SSH_SERVER_${name_upper}_/d" "$SSH_MANAGER_ENV" > "$temp"
|
|
208
|
+
|
|
209
|
+
# Find position to insert (after other servers or at end)
|
|
210
|
+
# Add updated server configuration
|
|
211
|
+
{
|
|
212
|
+
cat "$temp"
|
|
213
|
+
echo ""
|
|
214
|
+
echo "# Server: $name"
|
|
215
|
+
echo "SSH_SERVER_${name_upper}_HOST=$host"
|
|
216
|
+
echo "SSH_SERVER_${name_upper}_USER=$user"
|
|
217
|
+
echo "SSH_SERVER_${name_upper}_PORT=$port"
|
|
218
|
+
|
|
219
|
+
if [ "$auth_type" = "password" ]; then
|
|
220
|
+
echo "SSH_SERVER_${name_upper}_PASSWORD=$auth_value"
|
|
221
|
+
else
|
|
222
|
+
echo "SSH_SERVER_${name_upper}_KEYPATH=$auth_value"
|
|
223
|
+
fi
|
|
224
|
+
|
|
225
|
+
if [ -n "$description" ]; then
|
|
226
|
+
echo "SSH_SERVER_${name_upper}_DESCRIPTION=\"$description\""
|
|
227
|
+
fi
|
|
228
|
+
|
|
229
|
+
if [ -n "$default_dir" ]; then
|
|
230
|
+
echo "SSH_SERVER_${name_upper}_DEFAULT_DIR=$default_dir"
|
|
231
|
+
fi
|
|
232
|
+
} > "$SSH_MANAGER_ENV"
|
|
233
|
+
|
|
234
|
+
rm -f "$temp"
|
|
235
|
+
print_success "Server '$name' updated successfully"
|
|
236
|
+
}
|
|
237
|
+
|
|
162
238
|
# Remove server from .env
|
|
163
239
|
remove_server_from_env() {
|
|
164
240
|
local name="$1"
|
|
@@ -188,39 +264,53 @@ test_ssh_connection() {
|
|
|
188
264
|
local port=$(get_server_config "$server" "PORT")
|
|
189
265
|
local keypath=$(get_server_config "$server" "KEYPATH")
|
|
190
266
|
local password=$(get_server_config "$server" "PASSWORD")
|
|
191
|
-
|
|
267
|
+
|
|
192
268
|
port=${port:-22}
|
|
193
|
-
|
|
269
|
+
|
|
194
270
|
if [ -z "$host" ] || [ -z "$user" ]; then
|
|
195
271
|
print_error "Server '$server' not found or incomplete configuration"
|
|
196
272
|
return 1
|
|
197
273
|
fi
|
|
198
|
-
|
|
274
|
+
|
|
199
275
|
print_info "Testing connection to $server ($user@$host:$port)..."
|
|
200
|
-
|
|
201
|
-
local ssh_opts="-o ConnectTimeout=
|
|
202
|
-
|
|
276
|
+
|
|
277
|
+
local ssh_opts="-o ConnectTimeout=10 -o StrictHostKeyChecking=no"
|
|
278
|
+
local ssh_output=$(mktemp)
|
|
279
|
+
local ssh_status
|
|
280
|
+
|
|
203
281
|
if [ -n "$keypath" ]; then
|
|
204
282
|
ssh_opts="$ssh_opts -i $keypath"
|
|
205
283
|
fi
|
|
206
|
-
|
|
284
|
+
|
|
207
285
|
if [ -n "$password" ]; then
|
|
208
286
|
# Use sshpass if available
|
|
209
287
|
if command -v sshpass >/dev/null 2>&1; then
|
|
210
|
-
sshpass -p "$password" ssh $ssh_opts -p "$port" "$user@$host" "echo 'Connection successful'" 2
|
|
288
|
+
sshpass -p "$password" ssh $ssh_opts -p "$port" "$user@$host" "echo 'Connection successful'" > "$ssh_output" 2>&1
|
|
289
|
+
ssh_status=$?
|
|
211
290
|
else
|
|
212
291
|
print_warning "sshpass not installed, cannot test password authentication"
|
|
292
|
+
rm -f "$ssh_output"
|
|
213
293
|
return 1
|
|
214
294
|
fi
|
|
215
295
|
else
|
|
216
|
-
ssh $ssh_opts -p "$port" "$user@$host" "echo 'Connection successful'" 2
|
|
296
|
+
ssh $ssh_opts -p "$port" "$user@$host" "echo 'Connection successful'" > "$ssh_output" 2>&1
|
|
297
|
+
ssh_status=$?
|
|
217
298
|
fi
|
|
218
|
-
|
|
219
|
-
if [
|
|
299
|
+
|
|
300
|
+
if [ $ssh_status -eq 0 ]; then
|
|
220
301
|
print_success "Connection successful"
|
|
302
|
+
rm -f "$ssh_output"
|
|
221
303
|
return 0
|
|
222
304
|
else
|
|
223
305
|
print_error "Connection failed"
|
|
306
|
+
# Show error details if SSH_MANAGER_DEBUG is set
|
|
307
|
+
if [ -n "$SSH_MANAGER_DEBUG" ]; then
|
|
308
|
+
print_warning "Debug output:"
|
|
309
|
+
cat "$ssh_output" | sed 's/^/ /'
|
|
310
|
+
else
|
|
311
|
+
print_info "Set SSH_MANAGER_DEBUG=1 to see detailed error output"
|
|
312
|
+
fi
|
|
313
|
+
rm -f "$ssh_output"
|
|
224
314
|
return 1
|
|
225
315
|
fi
|
|
226
316
|
}
|
package/cli/lib/menu.sh
CHANGED
|
@@ -231,6 +231,130 @@ wizard_add_server() {
|
|
|
231
231
|
fi
|
|
232
232
|
}
|
|
233
233
|
|
|
234
|
+
# Edit server wizard
|
|
235
|
+
wizard_edit_server() {
|
|
236
|
+
# Select server to edit
|
|
237
|
+
if ! select_server_menu "Select Server to Edit"; then
|
|
238
|
+
return 1
|
|
239
|
+
fi
|
|
240
|
+
|
|
241
|
+
local server_name="$SELECTED_SERVER"
|
|
242
|
+
|
|
243
|
+
# Load existing configuration
|
|
244
|
+
local current_host=$(get_server_config "$server_name" "HOST")
|
|
245
|
+
local current_user=$(get_server_config "$server_name" "USER")
|
|
246
|
+
local current_port=$(get_server_config "$server_name" "PORT")
|
|
247
|
+
local current_keypath=$(get_server_config "$server_name" "KEYPATH")
|
|
248
|
+
local current_password=$(get_server_config "$server_name" "PASSWORD")
|
|
249
|
+
local current_description=$(get_server_config "$server_name" "DESCRIPTION")
|
|
250
|
+
local current_default_dir=$(get_server_config "$server_name" "DEFAULT_DIR")
|
|
251
|
+
|
|
252
|
+
current_port=${current_port:-22}
|
|
253
|
+
|
|
254
|
+
# Determine current auth type
|
|
255
|
+
local current_auth_type="key"
|
|
256
|
+
if [ -n "$current_password" ]; then
|
|
257
|
+
current_auth_type="password"
|
|
258
|
+
fi
|
|
259
|
+
|
|
260
|
+
clear
|
|
261
|
+
print_header "Edit Server - $server_name"
|
|
262
|
+
print_info "Press Enter to keep current value, or type new value"
|
|
263
|
+
echo
|
|
264
|
+
|
|
265
|
+
# Step 1: Connection Details
|
|
266
|
+
print_subheader "Step 1: Connection Details"
|
|
267
|
+
echo "----------------------------------------"
|
|
268
|
+
|
|
269
|
+
local host
|
|
270
|
+
prompt_input "Host/IP" "$current_host" "host"
|
|
271
|
+
|
|
272
|
+
local user
|
|
273
|
+
prompt_input "Username" "$current_user" "user"
|
|
274
|
+
|
|
275
|
+
local port
|
|
276
|
+
prompt_input "Port" "$current_port" "port"
|
|
277
|
+
|
|
278
|
+
# Step 2: Authentication Method
|
|
279
|
+
echo
|
|
280
|
+
print_subheader "Step 2: Authentication Method"
|
|
281
|
+
echo "----------------------------------------"
|
|
282
|
+
echo "Current method: $current_auth_type"
|
|
283
|
+
echo
|
|
284
|
+
echo " 1) 🔑 SSH Key (Recommended)"
|
|
285
|
+
echo " More secure, no password needed"
|
|
286
|
+
echo
|
|
287
|
+
echo " 2) 🔒 Password"
|
|
288
|
+
echo " Less secure, password required each time"
|
|
289
|
+
echo
|
|
290
|
+
read -p "Choose [1-2] or Enter to keep current: " auth_choice
|
|
291
|
+
|
|
292
|
+
local auth_type auth_value
|
|
293
|
+
if [ -z "$auth_choice" ]; then
|
|
294
|
+
# Keep current auth method
|
|
295
|
+
auth_type="$current_auth_type"
|
|
296
|
+
if [ "$auth_type" = "password" ]; then
|
|
297
|
+
auth_value="$current_password"
|
|
298
|
+
else
|
|
299
|
+
auth_value="$current_keypath"
|
|
300
|
+
fi
|
|
301
|
+
else
|
|
302
|
+
case "$auth_choice" in
|
|
303
|
+
2)
|
|
304
|
+
auth_type="password"
|
|
305
|
+
prompt_password "Password" "auth_value"
|
|
306
|
+
;;
|
|
307
|
+
*)
|
|
308
|
+
auth_type="key"
|
|
309
|
+
prompt_input "SSH key path" "${current_keypath:-$HOME/.ssh/id_rsa}" "auth_value"
|
|
310
|
+
# Expand ~ to home directory
|
|
311
|
+
auth_value="${auth_value/#\~/$HOME}"
|
|
312
|
+
;;
|
|
313
|
+
esac
|
|
314
|
+
fi
|
|
315
|
+
|
|
316
|
+
# Step 3: Optional Settings
|
|
317
|
+
echo
|
|
318
|
+
print_subheader "Step 3: Optional Settings"
|
|
319
|
+
echo "----------------------------------------"
|
|
320
|
+
|
|
321
|
+
local description
|
|
322
|
+
prompt_input "Description (optional)" "$current_description" "description"
|
|
323
|
+
|
|
324
|
+
local default_dir
|
|
325
|
+
prompt_input "Default directory (optional)" "$current_default_dir" "default_dir"
|
|
326
|
+
|
|
327
|
+
# Show summary
|
|
328
|
+
echo
|
|
329
|
+
print_subheader "Configuration Summary"
|
|
330
|
+
print_table_row "Name:" "$server_name"
|
|
331
|
+
print_table_row "Host:" "$host"
|
|
332
|
+
print_table_row "User:" "$user"
|
|
333
|
+
print_table_row "Port:" "$port"
|
|
334
|
+
print_table_row "Auth:" "$auth_type"
|
|
335
|
+
if [ "$auth_type" = "key" ]; then
|
|
336
|
+
print_table_row "Key:" "$auth_value"
|
|
337
|
+
fi
|
|
338
|
+
if [ -n "$description" ]; then
|
|
339
|
+
print_table_row "Description:" "$description"
|
|
340
|
+
fi
|
|
341
|
+
if [ -n "$default_dir" ]; then
|
|
342
|
+
print_table_row "Default Dir:" "$default_dir"
|
|
343
|
+
fi
|
|
344
|
+
|
|
345
|
+
echo
|
|
346
|
+
if prompt_yes_no "Save changes?" "y"; then
|
|
347
|
+
update_server_in_env "$server_name" "$host" "$user" "$auth_type" "$auth_value" "$port" "$description" "$default_dir"
|
|
348
|
+
|
|
349
|
+
echo
|
|
350
|
+
if prompt_yes_no "Test connection now?" "y"; then
|
|
351
|
+
test_ssh_connection "$server_name"
|
|
352
|
+
fi
|
|
353
|
+
else
|
|
354
|
+
print_info "Changes cancelled"
|
|
355
|
+
fi
|
|
356
|
+
}
|
|
357
|
+
|
|
234
358
|
# Server selection menu
|
|
235
359
|
select_server_menu() {
|
|
236
360
|
local prompt_text="${1:-Select a server}"
|
package/cli/ssh-manager
CHANGED
|
@@ -19,9 +19,10 @@ source "$SCRIPT_DIR/lib/menu.sh"
|
|
|
19
19
|
|
|
20
20
|
# Source command modules
|
|
21
21
|
source "$SCRIPT_DIR/commands/server.sh"
|
|
22
|
+
source "$SCRIPT_DIR/commands/tools.sh"
|
|
22
23
|
|
|
23
24
|
# Version
|
|
24
|
-
VERSION="
|
|
25
|
+
VERSION="3.1.0"
|
|
25
26
|
|
|
26
27
|
# Show version
|
|
27
28
|
show_version() {
|
|
@@ -77,6 +78,14 @@ ${BOLD}COMMANDS:${NC}
|
|
|
77
78
|
show Show configuration
|
|
78
79
|
init Initialize configuration
|
|
79
80
|
|
|
81
|
+
${CYAN}tools${NC} Tool activation/deactivation
|
|
82
|
+
list Show all tools and their status
|
|
83
|
+
configure Interactive configuration wizard
|
|
84
|
+
enable Enable a tool group
|
|
85
|
+
disable Disable a tool group
|
|
86
|
+
reset Reset to default (all tools enabled)
|
|
87
|
+
export Export Claude Code auto-approval config
|
|
88
|
+
|
|
80
89
|
${BOLD}OPTIONS:${NC}
|
|
81
90
|
-h, --help Show this help message
|
|
82
91
|
-v, --version Show version
|
|
@@ -341,6 +350,9 @@ main() {
|
|
|
341
350
|
tunnel)
|
|
342
351
|
cmd_tunnel "$@"
|
|
343
352
|
;;
|
|
353
|
+
tools)
|
|
354
|
+
cmd_tools "$@"
|
|
355
|
+
;;
|
|
344
356
|
config)
|
|
345
357
|
case "$1" in
|
|
346
358
|
edit)
|
|
@@ -414,11 +426,9 @@ interactive_mode() {
|
|
|
414
426
|
fi
|
|
415
427
|
;;
|
|
416
428
|
5)
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
read -p "Press Enter to continue..."
|
|
421
|
-
fi
|
|
429
|
+
wizard_edit_server
|
|
430
|
+
echo
|
|
431
|
+
read -p "Press Enter to continue..."
|
|
422
432
|
;;
|
|
423
433
|
6)
|
|
424
434
|
if select_server_menu "Remove Server"; then
|
|
@@ -431,7 +441,7 @@ interactive_mode() {
|
|
|
431
441
|
fi
|
|
432
442
|
;;
|
|
433
443
|
7)
|
|
434
|
-
|
|
444
|
+
cmd_server_edit_file
|
|
435
445
|
echo
|
|
436
446
|
read -p "Press Enter to continue..."
|
|
437
447
|
;;
|
package/context-test.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Server: production, Error: test-error
|