snow-flow 1.4.13 → 1.4.15
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.template +1 -2
- package/.mcp.json.template +7 -0
- package/CLAUDE.md +1 -1
- package/README.md +24 -4
- package/dist/cli.js +2 -1
- package/dist/cli.js.map +1 -1
- package/dist/mcp/snow-flow-mcp.d.ts +6 -0
- package/dist/mcp/snow-flow-mcp.d.ts.map +1 -0
- package/dist/mcp/snow-flow-mcp.js +880 -0
- package/dist/mcp/snow-flow-mcp.js.map +1 -0
- package/dist/version.d.ts +3 -1
- package/dist/version.d.ts.map +1 -1
- package/dist/version.js +19 -1
- package/dist/version.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,880 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Snow-Flow MCP Server
|
|
4
|
+
* Provides coordination tools for multi-agent orchestration
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
const index_js_1 = require("@modelcontextprotocol/sdk/server/index.js");
|
|
8
|
+
const stdio_js_1 = require("@modelcontextprotocol/sdk/server/stdio.js");
|
|
9
|
+
const types_js_1 = require("@modelcontextprotocol/sdk/types.js");
|
|
10
|
+
class SnowFlowMCPServer {
|
|
11
|
+
constructor() {
|
|
12
|
+
this.swarms = new Map();
|
|
13
|
+
this.agents = new Map();
|
|
14
|
+
this.tasks = new Map();
|
|
15
|
+
this.memory = {};
|
|
16
|
+
this.neuralModels = new Map();
|
|
17
|
+
this.server = new index_js_1.Server({
|
|
18
|
+
name: 'snow-flow',
|
|
19
|
+
version: '1.0.0',
|
|
20
|
+
}, {
|
|
21
|
+
capabilities: {
|
|
22
|
+
tools: {},
|
|
23
|
+
},
|
|
24
|
+
});
|
|
25
|
+
this.setupToolHandlers();
|
|
26
|
+
}
|
|
27
|
+
setupToolHandlers() {
|
|
28
|
+
// List tools handler
|
|
29
|
+
this.server.setRequestHandler(types_js_1.ListToolsRequestSchema, async () => {
|
|
30
|
+
const tools = [
|
|
31
|
+
// Swarm Management
|
|
32
|
+
{
|
|
33
|
+
name: 'swarm_init',
|
|
34
|
+
description: 'Initialize swarm with topology and configuration',
|
|
35
|
+
inputSchema: {
|
|
36
|
+
type: 'object',
|
|
37
|
+
properties: {
|
|
38
|
+
topology: {
|
|
39
|
+
type: 'string',
|
|
40
|
+
enum: ['hierarchical', 'mesh', 'ring', 'star'],
|
|
41
|
+
},
|
|
42
|
+
maxAgents: {
|
|
43
|
+
type: 'number',
|
|
44
|
+
default: 8,
|
|
45
|
+
},
|
|
46
|
+
strategy: {
|
|
47
|
+
type: 'string',
|
|
48
|
+
default: 'auto',
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
required: ['topology'],
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
name: 'agent_spawn',
|
|
56
|
+
description: 'Create specialized AI agents',
|
|
57
|
+
inputSchema: {
|
|
58
|
+
type: 'object',
|
|
59
|
+
properties: {
|
|
60
|
+
type: {
|
|
61
|
+
type: 'string',
|
|
62
|
+
enum: [
|
|
63
|
+
'coordinator',
|
|
64
|
+
'researcher',
|
|
65
|
+
'coder',
|
|
66
|
+
'analyst',
|
|
67
|
+
'architect',
|
|
68
|
+
'tester',
|
|
69
|
+
'reviewer',
|
|
70
|
+
'optimizer',
|
|
71
|
+
'documenter',
|
|
72
|
+
'monitor',
|
|
73
|
+
'specialist',
|
|
74
|
+
],
|
|
75
|
+
},
|
|
76
|
+
name: {
|
|
77
|
+
type: 'string',
|
|
78
|
+
},
|
|
79
|
+
capabilities: {
|
|
80
|
+
type: 'array',
|
|
81
|
+
},
|
|
82
|
+
swarmId: {
|
|
83
|
+
type: 'string',
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
required: ['type'],
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
name: 'task_orchestrate',
|
|
91
|
+
description: 'Orchestrate complex task workflows',
|
|
92
|
+
inputSchema: {
|
|
93
|
+
type: 'object',
|
|
94
|
+
properties: {
|
|
95
|
+
task: {
|
|
96
|
+
type: 'string',
|
|
97
|
+
},
|
|
98
|
+
strategy: {
|
|
99
|
+
type: 'string',
|
|
100
|
+
enum: ['parallel', 'sequential', 'adaptive', 'balanced'],
|
|
101
|
+
},
|
|
102
|
+
priority: {
|
|
103
|
+
type: 'string',
|
|
104
|
+
enum: ['low', 'medium', 'high', 'critical'],
|
|
105
|
+
},
|
|
106
|
+
dependencies: {
|
|
107
|
+
type: 'array',
|
|
108
|
+
},
|
|
109
|
+
},
|
|
110
|
+
required: ['task'],
|
|
111
|
+
},
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
name: 'swarm_status',
|
|
115
|
+
description: 'Monitor swarm health and performance',
|
|
116
|
+
inputSchema: {
|
|
117
|
+
type: 'object',
|
|
118
|
+
properties: {
|
|
119
|
+
swarmId: {
|
|
120
|
+
type: 'string',
|
|
121
|
+
},
|
|
122
|
+
},
|
|
123
|
+
},
|
|
124
|
+
},
|
|
125
|
+
// Neural & Memory
|
|
126
|
+
{
|
|
127
|
+
name: 'neural_status',
|
|
128
|
+
description: 'Check neural network status',
|
|
129
|
+
inputSchema: {
|
|
130
|
+
type: 'object',
|
|
131
|
+
properties: {
|
|
132
|
+
modelId: {
|
|
133
|
+
type: 'string',
|
|
134
|
+
},
|
|
135
|
+
},
|
|
136
|
+
},
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
name: 'neural_train',
|
|
140
|
+
description: 'Train neural patterns with WASM SIMD acceleration',
|
|
141
|
+
inputSchema: {
|
|
142
|
+
type: 'object',
|
|
143
|
+
properties: {
|
|
144
|
+
pattern_type: {
|
|
145
|
+
type: 'string',
|
|
146
|
+
enum: ['coordination', 'optimization', 'prediction'],
|
|
147
|
+
},
|
|
148
|
+
training_data: {
|
|
149
|
+
type: 'string',
|
|
150
|
+
},
|
|
151
|
+
epochs: {
|
|
152
|
+
type: 'number',
|
|
153
|
+
default: 50,
|
|
154
|
+
},
|
|
155
|
+
},
|
|
156
|
+
required: ['pattern_type', 'training_data'],
|
|
157
|
+
},
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
name: 'neural_patterns',
|
|
161
|
+
description: 'Analyze cognitive patterns',
|
|
162
|
+
inputSchema: {
|
|
163
|
+
type: 'object',
|
|
164
|
+
properties: {
|
|
165
|
+
action: {
|
|
166
|
+
type: 'string',
|
|
167
|
+
enum: ['analyze', 'learn', 'predict'],
|
|
168
|
+
},
|
|
169
|
+
operation: {
|
|
170
|
+
type: 'string',
|
|
171
|
+
},
|
|
172
|
+
outcome: {
|
|
173
|
+
type: 'string',
|
|
174
|
+
},
|
|
175
|
+
metadata: {
|
|
176
|
+
type: 'object',
|
|
177
|
+
},
|
|
178
|
+
},
|
|
179
|
+
required: ['action'],
|
|
180
|
+
},
|
|
181
|
+
},
|
|
182
|
+
{
|
|
183
|
+
name: 'memory_usage',
|
|
184
|
+
description: 'Store/retrieve persistent memory with TTL and namespacing',
|
|
185
|
+
inputSchema: {
|
|
186
|
+
type: 'object',
|
|
187
|
+
properties: {
|
|
188
|
+
action: {
|
|
189
|
+
type: 'string',
|
|
190
|
+
enum: ['store', 'retrieve', 'list', 'delete', 'search'],
|
|
191
|
+
},
|
|
192
|
+
key: {
|
|
193
|
+
type: 'string',
|
|
194
|
+
},
|
|
195
|
+
value: {
|
|
196
|
+
type: 'string',
|
|
197
|
+
},
|
|
198
|
+
namespace: {
|
|
199
|
+
type: 'string',
|
|
200
|
+
default: 'default',
|
|
201
|
+
},
|
|
202
|
+
ttl: {
|
|
203
|
+
type: 'number',
|
|
204
|
+
},
|
|
205
|
+
},
|
|
206
|
+
required: ['action'],
|
|
207
|
+
},
|
|
208
|
+
},
|
|
209
|
+
{
|
|
210
|
+
name: 'memory_search',
|
|
211
|
+
description: 'Search memory with patterns',
|
|
212
|
+
inputSchema: {
|
|
213
|
+
type: 'object',
|
|
214
|
+
properties: {
|
|
215
|
+
pattern: {
|
|
216
|
+
type: 'string',
|
|
217
|
+
},
|
|
218
|
+
namespace: {
|
|
219
|
+
type: 'string',
|
|
220
|
+
},
|
|
221
|
+
limit: {
|
|
222
|
+
type: 'number',
|
|
223
|
+
default: 10,
|
|
224
|
+
},
|
|
225
|
+
},
|
|
226
|
+
required: ['pattern'],
|
|
227
|
+
},
|
|
228
|
+
},
|
|
229
|
+
// Performance & Monitoring
|
|
230
|
+
{
|
|
231
|
+
name: 'performance_report',
|
|
232
|
+
description: 'Generate performance reports with real-time metrics',
|
|
233
|
+
inputSchema: {
|
|
234
|
+
type: 'object',
|
|
235
|
+
properties: {
|
|
236
|
+
format: {
|
|
237
|
+
type: 'string',
|
|
238
|
+
enum: ['summary', 'detailed', 'json'],
|
|
239
|
+
default: 'summary',
|
|
240
|
+
},
|
|
241
|
+
timeframe: {
|
|
242
|
+
type: 'string',
|
|
243
|
+
enum: ['24h', '7d', '30d'],
|
|
244
|
+
default: '24h',
|
|
245
|
+
},
|
|
246
|
+
},
|
|
247
|
+
},
|
|
248
|
+
},
|
|
249
|
+
{
|
|
250
|
+
name: 'bottleneck_analyze',
|
|
251
|
+
description: 'Identify performance bottlenecks',
|
|
252
|
+
inputSchema: {
|
|
253
|
+
type: 'object',
|
|
254
|
+
properties: {
|
|
255
|
+
component: {
|
|
256
|
+
type: 'string',
|
|
257
|
+
},
|
|
258
|
+
metrics: {
|
|
259
|
+
type: 'array',
|
|
260
|
+
},
|
|
261
|
+
},
|
|
262
|
+
},
|
|
263
|
+
},
|
|
264
|
+
{
|
|
265
|
+
name: 'token_usage',
|
|
266
|
+
description: 'Analyze token consumption',
|
|
267
|
+
inputSchema: {
|
|
268
|
+
type: 'object',
|
|
269
|
+
properties: {
|
|
270
|
+
operation: {
|
|
271
|
+
type: 'string',
|
|
272
|
+
},
|
|
273
|
+
timeframe: {
|
|
274
|
+
type: 'string',
|
|
275
|
+
default: '24h',
|
|
276
|
+
},
|
|
277
|
+
},
|
|
278
|
+
},
|
|
279
|
+
},
|
|
280
|
+
// GitHub Integration
|
|
281
|
+
{
|
|
282
|
+
name: 'github_repo_analyze',
|
|
283
|
+
description: 'Repository analysis',
|
|
284
|
+
inputSchema: {
|
|
285
|
+
type: 'object',
|
|
286
|
+
properties: {
|
|
287
|
+
repo: {
|
|
288
|
+
type: 'string',
|
|
289
|
+
},
|
|
290
|
+
analysis_type: {
|
|
291
|
+
type: 'string',
|
|
292
|
+
enum: ['code_quality', 'performance', 'security'],
|
|
293
|
+
},
|
|
294
|
+
},
|
|
295
|
+
required: ['repo'],
|
|
296
|
+
},
|
|
297
|
+
},
|
|
298
|
+
{
|
|
299
|
+
name: 'github_pr_manage',
|
|
300
|
+
description: 'Pull request management',
|
|
301
|
+
inputSchema: {
|
|
302
|
+
type: 'object',
|
|
303
|
+
properties: {
|
|
304
|
+
repo: {
|
|
305
|
+
type: 'string',
|
|
306
|
+
},
|
|
307
|
+
action: {
|
|
308
|
+
type: 'string',
|
|
309
|
+
enum: ['review', 'merge', 'close'],
|
|
310
|
+
},
|
|
311
|
+
pr_number: {
|
|
312
|
+
type: 'number',
|
|
313
|
+
},
|
|
314
|
+
},
|
|
315
|
+
required: ['repo', 'action'],
|
|
316
|
+
},
|
|
317
|
+
},
|
|
318
|
+
// Dynamic Agent Architecture
|
|
319
|
+
{
|
|
320
|
+
name: 'daa_agent_create',
|
|
321
|
+
description: 'Create dynamic agents',
|
|
322
|
+
inputSchema: {
|
|
323
|
+
type: 'object',
|
|
324
|
+
properties: {
|
|
325
|
+
agent_type: {
|
|
326
|
+
type: 'string',
|
|
327
|
+
},
|
|
328
|
+
capabilities: {
|
|
329
|
+
type: 'array',
|
|
330
|
+
},
|
|
331
|
+
resources: {
|
|
332
|
+
type: 'object',
|
|
333
|
+
},
|
|
334
|
+
},
|
|
335
|
+
required: ['agent_type'],
|
|
336
|
+
},
|
|
337
|
+
},
|
|
338
|
+
{
|
|
339
|
+
name: 'daa_capability_match',
|
|
340
|
+
description: 'Match capabilities to tasks',
|
|
341
|
+
inputSchema: {
|
|
342
|
+
type: 'object',
|
|
343
|
+
properties: {
|
|
344
|
+
task_requirements: {
|
|
345
|
+
type: 'array',
|
|
346
|
+
},
|
|
347
|
+
available_agents: {
|
|
348
|
+
type: 'array',
|
|
349
|
+
},
|
|
350
|
+
},
|
|
351
|
+
required: ['task_requirements'],
|
|
352
|
+
},
|
|
353
|
+
},
|
|
354
|
+
// Workflow Management
|
|
355
|
+
{
|
|
356
|
+
name: 'workflow_create',
|
|
357
|
+
description: 'Create custom workflows',
|
|
358
|
+
inputSchema: {
|
|
359
|
+
type: 'object',
|
|
360
|
+
properties: {
|
|
361
|
+
name: {
|
|
362
|
+
type: 'string',
|
|
363
|
+
},
|
|
364
|
+
steps: {
|
|
365
|
+
type: 'array',
|
|
366
|
+
},
|
|
367
|
+
triggers: {
|
|
368
|
+
type: 'array',
|
|
369
|
+
},
|
|
370
|
+
},
|
|
371
|
+
required: ['name', 'steps'],
|
|
372
|
+
},
|
|
373
|
+
},
|
|
374
|
+
{
|
|
375
|
+
name: 'sparc_mode',
|
|
376
|
+
description: 'Run SPARC development modes',
|
|
377
|
+
inputSchema: {
|
|
378
|
+
type: 'object',
|
|
379
|
+
properties: {
|
|
380
|
+
mode: {
|
|
381
|
+
type: 'string',
|
|
382
|
+
enum: ['dev', 'api', 'ui', 'test', 'refactor'],
|
|
383
|
+
},
|
|
384
|
+
task_description: {
|
|
385
|
+
type: 'string',
|
|
386
|
+
},
|
|
387
|
+
options: {
|
|
388
|
+
type: 'object',
|
|
389
|
+
},
|
|
390
|
+
},
|
|
391
|
+
required: ['mode', 'task_description'],
|
|
392
|
+
},
|
|
393
|
+
},
|
|
394
|
+
];
|
|
395
|
+
return { tools };
|
|
396
|
+
});
|
|
397
|
+
// Call tool handler
|
|
398
|
+
this.server.setRequestHandler(types_js_1.CallToolRequestSchema, async (request) => {
|
|
399
|
+
const { name, arguments: args } = request.params;
|
|
400
|
+
try {
|
|
401
|
+
switch (name) {
|
|
402
|
+
case 'swarm_init':
|
|
403
|
+
return await this.handleSwarmInit(args);
|
|
404
|
+
case 'agent_spawn':
|
|
405
|
+
return await this.handleAgentSpawn(args);
|
|
406
|
+
case 'task_orchestrate':
|
|
407
|
+
return await this.handleTaskOrchestrate(args);
|
|
408
|
+
case 'swarm_status':
|
|
409
|
+
return await this.handleSwarmStatus(args);
|
|
410
|
+
case 'memory_usage':
|
|
411
|
+
return await this.handleMemoryUsage(args);
|
|
412
|
+
case 'memory_search':
|
|
413
|
+
return await this.handleMemorySearch(args);
|
|
414
|
+
case 'neural_train':
|
|
415
|
+
return await this.handleNeuralTrain(args);
|
|
416
|
+
case 'neural_patterns':
|
|
417
|
+
return await this.handleNeuralPatterns(args);
|
|
418
|
+
case 'performance_report':
|
|
419
|
+
return await this.handlePerformanceReport(args);
|
|
420
|
+
default:
|
|
421
|
+
return {
|
|
422
|
+
content: [
|
|
423
|
+
{
|
|
424
|
+
type: 'text',
|
|
425
|
+
text: JSON.stringify({
|
|
426
|
+
error: `Tool ${name} not implemented yet`,
|
|
427
|
+
status: 'not_implemented',
|
|
428
|
+
}),
|
|
429
|
+
},
|
|
430
|
+
],
|
|
431
|
+
};
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
catch (error) {
|
|
435
|
+
return {
|
|
436
|
+
content: [
|
|
437
|
+
{
|
|
438
|
+
type: 'text',
|
|
439
|
+
text: JSON.stringify({
|
|
440
|
+
error: error.message,
|
|
441
|
+
status: 'error',
|
|
442
|
+
}),
|
|
443
|
+
},
|
|
444
|
+
],
|
|
445
|
+
};
|
|
446
|
+
}
|
|
447
|
+
});
|
|
448
|
+
}
|
|
449
|
+
async handleSwarmInit(args) {
|
|
450
|
+
const swarmId = `swarm_${Date.now()}`;
|
|
451
|
+
const swarm = {
|
|
452
|
+
id: swarmId,
|
|
453
|
+
topology: args.topology,
|
|
454
|
+
maxAgents: args.maxAgents || 8,
|
|
455
|
+
strategy: args.strategy || 'auto',
|
|
456
|
+
agents: [],
|
|
457
|
+
status: 'initializing',
|
|
458
|
+
createdAt: new Date(),
|
|
459
|
+
};
|
|
460
|
+
this.swarms.set(swarmId, swarm);
|
|
461
|
+
// Initialize coordinator agent automatically
|
|
462
|
+
const coordinator = {
|
|
463
|
+
id: `agent_${Date.now()}_coordinator`,
|
|
464
|
+
type: 'coordinator',
|
|
465
|
+
name: 'Swarm Coordinator',
|
|
466
|
+
status: 'idle',
|
|
467
|
+
capabilities: ['coordination', 'task_distribution', 'monitoring'],
|
|
468
|
+
createdAt: new Date(),
|
|
469
|
+
};
|
|
470
|
+
this.agents.set(coordinator.id, coordinator);
|
|
471
|
+
swarm.agents.push(coordinator);
|
|
472
|
+
swarm.status = 'active';
|
|
473
|
+
return {
|
|
474
|
+
content: [
|
|
475
|
+
{
|
|
476
|
+
type: 'text',
|
|
477
|
+
text: JSON.stringify({
|
|
478
|
+
swarmId,
|
|
479
|
+
topology: swarm.topology,
|
|
480
|
+
maxAgents: swarm.maxAgents,
|
|
481
|
+
strategy: swarm.strategy,
|
|
482
|
+
coordinator: coordinator.id,
|
|
483
|
+
status: 'active',
|
|
484
|
+
message: `Swarm initialized with ${swarm.topology} topology`,
|
|
485
|
+
}),
|
|
486
|
+
},
|
|
487
|
+
],
|
|
488
|
+
};
|
|
489
|
+
}
|
|
490
|
+
async handleAgentSpawn(args) {
|
|
491
|
+
const agentId = `agent_${Date.now()}_${args.type}`;
|
|
492
|
+
const agent = {
|
|
493
|
+
id: agentId,
|
|
494
|
+
type: args.type,
|
|
495
|
+
name: args.name || `${args.type.charAt(0).toUpperCase() + args.type.slice(1)} Agent`,
|
|
496
|
+
status: 'idle',
|
|
497
|
+
capabilities: args.capabilities || this.getDefaultCapabilities(args.type),
|
|
498
|
+
createdAt: new Date(),
|
|
499
|
+
};
|
|
500
|
+
this.agents.set(agentId, agent);
|
|
501
|
+
// Add to swarm if specified
|
|
502
|
+
if (args.swarmId && this.swarms.has(args.swarmId)) {
|
|
503
|
+
const swarm = this.swarms.get(args.swarmId);
|
|
504
|
+
swarm.agents.push(agent);
|
|
505
|
+
}
|
|
506
|
+
return {
|
|
507
|
+
content: [
|
|
508
|
+
{
|
|
509
|
+
type: 'text',
|
|
510
|
+
text: JSON.stringify({
|
|
511
|
+
agentId,
|
|
512
|
+
type: agent.type,
|
|
513
|
+
name: agent.name,
|
|
514
|
+
capabilities: agent.capabilities,
|
|
515
|
+
status: 'spawned',
|
|
516
|
+
message: `Agent ${agent.name} spawned successfully`,
|
|
517
|
+
}),
|
|
518
|
+
},
|
|
519
|
+
],
|
|
520
|
+
};
|
|
521
|
+
}
|
|
522
|
+
async handleTaskOrchestrate(args) {
|
|
523
|
+
const taskId = `task_${Date.now()}`;
|
|
524
|
+
const task = {
|
|
525
|
+
id: taskId,
|
|
526
|
+
description: args.task,
|
|
527
|
+
status: 'pending',
|
|
528
|
+
createdAt: new Date(),
|
|
529
|
+
};
|
|
530
|
+
this.tasks.set(taskId, task);
|
|
531
|
+
// Simulate task orchestration
|
|
532
|
+
task.status = 'in_progress';
|
|
533
|
+
// Find available agent
|
|
534
|
+
const availableAgent = Array.from(this.agents.values()).find((a) => a.status === 'idle');
|
|
535
|
+
if (availableAgent) {
|
|
536
|
+
task.assignedAgent = availableAgent.id;
|
|
537
|
+
availableAgent.status = 'busy';
|
|
538
|
+
}
|
|
539
|
+
return {
|
|
540
|
+
content: [
|
|
541
|
+
{
|
|
542
|
+
type: 'text',
|
|
543
|
+
text: JSON.stringify({
|
|
544
|
+
taskId,
|
|
545
|
+
task: task.description,
|
|
546
|
+
strategy: args.strategy || 'adaptive',
|
|
547
|
+
priority: args.priority || 'medium',
|
|
548
|
+
status: 'orchestrating',
|
|
549
|
+
assignedAgent: task.assignedAgent,
|
|
550
|
+
message: 'Task orchestration initiated',
|
|
551
|
+
}),
|
|
552
|
+
},
|
|
553
|
+
],
|
|
554
|
+
};
|
|
555
|
+
}
|
|
556
|
+
async handleSwarmStatus(args) {
|
|
557
|
+
const swarmId = args.swarmId;
|
|
558
|
+
if (!swarmId) {
|
|
559
|
+
// Return all swarms status
|
|
560
|
+
const allSwarms = Array.from(this.swarms.entries()).map(([id, swarm]) => ({
|
|
561
|
+
id,
|
|
562
|
+
topology: swarm.topology,
|
|
563
|
+
agents: swarm.agents.length,
|
|
564
|
+
maxAgents: swarm.maxAgents,
|
|
565
|
+
status: swarm.status,
|
|
566
|
+
}));
|
|
567
|
+
return {
|
|
568
|
+
content: [
|
|
569
|
+
{
|
|
570
|
+
type: 'text',
|
|
571
|
+
text: JSON.stringify({
|
|
572
|
+
swarms: allSwarms,
|
|
573
|
+
totalSwarms: allSwarms.length,
|
|
574
|
+
activeSwarms: allSwarms.filter((s) => s.status === 'active').length,
|
|
575
|
+
}),
|
|
576
|
+
},
|
|
577
|
+
],
|
|
578
|
+
};
|
|
579
|
+
}
|
|
580
|
+
const swarm = this.swarms.get(swarmId);
|
|
581
|
+
if (!swarm) {
|
|
582
|
+
throw new Error(`Swarm ${swarmId} not found`);
|
|
583
|
+
}
|
|
584
|
+
return {
|
|
585
|
+
content: [
|
|
586
|
+
{
|
|
587
|
+
type: 'text',
|
|
588
|
+
text: JSON.stringify({
|
|
589
|
+
swarmId,
|
|
590
|
+
topology: swarm.topology,
|
|
591
|
+
agents: swarm.agents.map((a) => ({
|
|
592
|
+
id: a.id,
|
|
593
|
+
type: a.type,
|
|
594
|
+
name: a.name,
|
|
595
|
+
status: a.status,
|
|
596
|
+
})),
|
|
597
|
+
totalAgents: swarm.agents.length,
|
|
598
|
+
maxAgents: swarm.maxAgents,
|
|
599
|
+
status: swarm.status,
|
|
600
|
+
uptime: Date.now() - swarm.createdAt.getTime(),
|
|
601
|
+
}),
|
|
602
|
+
},
|
|
603
|
+
],
|
|
604
|
+
};
|
|
605
|
+
}
|
|
606
|
+
async handleMemoryUsage(args) {
|
|
607
|
+
const { action, key, value, namespace = 'default' } = args;
|
|
608
|
+
const memoryKey = `${namespace}:${key}`;
|
|
609
|
+
switch (action) {
|
|
610
|
+
case 'store': {
|
|
611
|
+
this.memory[memoryKey] = {
|
|
612
|
+
value,
|
|
613
|
+
timestamp: Date.now(),
|
|
614
|
+
ttl: args.ttl,
|
|
615
|
+
};
|
|
616
|
+
return {
|
|
617
|
+
content: [
|
|
618
|
+
{
|
|
619
|
+
type: 'text',
|
|
620
|
+
text: JSON.stringify({
|
|
621
|
+
action: 'stored',
|
|
622
|
+
key: memoryKey,
|
|
623
|
+
status: 'success',
|
|
624
|
+
}),
|
|
625
|
+
},
|
|
626
|
+
],
|
|
627
|
+
};
|
|
628
|
+
}
|
|
629
|
+
case 'retrieve': {
|
|
630
|
+
const data = this.memory[memoryKey];
|
|
631
|
+
if (!data) {
|
|
632
|
+
return {
|
|
633
|
+
content: [
|
|
634
|
+
{
|
|
635
|
+
type: 'text',
|
|
636
|
+
text: JSON.stringify({
|
|
637
|
+
action: 'retrieve',
|
|
638
|
+
key: memoryKey,
|
|
639
|
+
value: null,
|
|
640
|
+
status: 'not_found',
|
|
641
|
+
}),
|
|
642
|
+
},
|
|
643
|
+
],
|
|
644
|
+
};
|
|
645
|
+
}
|
|
646
|
+
return {
|
|
647
|
+
content: [
|
|
648
|
+
{
|
|
649
|
+
type: 'text',
|
|
650
|
+
text: JSON.stringify({
|
|
651
|
+
action: 'retrieve',
|
|
652
|
+
key: memoryKey,
|
|
653
|
+
value: data.value,
|
|
654
|
+
timestamp: data.timestamp,
|
|
655
|
+
status: 'success',
|
|
656
|
+
}),
|
|
657
|
+
},
|
|
658
|
+
],
|
|
659
|
+
};
|
|
660
|
+
}
|
|
661
|
+
case 'list': {
|
|
662
|
+
const keys = Object.keys(this.memory).filter((k) => k.startsWith(namespace));
|
|
663
|
+
return {
|
|
664
|
+
content: [
|
|
665
|
+
{
|
|
666
|
+
type: 'text',
|
|
667
|
+
text: JSON.stringify({
|
|
668
|
+
action: 'list',
|
|
669
|
+
namespace,
|
|
670
|
+
keys,
|
|
671
|
+
count: keys.length,
|
|
672
|
+
status: 'success',
|
|
673
|
+
}),
|
|
674
|
+
},
|
|
675
|
+
],
|
|
676
|
+
};
|
|
677
|
+
}
|
|
678
|
+
case 'delete': {
|
|
679
|
+
delete this.memory[memoryKey];
|
|
680
|
+
return {
|
|
681
|
+
content: [
|
|
682
|
+
{
|
|
683
|
+
type: 'text',
|
|
684
|
+
text: JSON.stringify({
|
|
685
|
+
action: 'deleted',
|
|
686
|
+
key: memoryKey,
|
|
687
|
+
status: 'success',
|
|
688
|
+
}),
|
|
689
|
+
},
|
|
690
|
+
],
|
|
691
|
+
};
|
|
692
|
+
}
|
|
693
|
+
default:
|
|
694
|
+
throw new Error(`Unknown memory action: ${action}`);
|
|
695
|
+
}
|
|
696
|
+
}
|
|
697
|
+
async handleMemorySearch(args) {
|
|
698
|
+
const { pattern, namespace = 'default', limit = 10 } = args;
|
|
699
|
+
const regex = new RegExp(pattern, 'i');
|
|
700
|
+
const matches = Object.entries(this.memory)
|
|
701
|
+
.filter(([key, data]) => {
|
|
702
|
+
if (namespace && !key.startsWith(namespace))
|
|
703
|
+
return false;
|
|
704
|
+
return regex.test(key) || regex.test(JSON.stringify(data.value));
|
|
705
|
+
})
|
|
706
|
+
.slice(0, limit)
|
|
707
|
+
.map(([key, data]) => ({
|
|
708
|
+
key,
|
|
709
|
+
value: data.value,
|
|
710
|
+
timestamp: data.timestamp,
|
|
711
|
+
}));
|
|
712
|
+
return {
|
|
713
|
+
content: [
|
|
714
|
+
{
|
|
715
|
+
type: 'text',
|
|
716
|
+
text: JSON.stringify({
|
|
717
|
+
pattern,
|
|
718
|
+
namespace,
|
|
719
|
+
matches,
|
|
720
|
+
count: matches.length,
|
|
721
|
+
status: 'success',
|
|
722
|
+
}),
|
|
723
|
+
},
|
|
724
|
+
],
|
|
725
|
+
};
|
|
726
|
+
}
|
|
727
|
+
async handleNeuralTrain(args) {
|
|
728
|
+
const { pattern_type, epochs = 50 } = args;
|
|
729
|
+
const modelId = `model_${pattern_type}_${Date.now()}`;
|
|
730
|
+
// Simulate neural training
|
|
731
|
+
const model = {
|
|
732
|
+
id: modelId,
|
|
733
|
+
type: pattern_type,
|
|
734
|
+
epochs,
|
|
735
|
+
accuracy: 0.85 + Math.random() * 0.1,
|
|
736
|
+
loss: 0.15 - Math.random() * 0.05,
|
|
737
|
+
trainedAt: new Date(),
|
|
738
|
+
};
|
|
739
|
+
this.neuralModels.set(modelId, model);
|
|
740
|
+
return {
|
|
741
|
+
content: [
|
|
742
|
+
{
|
|
743
|
+
type: 'text',
|
|
744
|
+
text: JSON.stringify({
|
|
745
|
+
modelId,
|
|
746
|
+
pattern_type,
|
|
747
|
+
epochs,
|
|
748
|
+
accuracy: model.accuracy.toFixed(3),
|
|
749
|
+
loss: model.loss.toFixed(3),
|
|
750
|
+
status: 'trained',
|
|
751
|
+
message: `Model trained successfully with ${epochs} epochs`,
|
|
752
|
+
}),
|
|
753
|
+
},
|
|
754
|
+
],
|
|
755
|
+
};
|
|
756
|
+
}
|
|
757
|
+
async handleNeuralPatterns(args) {
|
|
758
|
+
const { action, operation, outcome } = args;
|
|
759
|
+
switch (action) {
|
|
760
|
+
case 'analyze':
|
|
761
|
+
return {
|
|
762
|
+
content: [
|
|
763
|
+
{
|
|
764
|
+
type: 'text',
|
|
765
|
+
text: JSON.stringify({
|
|
766
|
+
action: 'analyze',
|
|
767
|
+
patterns: [
|
|
768
|
+
'coordination_efficiency: 87%',
|
|
769
|
+
'task_distribution: balanced',
|
|
770
|
+
'agent_utilization: 76%',
|
|
771
|
+
'bottlenecks: none detected',
|
|
772
|
+
],
|
|
773
|
+
recommendations: [
|
|
774
|
+
'Consider adding more specialized agents',
|
|
775
|
+
'Optimize task queuing algorithm',
|
|
776
|
+
],
|
|
777
|
+
status: 'analyzed',
|
|
778
|
+
}),
|
|
779
|
+
},
|
|
780
|
+
],
|
|
781
|
+
};
|
|
782
|
+
case 'learn':
|
|
783
|
+
return {
|
|
784
|
+
content: [
|
|
785
|
+
{
|
|
786
|
+
type: 'text',
|
|
787
|
+
text: JSON.stringify({
|
|
788
|
+
action: 'learn',
|
|
789
|
+
operation,
|
|
790
|
+
outcome,
|
|
791
|
+
learned: true,
|
|
792
|
+
confidence: 0.92,
|
|
793
|
+
status: 'learned',
|
|
794
|
+
}),
|
|
795
|
+
},
|
|
796
|
+
],
|
|
797
|
+
};
|
|
798
|
+
case 'predict':
|
|
799
|
+
return {
|
|
800
|
+
content: [
|
|
801
|
+
{
|
|
802
|
+
type: 'text',
|
|
803
|
+
text: JSON.stringify({
|
|
804
|
+
action: 'predict',
|
|
805
|
+
prediction: 'Task will complete successfully',
|
|
806
|
+
confidence: 0.88,
|
|
807
|
+
factors: ['agent availability', 'task complexity', 'historical performance'],
|
|
808
|
+
status: 'predicted',
|
|
809
|
+
}),
|
|
810
|
+
},
|
|
811
|
+
],
|
|
812
|
+
};
|
|
813
|
+
default:
|
|
814
|
+
throw new Error(`Unknown neural action: ${action}`);
|
|
815
|
+
}
|
|
816
|
+
}
|
|
817
|
+
async handlePerformanceReport(args) {
|
|
818
|
+
const { format = 'summary', timeframe = '24h' } = args;
|
|
819
|
+
const report = {
|
|
820
|
+
timeframe,
|
|
821
|
+
metrics: {
|
|
822
|
+
totalTasks: this.tasks.size,
|
|
823
|
+
completedTasks: Array.from(this.tasks.values()).filter((t) => t.status === 'completed')
|
|
824
|
+
.length,
|
|
825
|
+
activeAgents: Array.from(this.agents.values()).filter((a) => a.status === 'busy').length,
|
|
826
|
+
totalAgents: this.agents.size,
|
|
827
|
+
activeSwarms: Array.from(this.swarms.values()).filter((s) => s.status === 'active').length,
|
|
828
|
+
averageTaskTime: '2.3 minutes',
|
|
829
|
+
successRate: '94.2%',
|
|
830
|
+
},
|
|
831
|
+
performance: {
|
|
832
|
+
cpu_usage: '23%',
|
|
833
|
+
memory_usage: '512MB',
|
|
834
|
+
token_usage: '45,231',
|
|
835
|
+
api_calls: '1,234',
|
|
836
|
+
},
|
|
837
|
+
};
|
|
838
|
+
if (format === 'detailed') {
|
|
839
|
+
report['taskBreakdown'] = Array.from(this.tasks.values()).map((t) => ({
|
|
840
|
+
id: t.id,
|
|
841
|
+
description: t.description,
|
|
842
|
+
status: t.status,
|
|
843
|
+
duration: t.status === 'completed' ? '2.1 min' : 'ongoing',
|
|
844
|
+
}));
|
|
845
|
+
}
|
|
846
|
+
return {
|
|
847
|
+
content: [
|
|
848
|
+
{
|
|
849
|
+
type: 'text',
|
|
850
|
+
text: JSON.stringify(report),
|
|
851
|
+
},
|
|
852
|
+
],
|
|
853
|
+
};
|
|
854
|
+
}
|
|
855
|
+
getDefaultCapabilities(type) {
|
|
856
|
+
const capabilities = {
|
|
857
|
+
coordinator: ['task_distribution', 'monitoring', 'coordination'],
|
|
858
|
+
researcher: ['information_gathering', 'analysis', 'summarization'],
|
|
859
|
+
coder: ['implementation', 'debugging', 'optimization'],
|
|
860
|
+
analyst: ['data_analysis', 'pattern_recognition', 'reporting'],
|
|
861
|
+
architect: ['system_design', 'planning', 'documentation'],
|
|
862
|
+
tester: ['testing', 'validation', 'quality_assurance'],
|
|
863
|
+
reviewer: ['code_review', 'best_practices', 'feedback'],
|
|
864
|
+
optimizer: ['performance_tuning', 'efficiency', 'scaling'],
|
|
865
|
+
documenter: ['documentation', 'examples', 'tutorials'],
|
|
866
|
+
monitor: ['monitoring', 'alerting', 'logging'],
|
|
867
|
+
specialist: ['domain_expertise', 'problem_solving', 'innovation'],
|
|
868
|
+
};
|
|
869
|
+
return capabilities[type] || ['general_purpose'];
|
|
870
|
+
}
|
|
871
|
+
async run() {
|
|
872
|
+
const transport = new stdio_js_1.StdioServerTransport();
|
|
873
|
+
await this.server.connect(transport);
|
|
874
|
+
console.error('Snow-Flow MCP server running on stdio');
|
|
875
|
+
}
|
|
876
|
+
}
|
|
877
|
+
// Run the server
|
|
878
|
+
const server = new SnowFlowMCPServer();
|
|
879
|
+
server.run().catch(console.error);
|
|
880
|
+
//# sourceMappingURL=snow-flow-mcp.js.map
|