@agledger/mcp-server 1.4.1 → 1.5.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 (126) hide show
  1. package/dist/errors.d.ts +6 -0
  2. package/dist/errors.d.ts.map +1 -1
  3. package/dist/errors.js +8 -0
  4. package/dist/errors.js.map +1 -1
  5. package/dist/index.d.ts.map +1 -1
  6. package/dist/index.js +0 -2
  7. package/dist/index.js.map +1 -1
  8. package/dist/server.d.ts +6 -2
  9. package/dist/server.d.ts.map +1 -1
  10. package/dist/server.js +71 -76
  11. package/dist/server.js.map +1 -1
  12. package/dist/tool-scopes.js +3 -2
  13. package/dist/tool-scopes.js.map +1 -1
  14. package/dist/tools/a2a.d.ts.map +1 -1
  15. package/dist/tools/a2a.js +22 -222
  16. package/dist/tools/a2a.js.map +1 -1
  17. package/dist/tools/agent-mandates.d.ts.map +1 -1
  18. package/dist/tools/agent-mandates.js +11 -75
  19. package/dist/tools/agent-mandates.js.map +1 -1
  20. package/dist/tools/agents-refs.d.ts.map +1 -1
  21. package/dist/tools/agents-refs.js +10 -61
  22. package/dist/tools/agents-refs.js.map +1 -1
  23. package/dist/tools/capabilities.d.ts.map +1 -1
  24. package/dist/tools/capabilities.js +3 -15
  25. package/dist/tools/capabilities.js.map +1 -1
  26. package/dist/tools/code-mode.d.ts.map +1 -1
  27. package/dist/tools/code-mode.js +4 -35
  28. package/dist/tools/code-mode.js.map +1 -1
  29. package/dist/tools/compliance.d.ts.map +1 -1
  30. package/dist/tools/compliance.js +4 -13
  31. package/dist/tools/compliance.js.map +1 -1
  32. package/dist/tools/dashboard.d.ts.map +1 -1
  33. package/dist/tools/dashboard.js +4 -13
  34. package/dist/tools/dashboard.js.map +1 -1
  35. package/dist/tools/disputes.d.ts.map +1 -1
  36. package/dist/tools/disputes.js +5 -37
  37. package/dist/tools/disputes.js.map +1 -1
  38. package/dist/tools/enterprises.d.ts.map +1 -1
  39. package/dist/tools/enterprises.js +7 -39
  40. package/dist/tools/enterprises.js.map +1 -1
  41. package/dist/tools/events.d.ts.map +1 -1
  42. package/dist/tools/events.js +2 -20
  43. package/dist/tools/events.js.map +1 -1
  44. package/dist/tools/federation-admin.d.ts.map +1 -1
  45. package/dist/tools/federation-admin.js +25 -257
  46. package/dist/tools/federation-admin.js.map +1 -1
  47. package/dist/tools/federation.d.ts.map +1 -1
  48. package/dist/tools/federation.js +21 -198
  49. package/dist/tools/federation.js.map +1 -1
  50. package/dist/tools/health.d.ts.map +1 -1
  51. package/dist/tools/health.js +2 -14
  52. package/dist/tools/health.js.map +1 -1
  53. package/dist/tools/mandates.d.ts.map +1 -1
  54. package/dist/tools/mandates.js +11 -83
  55. package/dist/tools/mandates.js.map +1 -1
  56. package/dist/tools/openclaw.d.ts.map +1 -1
  57. package/dist/tools/openclaw.js +6 -33
  58. package/dist/tools/openclaw.js.map +1 -1
  59. package/dist/tools/receipts.d.ts.map +1 -1
  60. package/dist/tools/receipts.js +5 -96
  61. package/dist/tools/receipts.js.map +1 -1
  62. package/dist/tools/reputation.d.ts.map +1 -1
  63. package/dist/tools/reputation.js +4 -13
  64. package/dist/tools/reputation.js.map +1 -1
  65. package/dist/tools/schemas.d.ts.map +1 -1
  66. package/dist/tools/schemas.js +34 -159
  67. package/dist/tools/schemas.js.map +1 -1
  68. package/dist/tools/verification-keys.d.ts.map +1 -1
  69. package/dist/tools/verification-keys.js +2 -23
  70. package/dist/tools/verification-keys.js.map +1 -1
  71. package/dist/tools/verification.d.ts.map +1 -1
  72. package/dist/tools/verification.js +3 -28
  73. package/dist/tools/verification.js.map +1 -1
  74. package/package.json +1 -1
  75. package/src/errors.ts +9 -0
  76. package/src/index.ts +1 -3
  77. package/src/server.ts +77 -71
  78. package/src/tool-scopes.ts +3 -3
  79. package/src/tools/a2a.ts +22 -235
  80. package/src/tools/agent-mandates.ts +11 -77
  81. package/src/tools/agents-refs.ts +10 -65
  82. package/src/tools/capabilities.ts +3 -16
  83. package/src/tools/compliance.ts +4 -13
  84. package/src/tools/dashboard.ts +4 -13
  85. package/src/tools/disputes.ts +5 -38
  86. package/src/tools/enterprises.ts +7 -39
  87. package/src/tools/events.ts +2 -21
  88. package/src/tools/federation-admin.ts +25 -282
  89. package/src/tools/federation.ts +21 -218
  90. package/src/tools/health.ts +2 -15
  91. package/src/tools/mandates.ts +11 -85
  92. package/src/tools/openclaw.ts +6 -52
  93. package/src/tools/receipts.ts +5 -97
  94. package/src/tools/reputation.ts +4 -13
  95. package/src/tools/schemas.ts +34 -166
  96. package/src/tools/verification-keys.ts +2 -25
  97. package/src/tools/verification.ts +3 -30
  98. package/tests/conformance.test.ts +197 -0
  99. package/tests/conformance.ts +65 -0
  100. package/tests/harness.ts +55 -0
  101. package/tests/mock-client.ts +71 -0
  102. package/tests/profiles.test.ts +120 -0
  103. package/tests/resources/contract-types.test.ts +82 -0
  104. package/tests/tools/a2a.test.ts +213 -0
  105. package/tests/tools/agent-mandates.test.ts +196 -0
  106. package/tests/tools/agents-refs.test.ts +190 -0
  107. package/tests/tools/capabilities.test.ts +80 -0
  108. package/tests/tools/compliance.test.ts +123 -0
  109. package/tests/tools/dashboard.test.ts +111 -0
  110. package/tests/tools/disputes.test.ts +123 -0
  111. package/tests/tools/enterprises.test.ts +171 -0
  112. package/tests/tools/events.test.ts +56 -0
  113. package/tests/tools/federation-admin.test.ts +468 -0
  114. package/tests/tools/federation.test.ts +522 -0
  115. package/tests/tools/health.test.ts +56 -0
  116. package/tests/tools/mandates.test.ts +143 -0
  117. package/tests/tools/openclaw.test.ts +148 -0
  118. package/tests/tools/receipts.test.ts +157 -0
  119. package/tests/tools/reputation.test.ts +108 -0
  120. package/tests/tools/schemas.test.ts +374 -0
  121. package/tests/tools/verification-keys.test.ts +56 -0
  122. package/tests/tools/verification.test.ts +64 -0
  123. package/src/tools/code-mode.ts +0 -461
  124. package/tests/code-mode-manifest.test.ts +0 -144
  125. package/tests/enterprises.test.ts +0 -96
  126. package/tests/schemas.test.ts +0 -531
@@ -0,0 +1,374 @@
1
+ import { describe, it, expect, beforeAll, afterAll, vi } from 'vitest';
2
+ import { registerSchemaTools } from '../../src/tools/schemas.js';
3
+ import { createTestHarness, type TestHarness } from '../harness.js';
4
+ import { assertErrorResult, assertSuccessResult } from '../conformance.js';
5
+
6
+ const MOCK_SCHEMA = {
7
+ contractType: 'ACH-PROC-v1',
8
+ mandateSchema: { type: 'object', properties: { item: { type: 'string' } } },
9
+ receiptSchema: { type: 'object', properties: { delivered: { type: 'boolean' } } },
10
+ rulesConfig: { syncRuleIds: ['quantity-match'], asyncRuleIds: [] },
11
+ fieldMappings: [],
12
+ quickStart: {
13
+ criteria: { item: 'widget', quantity: 10 },
14
+ evidence: { delivered: true, quantity: 10 },
15
+ },
16
+ };
17
+
18
+ const MOCK_META_SCHEMA = {
19
+ constraints: { maxDepth: 5, maxNodes: 200, maxSizeBytes: 65536, maxCombinerEntries: 10, rootTypeMustBe: 'object', rootMustHaveRequired: true, blockedKeywords: ['$ref'] },
20
+ allowedFormats: ['date-time', 'uri', 'email'],
21
+ allowedRefs: [],
22
+ limits: { contractTypeMaxLength: 64, maxFieldMappings: 20, ruleIdPattern: '^[a-z-]+$', ruleIdMaxLength: 64, reservedPrefixes: ['ACH-'] },
23
+ fieldMappingValueTypes: ['number', 'denomination', 'string', 'boolean', 'datetime', 'expression'],
24
+ builtinRuleIds: ['quantity-match', 'amount-match'],
25
+ sharedSchemas: {},
26
+ examples: { minimalMandate: {}, minimalReceipt: {} },
27
+ };
28
+
29
+ const MOCK_VERSION = {
30
+ id: 'sv-1',
31
+ contractType: 'ACH-CUSTOM-v1',
32
+ version: 1,
33
+ enterpriseId: null,
34
+ displayName: 'Custom Type',
35
+ description: 'A custom type',
36
+ category: 'custom',
37
+ compatibilityMode: 'FULL',
38
+ status: 'ACTIVE',
39
+ isBuiltin: false,
40
+ createdAt: '2026-04-13T00:00:00Z',
41
+ updatedAt: '2026-04-13T00:00:00Z',
42
+ };
43
+
44
+ const MOCK_DIFF = {
45
+ contractType: 'ACH-CUSTOM-v1',
46
+ from: { version: 1, createdAt: '2026-04-01T00:00:00Z', status: 'DEPRECATED' },
47
+ to: { version: 2, createdAt: '2026-04-13T00:00:00Z', status: 'ACTIVE' },
48
+ mandate: { changes: [{ type: 'added', path: '/properties/newField' }] },
49
+ receipt: { changes: [] },
50
+ };
51
+
52
+ describe('schema tools', () => {
53
+ let harness: TestHarness;
54
+
55
+ const EXPECTED_TOOLS = [
56
+ 'check_schema_compatibility', 'delete_schema', 'diff_schema_versions',
57
+ 'export_schema', 'get_blank_schema_template', 'get_contract_schema',
58
+ 'get_meta_schema', 'get_schema_rules', 'get_schema_template',
59
+ 'get_schema_version', 'get_schema_versions', 'import_schema',
60
+ 'list_contract_schemas', 'preview_schema', 'register_schema',
61
+ 'validate_receipt_schema',
62
+ ];
63
+
64
+ beforeAll(async () => {
65
+ harness = await createTestHarness({
66
+ registerFns: [registerSchemaTools],
67
+ mockOverrides: {
68
+ schemas: {
69
+ list: vi.fn().mockResolvedValue({ data: ['ACH-PROC-v1', 'ACH-DLVR-v1'] }),
70
+ get: vi.fn().mockResolvedValue(MOCK_SCHEMA),
71
+ getMetaSchema: vi.fn().mockResolvedValue(MOCK_META_SCHEMA),
72
+ preview: vi.fn().mockResolvedValue({ valid: true, compiled: {} }),
73
+ register: vi.fn().mockResolvedValue(MOCK_VERSION),
74
+ getVersions: vi.fn().mockResolvedValue({ data: [MOCK_VERSION], hasMore: false }),
75
+ diff: vi.fn().mockResolvedValue(MOCK_DIFF),
76
+ getTemplate: vi.fn().mockResolvedValue({ contractType: 'ACH-PROC-v1', mandateSchema: {}, receiptSchema: {} }),
77
+ getBlankTemplate: vi.fn().mockResolvedValue({ contractType: '', mandateSchema: {}, receiptSchema: {} }),
78
+ checkCompatibility: vi.fn().mockResolvedValue({ compatible: true, issues: [] }),
79
+ getVersion: vi.fn().mockResolvedValue(MOCK_VERSION),
80
+ getRules: vi.fn().mockResolvedValue({ syncRuleIds: ['quantity-match'], asyncRuleIds: ['async-check'] }),
81
+ validateReceipt: vi.fn().mockResolvedValue({ valid: true }),
82
+ delete: vi.fn().mockResolvedValue({ deleted: true }),
83
+ exportSchema: vi.fn().mockResolvedValue({ bundle: { contractType: 'ACH-CUSTOM-v1' } }),
84
+ importSchema: vi.fn().mockResolvedValue({ imported: true }),
85
+ },
86
+ },
87
+ });
88
+ });
89
+
90
+ afterAll(async () => { await harness.cleanup(); });
91
+
92
+ it('registers exactly 16 tools', async () => {
93
+ const { tools } = await harness.client.listTools();
94
+ expect(tools.map((t: any) => t.name).sort()).toEqual(EXPECTED_TOOLS);
95
+ });
96
+
97
+ describe('list_contract_schemas', () => {
98
+ it('returns list of contract types', async () => {
99
+ const result = await harness.client.callTool({ name: 'list_contract_schemas', arguments: {} });
100
+ assertSuccessResult(result as any);
101
+ });
102
+
103
+ it('returns error on failure', async () => {
104
+ (harness.mockSdk.schemas as any).list.mockRejectedValueOnce(new Error('Unavailable'));
105
+ const result = await harness.client.callTool({ name: 'list_contract_schemas', arguments: {} });
106
+ assertErrorResult(result as any);
107
+ });
108
+ });
109
+
110
+ describe('get_contract_schema', () => {
111
+ it('returns schema details', async () => {
112
+ const result = await harness.client.callTool({ name: 'get_contract_schema', arguments: { contractType: 'ACH-PROC-v1' } });
113
+ assertSuccessResult(result as any);
114
+ });
115
+
116
+ it('returns error on failure', async () => {
117
+ (harness.mockSdk.schemas as any).get.mockRejectedValueOnce(new Error('Not found'));
118
+ const result = await harness.client.callTool({ name: 'get_contract_schema', arguments: { contractType: 'ACH-PROC-v1' } });
119
+ assertErrorResult(result as any);
120
+ });
121
+ });
122
+
123
+ describe('get_meta_schema', () => {
124
+ it('returns meta-schema constraints', async () => {
125
+ const result = await harness.client.callTool({ name: 'get_meta_schema', arguments: {} });
126
+ assertSuccessResult(result as any);
127
+ });
128
+
129
+ it('returns error on failure', async () => {
130
+ (harness.mockSdk.schemas as any).getMetaSchema.mockRejectedValueOnce(new Error('Fail'));
131
+ const result = await harness.client.callTool({ name: 'get_meta_schema', arguments: {} });
132
+ assertErrorResult(result as any);
133
+ });
134
+ });
135
+
136
+ describe('preview_schema', () => {
137
+ it('returns valid preview', async () => {
138
+ const result = await harness.client.callTool({
139
+ name: 'preview_schema',
140
+ arguments: {
141
+ contractType: 'ACH-CUSTOM-v1',
142
+ displayName: 'Custom',
143
+ mandateSchema: { type: 'object' },
144
+ receiptSchema: { type: 'object' },
145
+ },
146
+ });
147
+ assertSuccessResult(result as any);
148
+ });
149
+
150
+ it('returns error on failure', async () => {
151
+ (harness.mockSdk.schemas as any).preview.mockRejectedValueOnce(new Error('Bad schema'));
152
+ const result = await harness.client.callTool({
153
+ name: 'preview_schema',
154
+ arguments: {
155
+ contractType: 'ACH-PROC-v1',
156
+ displayName: 'Bad',
157
+ mandateSchema: {},
158
+ receiptSchema: {},
159
+ },
160
+ });
161
+ assertErrorResult(result as any);
162
+ });
163
+ });
164
+
165
+ describe('register_schema', () => {
166
+ it('registers and returns version', async () => {
167
+ const result = await harness.client.callTool({
168
+ name: 'register_schema',
169
+ arguments: {
170
+ contractType: 'ACH-CUSTOM-v1',
171
+ displayName: 'Custom',
172
+ mandateSchema: { type: 'object' },
173
+ receiptSchema: { type: 'object' },
174
+ },
175
+ });
176
+ assertSuccessResult(result as any);
177
+ });
178
+
179
+ it('returns error on failure', async () => {
180
+ (harness.mockSdk.schemas as any).register.mockRejectedValueOnce(new Error('Conflict'));
181
+ const result = await harness.client.callTool({
182
+ name: 'register_schema',
183
+ arguments: {
184
+ contractType: 'ACH-CUSTOM-v1',
185
+ displayName: 'Custom',
186
+ mandateSchema: {},
187
+ receiptSchema: {},
188
+ },
189
+ });
190
+ assertErrorResult(result as any);
191
+ });
192
+ });
193
+
194
+ describe('get_schema_versions', () => {
195
+ it('returns version list', async () => {
196
+ const result = await harness.client.callTool({ name: 'get_schema_versions', arguments: { contractType: 'ACH-CUSTOM-v1' } });
197
+ assertSuccessResult(result as any);
198
+ });
199
+
200
+ it('returns error on failure', async () => {
201
+ (harness.mockSdk.schemas as any).getVersions.mockRejectedValueOnce(new Error('Fail'));
202
+ const result = await harness.client.callTool({ name: 'get_schema_versions', arguments: { contractType: 'ACH-PROC-v1' } });
203
+ assertErrorResult(result as any);
204
+ });
205
+ });
206
+
207
+ describe('diff_schema_versions', () => {
208
+ it('returns diff between versions', async () => {
209
+ const result = await harness.client.callTool({
210
+ name: 'diff_schema_versions',
211
+ arguments: { contractType: 'ACH-CUSTOM-v1', from: 1, to: 2 },
212
+ });
213
+ assertSuccessResult(result as any);
214
+ });
215
+
216
+ it('returns error on failure', async () => {
217
+ (harness.mockSdk.schemas as any).diff.mockRejectedValueOnce(new Error('Not found'));
218
+ const result = await harness.client.callTool({
219
+ name: 'diff_schema_versions',
220
+ arguments: { contractType: 'ACH-PROC-v1', from: 1, to: 2 },
221
+ });
222
+ assertErrorResult(result as any);
223
+ });
224
+ });
225
+
226
+ describe('get_schema_template', () => {
227
+ it('returns template from existing type', async () => {
228
+ const result = await harness.client.callTool({ name: 'get_schema_template', arguments: { contractType: 'ACH-PROC-v1' } });
229
+ assertSuccessResult(result as any);
230
+ });
231
+
232
+ it('returns error on failure', async () => {
233
+ (harness.mockSdk.schemas as any).getTemplate.mockRejectedValueOnce(new Error('Not found'));
234
+ const result = await harness.client.callTool({ name: 'get_schema_template', arguments: { contractType: 'ACH-PROC-v1' } });
235
+ assertErrorResult(result as any);
236
+ });
237
+ });
238
+
239
+ describe('get_blank_schema_template', () => {
240
+ it('returns blank template', async () => {
241
+ const result = await harness.client.callTool({ name: 'get_blank_schema_template', arguments: {} });
242
+ assertSuccessResult(result as any);
243
+ });
244
+
245
+ it('returns error on failure', async () => {
246
+ (harness.mockSdk.schemas as any).getBlankTemplate.mockRejectedValueOnce(new Error('Fail'));
247
+ const result = await harness.client.callTool({ name: 'get_blank_schema_template', arguments: {} });
248
+ assertErrorResult(result as any);
249
+ });
250
+ });
251
+
252
+ describe('check_schema_compatibility', () => {
253
+ it('returns compatibility result', async () => {
254
+ const result = await harness.client.callTool({
255
+ name: 'check_schema_compatibility',
256
+ arguments: {
257
+ contractType: 'ACH-CUSTOM-v1',
258
+ mandateSchema: { type: 'object' },
259
+ receiptSchema: { type: 'object' },
260
+ },
261
+ });
262
+ assertSuccessResult(result as any);
263
+ });
264
+
265
+ it('returns error on failure', async () => {
266
+ (harness.mockSdk.schemas as any).checkCompatibility.mockRejectedValueOnce(new Error('Fail'));
267
+ const result = await harness.client.callTool({
268
+ name: 'check_schema_compatibility',
269
+ arguments: {
270
+ contractType: 'ACH-PROC-v1',
271
+ mandateSchema: {},
272
+ receiptSchema: {},
273
+ },
274
+ });
275
+ assertErrorResult(result as any);
276
+ });
277
+ });
278
+
279
+ describe('get_schema_version', () => {
280
+ it('returns specific version', async () => {
281
+ const result = await harness.client.callTool({
282
+ name: 'get_schema_version',
283
+ arguments: { contractType: 'ACH-CUSTOM-v1', version: 1 },
284
+ });
285
+ assertSuccessResult(result as any);
286
+ });
287
+
288
+ it('returns error on failure', async () => {
289
+ (harness.mockSdk.schemas as any).getVersion.mockRejectedValueOnce(new Error('Not found'));
290
+ const result = await harness.client.callTool({
291
+ name: 'get_schema_version',
292
+ arguments: { contractType: 'ACH-PROC-v1', version: 99 },
293
+ });
294
+ assertErrorResult(result as any);
295
+ });
296
+ });
297
+
298
+ describe('validate_receipt_schema', () => {
299
+ it('returns valid result', async () => {
300
+ const result = await harness.client.callTool({
301
+ name: 'validate_receipt_schema',
302
+ arguments: { contractType: 'ACH-PROC-v1', evidence: { delivered: true } },
303
+ });
304
+ assertSuccessResult(result as any);
305
+ });
306
+
307
+ it('returns error on failure', async () => {
308
+ (harness.mockSdk.schemas as any).validateReceipt.mockRejectedValueOnce(new Error('Fail'));
309
+ const result = await harness.client.callTool({
310
+ name: 'validate_receipt_schema',
311
+ arguments: { contractType: 'ACH-PROC-v1', evidence: {} },
312
+ });
313
+ assertErrorResult(result as any);
314
+ });
315
+ });
316
+
317
+ describe('get_schema_rules', () => {
318
+ it('returns rules for contract type', async () => {
319
+ const result = await harness.client.callTool({ name: 'get_schema_rules', arguments: { contractType: 'ACH-PROC-v1' } });
320
+ assertSuccessResult(result as any);
321
+ });
322
+
323
+ it('returns error on failure', async () => {
324
+ (harness.mockSdk.schemas as any).getRules.mockRejectedValueOnce(new Error('Fail'));
325
+ const result = await harness.client.callTool({ name: 'get_schema_rules', arguments: { contractType: 'ACH-PROC-v1' } });
326
+ assertErrorResult(result as any);
327
+ });
328
+ });
329
+
330
+ describe('delete_schema', () => {
331
+ it('deletes a custom schema', async () => {
332
+ const result = await harness.client.callTool({ name: 'delete_schema', arguments: { contractType: 'ACH-CUSTOM-v1' } });
333
+ assertSuccessResult(result as any);
334
+ });
335
+
336
+ it('returns error on failure', async () => {
337
+ (harness.mockSdk.schemas as any).delete.mockRejectedValueOnce(new Error('Cannot delete builtin'));
338
+ const result = await harness.client.callTool({ name: 'delete_schema', arguments: { contractType: 'ACH-PROC-v1' } });
339
+ assertErrorResult(result as any);
340
+ });
341
+ });
342
+
343
+ describe('export_schema', () => {
344
+ it('exports schema bundle', async () => {
345
+ const result = await harness.client.callTool({ name: 'export_schema', arguments: { contractType: 'ACH-CUSTOM-v1' } });
346
+ assertSuccessResult(result as any);
347
+ });
348
+
349
+ it('returns error on failure', async () => {
350
+ (harness.mockSdk.schemas as any).exportSchema.mockRejectedValueOnce(new Error('Not found'));
351
+ const result = await harness.client.callTool({ name: 'export_schema', arguments: { contractType: 'ACH-PROC-v1' } });
352
+ assertErrorResult(result as any);
353
+ });
354
+ });
355
+
356
+ describe('import_schema', () => {
357
+ it('imports schema bundle', async () => {
358
+ const result = await harness.client.callTool({
359
+ name: 'import_schema',
360
+ arguments: { bundle: { contractType: 'ACH-CUSTOM-v1' } },
361
+ });
362
+ assertSuccessResult(result as any);
363
+ });
364
+
365
+ it('returns error on failure', async () => {
366
+ (harness.mockSdk.schemas as any).importSchema.mockRejectedValueOnce(new Error('Invalid bundle'));
367
+ const result = await harness.client.callTool({
368
+ name: 'import_schema',
369
+ arguments: { bundle: {} },
370
+ });
371
+ assertErrorResult(result as any);
372
+ });
373
+ });
374
+ });
@@ -0,0 +1,56 @@
1
+ import { describe, it, expect, beforeAll, afterAll, vi } from 'vitest';
2
+ import { registerVerificationKeysTools } from '../../src/tools/verification-keys.js';
3
+ import { createTestHarness, type TestHarness } from '../harness.js';
4
+ import { assertErrorResult, assertSuccessResult } from '../conformance.js';
5
+
6
+ describe('verification-keys tools', () => {
7
+ let harness: TestHarness;
8
+
9
+ beforeAll(async () => {
10
+ harness = await createTestHarness({
11
+ registerFns: [registerVerificationKeysTools],
12
+ mockOverrides: {
13
+ verificationKeys: {
14
+ list: vi.fn().mockResolvedValue({
15
+ data: [
16
+ { keyId: 'key-1', algorithm: 'Ed25519', publicKey: 'base64key1', status: 'active', activatedAt: '2026-01-01', retiredAt: null },
17
+ { keyId: 'key-2', algorithm: 'Ed25519', publicKey: 'base64key2', status: 'retired', activatedAt: '2025-01-01', retiredAt: '2026-01-01' },
18
+ ],
19
+ canonicalization: 'RFC8785',
20
+ hashAlgorithm: 'SHA-256',
21
+ signatureAlgorithm: 'Ed25519',
22
+ }),
23
+ },
24
+ },
25
+ });
26
+ });
27
+
28
+ afterAll(async () => {
29
+ await harness.cleanup();
30
+ });
31
+
32
+ it('registers exactly 1 tool: list_verification_keys', async () => {
33
+ const { tools } = await harness.client.listTools();
34
+ expect(tools.map((t: any) => t.name)).toEqual(['list_verification_keys']);
35
+ });
36
+
37
+ describe('list_verification_keys', () => {
38
+ it('returns verification keys on success', async () => {
39
+ const result = await harness.client.callTool({
40
+ name: 'list_verification_keys',
41
+ arguments: {},
42
+ });
43
+ assertSuccessResult(result as any);
44
+ expect((harness.mockSdk.verificationKeys as any).list).toHaveBeenCalledOnce();
45
+ });
46
+
47
+ it('returns error on failure', async () => {
48
+ (harness.mockSdk.verificationKeys as any).list.mockRejectedValueOnce(new Error('Connection refused'));
49
+ const result = await harness.client.callTool({
50
+ name: 'list_verification_keys',
51
+ arguments: {},
52
+ });
53
+ assertErrorResult(result as any);
54
+ });
55
+ });
56
+ });
@@ -0,0 +1,64 @@
1
+ import { describe, it, expect, beforeAll, afterAll, vi } from 'vitest';
2
+ import { registerVerificationTools } from '../../src/tools/verification.js';
3
+ import { createTestHarness, type TestHarness } from '../harness.js';
4
+ import { assertErrorResult, assertSuccessResult } from '../conformance.js';
5
+
6
+ describe('verification tools', () => {
7
+ let harness: TestHarness;
8
+
9
+ beforeAll(async () => {
10
+ harness = await createTestHarness({
11
+ registerFns: [registerVerificationTools],
12
+ mockOverrides: {
13
+ verification: {
14
+ verify: vi.fn().mockResolvedValue({
15
+ mandateId: 'm-1',
16
+ receipts: [{ receiptId: 'r-1', phase1Result: { passed: true } }],
17
+ overallStatus: 'PASS',
18
+ }),
19
+ getStatus: vi.fn().mockResolvedValue({
20
+ mandateId: 'm-1',
21
+ phase1Status: 'COMPLETE',
22
+ phase2Status: 'PENDING',
23
+ lastVerifiedAt: '2026-04-13T00:00:00Z',
24
+ pendingRules: ['async-rule-1'],
25
+ }),
26
+ },
27
+ },
28
+ });
29
+ });
30
+
31
+ afterAll(async () => { await harness.cleanup(); });
32
+
33
+ it('registers exactly 2 tools', async () => {
34
+ const { tools } = await harness.client.listTools();
35
+ expect(tools.map((t: any) => t.name).sort()).toEqual(['get_verification_status', 'verify_mandate']);
36
+ });
37
+
38
+ describe('verify_mandate', () => {
39
+ it('returns verification result on success', async () => {
40
+ const result = await harness.client.callTool({ name: 'verify_mandate', arguments: { mandateId: 'm-1' } });
41
+ assertSuccessResult(result as any);
42
+ expect((harness.mockSdk.verification as any).verify).toHaveBeenCalledWith('m-1');
43
+ });
44
+
45
+ it('returns error on failure', async () => {
46
+ (harness.mockSdk.verification as any).verify.mockRejectedValueOnce(new Error('Mandate not found'));
47
+ const result = await harness.client.callTool({ name: 'verify_mandate', arguments: { mandateId: 'bad-id' } });
48
+ assertErrorResult(result as any);
49
+ });
50
+ });
51
+
52
+ describe('get_verification_status', () => {
53
+ it('returns status on success', async () => {
54
+ const result = await harness.client.callTool({ name: 'get_verification_status', arguments: { mandateId: 'm-1' } });
55
+ assertSuccessResult(result as any);
56
+ });
57
+
58
+ it('returns error on failure', async () => {
59
+ (harness.mockSdk.verification as any).getStatus.mockRejectedValueOnce(new Error('Not found'));
60
+ const result = await harness.client.callTool({ name: 'get_verification_status', arguments: { mandateId: 'bad' } });
61
+ assertErrorResult(result as any);
62
+ });
63
+ });
64
+ });