@hivemind-os/collective-mcp-server 0.2.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.
Files changed (49) hide show
  1. package/.turbo/turbo-build.log +14 -0
  2. package/dist/index.d.ts +493 -0
  3. package/dist/index.js +2129 -0
  4. package/dist/index.js.map +1 -0
  5. package/package.json +31 -0
  6. package/src/context.ts +58 -0
  7. package/src/encryption.ts +25 -0
  8. package/src/index.ts +41 -0
  9. package/src/resources/agent.ts +77 -0
  10. package/src/resources/capabilities.ts +24 -0
  11. package/src/resources/index.ts +70 -0
  12. package/src/resources/task.ts +58 -0
  13. package/src/resources/wallet.ts +32 -0
  14. package/src/tools/analytics.ts +122 -0
  15. package/src/tools/balance.ts +36 -0
  16. package/src/tools/deactivate.ts +33 -0
  17. package/src/tools/discover.ts +256 -0
  18. package/src/tools/dispute.ts +135 -0
  19. package/src/tools/execute-async.ts +39 -0
  20. package/src/tools/execute.ts +418 -0
  21. package/src/tools/index.ts +152 -0
  22. package/src/tools/indexer-client.ts +163 -0
  23. package/src/tools/marketplace-accept-bid.ts +43 -0
  24. package/src/tools/marketplace-bid.ts +56 -0
  25. package/src/tools/marketplace-browse.ts +66 -0
  26. package/src/tools/marketplace-post.ts +96 -0
  27. package/src/tools/metering.ts +214 -0
  28. package/src/tools/multi-execute.ts +218 -0
  29. package/src/tools/policy-update.ts +94 -0
  30. package/src/tools/register.ts +78 -0
  31. package/src/tools/relay-registry.ts +95 -0
  32. package/src/tools/stake.ts +103 -0
  33. package/src/tools/task-history.ts +86 -0
  34. package/src/tools/task-status.ts +66 -0
  35. package/tests/analytics.test.ts +41 -0
  36. package/tests/auth-errors.test.ts +85 -0
  37. package/tests/balance.test.ts +32 -0
  38. package/tests/context.test.ts +112 -0
  39. package/tests/discover.test.ts +207 -0
  40. package/tests/dispute.test.ts +140 -0
  41. package/tests/execute.test.ts +150 -0
  42. package/tests/marketplace.test.ts +117 -0
  43. package/tests/metering.test.ts +173 -0
  44. package/tests/multi-execute.test.ts +123 -0
  45. package/tests/relay-registry.test.ts +71 -0
  46. package/tests/stake.test.ts +90 -0
  47. package/tsconfig.json +9 -0
  48. package/tsup.config.ts +10 -0
  49. package/vitest.config.ts +8 -0
@@ -0,0 +1,14 @@
1
+ $ tsup
2
+ CLI Building entry: src/index.ts
3
+ CLI Using tsconfig: tsconfig.json
4
+ CLI tsup v8.5.1
5
+ CLI Using tsup config: /home/runner/work/collective/collective/packages/mcp-server/tsup.config.ts
6
+ CLI Target: es2022
7
+ CLI Cleaning output folder
8
+ ESM Build start
9
+ ESM dist/index.js 74.28 KB
10
+ ESM dist/index.js.map 142.69 KB
11
+ ESM ⚡️ Build success in 125ms
12
+ DTS Build start
13
+ DTS ⚡️ Build success in 6780ms
14
+ DTS dist/index.d.ts 13.40 KB
@@ -0,0 +1,493 @@
1
+ import { Server } from '@modelcontextprotocol/sdk/server/index.js';
2
+ import { MeshSuiClient, RegistryClient, TaskClient, AgentCache, BlobStore, SpendingPolicyEngine, StakingClient, RelayRegistryClient, DisputeClient, MarketplaceClient, AuthProvider, X402Client, PaymentRailSelector, ReputationEventPublisher, ReputationStore } from '@hivemind-os/collective-core';
3
+ import * as _hivemind_os_collective_types from '@hivemind-os/collective-types';
4
+ import { DID, NetworkConfig, ProviderSelectionStrategy, AggregationMode, PaymentRail, PaymentScheme } from '@hivemind-os/collective-types';
5
+ import { Signer } from '@mysten/sui/cryptography';
6
+
7
+ interface MeshToolContext {
8
+ did: DID;
9
+ keypair: Signer;
10
+ suiClient: MeshSuiClient;
11
+ registryClient: RegistryClient;
12
+ taskClient: TaskClient;
13
+ agentCache: AgentCache;
14
+ blobStore: BlobStore;
15
+ spendingPolicy: SpendingPolicyEngine;
16
+ networkConfig: NetworkConfig;
17
+ /** The name of the MCP client app invoking the tool (for per-app spending). */
18
+ originAppName?: string;
19
+ stakingClient?: StakingClient;
20
+ relayRegistryClient?: RelayRegistryClient;
21
+ disputeClient?: DisputeClient;
22
+ marketplaceClient?: MarketplaceClient;
23
+ encryption?: {
24
+ enabled: boolean;
25
+ requireEncryption: boolean;
26
+ publicKey?: string;
27
+ };
28
+ relayAuthProvider?: AuthProvider;
29
+ authProvider?: AuthProvider;
30
+ x402Client?: X402Client;
31
+ paymentRailSelector?: PaymentRailSelector;
32
+ logger?: {
33
+ info?: (payload: unknown, message?: string) => void;
34
+ warn?: (payload: unknown, message?: string) => void;
35
+ };
36
+ indexer?: {
37
+ enabled?: boolean;
38
+ graphqlUrl?: string;
39
+ fetch?: typeof fetch;
40
+ };
41
+ reputationPublisher?: ReputationEventPublisher;
42
+ reputationStore?: ReputationStore;
43
+ taskHistoryDb?: unknown;
44
+ }
45
+
46
+ type MeshToolHandler = (params: never, context: MeshToolContext) => Promise<unknown>;
47
+ declare const meshToolHandlers: Record<string, MeshToolHandler>;
48
+ declare const meshToolDefinitions: ({
49
+ name: string;
50
+ description: string;
51
+ inputSchema: {
52
+ type: "object";
53
+ properties: {};
54
+ required: never[];
55
+ };
56
+ } | {
57
+ name: string;
58
+ description: string;
59
+ inputSchema: {
60
+ type: "object";
61
+ properties: {
62
+ view: {
63
+ type: string;
64
+ enum: string[];
65
+ };
66
+ period: {
67
+ type: string;
68
+ enum: string[];
69
+ };
70
+ buckets: {
71
+ type: string;
72
+ };
73
+ limit: {
74
+ type: string;
75
+ };
76
+ sort_by: {
77
+ type: string;
78
+ enum: string[];
79
+ };
80
+ };
81
+ };
82
+ } | {
83
+ name: string;
84
+ description: string;
85
+ inputSchema: {
86
+ type: "object";
87
+ properties: {
88
+ agent_card_id: {
89
+ type: string;
90
+ description: string;
91
+ };
92
+ };
93
+ required: string[];
94
+ };
95
+ } | {
96
+ name: string;
97
+ description: string;
98
+ inputSchema: {
99
+ type: "object";
100
+ properties: {
101
+ capability: {
102
+ type: string;
103
+ description: string;
104
+ };
105
+ limit: {
106
+ type: string;
107
+ description: string;
108
+ };
109
+ sort_by: {
110
+ type: string;
111
+ enum: string[];
112
+ description: string;
113
+ };
114
+ useIndexer: {
115
+ type: string;
116
+ description: string;
117
+ };
118
+ };
119
+ required: string[];
120
+ };
121
+ } | {
122
+ name: string;
123
+ description: string;
124
+ inputSchema: {
125
+ type: "object";
126
+ properties: {
127
+ capability: {
128
+ type: string;
129
+ description: string;
130
+ };
131
+ provider_did: {
132
+ type: string;
133
+ description: string;
134
+ };
135
+ input: {
136
+ type: string;
137
+ description: string;
138
+ };
139
+ max_price_mist: {
140
+ type: string;
141
+ description: string;
142
+ };
143
+ };
144
+ required: string[];
145
+ };
146
+ } | {
147
+ name: string;
148
+ description: string;
149
+ inputSchema: {
150
+ type: "object";
151
+ properties: {
152
+ task_id: {
153
+ type: string;
154
+ description: string;
155
+ };
156
+ };
157
+ required: string[];
158
+ };
159
+ } | {
160
+ name: string;
161
+ description: string;
162
+ inputSchema: {
163
+ type: "object";
164
+ properties: {
165
+ capability: {
166
+ type: string;
167
+ description: string;
168
+ };
169
+ category: {
170
+ type: string;
171
+ description: string;
172
+ };
173
+ price_mist: {
174
+ type: string;
175
+ description: string;
176
+ };
177
+ input: {
178
+ type: string;
179
+ description: string;
180
+ };
181
+ input_blob_id: {
182
+ type: string;
183
+ description: string;
184
+ };
185
+ agreement_hash: {
186
+ type: string;
187
+ description: string;
188
+ };
189
+ dispute_window_ms: {
190
+ type: string;
191
+ description: string;
192
+ };
193
+ expiry_hours: {
194
+ type: string;
195
+ description: string;
196
+ };
197
+ };
198
+ required: string[];
199
+ };
200
+ } | {
201
+ name: string;
202
+ description: string;
203
+ inputSchema: {
204
+ type: "object";
205
+ properties: {
206
+ capability: {
207
+ type: string;
208
+ description: string;
209
+ };
210
+ input: {
211
+ description: string;
212
+ };
213
+ fanOutCount: {
214
+ type: string;
215
+ description: string;
216
+ };
217
+ strategy: {
218
+ type: string;
219
+ enum: _hivemind_os_collective_types.ProviderSelectionStrategy[];
220
+ description: string;
221
+ };
222
+ aggregation: {
223
+ type: string;
224
+ enum: _hivemind_os_collective_types.AggregationMode[];
225
+ description: string;
226
+ };
227
+ timeout: {
228
+ type: string;
229
+ description: string;
230
+ };
231
+ maxPricePerProvider: {
232
+ type: string;
233
+ description: string;
234
+ };
235
+ };
236
+ required: string[];
237
+ };
238
+ } | {
239
+ name: string;
240
+ description: string;
241
+ inputSchema: {
242
+ type: "object";
243
+ properties: {
244
+ name: {
245
+ type: string;
246
+ description: string;
247
+ };
248
+ description: {
249
+ type: string;
250
+ description: string;
251
+ };
252
+ capabilities: {
253
+ type: "array";
254
+ items: {
255
+ type: "object";
256
+ properties: {
257
+ name: {
258
+ type: string;
259
+ };
260
+ description: {
261
+ type: string;
262
+ };
263
+ version: {
264
+ type: string;
265
+ };
266
+ price_mist: {
267
+ type: string;
268
+ };
269
+ };
270
+ required: string[];
271
+ };
272
+ };
273
+ };
274
+ required: string[];
275
+ };
276
+ } | {
277
+ name: string;
278
+ description: string;
279
+ inputSchema: {
280
+ type: "object";
281
+ properties: {
282
+ action: {
283
+ type: string;
284
+ enum: string[];
285
+ };
286
+ endpoint: {
287
+ type: string;
288
+ description: string;
289
+ };
290
+ stake_id: {
291
+ type: string;
292
+ description: string;
293
+ };
294
+ region: {
295
+ type: string;
296
+ description: string;
297
+ };
298
+ routing_fee_bps: {
299
+ type: string;
300
+ description: string;
301
+ };
302
+ capabilities: {
303
+ type: string;
304
+ items: {
305
+ type: string;
306
+ };
307
+ description: string;
308
+ };
309
+ };
310
+ required: string[];
311
+ };
312
+ } | {
313
+ name: string;
314
+ description: string;
315
+ inputSchema: {
316
+ type: "object";
317
+ properties: {
318
+ action: {
319
+ type: string;
320
+ enum: string[];
321
+ };
322
+ amount_sui: {
323
+ type: string;
324
+ description: string;
325
+ };
326
+ stake_type: {
327
+ type: string;
328
+ enum: string[];
329
+ description: string;
330
+ };
331
+ };
332
+ required: string[];
333
+ };
334
+ })[];
335
+
336
+ declare function registerResourceHandlers(server: Server, context: MeshToolContext): void;
337
+
338
+ interface MeshMultiExecuteParams {
339
+ capability: string;
340
+ input: unknown;
341
+ fanOutCount?: number;
342
+ strategy?: ProviderSelectionStrategy | `${ProviderSelectionStrategy}`;
343
+ aggregation?: AggregationMode | `${AggregationMode}`;
344
+ timeout?: number;
345
+ maxPricePerProvider?: number;
346
+ }
347
+ declare const meshMultiExecuteTool: {
348
+ name: string;
349
+ description: string;
350
+ inputSchema: {
351
+ type: "object";
352
+ properties: {
353
+ capability: {
354
+ type: string;
355
+ description: string;
356
+ };
357
+ input: {
358
+ description: string;
359
+ };
360
+ fanOutCount: {
361
+ type: string;
362
+ description: string;
363
+ };
364
+ strategy: {
365
+ type: string;
366
+ enum: ProviderSelectionStrategy[];
367
+ description: string;
368
+ };
369
+ aggregation: {
370
+ type: string;
371
+ enum: AggregationMode[];
372
+ description: string;
373
+ };
374
+ timeout: {
375
+ type: string;
376
+ description: string;
377
+ };
378
+ maxPricePerProvider: {
379
+ type: string;
380
+ description: string;
381
+ };
382
+ };
383
+ required: string[];
384
+ };
385
+ };
386
+ interface MeshMultiExecuteResult {
387
+ capability: string;
388
+ strategy: ProviderSelectionStrategy;
389
+ aggregation: AggregationMode;
390
+ providers: Array<{
391
+ did: string;
392
+ price_mist: string;
393
+ reputation: number;
394
+ estimated_latency_ms?: number;
395
+ composite_score: number;
396
+ }>;
397
+ results: Array<{
398
+ provider: string;
399
+ status: 'success' | 'failure' | 'timeout';
400
+ result?: unknown;
401
+ duration_ms: number;
402
+ error?: string;
403
+ }>;
404
+ aggregated_result?: unknown;
405
+ total_cost_mist: string;
406
+ }
407
+ declare function runMeshMultiExecute(params: MeshMultiExecuteParams, context: MeshToolContext): Promise<MeshMultiExecuteResult>;
408
+
409
+ interface MeshMeteredExecuteParams {
410
+ capability: string;
411
+ provider_did?: string;
412
+ input: string;
413
+ max_price_mist: number;
414
+ unit_price_mist: number;
415
+ timeout_seconds?: number;
416
+ }
417
+ interface MeshVerifyResultParams {
418
+ task_id: string;
419
+ }
420
+ declare const meshMeteredExecuteTool: {
421
+ name: string;
422
+ description: string;
423
+ inputSchema: {
424
+ type: "object";
425
+ properties: {
426
+ capability: {
427
+ type: string;
428
+ description: string;
429
+ };
430
+ provider_did: {
431
+ type: string;
432
+ description: string;
433
+ };
434
+ input: {
435
+ type: string;
436
+ description: string;
437
+ };
438
+ max_price_mist: {
439
+ type: string;
440
+ description: string;
441
+ };
442
+ unit_price_mist: {
443
+ type: string;
444
+ description: string;
445
+ };
446
+ timeout_seconds: {
447
+ type: string;
448
+ description: string;
449
+ };
450
+ };
451
+ required: string[];
452
+ };
453
+ };
454
+ declare const meshVerifyResultTool: {
455
+ name: string;
456
+ description: string;
457
+ inputSchema: {
458
+ type: "object";
459
+ properties: {
460
+ task_id: {
461
+ type: string;
462
+ description: string;
463
+ };
464
+ };
465
+ required: string[];
466
+ };
467
+ };
468
+ declare function runMeshMeteredExecute(params: MeshMeteredExecuteParams, context: MeshToolContext): Promise<{
469
+ task_id: string;
470
+ provider_did: string;
471
+ result: string;
472
+ status: string;
473
+ payment_rail: PaymentRail;
474
+ payment_scheme: PaymentScheme.UPTO;
475
+ max_price_mist: string;
476
+ actual_price_mist: string;
477
+ unit_price_mist: string;
478
+ metered_units: number;
479
+ verification_hash: string;
480
+ verified: boolean;
481
+ }>;
482
+ declare function runMeshVerifyResult(params: MeshVerifyResultParams, context: MeshToolContext): Promise<{
483
+ task_id: string;
484
+ verified: boolean;
485
+ verification_hash: string;
486
+ metered_units: number;
487
+ result: string;
488
+ }>;
489
+
490
+ declare function registerMeshTools(server: Server, context: MeshToolContext): void;
491
+ declare function createMeshMcpServer(context: MeshToolContext): Server;
492
+
493
+ export { type MeshMeteredExecuteParams, type MeshMultiExecuteParams, type MeshMultiExecuteResult, type MeshToolContext, type MeshToolHandler, type MeshVerifyResultParams, createMeshMcpServer, meshMeteredExecuteTool, meshMultiExecuteTool, meshToolDefinitions, meshToolHandlers, meshVerifyResultTool, registerMeshTools, registerResourceHandlers, runMeshMeteredExecute, runMeshMultiExecute, runMeshVerifyResult };