claude-flow-novice 2.14.8 → 2.14.10
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/commands/cfn-loop-cli.md +1 -1
- package/.claude/skills/cfn-agent-selector/SKILL.md +2 -2
- package/.claude/skills/cfn-agent-selector/SKILL.md.backup_before_replace +91 -0
- package/.claude/skills/cfn-loop-orchestration/orchestrate.sh +72 -5
- package/README.md +4 -4
- package/README.md.backup_before_replace +781 -0
- package/claude-assets/agents/AGENT_LIFECYCLE.md +3 -3
- package/claude-assets/agents/AGENT_LIFECYCLE.md.backup_before_replace +530 -0
- package/claude-assets/agents/README-AGENT_LIFECYCLE.md +3 -3
- package/claude-assets/agents/README-AGENT_LIFECYCLE.md.backup_before_replace +522 -0
- package/claude-assets/agents/cfn-dev-team/CLAUDE.md +3 -3
- package/claude-assets/agents/cfn-dev-team/CLAUDE.md.backup_before_replace +1086 -0
- package/claude-assets/agents/cfn-dev-team/README.md +1 -1
- package/claude-assets/agents/cfn-dev-team/README.md.backup_before_replace +116 -0
- package/claude-assets/agents/cfn-dev-team/coordinators/cfn-v3-coordinator.md +2 -2
- package/claude-assets/agents/cfn-dev-team/coordinators/cfn-v3-coordinator.md.backup_before_replace +451 -0
- package/claude-assets/agents/cfn-dev-team/developers/README.md +3 -3
- package/claude-assets/agents/cfn-dev-team/developers/README.md.backup_before_replace +69 -0
- package/claude-assets/agents/cfn-dev-team/documentation/agent-type-guidelines.md +1 -1
- package/claude-assets/agents/cfn-dev-team/documentation/agent-type-guidelines.md.backup_before_replace +465 -0
- package/claude-assets/agents/cfn-dev-team/test-agent.md +2 -2
- package/claude-assets/agents/cfn-dev-team/test-agent.md.backup_before_replace +141 -0
- package/claude-assets/commands/cfn-loop-cli.md +1 -1
- package/claude-assets/skills/cfn-agent-selector/SKILL.md +2 -2
- package/claude-assets/skills/cfn-agent-selector/SKILL.md.backup_before_replace +91 -0
- package/claude-assets/skills/cfn-cli-setup/validate-cli-environment.sh +192 -0
- package/claude-assets/skills/cfn-deliverable-validation/confidence-calculator.sh +262 -0
- package/claude-assets/skills/cfn-loop-orchestration/orchestrate.sh +72 -5
- package/claude-assets/skills/cfn-mcp-container-selector/SKILL.md +555 -0
- package/claude-assets/skills/cfn-memory-monitoring/SKILL.md +531 -0
- package/claude-assets/skills/cfn-redis-cleanup/cleanup-redis.sh +130 -0
- package/claude-assets/skills/cfn-task-decomposition/task-decomposer.sh +279 -0
- package/dist/agents/agent-loader.js +165 -146
- package/dist/cli/cli-agent-context.js +6 -0
- package/dist/cli/cli-agent-context.js.map +1 -1
- package/dist/cli/config-manager.js +109 -91
- package/dist/cli/config-manager.js.map +1 -1
- package/dist/types/index.js +11 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/user.js +22 -0
- package/dist/types/user.js.map +1 -0
- package/package.json +1 -1
- package/readme/README.md +1 -1
- package/scripts/docker-playwright-fix.sh +312 -0
- package/scripts/zone-d-type-fixes.sh +333 -0
|
@@ -0,0 +1,555 @@
|
|
|
1
|
+
# MCP Container Selector Skill
|
|
2
|
+
|
|
3
|
+
**Implementation Date:** 2025-11-04
|
|
4
|
+
**Purpose:** Dedicated MCP per container architecture for specialized agent tooling
|
|
5
|
+
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## Overview
|
|
9
|
+
|
|
10
|
+
The MCP Container Selector skill manages dedicated MCP servers per container type, ensuring that:
|
|
11
|
+
|
|
12
|
+
1. **Frontend agents** get Playwright and browser automation tools
|
|
13
|
+
2. **Backend agents** get database, API testing, and Redis tools
|
|
14
|
+
3. **Context efficiency** - agents only load relevant MCP tools
|
|
15
|
+
4. **Resource optimization** - specialized containers with minimal overhead
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## Container MCP Architecture
|
|
20
|
+
|
|
21
|
+
### Frontend Container MCP Configuration
|
|
22
|
+
|
|
23
|
+
```json
|
|
24
|
+
{
|
|
25
|
+
"mcpServers": {
|
|
26
|
+
"playwright": {
|
|
27
|
+
"command": "docker",
|
|
28
|
+
"args": [
|
|
29
|
+
"run", "-i", "--rm", "--init",
|
|
30
|
+
"--name", "mcp-playwright-${AGENT_ID}",
|
|
31
|
+
"--memory=1g",
|
|
32
|
+
"--shm-size=2g",
|
|
33
|
+
"-e", "AGENT_ID=${AGENT_ID}",
|
|
34
|
+
"-e", "DISPLAY=${DISPLAY:-:0}",
|
|
35
|
+
"-v", "/tmp/.X11-unix:/tmp/.X11-unix:ro",
|
|
36
|
+
"-v", "${PWD}/workspace:/workspace",
|
|
37
|
+
"-v", "${PWD}/screenshots:/screenshots",
|
|
38
|
+
"mcp/playwright:latest"
|
|
39
|
+
]
|
|
40
|
+
},
|
|
41
|
+
"browser-automation": {
|
|
42
|
+
"command": "docker",
|
|
43
|
+
"args": [
|
|
44
|
+
"run", "-i", "--rm", "--init",
|
|
45
|
+
"--name", "mcp-browser-${AGENT_ID}",
|
|
46
|
+
"--memory=512m",
|
|
47
|
+
"--shm-size=1g",
|
|
48
|
+
"-e", "AGENT_ID=${AGENT_ID}",
|
|
49
|
+
"-e", "BROWSER_TYPE=chromium",
|
|
50
|
+
"-v", "${PWD}/workspace:/workspace",
|
|
51
|
+
"mcp/browser-automation:latest"
|
|
52
|
+
]
|
|
53
|
+
},
|
|
54
|
+
"screenshot-service": {
|
|
55
|
+
"command": "docker",
|
|
56
|
+
"args": [
|
|
57
|
+
"run", "-i", "--rm", "--init",
|
|
58
|
+
"--name", "mcp-screenshot-${AGENT_ID}",
|
|
59
|
+
"--memory=256m",
|
|
60
|
+
"-e", "AGENT_ID=${AGENT_ID}",
|
|
61
|
+
"-v", "${PWD}/screenshots:/screenshots",
|
|
62
|
+
"mcp/screenshot:latest"
|
|
63
|
+
]
|
|
64
|
+
},
|
|
65
|
+
"image-analysis": {
|
|
66
|
+
"command": "docker",
|
|
67
|
+
"args": [
|
|
68
|
+
"run", "-i", "--rm", "--init",
|
|
69
|
+
"--name", "mcp-image-${AGENT_ID}",
|
|
70
|
+
"--memory=1g",
|
|
71
|
+
"-e", "AGENT_ID=${AGENT_ID}",
|
|
72
|
+
"-v", "${PWD}/images:/images:ro",
|
|
73
|
+
"mcp/image-analysis:latest"
|
|
74
|
+
]
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### Backend Container MCP Configuration
|
|
81
|
+
|
|
82
|
+
```json
|
|
83
|
+
{
|
|
84
|
+
"mcpServers": {
|
|
85
|
+
"database": {
|
|
86
|
+
"command": "docker",
|
|
87
|
+
"args": [
|
|
88
|
+
"run", "-i", "--rm", "--init",
|
|
89
|
+
"--name", "mcp-database-${AGENT_ID}",
|
|
90
|
+
"--memory=256m",
|
|
91
|
+
"-e", "DATABASE_URL=${DATABASE_URL}",
|
|
92
|
+
"-e", "AGENT_ID=${AGENT_ID}",
|
|
93
|
+
"mcp/postgresql:latest"
|
|
94
|
+
]
|
|
95
|
+
},
|
|
96
|
+
"api-testing": {
|
|
97
|
+
"command": "docker",
|
|
98
|
+
"args": [
|
|
99
|
+
"run", "-i", "--rm", "--init",
|
|
100
|
+
"--name", "mcp-api-${AGENT_ID}",
|
|
101
|
+
"--memory=256m",
|
|
102
|
+
"-e", "AGENT_ID=${AGENT_ID}",
|
|
103
|
+
"mcp/api-testing:latest"
|
|
104
|
+
]
|
|
105
|
+
},
|
|
106
|
+
"redis-tools": {
|
|
107
|
+
"command": "docker",
|
|
108
|
+
"args": [
|
|
109
|
+
"run", "-i", "--rm", "--init",
|
|
110
|
+
"--name", "mcp-redis-${AGENT_ID}",
|
|
111
|
+
"--memory=128m",
|
|
112
|
+
"-e", "REDIS_HOST=${REDIS_HOST}",
|
|
113
|
+
"-e", "REDIS_PORT=${REDIS_PORT:-6379}",
|
|
114
|
+
"-e", "AGENT_ID=${AGENT_ID}",
|
|
115
|
+
"mcp/redis-tools:latest"
|
|
116
|
+
]
|
|
117
|
+
},
|
|
118
|
+
"filesystem": {
|
|
119
|
+
"command": "docker",
|
|
120
|
+
"args": [
|
|
121
|
+
"run", "-i", "--rm", "--init",
|
|
122
|
+
"--name", "mcp-filesystem-${AGENT_ID}",
|
|
123
|
+
"--memory=128m",
|
|
124
|
+
"-e", "AGENT_ID=${AGENT_ID}",
|
|
125
|
+
"-v", "${PWD}/workspace:/workspace",
|
|
126
|
+
"mcp/filesystem:latest"
|
|
127
|
+
]
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
---
|
|
134
|
+
|
|
135
|
+
## Container Selection Logic
|
|
136
|
+
|
|
137
|
+
### Agent Type to MCP Mapping
|
|
138
|
+
|
|
139
|
+
```bash
|
|
140
|
+
#!/bin/bash
|
|
141
|
+
# .claude/skills/cfn-mcp-container-selector/select-mcp-config.sh
|
|
142
|
+
|
|
143
|
+
select_mcp_config() {
|
|
144
|
+
local agent_type="$1"
|
|
145
|
+
local agent_id="$2"
|
|
146
|
+
local config_file="$3"
|
|
147
|
+
|
|
148
|
+
case "$agent_type" in
|
|
149
|
+
"react-frontend-engineer"|"frontend-developer"|"ui-designer"|"mobile-dev")
|
|
150
|
+
cat > "$config_file" << EOF
|
|
151
|
+
{
|
|
152
|
+
"mcpServers": {
|
|
153
|
+
"playwright": {
|
|
154
|
+
"command": "docker",
|
|
155
|
+
"args": [
|
|
156
|
+
"run", "-i", "--rm", "--init",
|
|
157
|
+
"--name", "mcp-playwright-${agent_id}",
|
|
158
|
+
"--memory=1g",
|
|
159
|
+
"--shm-size=2g",
|
|
160
|
+
"-e", "AGENT_ID=${agent_id}",
|
|
161
|
+
"-e", "DISPLAY=${DISPLAY:-:0}",
|
|
162
|
+
"-v", "/tmp/.X11-unix:/tmp/.X11-unix:ro",
|
|
163
|
+
"-v", "${PWD}/workspace:/workspace",
|
|
164
|
+
"mcp/playwright:latest"
|
|
165
|
+
]
|
|
166
|
+
},
|
|
167
|
+
"browser-automation": {
|
|
168
|
+
"command": "docker",
|
|
169
|
+
"args": [
|
|
170
|
+
"run", "-i", "--rm", "--init",
|
|
171
|
+
"--name", "mcp-browser-${agent_id}",
|
|
172
|
+
"--memory=512m",
|
|
173
|
+
"-e", "AGENT_ID=${agent_id}",
|
|
174
|
+
"v", "${PWD}/workspace:/workspace",
|
|
175
|
+
"mcp/browser-automation:latest"
|
|
176
|
+
]
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
EOF
|
|
181
|
+
;;
|
|
182
|
+
|
|
183
|
+
"backend-developer"|"database-architect"|"api-gateway-specialist")
|
|
184
|
+
cat > "$config_file" << EOF
|
|
185
|
+
{
|
|
186
|
+
"mcpServers": {
|
|
187
|
+
"database": {
|
|
188
|
+
"command": "docker",
|
|
189
|
+
"args": [
|
|
190
|
+
"run", "-i", "--rm", "--init",
|
|
191
|
+
"--name", "mcp-database-${agent_id}",
|
|
192
|
+
"--memory=256m",
|
|
193
|
+
"-e", "DATABASE_URL=${DATABASE_URL}",
|
|
194
|
+
"-e", "AGENT_ID=${agent_id}",
|
|
195
|
+
"mcp/postgresql:latest"
|
|
196
|
+
]
|
|
197
|
+
},
|
|
198
|
+
"api-testing": {
|
|
199
|
+
"command": "docker",
|
|
200
|
+
"args": [
|
|
201
|
+
"run", "-i", "--rm", "--init",
|
|
202
|
+
"--name", "mcp-api-${agent_id}",
|
|
203
|
+
"--memory=256m",
|
|
204
|
+
"-e", "AGENT_ID=${agent_id}",
|
|
205
|
+
"mcp/api-testing:latest"
|
|
206
|
+
]
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
EOF
|
|
211
|
+
;;
|
|
212
|
+
|
|
213
|
+
"tester"|"playwright-tester"|"api-testing-specialist")
|
|
214
|
+
cat > "$config_file" << EOF
|
|
215
|
+
{
|
|
216
|
+
"mcpServers": {
|
|
217
|
+
"playwright": {
|
|
218
|
+
"command": "docker",
|
|
219
|
+
"args": [
|
|
220
|
+
"run", "-i", "--rm", "--init",
|
|
221
|
+
"--name", "mcp-playwright-${agent_id}",
|
|
222
|
+
"--memory=1g",
|
|
223
|
+
"--shm-size=2g",
|
|
224
|
+
"-e", "AGENT_ID=${agent_id}",
|
|
225
|
+
"v", "${PWD}/test-results:/test-results",
|
|
226
|
+
"mcp/playwright:latest"
|
|
227
|
+
]
|
|
228
|
+
},
|
|
229
|
+
"api-testing": {
|
|
230
|
+
"command": "docker",
|
|
231
|
+
"args": [
|
|
232
|
+
"run", "-i", "--rm", "--init",
|
|
233
|
+
"--name", "mcp-api-${agent_id}",
|
|
234
|
+
"--memory=256m",
|
|
235
|
+
"-e", "AGENT_ID=${agent_id}",
|
|
236
|
+
"mcp/api-testing:latest"
|
|
237
|
+
]
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
EOF
|
|
242
|
+
;;
|
|
243
|
+
|
|
244
|
+
*)
|
|
245
|
+
# Default minimal MCP configuration
|
|
246
|
+
cat > "$config_file" << EOF
|
|
247
|
+
{
|
|
248
|
+
"mcpServers": {
|
|
249
|
+
"filesystem": {
|
|
250
|
+
"command": "docker",
|
|
251
|
+
"args": [
|
|
252
|
+
"run", "-i", "--rm", "--init",
|
|
253
|
+
"--name", "mcp-filesystem-${agent_id}",
|
|
254
|
+
"--memory=128m",
|
|
255
|
+
"-e", "AGENT_ID=${agent_id}",
|
|
256
|
+
"-v", "${PWD}/workspace:/workspace",
|
|
257
|
+
"mcp/filesystem:latest"
|
|
258
|
+
]
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
EOF
|
|
263
|
+
;;
|
|
264
|
+
esac
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
# Execute selection if called directly
|
|
268
|
+
if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
|
|
269
|
+
if [[ $# -lt 3 ]]; then
|
|
270
|
+
echo "Usage: $0 <agent_type> <agent_id> <output_file>"
|
|
271
|
+
exit 1
|
|
272
|
+
fi
|
|
273
|
+
|
|
274
|
+
select_mcp_config "$1" "$2" "$3"
|
|
275
|
+
echo "MCP configuration generated for $1 -> $3"
|
|
276
|
+
fi
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
---
|
|
280
|
+
|
|
281
|
+
## Docker Compose Services
|
|
282
|
+
|
|
283
|
+
### MCP Service Definitions
|
|
284
|
+
|
|
285
|
+
```yaml
|
|
286
|
+
# docker-compose.mcp-services.yml
|
|
287
|
+
version: '3.8'
|
|
288
|
+
|
|
289
|
+
services:
|
|
290
|
+
# Frontend MCP Services
|
|
291
|
+
mcp-playwright:
|
|
292
|
+
image: mcp/playwright:latest
|
|
293
|
+
deploy:
|
|
294
|
+
resources:
|
|
295
|
+
limits:
|
|
296
|
+
memory: 1G
|
|
297
|
+
reservations:
|
|
298
|
+
memory: 512M
|
|
299
|
+
environment:
|
|
300
|
+
- AGENT_ID=${AGENT_ID}
|
|
301
|
+
- DISPLAY=${DISPLAY:-:0}
|
|
302
|
+
volumes:
|
|
303
|
+
- /tmp/.X11-unix:/tmp/.X11-unix:ro
|
|
304
|
+
- workspace:/workspace
|
|
305
|
+
- screenshots:/screenshots
|
|
306
|
+
restart: unless-stopped
|
|
307
|
+
|
|
308
|
+
mcp-browser-automation:
|
|
309
|
+
image: mcp/browser-automation:latest
|
|
310
|
+
deploy:
|
|
311
|
+
resources:
|
|
312
|
+
limits:
|
|
313
|
+
memory: 512M
|
|
314
|
+
reservations:
|
|
315
|
+
memory: 256M
|
|
316
|
+
environment:
|
|
317
|
+
- AGENT_ID=${AGENT_ID}
|
|
318
|
+
- BROWSER_TYPE=chromium
|
|
319
|
+
volumes:
|
|
320
|
+
- workspace:/workspace
|
|
321
|
+
restart: unless-stopped
|
|
322
|
+
|
|
323
|
+
# Backend MCP Services
|
|
324
|
+
mcp-database:
|
|
325
|
+
image: mcp/postgresql:latest
|
|
326
|
+
deploy:
|
|
327
|
+
resources:
|
|
328
|
+
limits:
|
|
329
|
+
memory: 256M
|
|
330
|
+
reservations:
|
|
331
|
+
memory: 128M
|
|
332
|
+
environment:
|
|
333
|
+
- AGENT_ID=${AGENT_ID}
|
|
334
|
+
- DATABASE_URL=${DATABASE_URL}
|
|
335
|
+
restart: unless-stopped
|
|
336
|
+
|
|
337
|
+
mcp-api-testing:
|
|
338
|
+
image: mcp/api-testing:latest
|
|
339
|
+
deploy:
|
|
340
|
+
resources:
|
|
341
|
+
limits:
|
|
342
|
+
memory: 256M
|
|
343
|
+
reservations:
|
|
344
|
+
memory: 128M
|
|
345
|
+
environment:
|
|
346
|
+
- AGENT_ID=${AGENT_ID}
|
|
347
|
+
restart: unless-stopped
|
|
348
|
+
|
|
349
|
+
mcp-redis-tools:
|
|
350
|
+
image: mcp/redis-tools:latest
|
|
351
|
+
deploy:
|
|
352
|
+
resources:
|
|
353
|
+
limits:
|
|
354
|
+
memory: 128M
|
|
355
|
+
reservations:
|
|
356
|
+
memory: 64M
|
|
357
|
+
environment:
|
|
358
|
+
- AGENT_ID=${AGENT_ID}
|
|
359
|
+
- REDIS_HOST=${REDIS_HOST}
|
|
360
|
+
- REDIS_PORT=${REDIS_PORT:-6379}
|
|
361
|
+
restart: unless-stopped
|
|
362
|
+
|
|
363
|
+
# Common Services
|
|
364
|
+
mcp-filesystem:
|
|
365
|
+
image: mcp/filesystem:latest
|
|
366
|
+
deploy:
|
|
367
|
+
resources:
|
|
368
|
+
limits:
|
|
369
|
+
memory: 128M
|
|
370
|
+
reservations:
|
|
371
|
+
memory: 64M
|
|
372
|
+
environment:
|
|
373
|
+
- AGENT_ID=${AGENT_ID}
|
|
374
|
+
volumes:
|
|
375
|
+
- workspace:/workspace
|
|
376
|
+
restart: unless-stopped
|
|
377
|
+
|
|
378
|
+
volumes:
|
|
379
|
+
workspace:
|
|
380
|
+
screenshots:
|
|
381
|
+
```
|
|
382
|
+
|
|
383
|
+
---
|
|
384
|
+
|
|
385
|
+
## Implementation Integration
|
|
386
|
+
|
|
387
|
+
### Agent Spawning with MCP Selection
|
|
388
|
+
|
|
389
|
+
```bash
|
|
390
|
+
#!/bin/bash
|
|
391
|
+
# scripts/spawn-agent-with-mcp.sh
|
|
392
|
+
|
|
393
|
+
set -euo pipefail
|
|
394
|
+
|
|
395
|
+
# Configuration
|
|
396
|
+
AGENT_TYPE="$1"
|
|
397
|
+
AGENT_ID="$2"
|
|
398
|
+
TASK_ID="${3:-$(date +%s)}"
|
|
399
|
+
MEMORY_LIMIT="${4:-1024}"
|
|
400
|
+
MCP_SELECTOR_SKILL=".claude/skills/cfn-mcp-container-selector/select-mcp-config.sh"
|
|
401
|
+
|
|
402
|
+
echo "Spawning agent: $AGENT_TYPE (ID: $AGENT_ID)"
|
|
403
|
+
|
|
404
|
+
# Generate MCP configuration based on agent type
|
|
405
|
+
MCP_CONFIG_DIR="/tmp/mcp-configs"
|
|
406
|
+
mkdir -p "$MCP_CONFIG_DIR"
|
|
407
|
+
MCP_CONFIG_FILE="$MCP_CONFIG_DIR/mcp-${AGENT_ID}.json"
|
|
408
|
+
|
|
409
|
+
echo "Generating MCP configuration for $AGENT_TYPE..."
|
|
410
|
+
"$MCP_SELECTOR_SKILL" "$AGENT_TYPE" "$AGENT_ID" "$MCP_CONFIG_FILE"
|
|
411
|
+
|
|
412
|
+
# Determine container type and memory limits
|
|
413
|
+
case "$AGENT_TYPE" in
|
|
414
|
+
"react-frontend-engineer"|"frontend-developer"|"ui-designer"|"mobile-dev"|"tester"|"playwright-tester")
|
|
415
|
+
CONTAINER_TYPE="frontend"
|
|
416
|
+
MEMORY_LIMIT="${MEMORY_LIMIT:-2048}"
|
|
417
|
+
MCP_SERVICES="playwright,browser-automation,screenshot"
|
|
418
|
+
;;
|
|
419
|
+
"backend-developer"|"database-architect"|"api-gateway-specialist")
|
|
420
|
+
CONTAINER_TYPE="backend"
|
|
421
|
+
MEMORY_LIMIT="${MEMORY_LIMIT:-1024}"
|
|
422
|
+
MCP_SERVICES="database,api-testing,redis-tools"
|
|
423
|
+
;;
|
|
424
|
+
*)
|
|
425
|
+
CONTAINER_TYPE="minimal"
|
|
426
|
+
MEMORY_LIMIT="${MEMORY_LIMIT:-512}"
|
|
427
|
+
MCP_SERVICES="filesystem"
|
|
428
|
+
;;
|
|
429
|
+
esac
|
|
430
|
+
|
|
431
|
+
echo "Container type: $CONTAINER_TYPE"
|
|
432
|
+
echo "Memory limit: ${MEMORY_LIMIT}MB"
|
|
433
|
+
echo "MCP services: $MCP_SERVICES"
|
|
434
|
+
|
|
435
|
+
# Spawn the agent container
|
|
436
|
+
echo "Starting agent container..."
|
|
437
|
+
docker run -d \
|
|
438
|
+
--name "agent-${AGENT_ID}" \
|
|
439
|
+
--memory="${MEMORY_LIMIT}m" \
|
|
440
|
+
--memory-swap="${MEMORY_LIMIT}m" \
|
|
441
|
+
--cpus="1.0" \
|
|
442
|
+
-e AGENT_ID="$AGENT_ID" \
|
|
443
|
+
-e AGENT_TYPE="$AGENT_TYPE" \
|
|
444
|
+
-e TASK_ID="$TASK_ID" \
|
|
445
|
+
-e CONTAINER_TYPE="$CONTAINER_TYPE" \
|
|
446
|
+
-e MCP_SERVICES="$MCP_SERVICES" \
|
|
447
|
+
-e MEMORY_MONITORING=true \
|
|
448
|
+
-e MEMORY_REPORT_INTERVAL=30 \
|
|
449
|
+
-e MEMORY_ALERT_THRESHOLD=80 \
|
|
450
|
+
-e REDIS_HOST=host.docker.internal \
|
|
451
|
+
-e REDIS_PORT=6379 \
|
|
452
|
+
-v "$(pwd):/app/workspace" \
|
|
453
|
+
-v "$MCP_CONFIG_FILE:/app/.claude/settings.json:ro" \
|
|
454
|
+
-v "agent_logs_${AGENT_ID}:/app/logs" \
|
|
455
|
+
claude-flow-novice:memory-monitored \
|
|
456
|
+
/app/monitor-wrapper.sh start-agent \
|
|
457
|
+
--agent-id "$AGENT_ID" \
|
|
458
|
+
--agent-type "$AGENT_TYPE" \
|
|
459
|
+
--task-id "$TASK_ID"
|
|
460
|
+
|
|
461
|
+
echo "Agent container started: agent-${AGENT_ID}"
|
|
462
|
+
|
|
463
|
+
# Return container info
|
|
464
|
+
cat << EOF
|
|
465
|
+
{
|
|
466
|
+
"container_name": "agent-${AGENT_ID}",
|
|
467
|
+
"agent_id": "$AGENT_ID",
|
|
468
|
+
"agent_type": "$AGENT_TYPE",
|
|
469
|
+
"container_type": "$CONTAINER_TYPE",
|
|
470
|
+
"memory_limit_mb": $MEMORY_LIMIT,
|
|
471
|
+
"mcp_services": "$MCP_SERVICES",
|
|
472
|
+
"mcp_config": "$MCP_CONFIG_FILE",
|
|
473
|
+
"status": "starting"
|
|
474
|
+
}
|
|
475
|
+
EOF
|
|
476
|
+
|
|
477
|
+
echo "Agent spawn completed successfully!"
|
|
478
|
+
```
|
|
479
|
+
|
|
480
|
+
---
|
|
481
|
+
|
|
482
|
+
## Benefits Analysis
|
|
483
|
+
|
|
484
|
+
### Context Efficiency
|
|
485
|
+
|
|
486
|
+
**Before (All agents load all MCP tools):**
|
|
487
|
+
```
|
|
488
|
+
Agent: backend-developer
|
|
489
|
+
MCP Tools: [playwright, browser, database, api, redis, filesystem]
|
|
490
|
+
Context Usage: ~15,000 tokens (80% irrelevant)
|
|
491
|
+
Memory Usage: ~2GB
|
|
492
|
+
```
|
|
493
|
+
|
|
494
|
+
**After (Specialized MCP per container):**
|
|
495
|
+
```
|
|
496
|
+
Agent: backend-developer
|
|
497
|
+
MCP Tools: [database, api, redis, filesystem]
|
|
498
|
+
Context Usage: ~6,000 tokens (100% relevant)
|
|
499
|
+
Memory Usage: ~1GB
|
|
500
|
+
```
|
|
501
|
+
|
|
502
|
+
### Resource Optimization
|
|
503
|
+
|
|
504
|
+
| Agent Type | Memory Before | Memory After | Context Reduction |
|
|
505
|
+
|------------|---------------|--------------|-------------------|
|
|
506
|
+
| Frontend | 2GB | 2GB | 0% (needs Playwright) |
|
|
507
|
+
| Backend | 2GB | 1GB | 50% |
|
|
508
|
+
| Tester | 2GB | 2GB | 0% (needs both) |
|
|
509
|
+
| General | 2GB | 512MB | 75% |
|
|
510
|
+
|
|
511
|
+
### Performance Benefits
|
|
512
|
+
|
|
513
|
+
1. **Faster agent startup** - less MCP tool initialization
|
|
514
|
+
2. **Lower memory usage** - only load relevant tools
|
|
515
|
+
3. **Better tool relevance** - no irrelevant Playwright prompts for backend agents
|
|
516
|
+
4. **Resource isolation** - per-container memory limits
|
|
517
|
+
5. **Scalability** - can run more agents on same hardware
|
|
518
|
+
|
|
519
|
+
---
|
|
520
|
+
|
|
521
|
+
## Usage Examples
|
|
522
|
+
|
|
523
|
+
### Spawn Frontend Agent with Playwright
|
|
524
|
+
|
|
525
|
+
```bash
|
|
526
|
+
./scripts/spawn-agent-with-mcp.sh \
|
|
527
|
+
react-frontend-engineer \
|
|
528
|
+
fe-$(date +%s) \
|
|
529
|
+
task-123 \
|
|
530
|
+
2048
|
|
531
|
+
```
|
|
532
|
+
|
|
533
|
+
**Result:** Frontend container with Playwright, browser automation, screenshot tools
|
|
534
|
+
|
|
535
|
+
### Spawn Backend Agent without Playwright
|
|
536
|
+
|
|
537
|
+
```bash
|
|
538
|
+
./scripts/spawn-agent-with-mcp.sh \
|
|
539
|
+
backend-developer \
|
|
540
|
+
be-$(date +%s) \
|
|
541
|
+
task-456 \
|
|
542
|
+
1024
|
|
543
|
+
```
|
|
544
|
+
|
|
545
|
+
**Result:** Backend container with database, API testing, Redis tools
|
|
546
|
+
|
|
547
|
+
---
|
|
548
|
+
|
|
549
|
+
## Next Steps
|
|
550
|
+
|
|
551
|
+
1. **Build MCP service images** for each tool category
|
|
552
|
+
2. **Test agent spawning** with different MCP configurations
|
|
553
|
+
3. **Measure context reduction** and performance improvements
|
|
554
|
+
4. **Deploy to production** with container orchestration
|
|
555
|
+
5. **Monitor resource usage** and optimize configurations
|