π MCP Orchestrator β SSH/SFTP Infrastructure Orchestration Server
Version : 11.3.0
License : MIT
Node : >= 18.0.0
A Model Context Protocol (MCP) server that turns any AI agent (Claude, OpenCode, Cursor...) into a full-fledged system administrator. Persistent queue, SSH connection pool, hybrid sync/async execution.
β¨ Key Features
- 63 MCP tools β SSH, SFTP, file ops, monitoring, snapshots, tunnels
- Built-in security β Command blocklist, port allowlist, hash protection
- Multi-server β
task_exec {alias:["vps1","vps2"]} or alias:"all"}
- Persistence β tmux + persistent queue = sessions that survive crashes
- Snapshots β Deduplicated versioning of your critical files
- SSH Tunnels β Local, Remote, SOCKS5 with secured port allowlist
- AI Guide β Built-in manual for the agent (section:index/workflows/audit/security)
π«π· Version franΓ§aise : README.fr.md
π¦ Installation
Via npx (recommended)
npx @fkom13/mcp-sftp-orchestrator
Via git
git clone https://github.com/fkom13/mcp-sftp-orchestrator.git
cd mcp-sftp-orchestrator
npm install
cp .env.example .env
# Edit .env with your paths
Requirements: Node.js >= 18.0.0
βοΈ Configuration (.env)
All variables are optional. Defaults are designed for standard usage.
| Variable | Default | Description |
|---|
MCP_DATA_DIR | ~/.config/mcp-orchestrator | Data directory (servers.json, apis.json, queue.json) |
MCP_SYNC_TIMEOUT_S | 120 | Seconds before background execution |
MCP_DEFAULT_CMD_TIMEOUT_S | 600 | Default SSH timeout (0 = unlimited) |
MCP_INTERACTIVE_CMD_TIMEOUT_S | 300 | Interactive command timeout (0 = unlimited) |
MCP_MAX_WAIT_TIMEOUT_S | 600 | Max timeout for task_wait |
MAX_CONNECTIONS_PER_SERVER | 5 | Max parallel SSH connections per server |
MIN_CONNECTIONS_PER_SERVER | 1 | Min pooled connections per server |
IDLE_TIMEOUT | 300000 | Idle connection close delay (ms) |
KEEP_ALIVE_INTERVAL | 30000 | SSH keepalive interval (ms) |
MAX_QUEUE_SIZE | 1000 | Max jobs in queue |
SAVE_INTERVAL | 5000 | Queue disk save interval (ms) |
MCP_ALLOWED_ROOTS | (empty) | Restrict file access to these roots (comma-separated). Empty = full access |
MCP_DEBUG | false | Enable detailed debug logs |
π MCP Client Configuration (OpenCode, Claude Desktop, etc.)
{
"mcpServers": {
"orchestrator": {
"command": "node",
"args": ["/path/to/sftp-mcp/server.js"],
"env": {
"MCP_DATA_DIR": "/path/to/sftp-mcp/data"
}
}
}
}
π§° Tool Reference (63 tools)
Help & Diagnostics
| Tool | Description |
|---|
help | Complete guide: tools, env vars, parameter schemas |
guide | AI manual: workflows, cheatsheet, audit, security |
system_diagnostics | Full system diagnostic (queue, pool, servers, APIs) |
Server Management
| Tool | Description |
|---|
server_add | Add/update a server alias |
server_list | List all configured servers |
server_remove | Remove a server alias |
infra_overview | Fleet-wide overview (roles, services, warnings) |
server_note_set/get/list/remove | Documented server context |
Security (Blocklist)
| Tool | Description |
|---|
policy_blocklist_list | List blocked commands |
policy_blocklist_add | Add a pattern to blocklist |
policy_blocklist_remove | Remove a pattern from blocklist |
Task Execution
| Tool | Description |
|---|
task_exec | SSH one-shot. Supports alias:["vps1","vps2"] or alias:"all" |
task_exec_interactive | SSH with interactive prompt handling |
task_exec_sequence | Sequential SSH commands |
task_transfer | SFTP transfer. Supports server_to_server |
task_transfer_multi | Bulk transfers with glob patterns |
Monitoring
| Tool | Description |
|---|
get_system_resources | CPU, RAM, Disk metrics |
get_services_status | systemd, Docker, PM2 status (graceful fallback) |
get_fail2ban_status | Fail2Ban status |
check_api_health | HTTP health check |
Logs
| Tool | Description |
|---|
get_pm2_logs | PM2 logs |
get_docker_logs | Docker logs |
tail_file | Tail a remote file |
File Operations (Local + Remote)
| Tool | Description |
|---|
file_read | Read file + SHA-256 hash (edit protection) |
file_write | Create/overwrite with dryRun and backup |
file_edit | Surgical or full edit + hash protection |
Comparison & Drift Detection
| Tool | Description |
|---|
diff_files | Compare 2 files (local/remote, cross-server) |
diff_folders | Compare 2 directories |
compare_all_sources | Detect drifts across N servers |
Persistent Shell Sessions
| Tool | Description |
|---|
shell_create | Open a persistent shell (cd/env preserved) |
shell_exec | Execute in an existing session |
shell_list / shell_close | List/close sessions |
tmux (Surviving Terminal Sessions)
| Tool | Description |
|---|
tmux_create | Create a persistent tmux session |
tmux_exec | Send a command to a session |
tmux_read | Read session buffer |
tmux_list / tmux_kill | List/kill sessions |
SSH Tunnels
| Tool | Description |
|---|
tunnel_create | Local/remote/SOCKS5 tunnel, persistent via tmux |
tunnel_list | List active tunnels |
tunnel_close | Close a tunnel |
tunnel_allowlist_add/remove | Manage allowed ports |
Snapshots (File Versioning)
| Tool | Description |
|---|
snapshot_create | Capture file state with deduplication |
snapshot_list | List snapshots |
snapshot_diff | Compare 2 snapshots |
snapshot_restore | Restore (dryRun by default) |
snapshot_delete | Delete + orphan cleanup |
Queue & Monitoring
| Tool | Description |
|---|
task_queue | View all active/pending tasks |
task_status | Task detail by ID |
task_history | Filterable history |
task_retry | Retry a failed task |
task_wait | Wait for a background task |
task_logs | MCP internal logs |
queue_stats / pool_stats | Queue and SSH pool stats |
API Catalog
| Tool | Description |
|---|
api_add / api_list / api_remove | API monitoring catalog |
api_check | Health check via SSH + curl |
π Usage Examples
Multi-server
# One command, multiple servers
task_exec {alias:["vps1","vps2","vps3"], cmd:"uptime"}
# Entire fleet
task_exec {alias:"all", cmd:"df -h /"}
SOCKS5 Proxy Tunnel
tunnel_create {name:"proxy", type:"socks", listen_port:1080, via:"vps_paris"}
# β Browser β SOCKS5 127.0.0.1:1080 β Paris VPS
Local Tunnel (access remote service)
tunnel_create {name:"crm", type:"local", listen_port:8080, target:"127.0.0.1:3100", via:"vps_prod"}
# β http://localhost:8080 β production CRM
Remote Tunnel (expose local service)
tunnel_create {name:"dev", type:"remote", listen_port:9090, target:"127.0.0.1:3000", via:"vps", source:"vps_prod", key_path:"/home/user/.ssh/vps.key"}
# β vps_prod:9090 β your local machine:3000
Persistent tmux Session
tmux_create {alias:"vps", name:"build", start_cmd:"npm run build"}
tmux_read {alias:"vps", session:"build"}
tmux_kill {alias:"vps", session:"build"}
Security Blocklist
# List blocked commands
policy_blocklist_list
# β ["rm -rf /", "mkfs*", ...]
# Conscious bypass
task_exec {alias:"vps", cmd:"rm -rf /tmp/cache", skip_policy:true}
Secure File Editing
# Read + hash
file_read {source:{type:"remote", alias:"vps", path:"/etc/nginx/nginx.conf"}}
# β content + hash
# Edit with protection
file_edit {source:{type:"remote", alias:"vps", path:"/etc/nginx/nginx.conf"},
oldString:"worker_connections 768;",
newString:"worker_connections 1024;",
expectedHash:"abc123...",
backup:true}
# Preview without writing
file_edit {source:{type:"remote", alias:"vps", path:"/etc/nginx/nginx.conf"},
oldString:"worker_connections 768;",
newString:"worker_connections 1024;",
dryRun:true}
Snapshot Before Risky Changes
# Before
snapshot_create {source:{type:"remote", alias:"vps"}, paths:["/etc/nginx/"], tag:"before-fix"}
# After if something broke
snapshot_restore {snapshotId:"...", target:{type:"remote", alias:"vps"}, dryRun:false, force:true}
Multi-server Drift Detection
compare_all_sources {sources:[
{type:"remote", alias:"vps1", path:"/etc/nginx/nginx.conf", label:"prod"},
{type:"remote", alias:"vps2", path:"/etc/nginx/nginx.conf", label:"staging"}
]}
π AI Built-in Manual (guide)
The orchestrator includes an interactive manual for your AI agent:
guide section:index # Table of contents
guide section:workflows # Copy-paste recipes
guide section:cheatsheet # Tool β usage table
guide section:audit # Full fleet audit in 8 steps
guide section:security # Blocklist + tunnels
guide section:pitfalls # Common mistakes
ποΈ Architecture
MCP Client (stdio)
β
server.js βββ 63 MCP tools registered
β
βββ queue.js βββββββ Persistent job queue (JSON + backup)
βββ ssh.js βββββββββ SSH execution (pool + dedicated connections)
βββ sftp.js ββββββββ SFTP transfers (upload/download/multi)
βββ sshPool.js βββββ Persistent SSH connection pool
βββ servers.js βββββ CRUD server aliases
βββ apis.js ββββββββ CRUD API catalog
βββ history.js βββββ Task history
βββ config.js ββββββ Centralized configuration
βββ utils.js βββββββ Utilities (escapeShellArg)
βββ fileOps.js βββββ File operations (read/write/edit)
βββ diffEngine.js ββ Diff engine (files/dirs/sources)
βββ compareEngine.js β Multi-source comparison
βββ diffFormatter.js β Diff formatting
βββ sourceAdapter.js β Local/remote abstraction
βββ shellSessions.js β Persistent shell sessions
βββ snapshotManager.js β Versioned snapshots
βββ notes.js ββββββββ Documented server context
βββ policies.js ββββ Command blocklist
βββ tunnels.js ββββββ SSH tunnels (local/remote/SOCKS)
βββ guide.js ββββββββ AI built-in manual
βββ diagnose.js βββββ Diagnostics
Job Lifecycle
pending β running β completed / failed
β (on restart)
crashed β retry β pending
π Security
- Command Blocklist :
rm -rf /, mkfs*, fork bombs, and other destructive commands are blocked by default
- Conscious bypass :
skip_policy: true to force execution
- Tunnel port allowlist : only explicitly allowed ports can be used
- File access restriction :
MCP_ALLOWED_ROOTS env var to limit file operations to specific directories
escapeShellArg() : all URLs and paths are escaped before being passed to curl/shell
- Plaintext secret detection : warning on startup if passwords/API keys are in plaintext
- Pre-modification snapshots :
backup:true on file_edit/file_write for instant rollback
- Recommendation : use SSH keys (not passwords), store secrets in Vaultwarden
π§ͺ Tests
node diagnose.js # Full diagnostic
node test_mcp.js # MCP smoke test
node test_features.js # Unit tests (queue, pool, glob, prompts, crash)
π£οΈ Roadmap
| Version | Changes |
|---|
| 10.0.0 | New tools: file_read/write/edit, diff, snapshots, shell, notes |
| 10.4.0 | server_to_server, help with schemas, audit guide |
| 11.0.0 | Command Blocklist, Multi-host (alias:"all"), tmux |
| 11.2.0 | SSH Tunnels (local/remote/SOCKS5), allowlist, ssh2 stderr fix |
| 11.3.0 | AllowedRoots (MCP_ALLOWED_ROOTS) for file restriction |
| 12.0.0 (planned) | Auto key setup for tunnels, webhooks, static dashboard |
π License
MIT β Copyright (c) 2025-2026 Franck (fkom13)