mcp-ssh-manager 3.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/.claude/settings.local.json +87 -0
- package/.flake8 +15 -0
- package/.hooks-config.json +131 -0
- package/.pre-commit-config.yaml +105 -0
- package/CHANGELOG.md +137 -0
- package/CLAUDE.md +190 -0
- package/CONTRIBUTING.md +114 -0
- package/DESCRIPTION +1 -0
- package/INSTALLATION.md +180 -0
- package/LICENSE +21 -0
- package/QUICKSTART.md +77 -0
- package/README.md +718 -0
- package/cli/README.md +286 -0
- package/cli/build.sh +199 -0
- package/cli/commands/server.sh +284 -0
- package/cli/demo.sh +107 -0
- package/cli/install.sh +164 -0
- package/cli/lib/colors.sh +174 -0
- package/cli/lib/config.sh +284 -0
- package/cli/lib/menu.sh +430 -0
- package/cli/migrate.sh +168 -0
- package/cli/ssh-manager +525 -0
- package/docs/ALIASES_AND_HOOKS.md +285 -0
- package/docs/BACKUP_GUIDE.md +500 -0
- package/docs/DEPLOYMENT_GUIDE.md +241 -0
- package/docs/SEO.md +257 -0
- package/examples/backup-workflow.js +481 -0
- package/examples/claude-code-config.example.json +40 -0
- package/examples/codex-ssh-config.example.toml +71 -0
- package/examples/deploy-workflow.py +183 -0
- package/glama.json +6 -0
- package/package.json +85 -0
- package/profiles/README.md +40 -0
- package/profiles/default.json +52 -0
- package/profiles/docker.json +62 -0
- package/profiles/frappe.json +107 -0
- package/profiles/nodejs.json +63 -0
- package/pyproject.toml +17 -0
- package/scripts/setup-hooks.sh +60 -0
- package/scripts/validate.sh +76 -0
- package/src/backup-manager.js +469 -0
- package/src/command-aliases.js +151 -0
- package/src/config-loader.js +281 -0
- package/src/database-manager.js +555 -0
- package/src/deploy-helper.js +176 -0
- package/src/health-monitor.js +428 -0
- package/src/hooks-system.js +327 -0
- package/src/index.js +4499 -0
- package/src/logger.js +276 -0
- package/src/profile-loader.js +187 -0
- package/src/server-aliases.js +150 -0
- package/src/server-groups.js +409 -0
- package/src/session-manager.js +410 -0
- package/src/ssh-key-manager.js +378 -0
- package/src/ssh-manager.js +435 -0
- package/src/tunnel-manager.js +576 -0
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
{
|
|
2
|
+
"permissions": {
|
|
3
|
+
"allow": [
|
|
4
|
+
"Bash(mkdir:*)",
|
|
5
|
+
"Bash(npm install)",
|
|
6
|
+
"Bash(pip install:*)",
|
|
7
|
+
"Bash(python tools/server-manager.py:*)",
|
|
8
|
+
"Bash(python:*)",
|
|
9
|
+
"Bash(mv:*)",
|
|
10
|
+
"Bash(tree:*)",
|
|
11
|
+
"Bash(timeout:*)",
|
|
12
|
+
"Bash(npm install:*)",
|
|
13
|
+
"Bash(npm ls:*)",
|
|
14
|
+
"Bash(node test-mcp.js)",
|
|
15
|
+
"Bash(node:*)",
|
|
16
|
+
"WebFetch(domain:github.com)",
|
|
17
|
+
"Bash(rm:*)",
|
|
18
|
+
"Bash(cat:*)",
|
|
19
|
+
"Bash(chmod:*)",
|
|
20
|
+
"Bash(uv run:*)",
|
|
21
|
+
"Bash(./test-claude-code.sh:*)",
|
|
22
|
+
"Bash(git add:*)",
|
|
23
|
+
"Bash(git commit:*)",
|
|
24
|
+
"Bash(grep:*)",
|
|
25
|
+
"Bash(git remote add:*)",
|
|
26
|
+
"Bash(git push:*)",
|
|
27
|
+
"Bash(./scripts/validate.sh:*)",
|
|
28
|
+
"Bash(npm run test:all:*)",
|
|
29
|
+
"mcp__ssh-manager__ssh_list_servers",
|
|
30
|
+
"mcp__ssh-manager__ssh_execute",
|
|
31
|
+
"mcp__ssh-manager__ssh_alias",
|
|
32
|
+
"mcp__ide__getDiagnostics",
|
|
33
|
+
"Bash(npm ci:*)",
|
|
34
|
+
"Bash(npx eslint:*)",
|
|
35
|
+
"Bash(npm run validate:*)",
|
|
36
|
+
"Bash(git pull:*)",
|
|
37
|
+
"Bash(npm test:*)",
|
|
38
|
+
"Bash(black:*)",
|
|
39
|
+
"Bash(flake8:*)",
|
|
40
|
+
"Bash(gh run list:*)",
|
|
41
|
+
"WebSearch",
|
|
42
|
+
"Bash(git clone:*)",
|
|
43
|
+
"Bash(echo:*)",
|
|
44
|
+
"Bash(claude mcp:*)",
|
|
45
|
+
"Bash(brew install:*)",
|
|
46
|
+
"Bash(gh run view:*)",
|
|
47
|
+
"Bash(git checkout:*)",
|
|
48
|
+
"Bash(gh:*)",
|
|
49
|
+
"Bash(SSH_VERBOSE:*)",
|
|
50
|
+
"Bash(git cherry-pick:*)",
|
|
51
|
+
"Bash(git merge:*)",
|
|
52
|
+
"Bash(bash:*)",
|
|
53
|
+
"Bash(./migrate.sh)",
|
|
54
|
+
"Bash(SSH_MANAGER_ENV=\"/Users/jeremy/mcp/mcp-ssh-manager-fix/.env\" /Users/jeremy/.ssh-manager-cli/ssh-manager server list)",
|
|
55
|
+
"Read(//Users/jeremy/.ssh-manager-cli/**)",
|
|
56
|
+
"mcp__ssh-manager__ssh_upload",
|
|
57
|
+
"mcp__ssh-manager__ssh_sync",
|
|
58
|
+
"Bash(npm uninstall:*)",
|
|
59
|
+
"mcp__ssh-manager__ssh_download",
|
|
60
|
+
"Bash(SSH_MANAGER_ENV=\"/Users/jeremy/mcp/mcp-ssh-manager/.env\" bash -c 'source /Users/jeremy/.ssh-manager-cli/lib/config.sh && get_server_config \"\"efaje_production\"\" \"\"HOST\"\"')",
|
|
61
|
+
"Bash(SSH_MANAGER_ENV=\"/Users/jeremy/mcp/mcp-ssh-manager/.env\" bash -c '\nsource /Users/jeremy/.ssh-manager-cli/lib/config.sh\nsource /Users/jeremy/.ssh-manager-cli/lib/menu.sh\n\n# Test avec un serveur qui n''''existe pas\nserver_name=\"\"efaje_production\"\"\nexisting_host=$(get_server_config \"\"$server_name\"\" \"\"HOST\"\" 2>/dev/null)\nif [ -n \"\"$existing_host\"\" ]; then\n echo \"\"ERREUR: Le serveur est d\\u00e9tect\\u00e9 comme existant\"\"\nelse\n echo \"\"OK: Le serveur n''''est pas d\\u00e9tect\\u00e9 comme existant\"\"\nfi\n\n# Test avec un serveur qui existe\nserver_name=\"\"efaje_staging\"\"\nexisting_host=$(get_server_config \"\"$server_name\"\" \"\"HOST\"\" 2>/dev/null)\nif [ -n \"\"$existing_host\"\" ]; then\n echo \"\"OK: Le serveur efaje_staging est bien d\\u00e9tect\\u00e9 (host: $existing_host)\"\"\nelse\n echo \"\"ERREUR: Le serveur efaje_staging n''''est pas d\\u00e9tect\\u00e9\"\"\nfi\n')",
|
|
62
|
+
"Bash(git init:*)",
|
|
63
|
+
"Bash(./build.sh:*)",
|
|
64
|
+
"Bash(SSH_MANAGER_ENV=\"/Users/jeremy/mcp/mcp-ssh-manager/.env\" /Users/jeremy/.ssh-manager-cli/ssh-manager --version)",
|
|
65
|
+
"Bash(git tag:*)",
|
|
66
|
+
"Bash(readlink:*)",
|
|
67
|
+
"Bash(SSH_MANAGER_ENV=\"/Users/jeremy/mcp/mcp-ssh-manager/.env\" bash -c '\nsource /Users/jeremy/.ssh-manager-cli/lib/config.sh\nserver=\"\"efaje_prod\"\"\nhost=$(get_server_config \"\"$server\"\" \"\"HOST\"\")\nif [ -n \"\"$host\"\" ]; then\n echo \"\"Server detected with host: $host\"\"\nelse\n echo \"\"Server not detected (host is empty)\"\"\nfi\n')",
|
|
68
|
+
"Bash(npm start:*)",
|
|
69
|
+
"Bash(ssh:*)",
|
|
70
|
+
"Bash(npm run build:*)",
|
|
71
|
+
"Read(//Users/jeremy/.ssh/**)",
|
|
72
|
+
"Read(//Users/jeremy/.codex/**)",
|
|
73
|
+
"Read(//Users/jeremy/.config/claude-code/**)",
|
|
74
|
+
"Bash(SSH_MANAGER_ENV=\"/Users/jeremy/mcp/mcp-ssh-manager/.env\" /Users/jeremy/.ssh-manager-cli/ssh-manager codex)",
|
|
75
|
+
"Bash(SSH_MANAGER_ENV=\"/Users/jeremy/mcp/mcp-ssh-manager/.env\" /Users/jeremy/.ssh-manager-cli/ssh-manager codex setup)",
|
|
76
|
+
"Bash(SSH_MANAGER_ENV=\"/Users/jeremy/mcp/mcp-ssh-manager/.env\" /Users/jeremy/.ssh-manager-cli/ssh-manager codex migrate)",
|
|
77
|
+
"Bash(SSH_MANAGER_ENV=\"/Users/jeremy/mcp/mcp-ssh-manager/.env\" /Users/jeremy/.ssh-manager-cli/ssh-manager codex test)",
|
|
78
|
+
"Bash(SSH_CONFIG_PATH=/Users/jeremy/.codex/ssh-config.toml node --check src/index.js)",
|
|
79
|
+
"Bash(ssh-manager:*)",
|
|
80
|
+
"Bash(npm whoami:*)",
|
|
81
|
+
"Bash(npm view:*)",
|
|
82
|
+
"Bash(npm pack:*)",
|
|
83
|
+
"Bash(npm publish:*)"
|
|
84
|
+
],
|
|
85
|
+
"deny": []
|
|
86
|
+
}
|
|
87
|
+
}
|
package/.flake8
ADDED
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
{
|
|
2
|
+
"pre-deploy": {
|
|
3
|
+
"enabled": true,
|
|
4
|
+
"description": "Run before any deployment",
|
|
5
|
+
"actions": [
|
|
6
|
+
{
|
|
7
|
+
"type": "validation",
|
|
8
|
+
"name": "check-git-status",
|
|
9
|
+
"command": "git status --porcelain",
|
|
10
|
+
"expectEmpty": true,
|
|
11
|
+
"errorMessage": "Uncommitted changes detected. Please commit or stash changes before deployment."
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
"type": "validation",
|
|
15
|
+
"name": "run-tests",
|
|
16
|
+
"command": "npm test 2>/dev/null || echo \"No tests configured\"",
|
|
17
|
+
"optional": true
|
|
18
|
+
}
|
|
19
|
+
]
|
|
20
|
+
},
|
|
21
|
+
"post-deploy": {
|
|
22
|
+
"enabled": true,
|
|
23
|
+
"description": "Run after successful deployment",
|
|
24
|
+
"actions": [
|
|
25
|
+
{
|
|
26
|
+
"type": "notification",
|
|
27
|
+
"name": "log-deployment",
|
|
28
|
+
"command": "echo \"[$(date)] Deployment completed to {server}\" >> deployments.log"
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
"type": "notification",
|
|
32
|
+
"name": "notify-slack",
|
|
33
|
+
"command": "curl -X POST -H \"Content-Type: application/json\" -d \"{{\\\"text\\\":\\\"Deployment to {server} completed\\\"}}\" $SLACK_WEBHOOK_URL 2>/dev/null || true",
|
|
34
|
+
"optional": true,
|
|
35
|
+
"requiresEnv": [
|
|
36
|
+
"SLACK_WEBHOOK_URL"
|
|
37
|
+
]
|
|
38
|
+
}
|
|
39
|
+
]
|
|
40
|
+
},
|
|
41
|
+
"on-error": {
|
|
42
|
+
"enabled": true,
|
|
43
|
+
"description": "Run when an error occurs",
|
|
44
|
+
"actions": [
|
|
45
|
+
{
|
|
46
|
+
"type": "notification",
|
|
47
|
+
"name": "log-error",
|
|
48
|
+
"command": "echo \"[$(date)] Error on {server}: {error}\" >> errors.log"
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
"type": "recovery",
|
|
52
|
+
"name": "attempt-recovery",
|
|
53
|
+
"remoteCommand": "bench restart && bench clear-cache",
|
|
54
|
+
"server": "{server}",
|
|
55
|
+
"optional": true
|
|
56
|
+
}
|
|
57
|
+
]
|
|
58
|
+
},
|
|
59
|
+
"pre-bench-update": {
|
|
60
|
+
"enabled": true,
|
|
61
|
+
"description": "Run before bench update",
|
|
62
|
+
"actions": [
|
|
63
|
+
{
|
|
64
|
+
"type": "backup",
|
|
65
|
+
"name": "backup-database",
|
|
66
|
+
"remoteCommand": "bench --site all backup --with-files",
|
|
67
|
+
"server": "{server}"
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
"type": "validation",
|
|
71
|
+
"name": "check-disk-space",
|
|
72
|
+
"remoteCommand": "df -h | grep -E \"/$|/home\" | awk '{print $5}' | sed 's/%//' | awk '{if($1 > 80) exit 1}'",
|
|
73
|
+
"server": "{server}",
|
|
74
|
+
"errorMessage": "Insufficient disk space (>80% used)"
|
|
75
|
+
}
|
|
76
|
+
]
|
|
77
|
+
},
|
|
78
|
+
"post-bench-update": {
|
|
79
|
+
"enabled": true,
|
|
80
|
+
"description": "Run after bench update",
|
|
81
|
+
"actions": [
|
|
82
|
+
{
|
|
83
|
+
"type": "verification",
|
|
84
|
+
"name": "check-services",
|
|
85
|
+
"remoteCommand": "supervisorctl status | grep -E \"RUNNING|STOPPED\"",
|
|
86
|
+
"server": "{server}"
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
"type": "verification",
|
|
90
|
+
"name": "check-site-status",
|
|
91
|
+
"remoteCommand": "bench --site all doctor",
|
|
92
|
+
"server": "{server}"
|
|
93
|
+
}
|
|
94
|
+
]
|
|
95
|
+
},
|
|
96
|
+
"pre-connect": {
|
|
97
|
+
"enabled": false,
|
|
98
|
+
"description": "Run before connecting to a server",
|
|
99
|
+
"actions": [
|
|
100
|
+
{
|
|
101
|
+
"type": "validation",
|
|
102
|
+
"name": "check-vpn",
|
|
103
|
+
"command": "ping -c 1 -W 2 10.0.0.1 > /dev/null 2>&1",
|
|
104
|
+
"errorMessage": "VPN not connected",
|
|
105
|
+
"optional": true
|
|
106
|
+
}
|
|
107
|
+
]
|
|
108
|
+
},
|
|
109
|
+
"post-connect": {
|
|
110
|
+
"enabled": false,
|
|
111
|
+
"description": "Run after successful connection",
|
|
112
|
+
"actions": [
|
|
113
|
+
{
|
|
114
|
+
"type": "notification",
|
|
115
|
+
"name": "log-connection",
|
|
116
|
+
"command": "echo \"[$(date)] Connected to {server}\" >> connections.log"
|
|
117
|
+
}
|
|
118
|
+
]
|
|
119
|
+
},
|
|
120
|
+
"context-test": {
|
|
121
|
+
"enabled": true,
|
|
122
|
+
"description": "Context replacement test",
|
|
123
|
+
"actions": [
|
|
124
|
+
{
|
|
125
|
+
"type": "notification",
|
|
126
|
+
"name": "use-context",
|
|
127
|
+
"command": "echo \"Server: {server}, Error: {error}\" > /Users/jeremy/mcp/mcp-ssh-manager/context-test.txt"
|
|
128
|
+
}
|
|
129
|
+
]
|
|
130
|
+
}
|
|
131
|
+
}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
repos:
|
|
2
|
+
# JavaScript/Node.js checks
|
|
3
|
+
- repo: local
|
|
4
|
+
hooks:
|
|
5
|
+
- id: check-js-syntax
|
|
6
|
+
name: Check JavaScript syntax
|
|
7
|
+
entry: node --check
|
|
8
|
+
language: system
|
|
9
|
+
files: '\.js$'
|
|
10
|
+
|
|
11
|
+
- id: eslint
|
|
12
|
+
name: ESLint
|
|
13
|
+
entry: npx eslint --fix
|
|
14
|
+
language: system
|
|
15
|
+
files: '\.js$'
|
|
16
|
+
require_serial: false
|
|
17
|
+
|
|
18
|
+
- id: prettier-js
|
|
19
|
+
name: Prettier JavaScript
|
|
20
|
+
entry: npx prettier --write
|
|
21
|
+
language: system
|
|
22
|
+
files: '\.(js|json)$'
|
|
23
|
+
exclude: 'package-lock\.json'
|
|
24
|
+
|
|
25
|
+
# Python checks
|
|
26
|
+
- repo: local
|
|
27
|
+
hooks:
|
|
28
|
+
- id: check-python-syntax
|
|
29
|
+
name: Check Python syntax
|
|
30
|
+
entry: python -m py_compile
|
|
31
|
+
language: system
|
|
32
|
+
files: '\.py$'
|
|
33
|
+
|
|
34
|
+
- repo: https://github.com/psf/black
|
|
35
|
+
rev: 23.12.1
|
|
36
|
+
hooks:
|
|
37
|
+
- id: black
|
|
38
|
+
language_version: python3
|
|
39
|
+
files: '\.py$'
|
|
40
|
+
|
|
41
|
+
- repo: https://github.com/PyCQA/flake8
|
|
42
|
+
rev: 7.0.0
|
|
43
|
+
hooks:
|
|
44
|
+
- id: flake8
|
|
45
|
+
files: '\.py$'
|
|
46
|
+
|
|
47
|
+
# General checks
|
|
48
|
+
- repo: https://github.com/pre-commit/pre-commit-hooks
|
|
49
|
+
rev: v4.5.0
|
|
50
|
+
hooks:
|
|
51
|
+
- id: trailing-whitespace
|
|
52
|
+
- id: end-of-file-fixer
|
|
53
|
+
- id: check-yaml
|
|
54
|
+
- id: check-json
|
|
55
|
+
exclude: 'package-lock\.json'
|
|
56
|
+
- id: check-added-large-files
|
|
57
|
+
args: ['--maxkb=500']
|
|
58
|
+
- id: check-merge-conflict
|
|
59
|
+
- id: detect-private-key
|
|
60
|
+
|
|
61
|
+
# Security check for secrets
|
|
62
|
+
- repo: https://github.com/Yelp/detect-secrets
|
|
63
|
+
rev: v1.4.0
|
|
64
|
+
hooks:
|
|
65
|
+
- id: detect-secrets
|
|
66
|
+
args: ['--baseline', '.secrets.baseline']
|
|
67
|
+
exclude: package-lock\.json
|
|
68
|
+
|
|
69
|
+
# Custom validation hooks
|
|
70
|
+
- repo: local
|
|
71
|
+
hooks:
|
|
72
|
+
- id: test-profiles
|
|
73
|
+
name: Test Profile System
|
|
74
|
+
entry: node tests/test-profiles.js
|
|
75
|
+
language: system
|
|
76
|
+
pass_filenames: false
|
|
77
|
+
files: 'profiles/.*\.json$|src/profile-loader\.js$'
|
|
78
|
+
|
|
79
|
+
- id: test-aliases
|
|
80
|
+
name: Test Command Aliases
|
|
81
|
+
entry: node tests/test-command-aliases.js
|
|
82
|
+
language: system
|
|
83
|
+
pass_filenames: false
|
|
84
|
+
files: 'src/command-aliases\.js$'
|
|
85
|
+
|
|
86
|
+
- id: test-hooks
|
|
87
|
+
name: Test Hooks System
|
|
88
|
+
entry: node tests/test-hooks.js
|
|
89
|
+
language: system
|
|
90
|
+
pass_filenames: false
|
|
91
|
+
files: 'src/hooks-system\.js$'
|
|
92
|
+
|
|
93
|
+
- id: validate-all-profiles
|
|
94
|
+
name: Validate all profile JSON files
|
|
95
|
+
entry: bash -c 'for f in profiles/*.json; do python -m json.tool "$f" > /dev/null || exit 1; done'
|
|
96
|
+
language: system
|
|
97
|
+
pass_filenames: false
|
|
98
|
+
files: 'profiles/.*\.json$'
|
|
99
|
+
|
|
100
|
+
- id: check-no-env-in-git
|
|
101
|
+
name: Ensure .env is not tracked
|
|
102
|
+
entry: bash -c '! git ls-files | grep -q "^\.env$"'
|
|
103
|
+
language: system
|
|
104
|
+
pass_filenames: false
|
|
105
|
+
always_run: true
|
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to MCP SSH Manager will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [3.0.0] - 2025-10-01
|
|
9
|
+
|
|
10
|
+
### 🎉 Major Release - Enterprise DevOps Features
|
|
11
|
+
|
|
12
|
+
This major release transforms MCP SSH Manager into a comprehensive DevOps automation platform with **12 new MCP tools** across three major feature areas.
|
|
13
|
+
|
|
14
|
+
### Added
|
|
15
|
+
|
|
16
|
+
#### Phase 1: Backup & Restore System (v2.1)
|
|
17
|
+
- **ssh_backup_create**: Create database or file backups with compression
|
|
18
|
+
- Supports MySQL, PostgreSQL, MongoDB, and file system backups
|
|
19
|
+
- Automatic gzip compression and metadata tracking
|
|
20
|
+
- Configurable retention policies
|
|
21
|
+
- Auto-creates backup directory if missing
|
|
22
|
+
- **ssh_backup_list**: List all available backups with detailed metadata
|
|
23
|
+
- **ssh_backup_restore**: Restore from previous backups with cross-database support
|
|
24
|
+
- **ssh_backup_schedule**: Schedule automatic backups using cron
|
|
25
|
+
|
|
26
|
+
#### Phase 2: Health Checks & Monitoring (v2.2)
|
|
27
|
+
- **ssh_health_check**: Comprehensive server health monitoring
|
|
28
|
+
- CPU, Memory (RAM/Swap), Disk usage for all filesystems
|
|
29
|
+
- Network statistics, system uptime, load average
|
|
30
|
+
- Overall health status: healthy/warning/critical
|
|
31
|
+
- **ssh_service_status**: Monitor services (nginx, mysql, docker, etc.)
|
|
32
|
+
- Supports systemd and sysv init systems
|
|
33
|
+
- Returns running/stopped status with PID
|
|
34
|
+
- **ssh_process_manager**: Process management
|
|
35
|
+
- List top processes sorted by CPU or memory
|
|
36
|
+
- Kill processes with configurable signals
|
|
37
|
+
- **ssh_alert_setup**: Configure health monitoring alerts with custom thresholds
|
|
38
|
+
|
|
39
|
+
#### Phase 3: Database Management (v2.3)
|
|
40
|
+
- **ssh_db_dump**: Create database dumps (MySQL, PostgreSQL, MongoDB)
|
|
41
|
+
- Gzip compression and selective table backups
|
|
42
|
+
- **ssh_db_import**: Import and restore databases
|
|
43
|
+
- Auto-detection of compressed files
|
|
44
|
+
- **ssh_db_list**: List databases or tables/collections
|
|
45
|
+
- Filters system databases automatically
|
|
46
|
+
- **ssh_db_query**: Execute read-only SQL queries
|
|
47
|
+
- **Security**: Only SELECT queries allowed
|
|
48
|
+
- Blocks DROP, DELETE, UPDATE, ALTER operations
|
|
49
|
+
|
|
50
|
+
### Fixed
|
|
51
|
+
|
|
52
|
+
- **ssh_service_status**: Fixed parsing bug where active services were incorrectly detected as "stopped"
|
|
53
|
+
- Redirected systemctl output to /dev/null for clean status detection
|
|
54
|
+
|
|
55
|
+
### Improved
|
|
56
|
+
|
|
57
|
+
- **ssh_backup_create**: Auto-creates backup directory with error handling
|
|
58
|
+
- Previously required manual creation of `/var/backups/ssh-manager`
|
|
59
|
+
|
|
60
|
+
### Documentation
|
|
61
|
+
|
|
62
|
+
- Added `docs/BACKUP_GUIDE.md` with comprehensive backup strategies
|
|
63
|
+
- Added `examples/backup-workflow.js` with 13 real-world examples
|
|
64
|
+
- Updated README.md and CLAUDE.md with all new tools
|
|
65
|
+
|
|
66
|
+
### Technical Details
|
|
67
|
+
|
|
68
|
+
- **New Modules**: backup-manager.js (469 lines), health-monitor.js (428 lines), database-manager.js (555 lines)
|
|
69
|
+
- **Total Lines Added**: ~4,100 lines of production code
|
|
70
|
+
- **Total Tools**: 37 MCP tools (25 existing + 12 new)
|
|
71
|
+
- **Supported Databases**: MySQL, PostgreSQL, MongoDB
|
|
72
|
+
- **Security**: SQL injection prevention, read-only query enforcement
|
|
73
|
+
|
|
74
|
+
### Breaking Changes
|
|
75
|
+
|
|
76
|
+
None. All existing tools remain fully compatible.
|
|
77
|
+
|
|
78
|
+
---
|
|
79
|
+
|
|
80
|
+
## [1.3.0] - 2025-09-04
|
|
81
|
+
|
|
82
|
+
### Added
|
|
83
|
+
- OpenAI Codex compatibility with TOML configuration support
|
|
84
|
+
- Enhanced documentation visibility for both Claude Code and Codex
|
|
85
|
+
- Dual configuration format support (.env and TOML)
|
|
86
|
+
- Badge system in README for platform compatibility
|
|
87
|
+
|
|
88
|
+
---
|
|
89
|
+
|
|
90
|
+
## [1.2.0] - 2025-08-12
|
|
91
|
+
|
|
92
|
+
### Added
|
|
93
|
+
- **ssh_deploy** tool for automated file deployment with permission handling
|
|
94
|
+
- **ssh_execute_sudo** tool for secure sudo command execution
|
|
95
|
+
- **ssh_alias** tool for managing server aliases
|
|
96
|
+
- Server alias support - use short names like "prod" instead of full server names
|
|
97
|
+
- Automatic permission detection for system directories
|
|
98
|
+
- Backup creation before file deployment
|
|
99
|
+
- Service restart capability after deployment
|
|
100
|
+
- Deployment helper functions for complex workflows
|
|
101
|
+
- Comprehensive deployment guide documentation
|
|
102
|
+
- Example deployment workflows
|
|
103
|
+
|
|
104
|
+
### Enhanced
|
|
105
|
+
- Connection resolution now supports aliases and partial matches
|
|
106
|
+
- Better error messages with available servers and aliases
|
|
107
|
+
- Secure sudo password handling (masked in logs)
|
|
108
|
+
- Support for batch file deployments
|
|
109
|
+
|
|
110
|
+
### Security
|
|
111
|
+
- Sudo passwords are never logged in plain text
|
|
112
|
+
- Automatic masking of sensitive information in command output
|
|
113
|
+
- Secure temporary file handling during deployments
|
|
114
|
+
|
|
115
|
+
## [1.1.0] - 2025-08-11
|
|
116
|
+
|
|
117
|
+
### Added
|
|
118
|
+
- Default directory configuration per server
|
|
119
|
+
- DEFAULT_DIR field in .env configuration
|
|
120
|
+
- Automatic working directory for commands
|
|
121
|
+
|
|
122
|
+
### Fixed
|
|
123
|
+
- Syntax error in index.js (extra parenthesis)
|
|
124
|
+
|
|
125
|
+
## [1.0.0] - 2025-08-10
|
|
126
|
+
|
|
127
|
+
### Initial Release
|
|
128
|
+
- Core SSH connection management
|
|
129
|
+
- ssh_execute tool for remote command execution
|
|
130
|
+
- ssh_upload tool for file uploads
|
|
131
|
+
- ssh_download tool for file downloads
|
|
132
|
+
- ssh_list_servers tool to list configured servers
|
|
133
|
+
- Password and SSH key authentication support
|
|
134
|
+
- Interactive server configuration tool
|
|
135
|
+
- Connection testing utility
|
|
136
|
+
- Pre-commit hooks for code quality
|
|
137
|
+
- GitHub Actions workflow for CI/CD
|
package/CLAUDE.md
ADDED
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
# CLAUDE.md
|
|
2
|
+
|
|
3
|
+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
|
|
4
|
+
|
|
5
|
+
## Project Overview
|
|
6
|
+
|
|
7
|
+
MCP SSH Manager is a Model Context Protocol server that enables Claude Code to manage multiple SSH connections. It provides tools for executing commands, transferring files, and managing deployments across remote servers.
|
|
8
|
+
|
|
9
|
+
## Architecture
|
|
10
|
+
|
|
11
|
+
The system consists of three main components:
|
|
12
|
+
|
|
13
|
+
1. **MCP Server** (`src/index.js`): Node.js-based MCP server using the Model Context Protocol SDK
|
|
14
|
+
- Handles SSH connections via node-ssh library
|
|
15
|
+
- Manages connection pooling to avoid reconnecting
|
|
16
|
+
- Provides MCP tools for Claude Code integration
|
|
17
|
+
|
|
18
|
+
2. **Server Management** (`tools/server_manager.py`): Python CLI for configuration
|
|
19
|
+
- Manages `.env` file with server configurations
|
|
20
|
+
- Tests connections using Paramiko
|
|
21
|
+
- Configures Claude Code integration
|
|
22
|
+
|
|
23
|
+
3. **Deployment Helpers** (`src/deploy-helper.js`, `src/server-aliases.js`): Advanced features
|
|
24
|
+
- Automated deployment strategies with permission handling
|
|
25
|
+
- Server alias management for simplified access
|
|
26
|
+
- Batch deployment scripts generation
|
|
27
|
+
|
|
28
|
+
## Commands
|
|
29
|
+
|
|
30
|
+
### Setup and Installation
|
|
31
|
+
```bash
|
|
32
|
+
npm install # Install Node.js dependencies
|
|
33
|
+
./scripts/setup-hooks.sh # Setup pre-commit hooks for development
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### Server Management (Bash CLI)
|
|
37
|
+
```bash
|
|
38
|
+
ssh-manager server add # Add a new server
|
|
39
|
+
ssh-manager server list # List configured servers
|
|
40
|
+
ssh-manager server test SERVER # Test connection to specific server
|
|
41
|
+
ssh-manager server remove SERVER # Remove a server
|
|
42
|
+
ssh-manager server show SERVER # Show server details
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### OpenAI Codex Integration
|
|
46
|
+
```bash
|
|
47
|
+
ssh-manager codex setup # Configure for Codex
|
|
48
|
+
ssh-manager codex migrate # Convert servers to TOML
|
|
49
|
+
ssh-manager codex test # Test Codex integration
|
|
50
|
+
ssh-manager codex convert to-toml # Convert .env to TOML
|
|
51
|
+
ssh-manager codex convert to-env # Convert TOML to .env
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### Development and Testing
|
|
55
|
+
```bash
|
|
56
|
+
npm start # Start MCP server (requires stdin)
|
|
57
|
+
./scripts/validate.sh # Run all validation checks
|
|
58
|
+
node --check src/index.js # Check JavaScript syntax
|
|
59
|
+
python -m py_compile tools/*.py # Check Python syntax
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### Debug Tools (in `debug/` directory)
|
|
63
|
+
```bash
|
|
64
|
+
./debug/test-claude-code.sh # Test Claude Code integration
|
|
65
|
+
node debug/test-mcp.js # Test MCP connection
|
|
66
|
+
node debug/test-ssh-command.js # Test SSH command execution
|
|
67
|
+
python debug/test_basic.py # Basic Python tests
|
|
68
|
+
python debug/test_fastmcp.py # FastMCP integration test
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
## MCP Tools Available
|
|
72
|
+
|
|
73
|
+
The server exposes these tools to Claude Code and OpenAI Codex:
|
|
74
|
+
|
|
75
|
+
### Core Tools
|
|
76
|
+
- `ssh_list_servers`: List all configured SSH servers
|
|
77
|
+
- `ssh_execute`: Execute commands on remote servers (supports default directories)
|
|
78
|
+
- `ssh_upload`: Upload files to remote servers
|
|
79
|
+
- `ssh_download`: Download files from remote servers
|
|
80
|
+
|
|
81
|
+
### Backup & Restore (v2.1+)
|
|
82
|
+
- `ssh_backup_create`: Create database or file backups (MySQL, PostgreSQL, MongoDB, Files)
|
|
83
|
+
- `ssh_backup_list`: List all available backups with metadata
|
|
84
|
+
- `ssh_backup_restore`: Restore from previous backups
|
|
85
|
+
- `ssh_backup_schedule`: Schedule automatic backups using cron
|
|
86
|
+
|
|
87
|
+
### Health & Monitoring (v2.2+)
|
|
88
|
+
- `ssh_health_check`: Comprehensive server health check (CPU, RAM, Disk, Network)
|
|
89
|
+
- `ssh_service_status`: Check status of services (nginx, mysql, docker, etc.)
|
|
90
|
+
- `ssh_process_manager`: List, monitor, or kill processes
|
|
91
|
+
- `ssh_alert_setup`: Configure health monitoring alerts and thresholds
|
|
92
|
+
|
|
93
|
+
### Database Management (v2.3+)
|
|
94
|
+
- `ssh_db_dump`: Create database dumps (MySQL, PostgreSQL, MongoDB)
|
|
95
|
+
- `ssh_db_import`: Import SQL dumps or restore databases
|
|
96
|
+
- `ssh_db_list`: List databases or tables/collections
|
|
97
|
+
- `ssh_db_query`: Execute read-only SELECT queries (security validated)
|
|
98
|
+
|
|
99
|
+
### Deployment & Management
|
|
100
|
+
- `ssh_deploy`: Deploy files with automatic permission/backup handling
|
|
101
|
+
- `ssh_execute_sudo`: Execute commands with sudo privileges
|
|
102
|
+
- `ssh_alias`: Manage server aliases (add/remove/list)
|
|
103
|
+
- `ssh_sync`: Bidirectional file synchronization with rsync
|
|
104
|
+
- `ssh_monitor`: System resource monitoring
|
|
105
|
+
- `ssh_tail`: Real-time log monitoring
|
|
106
|
+
|
|
107
|
+
### Advanced Features
|
|
108
|
+
- `ssh_session_*`: Persistent SSH sessions
|
|
109
|
+
- `ssh_tunnel_*`: SSH tunnel management (local/remote/SOCKS)
|
|
110
|
+
- `ssh_group_*`: Server group operations
|
|
111
|
+
- `ssh_command_alias`: Command alias management
|
|
112
|
+
- `ssh_hooks`: Automation hooks
|
|
113
|
+
- `ssh_profile`: Profile management
|
|
114
|
+
|
|
115
|
+
## Server Configuration
|
|
116
|
+
|
|
117
|
+
### Configuration Formats
|
|
118
|
+
|
|
119
|
+
MCP SSH Manager supports two configuration formats:
|
|
120
|
+
|
|
121
|
+
1. **Environment Variables (.env)** - Traditional format for Claude Code
|
|
122
|
+
2. **TOML** - Modern format for OpenAI Codex
|
|
123
|
+
|
|
124
|
+
### Configuration Loading Priority
|
|
125
|
+
|
|
126
|
+
The system loads configurations in this order (highest to lowest priority):
|
|
127
|
+
1. Environment variables (process.env)
|
|
128
|
+
2. `.env` file in project root
|
|
129
|
+
3. TOML file (specified by SSH_CONFIG_PATH or ~/.codex/ssh-config.toml)
|
|
130
|
+
|
|
131
|
+
### .env Format
|
|
132
|
+
```
|
|
133
|
+
SSH_SERVER_[NAME]_HOST=hostname
|
|
134
|
+
SSH_SERVER_[NAME]_USER=username
|
|
135
|
+
SSH_SERVER_[NAME]_PASSWORD=password # For password auth
|
|
136
|
+
SSH_SERVER_[NAME]_KEYPATH=~/.ssh/key # For SSH key auth
|
|
137
|
+
SSH_SERVER_[NAME]_PORT=22 # Optional
|
|
138
|
+
SSH_SERVER_[NAME]_DEFAULT_DIR=/path # Optional default working directory
|
|
139
|
+
SSH_SERVER_[NAME]_SUDO_PASSWORD=pass # Optional for automated sudo
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
### TOML Format
|
|
143
|
+
```toml
|
|
144
|
+
[ssh_servers.name]
|
|
145
|
+
host = "hostname"
|
|
146
|
+
user = "username"
|
|
147
|
+
password = "password" # For password auth
|
|
148
|
+
key_path = "~/.ssh/key" # For SSH key auth
|
|
149
|
+
port = 22 # Optional
|
|
150
|
+
default_dir = "/path" # Optional default working directory
|
|
151
|
+
sudo_password = "pass" # Optional for automated sudo
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
## Key Implementation Details
|
|
155
|
+
|
|
156
|
+
1. **Connection Pooling**: The server maintains persistent SSH connections in a Map to avoid reconnection overhead (src/index.js:31)
|
|
157
|
+
|
|
158
|
+
2. **Server Resolution**: Server names are resolved through aliases first, then direct lookup. Names are normalized to lowercase (src/index.js:54-68)
|
|
159
|
+
|
|
160
|
+
3. **Default Directories**: If a server has a DEFAULT_DIR configured and no cwd is provided to ssh_execute, commands run in that directory
|
|
161
|
+
|
|
162
|
+
4. **Deployment Strategy**: The deploy helper detects permission issues and automatically creates scripts for sudo execution when needed
|
|
163
|
+
|
|
164
|
+
5. **Environment Loading**: Uses dotenv to load configuration from `.env` file in project root
|
|
165
|
+
|
|
166
|
+
## Security Considerations
|
|
167
|
+
|
|
168
|
+
- Never commit `.env` files (included in .gitignore)
|
|
169
|
+
- SSH keys preferred over passwords
|
|
170
|
+
- Sudo passwords stored separately from regular passwords
|
|
171
|
+
- Connection errors logged to stderr for debugging
|
|
172
|
+
- Pre-commit hooks check for sensitive data leaks
|
|
173
|
+
|
|
174
|
+
## Validation and Quality
|
|
175
|
+
|
|
176
|
+
Run `./scripts/validate.sh` before commits to check:
|
|
177
|
+
- JavaScript syntax validity
|
|
178
|
+
- Python syntax validity
|
|
179
|
+
- No `.env` file in git
|
|
180
|
+
- MCP server startup
|
|
181
|
+
- Dependencies installed
|
|
182
|
+
|
|
183
|
+
## Claude Code Integration
|
|
184
|
+
|
|
185
|
+
To install in Claude Code:
|
|
186
|
+
```bash
|
|
187
|
+
claude mcp add ssh-manager node /absolute/path/to/mcp-ssh-manager/src/index.js
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
Configuration is stored in `~/.config/claude-code/claude_code_config.json`
|