@fkom13/mcp-sftp-orchestrator 6.0.0 → 11.8.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/.env.example CHANGED
@@ -1,22 +1,34 @@
1
- # Chemin seront stockés les fichiers servers.json et history.json
2
- # Par défaut, ce sera ~/.config/mcp-orchestrator
1
+ # Répertoire de données (configs, historique, queue)
3
2
  MCP_DATA_DIR="/home/fkomp/Bureau/oracle/tools/sftp-mcp/data"
4
3
 
5
- # Délai en secondes avant qu'une tâche ne passe en arrière-plan (mode asynchrone)
6
- MCP_SYNC_TIMEOUT_S=30
4
+ # Délai avant passage en arrière-plan (secondes)
5
+ MCP_SYNC_TIMEOUT_S=120
7
6
 
8
- # Timeout pour l'exécution synchrone (ms)
9
- SYNC_TIMEOUT=30000
7
+ # Timeouts d'exécution (secondes)
8
+ MCP_DEFAULT_CMD_TIMEOUT_S=600 # 10 minutes
9
+ MCP_INTERACTIVE_CMD_TIMEOUT_S=300 # 5 minutes
10
+ MCP_MAX_WAIT_TIMEOUT_S=600 # 10 minutes max pour task_wait
10
11
 
11
- # Taille maximale de la queue
12
- MAX_QUEUE_SIZE=1000
13
-
14
- # Pool de connexions
12
+ # Pool de connexions SSH
15
13
  MAX_CONNECTIONS_PER_SERVER=5
16
14
  MIN_CONNECTIONS_PER_SERVER=1
17
- IDLE_TIMEOUT=320000
18
- KEEP_ALIVE_INTERVAL=300000
15
+ IDLE_TIMEOUT=300000 # 5 minutes
16
+ KEEP_ALIVE_INTERVAL=30000 # 30 secondes
17
+
18
+ # Queue
19
+ MAX_QUEUE_SIZE=1000
20
+ SAVE_INTERVAL=5000 # Sauvegarde toutes les 5s
21
+ HISTORY_RETENTION=2678400000 # 31 jours
22
+
23
+ # Restreindre l'accès fichiers à des racines spécifiques (optionnel)
24
+ # Défaut: vide = accès complet. Exemple: MCP_ALLOWED_ROOTS=/srv/apps,/etc/nginx
25
+ MCP_ALLOWED_ROOTS=
26
+
27
+ # Activer ou désactiver Debug wrapper
28
+ MCP_DEBUG=false
29
+
30
+ # Mode lecture seule (exploration safe) : refuse écritures / task_exec mutantes
31
+ # MCP_READONLY=1
19
32
 
20
- # Sauvegarde
21
- SAVE_INTERVAL=5000
22
- HISTORY_RETENTION=2678400000
33
+ # Réponses compactes (moins de tokens pour l'agent)
34
+ # MCP_COMPACT=1
package/CHANGELOG.md ADDED
@@ -0,0 +1,174 @@
1
+ # Changelog — MCP Orchestrator (`@fkom13/mcp-sftp-orchestrator`)
2
+
3
+ ## 11.8.0 — Security Refresh (2026-09-20)
4
+
5
+ - Met à jour `@modelcontextprotocol/sdk` de 1.29.x vers **1.30.0**.
6
+ - Met à jour `glob` vers **13.0.6** et `uuid` vers **11.1.1+**.
7
+ - Rafraîchit les dépendances transitives vulnérables (`ajv`, `fast-uri`, `minimatch`, `picomatch`, `qs`, `hono`, `ip-address`, `@hono/node-server`, brace expansion).
8
+ - `npm audit --omit=dev` passe de 11 vulnérabilités à **0**.
9
+ - Ajoute `.npmignore` pour empêcher la publication de `.gencodedoc/`, `data/`, `.env`, backups et artefacts locaux dans npm.
10
+ - Exclut `.gencodedoc` de ses propres scans afin d'éviter l'auto-indexation récursive des snapshots locaux.
11
+ - Conserve le transport MCP **stdio**, les 82 tools/capabilities et les hardenings 11.6/11.7 sans réduction de surface.
12
+ - Réaligne les constantes/runtime/tests/docs de version sur 11.8.0.
13
+ - Cette release devient la base de réalignement GitHub/npm et des vendors IACA.
14
+
15
+ ## 11.7.0 — AIX / Infrastructure Topology (2026-08-22)
16
+
17
+ - Conserve les **82 capabilities/tools** : aucune réduction artificielle de surface.
18
+ - Ajoute des **annotations MCP standard sur les 82 tools** (`readOnlyHint`, `destructiveHint`, `idempotentHint`, `openWorldHint`) via `toolMetadata.js`; les policies serveur restent l'autorité.
19
+ - Clarifie les descriptions de choix entre `system_diagnostics`, `infra_audit`, `fleet_status`, `server_inventory`, `infra_overview`, les familles exec/terminal/transfer/file/snapshot.
20
+ - Transforme `infra_overview` : sans alias = contexte de parc léger; avec alias/group/all = **topologie live** listeners + Docker/Compose + PM2 + systemd + Nginx avec graphe `domain -> proxy -> host port -> container/service`.
21
+ - Ajoute `outputSchema` + `structuredContent` à `infra_overview`.
22
+ - Cache topologique court (2 min), `force`, timeout par machine et réponse compacte par défaut.
23
+ - Fusionne les server blocks Nginx HTTP/HTTPS d'un même domaine dans une vue unique.
24
+ - `task_queue` et `task_history` deviennent filtrables/paginables/compactables; `task_logs` borne son volume.
25
+ - Nouvelle suite `test_aix_117.js`; certification MCP réelle : 82/82 tools annotés.
26
+ - Smoke live Contabo certifié : 52 conteneurs, 24 projets Compose, 60 listeners, 30 domaines agrégés; résolution automatique de routes IACA/Connect/Hermes/DeepSeek/NIM/etc.
27
+
28
+ Archive candidate PC2 : `~/ea-audits/orchestrator-20260822/mcp-sftp-orchestrator-11.7.0-source.tgz`.
29
+
30
+
31
+ Format basé sur [Keep a Changelog](https://keepachangelog.com/).
32
+ Versions snappshottées via **gencodedoc** (IDs locaux sur le dépôt).
33
+
34
+ ---
35
+
36
+ ## [11.6.1] — 2026-08-22
37
+
38
+ ### Hardening MCP / multi-agent
39
+ - `server_to_server` supporte désormais les dossiers et le multi-fichiers ; comptage d'échec corrigé.
40
+ - `force:false` est enfin respecté en transfert serveur→serveur.
41
+ - `task_transfer_multi` accepte `server_to_server` avec `source_alias` global ou par entrée.
42
+ - `MCP_ALLOWED_ROOTS` descend au niveau `sourceAdapter` et bloque aussi les échappements par symlink.
43
+ - Guards `MCP_READONLY` / `readonly:true` ajoutés aux transferts, exec interactifs/séquences, shell, restores, tmux, tunnels et mutations de registres.
44
+ - Quoting tmux/tunnels durci via `escapeShellArg`.
45
+ - Interpolations shell restantes durcies (`fail2ban`, nom PM2, `docker --since`).
46
+ - Nouvelle suite `test_hardening_1161.js`.
47
+
48
+ ## [11.6.0] — 2026-07-15
49
+
50
+ **Snapshot gencodedoc : #22 (dev) → #23 (final docs)**
51
+ **82 tools MCP**
52
+
53
+ ### Added — couche sémantique agent (A–E)
54
+
55
+ - **Projets** (`projects.js`)
56
+ - `project_list` / `project_get` / `project_set` / `project_remove` / `project_resolve`
57
+ - Registre `data/projects.json` : local path ↔ remote alias/path/runtime/url
58
+ - Seed exemple : projet `p-image`
59
+ - **`project_diff`** : diff local↔remote d’un projet (ignore patterns du registre)
60
+ - **Work sessions** (`workSession.js`)
61
+ - `work_start` / `work_log` / `work_list` / `work_end`
62
+ - Journal `data/work_sessions.json` ; `work_end` met à jour `server_note` (`last_intervention`)
63
+ - Option snapshot remote au démarrage
64
+ - **`server_inventory`** (`inventory.js`) : inventaire léger (host, disk, mem, pm2, docker, `$HOME`, tailscale) avec **cache 10 min**
65
+ - **RO par alias** : `server_add.readonly` / `servers.json` `readonly:true` bloque write/exec sur cet alias
66
+ - **`MCP_COMPACT` / `compact:true`** : `utils.compactResult` pour réponses agent plus courtes
67
+
68
+ ### Added — trust SSH (v11.6 roadmap)
69
+
70
+ - **`ssh_authorize_key`** (`sshTrust.js`)
71
+ - Ajoute une **pubkey** dans `authorized_keys` distant
72
+ - Sources : `string` | `local_path` (.pub) | `alias` (dérive `.pub` / `ssh-keygen -y`)
73
+ - **Jamais** de copie de clé privée
74
+ - `dry_run: true` par défaut ; chmod 700/600 du `.ssh`
75
+
76
+ ### Security / hardening (portés depuis 11.3–11.4)
77
+
78
+ - Masquage secrets dans `api_list`, `server_list`, `system_diagnostics`, `infra_audit`
79
+ - Policy blocklist sur `shell_exec` et chaque étape de `task_exec_sequence`
80
+ - Fix faux positif blocklist `rm -rf /` vs `rm -rf /tmp/...`
81
+ - Port SSH configurable (`serverConfig.port`, défaut 22)
82
+ - `waitForJobCompletion` : statuts terminaux `partial` + `crashed`
83
+ - Fix timeout interactif (secondes confondues avec ms)
84
+ - Pool SSH rewrite : listeners non empilés, flag `ready`/`closed`
85
+ - `MCP_READONLY=1` global + dry-run commandes destructives sur `task_exec`
86
+
87
+ ### Tests
88
+
89
+ - `test_p0_unit.js` (24) — utils, policies, secrets, timeouts
90
+ - `test_p1_unit.js` (12) — groups, purge, destructive, version
91
+ - `test_p16_unit.js` (7) — projects, work session, compact, sshTrust
92
+ - `npm test` / `npm test:unit`
93
+
94
+ ### Data files
95
+
96
+ | Fichier | Rôle |
97
+ |---------|------|
98
+ | `data/projects.json` | Registre projets |
99
+ | `data/work_sessions.json` | Sessions de travail |
100
+ | `data/server_groups.json` | Groupes d’alias (v11.4) |
101
+ | `data/servers.json` | Alias SSH (+ `readonly?`, `port?`) |
102
+
103
+ ---
104
+
105
+ ## [11.4.0] — 2026-07-15
106
+
107
+ **Snapshot gencodedoc : #21** · **70 tools**
108
+
109
+ ### Added
110
+
111
+ - `fleet_status` — ping SSH parallèle (latence, load, disk, clé manquante)
112
+ - `infra_audit` — synthèse parc (version, serveurs masqués, notes, crashed, pool)
113
+ - `server_group_list` / `server_group_set` / `server_group_remove` — groupes (`group:oci`, …)
114
+ - `task_retry_all` — relance bulk crashed/failed (+ dry_run)
115
+ - `task_purge` — purge queue (dry_run par défaut)
116
+ - `task_exec` : résolution `all` / `group:x` / nom de groupe ; dry_run / force sur commandes destructives
117
+ - Modules : `fleet.js`, `groups.js`
118
+
119
+ ### Fixed
120
+
121
+ - Pool SSH : retry sans empiler les listeners ; readiness réelle
122
+ - SFTP `server_to_server` 100 % via pool `sourceAdapter` (plus de client SFTP inutile)
123
+ - Queue : `maxQueueSize` / `saveInterval` lus depuis config
124
+
125
+ ---
126
+
127
+ ## [11.3.0] — 2026-07-15
128
+
129
+ **Snapshot gencodedoc : #20** · alignement version runtime/package
130
+
131
+ ### Security
132
+
133
+ - `utils.redactSensitiveObject` / `maskSecret` sur diagnostics et listes API
134
+ - Policy sur shell + sequences
135
+ - Warning secrets en clair au boot
136
+
137
+ ### Fixed
138
+
139
+ - Interactive hybrid wait (timeout secondes vs ms)
140
+ - Job status `partial` considéré terminal
141
+ - Port SSH non hardcodé 22 partout
142
+ - Blocklist ancrage pour patterns finissant par `/`
143
+ - Double `sftp.end()` supprimé ; glob remote en `path.posix`
144
+
145
+ ### Added
146
+
147
+ - `test_p0_unit.js`
148
+
149
+ ---
150
+
151
+ ## [11.x / 10.x] — antérieurs (résumé)
152
+
153
+ | Version | Highlights |
154
+ |---------|------------|
155
+ | 10.4.0 | `sourceSchema` centralisé, `server_to_server` transfert |
156
+ | 10.3.0 | guide, notes, infra_overview, diffFormatter |
157
+ | 10.2.0 | File ops / diff / snapshot via pool SSH |
158
+ | 10.0.0 | Snapshots infra content-addressable |
159
+ | 9.3.0 | Shell sessions PTY persistantes |
160
+ | 9.2.0 | diff_files / diff_folders / compare_all_sources |
161
+ | 9.1.0 | file_read / write / edit + hash |
162
+ | 9.0.x | stdio only, help, sécu escapeShellArg |
163
+ | 8.x | SFTP force, timeouts, interactif, pool |
164
+
165
+ Voir aussi `ROADMAP.md` et `ROADMAP_EXTENDED.md` pour le détail historique des étapes 7–11.
166
+
167
+ ---
168
+
169
+ ## Liens
170
+
171
+ - Package : `@fkom13/mcp-sftp-orchestrator`
172
+ - Entry : `server.js` (stdio MCP)
173
+ - Tests : `npm test:unit` · `npm test`
174
+ - Snapshots code : gencodedoc dans le dépôt projet
package/README.fr.md ADDED
@@ -0,0 +1,356 @@
1
+ # 🚀 MCP Orchestrator — Serveur d'orchestration SSH/SFTP
2
+
3
+ > **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`.
4
+
5
+
6
+ **Version** : 11.8.0
7
+ **Tools** : 82
8
+ **License** : MIT
9
+ **Node** : >= 18.0.0
10
+ **Changelog** : [CHANGELOG.md](./CHANGELOG.md)
11
+
12
+ 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.
13
+
14
+ ---
15
+
16
+ ## ✨ Points forts (v11.6)
17
+
18
+ | Domaine | Capacité |
19
+ |---------|----------|
20
+ | **Exécution** | `task_exec` multi-serveur / `group:oci` / dry-run destructif / force |
21
+ | **Fichiers** | `file_read` / `file_edit` (chirurgical) / `file_write` + hash + dryRun + backup |
22
+ | **Parc** | notes, `infra_audit`, `fleet_status`, `server_inventory` |
23
+ | **Projets** | registre local↔remote + `project_diff` |
24
+ | **Travail** | `work_start` → edits → `work_end` (note d’intervention auto) |
25
+ | **Trust** | `ssh_authorize_key` (pubkey only, dry_run par défaut) |
26
+ | **Sécu** | secrets masqués, RO global + **RO par alias**, blocklist, pool SSH robuste |
27
+
28
+ ---
29
+
30
+ ## 📦 Installation
31
+
32
+ ```bash
33
+ git clone https://github.com/fkom13/mcp-sftp-orchestrator.git
34
+ cd sftp-mcp # ou tools/sftp-mcp
35
+ npm install
36
+ cp .env.example .env
37
+ # Éditer MCP_DATA_DIR et chemins de clés
38
+ ```
39
+
40
+ Prérequis : **Node.js >= 18**
41
+
42
+ ---
43
+
44
+ ## ⚙️ Configuration (`.env`)
45
+
46
+ Toutes les variables sont optionnelles.
47
+
48
+ | Variable | Défaut | Description |
49
+ |----------|--------|-------------|
50
+ | `MCP_DATA_DIR` | `~/.config/mcp-orchestrator` | Dossier data (JSON, snapshots, projets…) |
51
+ | `MCP_SYNC_TIMEOUT_S` | `120` | Délai (s) avant passage d’une tâche en arrière-plan |
52
+ | `MCP_DEFAULT_CMD_TIMEOUT_S` | `600` | Timeout SSH commande (s). `0` = infini |
53
+ | `MCP_INTERACTIVE_CMD_TIMEOUT_S` | `300` | Timeout interactif (s). `0` = infini |
54
+ | `MCP_MAX_WAIT_TIMEOUT_S` | `600` | Timeout max `task_wait` (s) |
55
+ | `MAX_CONNECTIONS_PER_SERVER` | `5` | Pool SSH max / serveur |
56
+ | `MIN_CONNECTIONS_PER_SERVER` | `1` | Pool SSH min / serveur |
57
+ | `IDLE_TIMEOUT` | `300000` | Fermeture connexion inactive (ms) |
58
+ | `KEEP_ALIVE_INTERVAL` | `30000` | Keepalive SSH (ms) |
59
+ | `MAX_QUEUE_SIZE` | `1000` | Taille max queue jobs |
60
+ | `SAVE_INTERVAL` | `5000` | Autosave queue (ms) |
61
+ | `MCP_ALLOWED_ROOTS` | _(vide)_ | Racines autorisées pour paths locaux (CSV) |
62
+ | `MCP_READONLY` | `false` | `1` = refuse écritures / exec mutantes (global) |
63
+ | `MCP_COMPACT` | `false` | `1` = réponses tronquées (tokens agent) |
64
+ | `MCP_DEBUG` | `false` | Logs détaillés stderr |
65
+
66
+ ### Fichiers sous `MCP_DATA_DIR`
67
+
68
+ | Fichier | Contenu |
69
+ |---------|---------|
70
+ | `servers.json` | Alias SSH (`host`, `user`, `keyPath`/`password`, `port?`, `readonly?`) |
71
+ | `apis.json` | Catalogue APIs (secrets masqués en lecture tools) |
72
+ | `queue.json` / `queue.backup.json` | Jobs |
73
+ | `history.json` | Historique tâches |
74
+ | `server_notes.json` | Protocoles / notes par serveur |
75
+ | `server_groups.json` | Groupes d’alias |
76
+ | `projects.json` | Registre projets |
77
+ | `work_sessions.json` | Sessions de travail |
78
+ | `policies.json` | Blocklist commandes |
79
+ | `tunnels.json` / `tunnel_allowlist.json` | Tunnels SSH |
80
+ | `infra_snapshots/` | Snapshots content-addressable |
81
+
82
+ ---
83
+
84
+ ## 🔌 Connexion client MCP
85
+
86
+ ### Grok / config.toml
87
+
88
+ ```toml
89
+ [mcp_servers.orchestrator]
90
+ command = "node"
91
+ args = ["/chemin/absolu/sftp-mcp/server.js"]
92
+ # optionnel:
93
+ # env = { MCP_DATA_DIR = "/chemin/absolu/sftp-mcp/data" }
94
+ ```
95
+
96
+ ### OpenCode / Claude Desktop (JSON)
97
+
98
+ ```json
99
+ {
100
+ "mcpServers": {
101
+ "orchestrator": {
102
+ "command": "node",
103
+ "args": ["/chemin/absolu/sftp-mcp/server.js"],
104
+ "env": {
105
+ "MCP_DATA_DIR": "/chemin/absolu/sftp-mcp/data"
106
+ }
107
+ }
108
+ }
109
+ }
110
+ ```
111
+
112
+ Après modification du code : recharger le serveur MCP (`/mcps` → `r` ou restart session). Vérifier `system_diagnostics` → `version: "11.8.0"`.
113
+
114
+ ---
115
+
116
+ ## 🧰 Référence des outils (82)
117
+
118
+ ### Diagnostic & audit
119
+ | Outil | Description |
120
+ |-------|-------------|
121
+ | `help` | Guide outils + .env + astuces |
122
+ | `guide` | Manuel IA (workflows, cheatsheet, pitfalls, audit, security) |
123
+ | `system_diagnostics` | Queue, pool, serveurs/APIs **masqués**, version, readOnly |
124
+ | `infra_audit` | Synthèse parc + projets + notes + crashed |
125
+ | `infra_overview` | Serveurs + notes (vue légère) |
126
+ | `fleet_status` | Ping SSH parallèle (latence, load, disk) |
127
+ | `server_inventory` | Inventaire léger (pm2/docker/disk/home, cache 10 min) |
128
+
129
+ ### Serveurs & groupes
130
+ | Outil | Description |
131
+ |-------|-------------|
132
+ | `server_add` | CRUD alias (`keyPath` ou `password`, `port`, **`readonly`**) |
133
+ | `server_list` | Liste (passwords masqués) |
134
+ | `server_remove` | Supprime un alias |
135
+ | `server_group_list/set/remove` | Groupes (`oci`, `contabo`…). Usage : `group:oci` ou nom de groupe |
136
+
137
+ ### Projets (v11.6)
138
+ | Outil | Description |
139
+ |-------|-------------|
140
+ | `project_list` / `project_get` / `project_set` / `project_remove` | Registre |
141
+ | `project_resolve` | → `{ local, remote, ignore, runtime }` |
142
+ | `project_diff` | Diff local↔remote du projet |
143
+
144
+ Exemple `project_set` :
145
+
146
+ ```json
147
+ {
148
+ "name": "p-image",
149
+ "local": { "path": "/home/.../dev-serveur/p-image" },
150
+ "servers": {
151
+ "prod": {
152
+ "alias": "fkomprodmini2_prod",
153
+ "path": "/home/ubuntu/p-image",
154
+ "runtime": { "pm2": "p-image", "port": 5002 },
155
+ "url": "https://pruna.esprit-artificiel.com"
156
+ }
157
+ },
158
+ "ignore": ["node_modules", ".git", "data"]
159
+ }
160
+ ```
161
+
162
+ ### Sessions de travail (v11.6)
163
+ | Outil | Description |
164
+ |-------|-------------|
165
+ | `work_start` | Ouvre un journal (`alias`, `project`, `tag`, snapshot optionnel) |
166
+ | `work_log` | Event (`file_edit`, `task_exec`, …) |
167
+ | `work_list` | Sessions actives (+ historique) |
168
+ | `work_end` | Clôture + `server_note` `last_intervention` |
169
+
170
+ ### Trust SSH (v11.6)
171
+ | Outil | Description |
172
+ |-------|-------------|
173
+ | `ssh_authorize_key` | Ajoute une **pubkey** dans `authorized_keys` distant. `dry_run` défaut. Sources : `string` \| `local_path` \| `alias` |
174
+
175
+ ```json
176
+ {
177
+ "target_alias": "fkomprodmini1_prod",
178
+ "source": { "type": "alias", "alias": "vps_contabo" },
179
+ "comment": "fleet-from-contabo",
180
+ "dry_run": true
181
+ }
182
+ ```
183
+
184
+ ### Policies
185
+ | Outil | Description |
186
+ |-------|-------------|
187
+ | `policy_blocklist_list/add/remove` | Blocklist commandes (aussi appliquée à shell + sequences) |
188
+
189
+ ### Catalogue API
190
+ | Outil | Description |
191
+ |-------|-------------|
192
+ | `api_add` / `api_list` / `api_remove` / `api_check` | Monitoring (clés masquées en list) |
193
+
194
+ ### Exécution de tâches
195
+ | Outil | Description |
196
+ |-------|-------------|
197
+ | `task_exec` | SSH ; alias \| tableau \| `all` \| `group:x` ; dry_run/force destructif |
198
+ | `task_exec_interactive` | Prompts yes/no, menus |
199
+ | `task_exec_sequence` | Séquence sur un serveur (policy par étape) |
200
+ | `task_transfer` | SFTP upload/download/`server_to_server` |
201
+ | `task_transfer_multi` | Multi + globs |
202
+
203
+ ### Files / Diff / Shell / Snapshots
204
+ | Famille | Outils |
205
+ |---------|--------|
206
+ | Files | `file_read`, `file_write`, `file_edit` |
207
+ | Diff | `diff_files`, `diff_folders`, `compare_all_sources` |
208
+ | Shell | `shell_create`, `shell_exec` (+ `skip_policy`), `shell_list`, `shell_close` |
209
+ | Snapshots | `snapshot_create/list/diff/restore/delete` |
210
+
211
+ **Édition safe** : `file_read` → hash → `file_edit` + `expectedHash` (+ `dryRun` / `backup`).
212
+
213
+ ### Notes serveur
214
+ | Outil | Description |
215
+ |-------|-------------|
216
+ | `server_note_set/get/list/remove` | Protocole (description, services, warnings, intervention) |
217
+
218
+ ### Monitoring & logs
219
+ | Outil | Description |
220
+ |-------|-------------|
221
+ | `get_system_resources` | CPU / RAM / disque |
222
+ | `get_services_status` | systemd / Docker / PM2 |
223
+ | `get_fail2ban_status` | Fail2Ban |
224
+ | `check_api_health` | HTTP via SSH+curl |
225
+ | `get_pm2_logs` / `get_docker_logs` / `tail_file` | Logs |
226
+
227
+ ### Queue
228
+ | Outil | Description |
229
+ |-------|-------------|
230
+ | `task_queue` / `task_status` / `task_history` / `task_wait` / `task_logs` | Suivi |
231
+ | `task_retry` / `task_retry_all` | Relance |
232
+ | `task_purge` | Purge (dry_run défaut) |
233
+ | `queue_stats` / `pool_stats` | Stats |
234
+
235
+ ### Tmux & tunnels
236
+ | Outil | Description |
237
+ |-------|-------------|
238
+ | `tmux_create/exec/read/list/kill` | Sessions tmux distantes |
239
+ | `tunnel_create/list/close` | Tunnels SSH local/remote/socks |
240
+ | `tunnel_allowlist_add/remove` | Ports autorisés pour tunnels |
241
+
242
+ ---
243
+
244
+ ## 📖 Workflows agent recommandés
245
+
246
+ ### Début de session
247
+ ```
248
+ infra_audit (ou infra_overview)
249
+ fleet_status
250
+ project_list / project_resolve
251
+ ```
252
+
253
+ ### Chantier sur un projet
254
+ ```
255
+ work_start { project: "p-image", alias: "fkomprodmini2_prod", tag: "fix-x", message: "…" }
256
+ file_read → file_edit (expectedHash, dryRun puis apply)
257
+ work_log { type: "file_edit", path: "…" }
258
+ work_end { summary: "…" } → note serveur mise à jour
259
+ project_diff { name: "p-image" }
260
+ ```
261
+
262
+ ### Commandes longues
263
+ ```
264
+ task_exec { timeout: 0, … } → si > syncTimeout → task_wait { id }
265
+ ```
266
+
267
+ ### Cibles multi-serveurs
268
+ ```
269
+ task_exec { alias: "group:oci", cmd: "hostname" }
270
+ task_exec { alias: "all", cmd: "uptime" }
271
+ ```
272
+
273
+ ---
274
+
275
+ ## 🏗️ Architecture
276
+
277
+ ```
278
+ Client MCP (stdio)
279
+
280
+ server.js ─── 82 tools
281
+
282
+ ├── queue.js File d’attente persistante + purge/retry
283
+ ├── ssh.js / sshPool Exécution + pool (retry safe, port configurable)
284
+ ├── sftp.js Transferts (server_to_server via sourceAdapter/pool)
285
+ ├── sourceAdapter.js Local fs | remote SFTP pool
286
+ ├── fileOps.js Read/write/edit + hash + dryRun + backup
287
+ ├── diffEngine.js / compareEngine.js / diffFormatter.js
288
+ ├── shellSessions.js PTY persistants + policy
289
+ ├── snapshotManager.js
290
+ ├── projects.js / workSession.js / inventory.js / groups.js / fleet.js
291
+ ├── sshTrust.js authorized_keys (pubkey only)
292
+ ├── servers.js / apis.js / notes.js / policies.js / tunnels.js
293
+ ├── history.js / guide.js / config.js / utils.js
294
+ ```
295
+
296
+ ### Cycle de vie d’un job
297
+
298
+ ```
299
+ pending → running → completed | failed | partial
300
+ ↓ (redémarrage MCP pendant running)
301
+ crashed → task_retry → pending
302
+ ```
303
+
304
+ ---
305
+
306
+ ## 🔒 Sécurité
307
+
308
+ | Mécanisme | Détail |
309
+ |-----------|--------|
310
+ | Secrets | Masqués en `api_list` / diagnostics (`***` + 4 derniers car.) |
311
+ | Shell escape | `escapeShellArg` sur curl, logs, chemins |
312
+ | Blocklist | `policies.json` ; shell + sequence inclus ; `skip_policy` pour forcer |
313
+ | RO global | `MCP_READONLY=1` |
314
+ | RO alias | `"readonly": true` dans `servers.json` |
315
+ | Destructif | `task_exec` dry-run si pattern dangereux sans `force:true` |
316
+ | Trust | Pubkey only ; dry_run par défaut |
317
+ | Clés | Préférer `keyPath` SSH ; Vaultwarden pour secrets API |
318
+
319
+ ---
320
+
321
+ ## 🧪 Tests
322
+
323
+ ```bash
324
+ npm test:unit # p0 + p1 + p16 (43 tests)
325
+ npm test # unit + smoke MCP + features
326
+ node diagnose.js # diagnostic local optionnel
327
+ ```
328
+
329
+ | Fichier | Couverture |
330
+ |---------|------------|
331
+ | `test_p0_unit.js` | utils, policies, redact, timeouts, version |
332
+ | `test_p1_unit.js` | groups, purge, destructive, RO env |
333
+ | `test_p16_unit.js` | projects, work session, compact, sshTrust |
334
+ | `test_mcp.js` | smoke SDK |
335
+ | `test_features.js` | queue / pool / globs / prompts |
336
+
337
+ ---
338
+
339
+ ## 🛣️ Versions récentes
340
+
341
+ | Version | Contenu | Snapshot gencodedoc |
342
+ |---------|---------|---------------------|
343
+ | **11.6.1** | Hardening multi-agent: RO transversal, server-to-server dossiers/force, allowed roots anti-symlink, quoting shell/tmux, queue + JSON stores atomiques | — |
344
+ | **11.6.0** | Projets, work sessions, inventory, ssh_authorize_key, RO alias, compact | **#23** (final docs) |
345
+ | 11.4.0 | fleet, infra_audit, groups, retry_all, purge, pool rewrite | #21 |
346
+ | 11.3.0 | Secrets mask, policy shell/seq, port SSH, wait partial | #20 |
347
+ | 10.4–10.0 | file ops, diff, shell, snapshots, notes, guide | #17–19 |
348
+ | 9.x / 8.x | SFTP force, timeouts, interactif, sécu de base | — |
349
+
350
+ Détail : **[CHANGELOG.md](./CHANGELOG.md)** · plans historiques : `ROADMAP.md`, `ROADMAP_EXTENDED.md`.
351
+
352
+ ---
353
+
354
+ ## 📄 Licence
355
+
356
+ MIT — Copyright (c) 2025-2026 Franck (fkom13)