@agledger/mcp-server 1.5.0 → 2.0.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 (66) hide show
  1. package/dist/api-client.d.ts +16 -0
  2. package/dist/api-client.d.ts.map +1 -0
  3. package/dist/api-client.js +52 -0
  4. package/dist/api-client.js.map +1 -0
  5. package/dist/index.d.ts.map +1 -1
  6. package/dist/index.js +17 -58
  7. package/dist/index.js.map +1 -1
  8. package/dist/server.d.ts +2 -13
  9. package/dist/server.d.ts.map +1 -1
  10. package/dist/server.js +113 -109
  11. package/dist/server.js.map +1 -1
  12. package/package.json +2 -3
  13. package/src/api-client.ts +72 -0
  14. package/src/index.ts +27 -60
  15. package/src/server.ts +136 -120
  16. package/tests/api-client.test.ts +147 -0
  17. package/tests/harness.ts +8 -35
  18. package/tests/integration.test.ts +373 -0
  19. package/tests/server.test.ts +286 -0
  20. package/src/enums.ts +0 -47
  21. package/src/errors.ts +0 -44
  22. package/src/resources/contract-types.ts +0 -130
  23. package/src/tool-scopes.ts +0 -180
  24. package/src/tools/a2a.ts +0 -430
  25. package/src/tools/agent-mandates.ts +0 -259
  26. package/src/tools/agents-refs.ts +0 -232
  27. package/src/tools/capabilities.ts +0 -63
  28. package/src/tools/compliance.ts +0 -70
  29. package/src/tools/dashboard.ts +0 -64
  30. package/src/tools/disputes.ts +0 -121
  31. package/src/tools/enterprises.ts +0 -203
  32. package/src/tools/events.ts +0 -33
  33. package/src/tools/federation-admin.ts +0 -665
  34. package/src/tools/federation.ts +0 -587
  35. package/src/tools/health.ts +0 -30
  36. package/src/tools/mandates.ts +0 -264
  37. package/src/tools/openclaw.ts +0 -122
  38. package/src/tools/receipts.ts +0 -134
  39. package/src/tools/reputation.ts +0 -69
  40. package/src/tools/schemas.ts +0 -535
  41. package/src/tools/verification-keys.ts +0 -33
  42. package/src/tools/verification.ts +0 -59
  43. package/tests/conformance.test.ts +0 -197
  44. package/tests/conformance.ts +0 -65
  45. package/tests/mock-client.ts +0 -71
  46. package/tests/profiles.test.ts +0 -120
  47. package/tests/resources/contract-types.test.ts +0 -82
  48. package/tests/tools/a2a.test.ts +0 -213
  49. package/tests/tools/agent-mandates.test.ts +0 -196
  50. package/tests/tools/agents-refs.test.ts +0 -190
  51. package/tests/tools/capabilities.test.ts +0 -80
  52. package/tests/tools/compliance.test.ts +0 -123
  53. package/tests/tools/dashboard.test.ts +0 -111
  54. package/tests/tools/disputes.test.ts +0 -123
  55. package/tests/tools/enterprises.test.ts +0 -171
  56. package/tests/tools/events.test.ts +0 -56
  57. package/tests/tools/federation-admin.test.ts +0 -468
  58. package/tests/tools/federation.test.ts +0 -522
  59. package/tests/tools/health.test.ts +0 -56
  60. package/tests/tools/mandates.test.ts +0 -143
  61. package/tests/tools/openclaw.test.ts +0 -148
  62. package/tests/tools/receipts.test.ts +0 -157
  63. package/tests/tools/reputation.test.ts +0 -108
  64. package/tests/tools/schemas.test.ts +0 -374
  65. package/tests/tools/verification-keys.test.ts +0 -56
  66. package/tests/tools/verification.test.ts +0 -64
@@ -1,468 +0,0 @@
1
- import { describe, it, expect, beforeAll, afterAll, vi } from 'vitest';
2
- import { registerFederationAdminTools } from '../../src/tools/federation-admin.js';
3
- import { createTestHarness, type TestHarness } from '../harness.js';
4
- import { assertErrorResult, assertSuccessResult } from '../conformance.js';
5
-
6
- const EXPECTED_TOOLS = [
7
- 'federation_activate_hub_key',
8
- 'federation_admin_revoke',
9
- 'federation_audit_log',
10
- 'federation_create_peering_token',
11
- 'federation_create_token',
12
- 'federation_delete_dlq',
13
- 'federation_delete_schema_version',
14
- 'federation_expire_hub_key',
15
- 'federation_get_mandate_criteria_status',
16
- 'federation_get_peer',
17
- 'federation_health',
18
- 'federation_list_dlq',
19
- 'federation_list_gateways',
20
- 'federation_list_hub_keys',
21
- 'federation_list_peers',
22
- 'federation_list_reputation_contributions',
23
- 'federation_query_mandates',
24
- 'federation_register_peer',
25
- 'federation_reset_reputation',
26
- 'federation_reset_sequence',
27
- 'federation_resync_peer',
28
- 'federation_retry_dlq',
29
- 'federation_rotate_hub_key',
30
- 'federation_revoke_peer',
31
- ];
32
-
33
- describe('federation admin tools', () => {
34
- let harness: TestHarness;
35
-
36
- beforeAll(async () => {
37
- harness = await createTestHarness({
38
- registerFns: [registerFederationAdminTools],
39
- mockOverrides: {
40
- federationAdmin: {
41
- createRegistrationToken: vi.fn().mockResolvedValue({
42
- token: 'reg-tok-1',
43
- label: 'test',
44
- expiresAt: '2026-05-01T00:00:00Z',
45
- createdAt: '2026-04-13T00:00:00Z',
46
- }),
47
- listGateways: vi.fn().mockResolvedValue({
48
- data: [{ id: 'gw-1', name: 'Gateway 1', status: 'active', createdAt: '2026-04-13T00:00:00Z' }],
49
- total: 1,
50
- gateways: [{ id: 'gw-1', name: 'Gateway 1', status: 'active', createdAt: '2026-04-13T00:00:00Z' }],
51
- }),
52
- revokeGateway: vi.fn().mockResolvedValue({
53
- gatewayId: 'gw-1',
54
- status: 'revoked',
55
- revokedAt: '2026-04-13T00:00:00Z',
56
- }),
57
- queryMandates: vi.fn().mockResolvedValue({
58
- data: [{ id: 'fm-1', gatewayId: 'gw-1', hubState: 'ACTIVE', createdAt: '2026-04-13T00:00:00Z' }],
59
- total: 1,
60
- mandates: [{ id: 'fm-1', gatewayId: 'gw-1', hubState: 'ACTIVE', contractType: 'ACH-PROC-v1', createdAt: '2026-04-13T00:00:00Z' }],
61
- }),
62
- getAuditLog: vi.fn().mockResolvedValue({
63
- data: [{ id: 'ae-1', entryType: 'transition', timestamp: '2026-04-13T00:00:00Z' }],
64
- total: 1,
65
- entries: [{ id: 'ae-1', entryType: 'transition', timestamp: '2026-04-13T00:00:00Z' }],
66
- }),
67
- getHealth: vi.fn().mockResolvedValue({
68
- status: 'healthy',
69
- timestamp: '2026-04-13T00:00:00Z',
70
- activeGateways: 3,
71
- pendingMandates: 2,
72
- dlqDepth: 0,
73
- gateways: { active: 3, suspended: 1, revoked: 0 },
74
- auditChainLength: 150,
75
- }),
76
- resetSequence: vi.fn().mockResolvedValue({
77
- gatewayId: 'gw-1',
78
- reset: true,
79
- previousSeq: 42,
80
- newSeq: 0,
81
- }),
82
- listDlq: vi.fn().mockResolvedValue({
83
- data: [{ id: 'dlq-1', error: 'timeout', createdAt: '2026-04-13T00:00:00Z' }],
84
- hasMore: false,
85
- entries: [{ id: 'dlq-1', error: 'timeout', createdAt: '2026-04-13T00:00:00Z' }],
86
- }),
87
- retryDlq: vi.fn().mockResolvedValue({
88
- dlqId: 'dlq-1',
89
- retried: true,
90
- status: 'retried',
91
- }),
92
- deleteDlq: vi.fn().mockResolvedValue({
93
- dlqId: 'dlq-1',
94
- deleted: true,
95
- }),
96
- rotateHubKey: vi.fn().mockResolvedValue({
97
- id: 'hk-new',
98
- keyId: 'hk-new',
99
- publicKey: 'pub-key-base64',
100
- status: 'pending',
101
- createdAt: '2026-04-13T00:00:00Z',
102
- }),
103
- listHubKeys: vi.fn().mockResolvedValue([
104
- { keyId: 'hk-1', status: 'active', createdAt: '2026-04-13T00:00:00Z' },
105
- { keyId: 'hk-2', status: 'expired', createdAt: '2026-04-12T00:00:00Z' },
106
- ]),
107
- activateHubKey: vi.fn().mockResolvedValue({
108
- keyId: 'hk-new',
109
- status: 'active',
110
- }),
111
- expireHubKey: vi.fn().mockResolvedValue({
112
- keyId: 'hk-old',
113
- status: 'expired',
114
- }),
115
- registerPeer: vi.fn().mockResolvedValue({
116
- hubId: 'peer-1',
117
- name: 'Peer Hub',
118
- endpoint: 'https://peer.example.com',
119
- status: 'active',
120
- }),
121
- listPeers: vi.fn().mockResolvedValue({
122
- data: [{ hubId: 'peer-1', name: 'Peer Hub', status: 'active' }],
123
- peers: [{ hubId: 'peer-1', name: 'Peer Hub', status: 'active' }],
124
- }),
125
- getPeer: vi.fn().mockResolvedValue({
126
- hubId: 'peer-1',
127
- name: 'Peer Hub',
128
- status: 'active',
129
- lastSyncAt: '2026-04-13T00:00:00Z',
130
- }),
131
- revokePeer: vi.fn().mockResolvedValue({
132
- hubId: 'peer-1',
133
- revoked: true,
134
- status: 'revoked',
135
- }),
136
- resyncPeer: vi.fn().mockResolvedValue({
137
- hubId: 'peer-1',
138
- synced: true,
139
- status: 'synced',
140
- }),
141
- createPeeringToken: vi.fn().mockResolvedValue({
142
- token: 'peer-tok-1',
143
- expiresAt: '2026-05-01T00:00:00Z',
144
- }),
145
- deleteSchemaVersion: vi.fn().mockResolvedValue({
146
- contractType: 'ACH-PROC-v1',
147
- version: '1',
148
- deleted: true,
149
- }),
150
- listReputationContributions: vi.fn().mockResolvedValue([
151
- { agentId: 'agent-1', contractType: 'ACH-PROC-v1', outcome: 'PASS' },
152
- ]),
153
- resetReputation: vi.fn().mockResolvedValue({
154
- agentId: 'agent-1',
155
- reset: true,
156
- }),
157
- getMandateCriteriaStatus: vi.fn().mockResolvedValue({
158
- mandateId: 'mnd-1',
159
- principalSubmitted: true,
160
- performerSubmitted: false,
161
- agreementReached: false,
162
- }),
163
- },
164
- },
165
- });
166
- });
167
-
168
- afterAll(async () => { await harness.cleanup(); });
169
-
170
- it('registers exactly 24 tools', async () => {
171
- const { tools } = await harness.client.listTools();
172
- expect(tools.map((t: any) => t.name).sort()).toEqual(EXPECTED_TOOLS.sort());
173
- });
174
-
175
- // --- Top 5 tools: happy path + error ---
176
-
177
- describe('federation_create_token', () => {
178
- it('creates a registration token', async () => {
179
- const result = await harness.client.callTool({
180
- name: 'federation_create_token',
181
- arguments: { label: 'test', expiresInHours: 24 },
182
- });
183
- assertSuccessResult(result as any);
184
- });
185
-
186
- it('returns error on failure', async () => {
187
- (harness.mockSdk.federationAdmin as any).createRegistrationToken.mockRejectedValueOnce(new Error('Unauthorized'));
188
- const result = await harness.client.callTool({
189
- name: 'federation_create_token',
190
- arguments: {},
191
- });
192
- assertErrorResult(result as any);
193
- });
194
- });
195
-
196
- describe('federation_list_gateways', () => {
197
- it('lists gateways', async () => {
198
- const result = await harness.client.callTool({
199
- name: 'federation_list_gateways',
200
- arguments: {},
201
- });
202
- assertSuccessResult(result as any);
203
- });
204
-
205
- it('returns error on failure', async () => {
206
- (harness.mockSdk.federationAdmin as any).listGateways.mockRejectedValueOnce(new Error('Internal'));
207
- const result = await harness.client.callTool({
208
- name: 'federation_list_gateways',
209
- arguments: {},
210
- });
211
- assertErrorResult(result as any);
212
- });
213
- });
214
-
215
- describe('federation_admin_revoke', () => {
216
- it('revokes a gateway', async () => {
217
- const result = await harness.client.callTool({
218
- name: 'federation_admin_revoke',
219
- arguments: { gatewayId: 'gw-1', reason: 'compromised' },
220
- });
221
- assertSuccessResult(result as any);
222
- });
223
-
224
- it('returns error on failure', async () => {
225
- (harness.mockSdk.federationAdmin as any).revokeGateway.mockRejectedValueOnce(new Error('Gateway not found'));
226
- const result = await harness.client.callTool({
227
- name: 'federation_admin_revoke',
228
- arguments: { gatewayId: 'bad-gw', reason: 'test' },
229
- });
230
- assertErrorResult(result as any);
231
- });
232
- });
233
-
234
- describe('federation_query_mandates', () => {
235
- it('queries federation mandates', async () => {
236
- const result = await harness.client.callTool({
237
- name: 'federation_query_mandates',
238
- arguments: { gatewayId: 'gw-1' },
239
- });
240
- assertSuccessResult(result as any);
241
- });
242
-
243
- it('returns error on failure', async () => {
244
- (harness.mockSdk.federationAdmin as any).queryMandates.mockRejectedValueOnce(new Error('Bad filter'));
245
- const result = await harness.client.callTool({
246
- name: 'federation_query_mandates',
247
- arguments: { hubState: 'ACTIVE' },
248
- });
249
- assertErrorResult(result as any);
250
- });
251
- });
252
-
253
- describe('federation_audit_log', () => {
254
- it('retrieves audit log entries', async () => {
255
- const result = await harness.client.callTool({
256
- name: 'federation_audit_log',
257
- arguments: { gatewayId: 'gw-1' },
258
- });
259
- assertSuccessResult(result as any);
260
- });
261
-
262
- it('returns error on failure', async () => {
263
- (harness.mockSdk.federationAdmin as any).getAuditLog.mockRejectedValueOnce(new Error('Timeout'));
264
- const result = await harness.client.callTool({
265
- name: 'federation_audit_log',
266
- arguments: {},
267
- });
268
- assertErrorResult(result as any);
269
- });
270
- });
271
-
272
- // --- Remaining tools: happy path only ---
273
-
274
- describe('federation_health', () => {
275
- it('gets federation health', async () => {
276
- const result = await harness.client.callTool({
277
- name: 'federation_health',
278
- arguments: {},
279
- });
280
- assertSuccessResult(result as any);
281
- });
282
- });
283
-
284
- describe('federation_reset_sequence', () => {
285
- it('resets gateway sequence', async () => {
286
- const result = await harness.client.callTool({
287
- name: 'federation_reset_sequence',
288
- arguments: { gatewayId: 'gw-1', newSeq: 0 },
289
- });
290
- assertSuccessResult(result as any);
291
- });
292
- });
293
-
294
- describe('federation_list_dlq', () => {
295
- it('lists DLQ entries', async () => {
296
- const result = await harness.client.callTool({
297
- name: 'federation_list_dlq',
298
- arguments: {},
299
- });
300
- assertSuccessResult(result as any);
301
- });
302
- });
303
-
304
- describe('federation_retry_dlq', () => {
305
- it('retries a DLQ entry', async () => {
306
- const result = await harness.client.callTool({
307
- name: 'federation_retry_dlq',
308
- arguments: { dlqId: 'dlq-1' },
309
- });
310
- assertSuccessResult(result as any);
311
- });
312
- });
313
-
314
- describe('federation_delete_dlq', () => {
315
- it('deletes a DLQ entry', async () => {
316
- const result = await harness.client.callTool({
317
- name: 'federation_delete_dlq',
318
- arguments: { dlqId: 'dlq-1' },
319
- });
320
- assertSuccessResult(result as any);
321
- });
322
- });
323
-
324
- describe('federation_rotate_hub_key', () => {
325
- it('rotates the hub signing key', async () => {
326
- const result = await harness.client.callTool({
327
- name: 'federation_rotate_hub_key',
328
- arguments: {},
329
- });
330
- assertSuccessResult(result as any);
331
- });
332
- });
333
-
334
- describe('federation_list_hub_keys', () => {
335
- it('lists hub signing keys', async () => {
336
- const result = await harness.client.callTool({
337
- name: 'federation_list_hub_keys',
338
- arguments: {},
339
- });
340
- assertSuccessResult(result as any);
341
- });
342
- });
343
-
344
- describe('federation_activate_hub_key', () => {
345
- it('activates a hub key', async () => {
346
- const result = await harness.client.callTool({
347
- name: 'federation_activate_hub_key',
348
- arguments: { keyId: 'hk-new' },
349
- });
350
- assertSuccessResult(result as any);
351
- });
352
- });
353
-
354
- describe('federation_expire_hub_key', () => {
355
- it('expires a hub key', async () => {
356
- const result = await harness.client.callTool({
357
- name: 'federation_expire_hub_key',
358
- arguments: { keyId: 'hk-old' },
359
- });
360
- assertSuccessResult(result as any);
361
- });
362
- });
363
-
364
- describe('federation_register_peer', () => {
365
- it('registers a peer hub', async () => {
366
- const result = await harness.client.callTool({
367
- name: 'federation_register_peer',
368
- arguments: {
369
- name: 'Peer Hub',
370
- endpoint: 'https://peer.example.com',
371
- publicKey: 'pub-key-base64',
372
- peeringToken: 'peer-tok-1',
373
- },
374
- });
375
- assertSuccessResult(result as any);
376
- });
377
- });
378
-
379
- describe('federation_list_peers', () => {
380
- it('lists peer hubs', async () => {
381
- const result = await harness.client.callTool({
382
- name: 'federation_list_peers',
383
- arguments: {},
384
- });
385
- assertSuccessResult(result as any);
386
- });
387
- });
388
-
389
- describe('federation_get_peer', () => {
390
- it('gets peer details', async () => {
391
- const result = await harness.client.callTool({
392
- name: 'federation_get_peer',
393
- arguments: { hubId: 'peer-1' },
394
- });
395
- assertSuccessResult(result as any);
396
- });
397
- });
398
-
399
- describe('federation_revoke_peer', () => {
400
- it('revokes a peer hub', async () => {
401
- const result = await harness.client.callTool({
402
- name: 'federation_revoke_peer',
403
- arguments: { hubId: 'peer-1' },
404
- });
405
- assertSuccessResult(result as any);
406
- });
407
- });
408
-
409
- describe('federation_resync_peer', () => {
410
- it('resyncs a peer hub', async () => {
411
- const result = await harness.client.callTool({
412
- name: 'federation_resync_peer',
413
- arguments: { hubId: 'peer-1' },
414
- });
415
- assertSuccessResult(result as any);
416
- });
417
- });
418
-
419
- describe('federation_create_peering_token', () => {
420
- it('creates a peering token', async () => {
421
- const result = await harness.client.callTool({
422
- name: 'federation_create_peering_token',
423
- arguments: {},
424
- });
425
- assertSuccessResult(result as any);
426
- });
427
- });
428
-
429
- describe('federation_delete_schema_version', () => {
430
- it('deletes a schema version', async () => {
431
- const result = await harness.client.callTool({
432
- name: 'federation_delete_schema_version',
433
- arguments: { contractType: 'ACH-PROC-v1', version: '1' },
434
- });
435
- assertSuccessResult(result as any);
436
- });
437
- });
438
-
439
- describe('federation_list_reputation_contributions', () => {
440
- it('lists reputation contributions', async () => {
441
- const result = await harness.client.callTool({
442
- name: 'federation_list_reputation_contributions',
443
- arguments: { agentId: 'agent-1' },
444
- });
445
- assertSuccessResult(result as any);
446
- });
447
- });
448
-
449
- describe('federation_reset_reputation', () => {
450
- it('resets agent reputation', async () => {
451
- const result = await harness.client.callTool({
452
- name: 'federation_reset_reputation',
453
- arguments: { agentId: 'agent-1' },
454
- });
455
- assertSuccessResult(result as any);
456
- });
457
- });
458
-
459
- describe('federation_get_mandate_criteria_status', () => {
460
- it('gets mandate criteria status', async () => {
461
- const result = await harness.client.callTool({
462
- name: 'federation_get_mandate_criteria_status',
463
- arguments: { mandateId: 'mnd-1' },
464
- });
465
- assertSuccessResult(result as any);
466
- });
467
- });
468
- });