MCP SFTP Orchestrator

Điều phối các tác vụ máy chủ từ xa qua SSH và SFTP với hàng đợi liên tục. Lý tưởng cho DevOps và các tác nhân AI.

GitHub
1
Dùng thử MCP nàyĐược tài trợ

Tài liệu

🚀 MCP Orchestrator — Serveur d'orchestration SSH/SFTP

v11.8.0 Security Refresh — Les 82 tools publient désormais les annotations MCP standard. infra_overview reste léger sans argument, mais infra_overview { alias: "..." } effectue une découverte live et corrèle Nginx/domaines, ports, Docker/Compose et services. Voir CHANGELOG.md.

Version : 11.8.0
Tools : 82
License : MIT
Node : >= 18.0.0
Changelog : CHANGELOG.md

Serveur MCP (Model Context Protocol, transport stdio) qui donne à un agent IA la capacité d’orchestrer un parc de serveurs : SSH, SFTP, édition de fichiers locale/remote (hash-safe), diffs cross-server, shell PTY, snapshots d’infra, notes de protocole, projets, sessions de travail, inventaire, trust SSH (pubkey), groupes d’alias et audit parc.


✨ Points forts (v11.6)

DomaineCapacité
Exécutiontask_exec multi-serveur / group:oci / dry-run destructif / force
Fichiersfile_read / file_edit (chirurgical) / file_write + hash + dryRun + backup
Parcnotes, infra_audit, fleet_status, server_inventory
Projetsregistre local↔remote + project_diff
Travailwork_start → edits → work_end (note d’intervention auto)
Trustssh_authorize_key (pubkey only, dry_run par défaut)
Sécusecrets masqués, RO global + RO par alias, blocklist, pool SSH robuste

📦 Installation

git clone https://github.com/fkom13/mcp-sftp-orchestrator.git
cd sftp-mcp   # ou tools/sftp-mcp
npm install
cp .env.example .env
# Éditer MCP_DATA_DIR et chemins de clés

Prérequis : Node.js >= 18


⚙️ Configuration (.env)

Toutes les variables sont optionnelles.

VariableDéfautDescription
MCP_DATA_DIR~/.config/mcp-orchestratorDossier data (JSON, snapshots, projets…)
MCP_SYNC_TIMEOUT_S120Délai (s) avant passage d’une tâche en arrière-plan
MCP_DEFAULT_CMD_TIMEOUT_S600Timeout SSH commande (s). 0 = infini
MCP_INTERACTIVE_CMD_TIMEOUT_S300Timeout interactif (s). 0 = infini
MCP_MAX_WAIT_TIMEOUT_S600Timeout max task_wait (s)
MAX_CONNECTIONS_PER_SERVER5Pool SSH max / serveur
MIN_CONNECTIONS_PER_SERVER1Pool SSH min / serveur
IDLE_TIMEOUT300000Fermeture connexion inactive (ms)
KEEP_ALIVE_INTERVAL30000Keepalive SSH (ms)
MAX_QUEUE_SIZE1000Taille max queue jobs
SAVE_INTERVAL5000Autosave queue (ms)
MCP_ALLOWED_ROOTS(vide)Racines autorisées pour paths locaux (CSV)
MCP_READONLYfalse1 = refuse écritures / exec mutantes (global)
MCP_COMPACTfalse1 = réponses tronquées (tokens agent)
MCP_DEBUGfalseLogs détaillés stderr

Fichiers sous MCP_DATA_DIR

FichierContenu
servers.jsonAlias SSH (host, user, keyPath/password, port?, readonly?)
apis.jsonCatalogue APIs (secrets masqués en lecture tools)
queue.json / queue.backup.jsonJobs
history.jsonHistorique tâches
server_notes.jsonProtocoles / notes par serveur
server_groups.jsonGroupes d’alias
projects.jsonRegistre projets
work_sessions.jsonSessions de travail
policies.jsonBlocklist commandes
tunnels.json / tunnel_allowlist.jsonTunnels SSH
infra_snapshots/Snapshots content-addressable

🔌 Connexion client MCP

Grok / config.toml

[mcp_servers.orchestrator]
command = "node"
args = ["/chemin/absolu/sftp-mcp/server.js"]
# optionnel:
# env = { MCP_DATA_DIR = "/chemin/absolu/sftp-mcp/data" }

OpenCode / Claude Desktop (JSON)

{
  "mcpServers": {
    "orchestrator": {
      "command": "node",
      "args": ["/chemin/absolu/sftp-mcp/server.js"],
      "env": {
        "MCP_DATA_DIR": "/chemin/absolu/sftp-mcp/data"
      }
    }
  }
}

Après modification du code : recharger le serveur MCP (/mcps → r ou restart session). Vérifier system_diagnostics → version: "11.8.0".


🧰 Référence des outils (82)

Diagnostic & audit

OutilDescription
helpGuide outils + .env + astuces
guideManuel IA (workflows, cheatsheet, pitfalls, audit, security)
system_diagnosticsQueue, pool, serveurs/APIs masqués, version, readOnly
infra_auditSynthèse parc + projets + notes + crashed
infra_overviewServeurs + notes (vue légère)
fleet_statusPing SSH parallèle (latence, load, disk)
server_inventoryInventaire léger (pm2/docker/disk/home, cache 10 min)

Serveurs & groupes

OutilDescription
server_addCRUD alias (keyPath ou password, port, readonly)
server_listListe (passwords masqués)
server_removeSupprime un alias
server_group_list/set/removeGroupes (oci, contabo…). Usage : group:oci ou nom de groupe

Projets (v11.6)

OutilDescription
project_list / project_get / project_set / project_removeRegistre
project_resolve→ { local, remote, ignore, runtime }
project_diffDiff local↔remote du projet

Exemple project_set :

{
  "name": "p-image",
  "local": { "path": "/home/.../dev-serveur/p-image" },
  "servers": {
    "prod": {
      "alias": "fkomprodmini2_prod",
      "path": "/home/ubuntu/p-image",
      "runtime": { "pm2": "p-image", "port": 5002 },
      "url": "https://pruna.esprit-artificiel.com"
    }
  },
  "ignore": ["node_modules", ".git", "data"]
}

Sessions de travail (v11.6)

OutilDescription
work_startOuvre un journal (alias, project, tag, snapshot optionnel)
work_logEvent (file_edit, task_exec, …)
work_listSessions actives (+ historique)
work_endClôture + server_note last_intervention

Trust SSH (v11.6)

OutilDescription
ssh_authorize_keyAjoute une pubkey dans authorized_keys distant. dry_run défaut. Sources : string | local_path | alias
{
  "target_alias": "fkomprodmini1_prod",
  "source": { "type": "alias", "alias": "vps_contabo" },
  "comment": "fleet-from-contabo",
  "dry_run": true
}

Policies

OutilDescription
policy_blocklist_list/add/removeBlocklist commandes (aussi appliquée à shell + sequences)

Catalogue API

OutilDescription
api_add / api_list / api_remove / api_checkMonitoring (clés masquées en list)

Exécution de tâches

OutilDescription
task_execSSH ; alias | tableau | all | group:x ; dry_run/force destructif
task_exec_interactivePrompts yes/no, menus
task_exec_sequenceSéquence sur un serveur (policy par étape)
task_transferSFTP upload/download/server_to_server
task_transfer_multiMulti + globs

Files / Diff / Shell / Snapshots

FamilleOutils
Filesfile_read, file_write, file_edit
Diffdiff_files, diff_folders, compare_all_sources
Shellshell_create, shell_exec (+ skip_policy), shell_list, shell_close
Snapshotssnapshot_create/list/diff/restore/delete

Édition safe : file_read → hash → file_edit + expectedHash (+ dryRun / backup).

Notes serveur

OutilDescription
server_note_set/get/list/removeProtocole (description, services, warnings, intervention)

Monitoring & logs

OutilDescription
get_system_resourcesCPU / RAM / disque
get_services_statussystemd / Docker / PM2
get_fail2ban_statusFail2Ban
check_api_healthHTTP via SSH+curl
get_pm2_logs / get_docker_logs / tail_fileLogs

Queue

OutilDescription
task_queue / task_status / task_history / task_wait / task_logsSuivi
task_retry / task_retry_allRelance
task_purgePurge (dry_run défaut)
queue_stats / pool_statsStats

Tmux & tunnels

OutilDescription
tmux_create/exec/read/list/killSessions tmux distantes
tunnel_create/list/closeTunnels SSH local/remote/socks
tunnel_allowlist_add/removePorts autorisés pour tunnels

📖 Workflows agent recommandés

Début de session

infra_audit  (ou infra_overview)
fleet_status
project_list / project_resolve

Chantier sur un projet

work_start { project: "p-image", alias: "fkomprodmini2_prod", tag: "fix-x", message: "…" }
file_read → file_edit (expectedHash, dryRun puis apply)
work_log { type: "file_edit", path: "…" }
work_end { summary: "…" }   → note serveur mise à jour
project_diff { name: "p-image" }

Commandes longues

task_exec { timeout: 0, … }  → si > syncTimeout → task_wait { id }

Cibles multi-serveurs

task_exec { alias: "group:oci", cmd: "hostname" }
task_exec { alias: "all", cmd: "uptime" }

🏗️ Architecture

Client MCP (stdio)
    │
server.js ─── 82 tools
    │
    ├── queue.js          File d’attente persistante + purge/retry
    ├── ssh.js / sshPool  Exécution + pool (retry safe, port configurable)
    ├── sftp.js           Transferts (server_to_server via sourceAdapter/pool)
    ├── sourceAdapter.js  Local fs | remote SFTP pool
    ├── fileOps.js        Read/write/edit + hash + dryRun + backup
    ├── diffEngine.js / compareEngine.js / diffFormatter.js
    ├── shellSessions.js  PTY persistants + policy
    ├── snapshotManager.js
    ├── projects.js / workSession.js / inventory.js / groups.js / fleet.js
    ├── sshTrust.js       authorized_keys (pubkey only)
    ├── servers.js / apis.js / notes.js / policies.js / tunnels.js
    ├── history.js / guide.js / config.js / utils.js

Cycle de vie d’un job

pending → running → completed | failed | partial
                      ↓ (redémarrage MCP pendant running)
                    crashed → task_retry → pending

🔒 Sécurité

MécanismeDétail
SecretsMasqués en api_list / diagnostics (*** + 4 derniers car.)
Shell escapeescapeShellArg sur curl, logs, chemins
Blocklistpolicies.json ; shell + sequence inclus ; skip_policy pour forcer
RO globalMCP_READONLY=1
RO alias"readonly": true dans servers.json
Destructiftask_exec dry-run si pattern dangereux sans force:true
TrustPubkey only ; dry_run par défaut
ClésPréférer keyPath SSH ; Vaultwarden pour secrets API

🧪 Tests

npm test:unit    # p0 + p1 + p16 (43 tests)
npm test         # unit + smoke MCP + features
node diagnose.js # diagnostic local optionnel
FichierCouverture
test_p0_unit.jsutils, policies, redact, timeouts, version
test_p1_unit.jsgroups, purge, destructive, RO env
test_p16_unit.jsprojects, work session, compact, sshTrust
test_mcp.jssmoke SDK
test_features.jsqueue / pool / globs / prompts

🛣️ Versions récentes

VersionContenuSnapshot gencodedoc
11.6.1Hardening multi-agent: RO transversal, server-to-server dossiers/force, allowed roots anti-symlink, quoting shell/tmux, queue + JSON stores atomiques—
11.6.0Projets, work sessions, inventory, ssh_authorize_key, RO alias, compact#23 (final docs)
11.4.0fleet, infra_audit, groups, retry_all, purge, pool rewrite#21
11.3.0Secrets mask, policy shell/seq, port SSH, wait partial#20
10.4–10.0file ops, diff, shell, snapshots, notes, guide#17–19
9.x / 8.xSFTP force, timeouts, interactif, sécu de base—

Détail : CHANGELOG.md · plans historiques : ROADMAP.md, ROADMAP_EXTENDED.md.


📄 Licence

MIT — Copyright (c) 2025-2026 Franck (fkom13)