@agledger/mcp-server 1.4.3 → 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 (119) hide show
  1. package/dist/index.d.ts.map +1 -1
  2. package/dist/index.js +0 -2
  3. package/dist/index.js.map +1 -1
  4. package/dist/server.d.ts +2 -2
  5. package/dist/server.d.ts.map +1 -1
  6. package/dist/server.js +1 -3
  7. package/dist/server.js.map +1 -1
  8. package/dist/tool-scopes.d.ts.map +1 -1
  9. package/dist/tool-scopes.js +0 -3
  10. package/dist/tool-scopes.js.map +1 -1
  11. package/dist/tools/a2a.d.ts.map +1 -1
  12. package/dist/tools/a2a.js +20 -220
  13. package/dist/tools/a2a.js.map +1 -1
  14. package/dist/tools/agent-mandates.d.ts.map +1 -1
  15. package/dist/tools/agent-mandates.js +10 -74
  16. package/dist/tools/agent-mandates.js.map +1 -1
  17. package/dist/tools/agents-refs.d.ts.map +1 -1
  18. package/dist/tools/agents-refs.js +9 -61
  19. package/dist/tools/agents-refs.js.map +1 -1
  20. package/dist/tools/capabilities.d.ts.map +1 -1
  21. package/dist/tools/capabilities.js +2 -14
  22. package/dist/tools/capabilities.js.map +1 -1
  23. package/dist/tools/code-mode.d.ts.map +1 -1
  24. package/dist/tools/code-mode.js +4 -35
  25. package/dist/tools/code-mode.js.map +1 -1
  26. package/dist/tools/compliance.d.ts.map +1 -1
  27. package/dist/tools/compliance.js +3 -37
  28. package/dist/tools/compliance.js.map +1 -1
  29. package/dist/tools/dashboard.d.ts.map +1 -1
  30. package/dist/tools/dashboard.js +3 -37
  31. package/dist/tools/dashboard.js.map +1 -1
  32. package/dist/tools/disputes.d.ts.map +1 -1
  33. package/dist/tools/disputes.js +4 -41
  34. package/dist/tools/disputes.js.map +1 -1
  35. package/dist/tools/enterprises.d.ts.map +1 -1
  36. package/dist/tools/enterprises.js +6 -62
  37. package/dist/tools/enterprises.js.map +1 -1
  38. package/dist/tools/events.d.ts.map +1 -1
  39. package/dist/tools/events.js +1 -19
  40. package/dist/tools/events.js.map +1 -1
  41. package/dist/tools/federation-admin.d.ts.map +1 -1
  42. package/dist/tools/federation-admin.js +24 -256
  43. package/dist/tools/federation-admin.js.map +1 -1
  44. package/dist/tools/federation.d.ts.map +1 -1
  45. package/dist/tools/federation.js +20 -197
  46. package/dist/tools/federation.js.map +1 -1
  47. package/dist/tools/health.d.ts.map +1 -1
  48. package/dist/tools/health.js +1 -13
  49. package/dist/tools/health.js.map +1 -1
  50. package/dist/tools/mandates.d.ts.map +1 -1
  51. package/dist/tools/mandates.js +10 -93
  52. package/dist/tools/mandates.js.map +1 -1
  53. package/dist/tools/openclaw.d.ts.map +1 -1
  54. package/dist/tools/openclaw.js +5 -32
  55. package/dist/tools/openclaw.js.map +1 -1
  56. package/dist/tools/receipts.d.ts.map +1 -1
  57. package/dist/tools/receipts.js +4 -94
  58. package/dist/tools/receipts.js.map +1 -1
  59. package/dist/tools/reputation.d.ts.map +1 -1
  60. package/dist/tools/reputation.js +3 -33
  61. package/dist/tools/reputation.js.map +1 -1
  62. package/dist/tools/schemas.d.ts.map +1 -1
  63. package/dist/tools/schemas.js +16 -186
  64. package/dist/tools/schemas.js.map +1 -1
  65. package/dist/tools/verification-keys.d.ts.map +1 -1
  66. package/dist/tools/verification-keys.js +1 -22
  67. package/dist/tools/verification-keys.js.map +1 -1
  68. package/dist/tools/verification.d.ts.map +1 -1
  69. package/dist/tools/verification.js +2 -27
  70. package/dist/tools/verification.js.map +1 -1
  71. package/package.json +1 -1
  72. package/src/index.ts +1 -3
  73. package/src/server.ts +3 -5
  74. package/src/tool-scopes.ts +0 -4
  75. package/src/tools/a2a.ts +20 -233
  76. package/src/tools/agent-mandates.ts +10 -76
  77. package/src/tools/agents-refs.ts +9 -65
  78. package/src/tools/capabilities.ts +2 -15
  79. package/src/tools/compliance.ts +3 -37
  80. package/src/tools/dashboard.ts +3 -37
  81. package/src/tools/disputes.ts +4 -42
  82. package/src/tools/enterprises.ts +6 -62
  83. package/src/tools/events.ts +1 -20
  84. package/src/tools/federation-admin.ts +24 -281
  85. package/src/tools/federation.ts +20 -217
  86. package/src/tools/health.ts +1 -14
  87. package/src/tools/mandates.ts +10 -95
  88. package/src/tools/openclaw.ts +5 -51
  89. package/src/tools/receipts.ts +4 -95
  90. package/src/tools/reputation.ts +3 -34
  91. package/src/tools/schemas.ts +16 -194
  92. package/src/tools/verification-keys.ts +1 -24
  93. package/src/tools/verification.ts +2 -29
  94. package/tests/conformance.test.ts +4 -26
  95. package/tests/conformance.ts +3 -13
  96. package/tests/profiles.test.ts +2 -17
  97. package/tests/tools/a2a.test.ts +0 -28
  98. package/tests/tools/agent-mandates.test.ts +0 -10
  99. package/tests/tools/agents-refs.test.ts +0 -9
  100. package/tests/tools/capabilities.test.ts +0 -6
  101. package/tests/tools/compliance.test.ts +0 -8
  102. package/tests/tools/dashboard.test.ts +0 -9
  103. package/tests/tools/disputes.test.ts +0 -8
  104. package/tests/tools/enterprises.test.ts +0 -10
  105. package/tests/tools/events.test.ts +0 -5
  106. package/tests/tools/federation-admin.test.ts +0 -41
  107. package/tests/tools/federation.test.ts +0 -34
  108. package/tests/tools/health.test.ts +1 -12
  109. package/tests/tools/mandates.test.ts +0 -12
  110. package/tests/tools/openclaw.test.ts +0 -12
  111. package/tests/tools/receipts.test.ts +1 -14
  112. package/tests/tools/reputation.test.ts +0 -9
  113. package/tests/tools/schemas.test.ts +0 -23
  114. package/tests/tools/verification-keys.test.ts +0 -6
  115. package/tests/tools/verification.test.ts +1 -11
  116. package/src/tools/code-mode.ts +0 -461
  117. package/tests/drift/code-mode-manifest.test.ts +0 -144
  118. package/tests/integration/output-schema-validation.test.ts +0 -167
  119. package/tests/tools/code-mode.test.ts +0 -168
@@ -98,7 +98,6 @@ describe('schema tools', () => {
98
98
  it('returns list of contract types', async () => {
99
99
  const result = await harness.client.callTool({ name: 'list_contract_schemas', arguments: {} });
100
100
  assertSuccessResult(result as any);
101
- expect((result as any).content[0].text).toContain('2 contract types');
102
101
  });
103
102
 
104
103
  it('returns error on failure', async () => {
@@ -112,8 +111,6 @@ describe('schema tools', () => {
112
111
  it('returns schema details', async () => {
113
112
  const result = await harness.client.callTool({ name: 'get_contract_schema', arguments: { contractType: 'ACH-PROC-v1' } });
114
113
  assertSuccessResult(result as any);
115
- expect((result as any).content[0].text).toContain('ACH-PROC-v1');
116
- expect((result as any).content[0].text).toContain('quickStart');
117
114
  });
118
115
 
119
116
  it('returns error on failure', async () => {
@@ -127,8 +124,6 @@ describe('schema tools', () => {
127
124
  it('returns meta-schema constraints', async () => {
128
125
  const result = await harness.client.callTool({ name: 'get_meta_schema', arguments: {} });
129
126
  assertSuccessResult(result as any);
130
- expect((result as any).content[0].text).toContain('max depth 5');
131
- expect((result as any).content[0].text).toContain('6 value types');
132
127
  });
133
128
 
134
129
  it('returns error on failure', async () => {
@@ -150,7 +145,6 @@ describe('schema tools', () => {
150
145
  },
151
146
  });
152
147
  assertSuccessResult(result as any);
153
- expect((result as any).content[0].text).toContain('valid');
154
148
  });
155
149
 
156
150
  it('returns error on failure', async () => {
@@ -180,8 +174,6 @@ describe('schema tools', () => {
180
174
  },
181
175
  });
182
176
  assertSuccessResult(result as any);
183
- expect((result as any).content[0].text).toContain('Registered');
184
- expect((result as any).content[0].text).toContain('ACH-CUSTOM-v1');
185
177
  });
186
178
 
187
179
  it('returns error on failure', async () => {
@@ -203,7 +195,6 @@ describe('schema tools', () => {
203
195
  it('returns version list', async () => {
204
196
  const result = await harness.client.callTool({ name: 'get_schema_versions', arguments: { contractType: 'ACH-CUSTOM-v1' } });
205
197
  assertSuccessResult(result as any);
206
- expect((result as any).content[0].text).toContain('1 version(s)');
207
198
  });
208
199
 
209
200
  it('returns error on failure', async () => {
@@ -220,8 +211,6 @@ describe('schema tools', () => {
220
211
  arguments: { contractType: 'ACH-CUSTOM-v1', from: 1, to: 2 },
221
212
  });
222
213
  assertSuccessResult(result as any);
223
- expect((result as any).content[0].text).toContain('1 mandate change(s)');
224
- expect((result as any).content[0].text).toContain('0 receipt change(s)');
225
214
  });
226
215
 
227
216
  it('returns error on failure', async () => {
@@ -238,7 +227,6 @@ describe('schema tools', () => {
238
227
  it('returns template from existing type', async () => {
239
228
  const result = await harness.client.callTool({ name: 'get_schema_template', arguments: { contractType: 'ACH-PROC-v1' } });
240
229
  assertSuccessResult(result as any);
241
- expect((result as any).content[0].text).toContain('Template from ACH-PROC-v1');
242
230
  });
243
231
 
244
232
  it('returns error on failure', async () => {
@@ -252,7 +240,6 @@ describe('schema tools', () => {
252
240
  it('returns blank template', async () => {
253
241
  const result = await harness.client.callTool({ name: 'get_blank_schema_template', arguments: {} });
254
242
  assertSuccessResult(result as any);
255
- expect((result as any).content[0].text).toContain('Blank schema template');
256
243
  });
257
244
 
258
245
  it('returns error on failure', async () => {
@@ -273,7 +260,6 @@ describe('schema tools', () => {
273
260
  },
274
261
  });
275
262
  assertSuccessResult(result as any);
276
- expect((result as any).content[0].text).toContain('Compatibility check');
277
263
  });
278
264
 
279
265
  it('returns error on failure', async () => {
@@ -297,8 +283,6 @@ describe('schema tools', () => {
297
283
  arguments: { contractType: 'ACH-CUSTOM-v1', version: 1 },
298
284
  });
299
285
  assertSuccessResult(result as any);
300
- expect((result as any).content[0].text).toContain('ACH-CUSTOM-v1 v1');
301
- expect((result as any).content[0].text).toContain('ACTIVE');
302
286
  });
303
287
 
304
288
  it('returns error on failure', async () => {
@@ -318,7 +302,6 @@ describe('schema tools', () => {
318
302
  arguments: { contractType: 'ACH-PROC-v1', evidence: { delivered: true } },
319
303
  });
320
304
  assertSuccessResult(result as any);
321
- expect((result as any).content[0].text).toContain('valid');
322
305
  });
323
306
 
324
307
  it('returns error on failure', async () => {
@@ -335,9 +318,6 @@ describe('schema tools', () => {
335
318
  it('returns rules for contract type', async () => {
336
319
  const result = await harness.client.callTool({ name: 'get_schema_rules', arguments: { contractType: 'ACH-PROC-v1' } });
337
320
  assertSuccessResult(result as any);
338
- expect((result as any).content[0].text).toContain('2 rule(s)');
339
- expect((result as any).content[0].text).toContain('1 sync');
340
- expect((result as any).content[0].text).toContain('1 async');
341
321
  });
342
322
 
343
323
  it('returns error on failure', async () => {
@@ -351,7 +331,6 @@ describe('schema tools', () => {
351
331
  it('deletes a custom schema', async () => {
352
332
  const result = await harness.client.callTool({ name: 'delete_schema', arguments: { contractType: 'ACH-CUSTOM-v1' } });
353
333
  assertSuccessResult(result as any);
354
- expect((result as any).content[0].text).toContain('deleted');
355
334
  });
356
335
 
357
336
  it('returns error on failure', async () => {
@@ -365,7 +344,6 @@ describe('schema tools', () => {
365
344
  it('exports schema bundle', async () => {
366
345
  const result = await harness.client.callTool({ name: 'export_schema', arguments: { contractType: 'ACH-CUSTOM-v1' } });
367
346
  assertSuccessResult(result as any);
368
- expect((result as any).content[0].text).toContain('Exported');
369
347
  });
370
348
 
371
349
  it('returns error on failure', async () => {
@@ -382,7 +360,6 @@ describe('schema tools', () => {
382
360
  arguments: { bundle: { contractType: 'ACH-CUSTOM-v1' } },
383
361
  });
384
362
  assertSuccessResult(result as any);
385
- expect((result as any).content[0].text).toContain('imported');
386
363
  });
387
364
 
388
365
  it('returns error on failure', async () => {
@@ -41,11 +41,6 @@ describe('verification-keys tools', () => {
41
41
  arguments: {},
42
42
  });
43
43
  assertSuccessResult(result as any);
44
- const text = (result as any).content[0].text;
45
- expect(text).toContain('2 verification key(s)');
46
- expect(text).toContain('1 active');
47
- expect(text).toContain('1 retired');
48
- expect(text).toContain('Ed25519');
49
44
  expect((harness.mockSdk.verificationKeys as any).list).toHaveBeenCalledOnce();
50
45
  });
51
46
 
@@ -56,7 +51,6 @@ describe('verification-keys tools', () => {
56
51
  arguments: {},
57
52
  });
58
53
  assertErrorResult(result as any);
59
- expect((result as any).content[0].text).toContain('Connection refused');
60
54
  });
61
55
  });
62
56
  });
@@ -1,7 +1,7 @@
1
1
  import { describe, it, expect, beforeAll, afterAll, vi } from 'vitest';
2
2
  import { registerVerificationTools } from '../../src/tools/verification.js';
3
3
  import { createTestHarness, type TestHarness } from '../harness.js';
4
- import { assertOutputSchemaValid, assertErrorResult, assertSuccessResult } from '../conformance.js';
4
+ import { assertErrorResult, assertSuccessResult } from '../conformance.js';
5
5
 
6
6
  describe('verification tools', () => {
7
7
  let harness: TestHarness;
@@ -35,17 +35,10 @@ describe('verification tools', () => {
35
35
  expect(tools.map((t: any) => t.name).sort()).toEqual(['get_verification_status', 'verify_mandate']);
36
36
  });
37
37
 
38
- it('all tools have valid outputSchema', async () => {
39
- const { tools } = await harness.client.listTools();
40
- for (const tool of tools) assertOutputSchemaValid(tool as any);
41
- });
42
-
43
38
  describe('verify_mandate', () => {
44
39
  it('returns verification result on success', async () => {
45
40
  const result = await harness.client.callTool({ name: 'verify_mandate', arguments: { mandateId: 'm-1' } });
46
41
  assertSuccessResult(result as any);
47
- expect((result as any).content[0].text).toContain('PASS');
48
- expect((result as any).content[0].text).toContain('1 receipt(s)');
49
42
  expect((harness.mockSdk.verification as any).verify).toHaveBeenCalledWith('m-1');
50
43
  });
51
44
 
@@ -53,7 +46,6 @@ describe('verification tools', () => {
53
46
  (harness.mockSdk.verification as any).verify.mockRejectedValueOnce(new Error('Mandate not found'));
54
47
  const result = await harness.client.callTool({ name: 'verify_mandate', arguments: { mandateId: 'bad-id' } });
55
48
  assertErrorResult(result as any);
56
- expect((result as any).content[0].text).toContain('Mandate not found');
57
49
  });
58
50
  });
59
51
 
@@ -61,8 +53,6 @@ describe('verification tools', () => {
61
53
  it('returns status on success', async () => {
62
54
  const result = await harness.client.callTool({ name: 'get_verification_status', arguments: { mandateId: 'm-1' } });
63
55
  assertSuccessResult(result as any);
64
- expect((result as any).content[0].text).toContain('phase1=COMPLETE');
65
- expect((result as any).content[0].text).toContain('phase2=PENDING');
66
56
  });
67
57
 
68
58
  it('returns error on failure', async () => {
@@ -1,461 +0,0 @@
1
- import { z } from 'zod';
2
- import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
3
- import type { AgledgerClient } from '@agledger/sdk';
4
- import { AgledgerApiError } from '@agledger/sdk';
5
- import { apiErrorResult } from '../errors.js';
6
- import { toolMeta } from '../tool-scopes.js';
7
-
8
- const RESOURCE_MANIFEST: Record<string, string> = {
9
- mandates: `## client.mandates
10
- - create(params: CreateMandateParams): Promise<Mandate>
11
- - createAgent(params: CreateAgentMandateParams): Promise<Mandate>
12
- - get(id: string): Promise<Mandate>
13
- - list(params: ListMandatesParams): Promise<Page<Mandate>>
14
- - listAll(params: ListMandatesParams): AsyncGenerator<Mandate>
15
- - search(params: SearchMandatesParams): Promise<Page<Mandate>>
16
- - update(id: string, params: UpdateMandateParams): Promise<Mandate>
17
- - transition(id: string, action: MandateTransitionAction, reason?: string): Promise<Mandate>
18
- - cancel(id: string, reason?: string): Promise<Mandate>
19
- - accept(id: string): Promise<Mandate>
20
- - reject(id: string, reason?: string): Promise<Mandate>
21
- - counterPropose(id: string, params: CounterProposeParams): Promise<Mandate>
22
- - acceptCounter(id: string): Promise<Mandate>
23
- - getChain(id: string): Promise<Mandate[]>
24
- - getSubMandates(id: string): Promise<Page<Mandate>>
25
- - delegate(id: string, params: DelegateMandateParams): Promise<Mandate>
26
- - bulkCreate(mandates: CreateMandateParams[]): Promise<BulkCreateResult>
27
- - getAudit(id: string): Promise<AuditChain>
28
- - listAsPrincipal(): Promise<Page<Mandate>>
29
- - listProposals(): Promise<Page<Mandate>>
30
- - requestRevision(id: string, reason?: string): Promise<Mandate>
31
- - createAndActivate(params: CreateMandateParams): Promise<Mandate>
32
- - reportOutcome(id: string, params: ReportOutcomeParams): Promise<OutcomeResult>
33
- - getSummary(params?: { enterpriseId?: string }): Promise<MandateStatusSummary>
34
- - getGraph(id: string): Promise<Record<string, unknown>>
35
- - batchGet(ids: string[]): Promise<Mandate[]>
36
- - getValidTransitions(mandate: Mandate): readonly string[] (client-side, no API call)`,
37
-
38
- receipts: `## client.receipts
39
- - submit(mandateId: string, params: SubmitReceiptParams): Promise<Receipt>
40
- - get(mandateId: string, receiptId: string): Promise<Receipt>
41
- - list(mandateId: string, params?: ListParams): Promise<Page<Receipt>>
42
- - listAll(mandateId: string, params?: ListParams): AsyncGenerator<Receipt>`,
43
-
44
- verification: `## client.verification
45
- - verify(mandateId: string, receiptIds?: string[]): Promise<VerificationResult>
46
- - getStatus(mandateId: string): Promise<VerificationStatus>`,
47
-
48
- disputes: `## client.disputes
49
- - create(mandateId: string, params: CreateDisputeParams): Promise<Dispute>
50
- - get(mandateId: string): Promise<DisputeResponse>
51
- - escalate(mandateId: string): Promise<Dispute>
52
- - submitEvidence(mandateId: string, params: { evidenceType: EvidenceType; payload: Record<string, unknown> }): Promise<Record<string, unknown>>`,
53
-
54
- webhooks: `## client.webhooks
55
- - create(params: CreateWebhookParams): Promise<Webhook>
56
- - list(params?: ListWebhooksParams): Promise<Page<Webhook>>
57
- - get(webhookId: string): Promise<Webhook>
58
- - update(webhookId: string, params: Partial<CreateWebhookParams>): Promise<Webhook>
59
- - delete(webhookId: string): Promise<void>
60
- - pause(webhookId: string): Promise<Webhook>
61
- - resume(webhookId: string): Promise<Webhook>
62
- - rotate(webhookId: string): Promise<Webhook>
63
- - ping(webhookId: string): Promise<WebhookTestResult>
64
- - listDeliveries(webhookId: string, params?: ListParams & { status?: string }): Promise<Page<WebhookDelivery>>
65
- - listDlq(webhookId: string, params?: ListParams): Promise<Page<WebhookDlqEntry>>
66
- - retryAllDlq(webhookId: string): Promise<{ retried: number }>
67
- - retryDlq(webhookId: string, dlqId: string): Promise<Record<string, unknown>>`,
68
-
69
- reputation: `## client.reputation
70
- - getAgent(agentId: string): Promise<Page<ReputationScore>>
71
- - getByContractType(agentId: string, contractType: string): Promise<ReputationScore>
72
- - getHistory(agentId: string, params?: ListParams & { from?: string; to?: string; contractType?: string; outcome?: 'PASS' | 'FAIL' }): Promise<Page<ReputationHistoryEntry>>`,
73
-
74
- events: `## client.events
75
- - list(params: { since: string; order?: 'asc' | 'desc' } & ListParams): Promise<Page<AgledgerEvent>>
76
- - listAll(params: { since: string; order?: 'asc' | 'desc' } & ListParams): AsyncGenerator<AgledgerEvent>
77
- - getAuditChain(mandateId: string): Promise<AuditChain>`,
78
-
79
- schemas: `## client.schemas
80
- - list(params?: { enterpriseId?: string }): Promise<Page<ContractType>>
81
- - get(contractType: string): Promise<ContractSchema>
82
- - delete(contractType: string): Promise<void>
83
- - getRules(contractType: string): Promise<{ contractType; syncRuleIds; asyncRuleIds }>
84
- - validateReceipt(contractType: string, evidence: Record<string, unknown>): Promise<SchemaValidationResult>
85
- - getMetaSchema(): Promise<MetaSchema>
86
- - getTemplate(contractType: string): Promise<SchemaTemplate>
87
- - getBlankTemplate(): Promise<SchemaTemplate>
88
- - getVersions(contractType: string): Promise<SchemaVersionDetail[]>
89
- - getVersion(contractType: string, version: number): Promise<SchemaVersionDetail>
90
- - diff(contractType: string, from: number, to: number): Promise<SchemaDiffResult>
91
- - preview(input: SchemaPreviewInput): Promise<SchemaPreviewResult>
92
- - checkCompatibility(contractType: string, schemas: { mandateSchema; receiptSchema }): Promise<SchemaCompatibilityResult>
93
- - register(input: RegisterSchemaParams): Promise<SchemaVersionDetail>
94
- - updateVersion(contractType: string, version: number, params: UpdateSchemaVersionParams): Promise<SchemaVersionDetail>
95
- - exportSchema(contractType: string, opts?: ExportSchemaOptions): Promise<SchemaExportResult>
96
- - importSchema(payload: SchemaImportPayload, opts?: ImportSchemaOptions): Promise<SchemaImportResult>
97
- - previewImport(payload: SchemaImportPayload, opts?: ImportSchemaOptions): Promise<SchemaImportDryRunResult>`,
98
-
99
- dashboard: `## client.dashboard
100
- - getSummary(): Promise<DashboardSummary>
101
- - getMetrics(params?: DashboardMetricsParams): Promise<DashboardMetrics>
102
- - listAgents(params?: DashboardAgentParams): Promise<Page<DashboardAgent>>
103
- - getAlerts(params?: ListParams): Promise<Page<DashboardAlert>>
104
- - getDisputes(params?: ListParams): Promise<Page<Record<string, unknown>>>
105
- - getAuditTrail(params?: ListParams): Promise<Page<Record<string, unknown>>>`,
106
-
107
- compliance: `## client.compliance
108
- - export(params: ExportComplianceParams): Promise<ComplianceExport>
109
- - getExportStatus(exportId: string): Promise<ComplianceExport>
110
- - downloadExport(exportId: string): Promise<Record<string, unknown>>
111
- - waitForExport(exportId: string, opts?: { pollIntervalMs?; timeoutMs?; signal? }): Promise<ComplianceExport>
112
- - createAssessment(mandateId: string, params: CreateAiImpactAssessmentParams): Promise<AiImpactAssessment>
113
- - getAssessment(mandateId: string): Promise<AiImpactAssessment>
114
- - getEuAiActReport(params?: { from?; to? }): Promise<EuAiActReport>
115
- - getEnterpriseReport(params?: { from?; to?; format? }): Promise<Record<string, unknown>>
116
- - analyzeAudit(mandateId: string): Promise<Record<string, unknown>>
117
- - createRecord(mandateId: string, params: CreateComplianceRecordParams): Promise<ComplianceRecord>
118
- - listRecords(mandateId: string, params?: ListParams): Promise<Page<ComplianceRecord>>
119
- - getRecord(mandateId: string, recordId: string): Promise<ComplianceRecord>
120
- - exportMandate(mandateId: string, params?: { format?: 'json' | 'csv' | 'ndjson' }): Promise<MandateAuditExport>
121
- - stream(params: AuditStreamParams): Promise<AuditStreamResult>
122
- - streamAll(params: AuditStreamParams): AsyncGenerator<Record<string, unknown>>`,
123
-
124
- registration: `## client.registration
125
- - getMe(): Promise<AccountProfile>
126
- - register(params: RegisterParams): Promise<RegisterResult>
127
- - registerEnterprise(params: { name: string; email?: string }): Promise<RegisterResult>
128
- - registerAgent(params: { name: string; email?: string; agentCardUrl?: string; enterpriseId?: string }): Promise<RegisterResult>
129
- - verifyAgentCard(agentCardUrl: string): Promise<Record<string, unknown>>
130
- - rotateApiKey(): Promise<{ apiKey: string }>
131
- - verifyEmail(token: string): Promise<{ sandboxMode: boolean; status: string }>
132
- - sendVerificationEmail(email: string): Promise<{ sandboxMode: boolean; status: string }>`,
133
-
134
- health: `## client.health
135
- - check(): Promise<HealthResponse>
136
- - status(): Promise<StatusResponse>
137
- - conformance(): Promise<ConformanceResponse>`,
138
-
139
- proxy: `## client.proxy
140
- Unified resource with sub-resources for governance sidecar proxy operations.
141
- - syncSession(params: SyncSessionParams): Promise<SyncSessionResult>
142
-
143
- ### client.proxy.sessions
144
- - create(params: CreateSessionParams): Promise<ProxySession>
145
- - get(sessionId: string): Promise<ProxySession>
146
- - list(params?: ListParams): Promise<Page<ProxySession>>
147
- - sync(params: SyncSessionParams): Promise<SyncSessionResult>
148
-
149
- ### client.proxy.toolCalls
150
- - ingest(sessionId: string, items: ToolCallBatchItem[]): Promise<BatchResult<ProxyToolCall>>
151
- - list(sessionId: string, params?: ListParams): Promise<Page<ProxyToolCall>>
152
-
153
- ### client.proxy.sidecarMandates
154
- - ingest(sessionId: string, items: SidecarMandateBatchItem[]): Promise<BatchResult<ProxySidecarMandate>>
155
- - list(params?: ListParams & { sessionId?: string }): Promise<Page<ProxySidecarMandate>>
156
- - listBySession(sessionId: string, params?: ListParams): Promise<Page<ProxySidecarMandate>>
157
- - update(id: string, params: UpdateSidecarMandateParams): Promise<ProxySidecarMandate>
158
- - formalize(id: string, formalizedMandateId: string): Promise<ProxySidecarMandate>
159
- - dismiss(id: string): Promise<ProxySidecarMandate>
160
-
161
- ### client.proxy.sidecarReceipts
162
- - ingest(sessionId: string, items: SidecarReceiptBatchItem[]): Promise<BatchResult<ProxySidecarReceipt>>
163
- - listBySession(sessionId: string, params?: ListParams): Promise<Page<ProxySidecarReceipt>>
164
-
165
- ### client.proxy.toolCatalog
166
- - ingest(sessionId: string, items: ToolCatalogBatchItem[]): Promise<BatchResult<ProxyToolCatalogEntry>>
167
- - list(sessionId: string): Promise<Page<ProxyToolCatalogEntry>>
168
-
169
- ### client.proxy.analytics
170
- - getSession(sessionId: string): Promise<SessionAnalytics>
171
- - getSummary(params?: { from?; to? }): Promise<AnalyticsSummary>
172
- - getMandateSummary(sessionId: string): Promise<MandateSummary>
173
- - getAlignment(sessionId: string): Promise<AlignmentAnalysis>`,
174
-
175
- admin: `## client.admin
176
- Platform-level administration. Requires platform API key.
177
- - listEnterprises(params?: ListParams): Promise<Page<AdminEnterprise>>
178
- - createEnterprise(params: CreateEnterpriseParams): Promise<AdminEnterprise>
179
- - listAgents(params?: ListParams): Promise<Page<AdminAgent>>
180
- - createAgent(params: CreateAgentParams): Promise<AdminAgent>
181
- - updateTrustLevel(accountId: string, params: UpdateTrustLevelParams): Promise<Record<string, unknown>>
182
- - deactivateAccount(accountId: string, params: { accountType: 'enterprise' | 'agent'; reason?: string }): Promise<Record<string, unknown>>
183
- - setCapabilities(agentId: string, params: SetCapabilitiesParams): Promise<Record<string, unknown>>
184
- - getFleetCapabilities(): Promise<Page<{ agentId; capabilities }>>
185
- - getEnterpriseConfig(enterpriseId: string): Promise<EnterpriseConfig>
186
- - replaceEnterpriseConfig(enterpriseId: string, params: SetEnterpriseConfigParams): Promise<EnterpriseConfig>
187
- - updateEnterpriseConfig(enterpriseId: string, params: SetEnterpriseConfigParams): Promise<EnterpriseConfig>
188
- - listApiKeys(params?: ListParams): Promise<Page<AdminApiKey>>
189
- - createApiKey(params: CreateApiKeyParams): Promise<CreateApiKeyResult>
190
- - toggleApiKey(keyId: string, isActive: boolean): Promise<AdminApiKey>
191
- - bulkRevokeApiKeys(keyIds: string[]): Promise<{ revoked: number }>
192
- - getLicense(): Promise<LicenseInfo>
193
- - listMandates(params?: QueryAdminMandatesParams): Promise<Page<Record<string, unknown>>>
194
- - listDlq(params?: ListParams): Promise<Page<WebhookDlqEntry>>
195
- - retryDlq(dlqId: string): Promise<Record<string, unknown>>
196
- - retryAllDlq(): Promise<{ retried: number }>
197
- - getSystemHealth(): Promise<SystemHealth>
198
- - listRateLimitExemptions(): Promise<Page<string>>
199
- - setRateLimitExemption(ip: string): Promise<{ ip; exempt }>
200
- - deleteRateLimitExemption(ip: string): Promise<{ ip; exempt }>
201
- - getWebhookHealth(params?: ListParams): Promise<Page<Record<string, unknown>>>
202
- - updateCircuitBreaker(webhookId: string, params: UpdateCircuitBreakerParams): Promise<CircuitBreakerResult>
203
- - listVaultSigningKeys(): Promise<VaultSigningKey[]>
204
- - rotateVaultSigningKey(): Promise<VaultSigningKey>
205
- - listVaultAnchors(): Promise<VaultAnchor[]>
206
- - verifyVaultAnchors(): Promise<VaultAnchorVerifyResult>
207
- - startVaultScan(): Promise<VaultScanJob>
208
- - getVaultScanStatus(jobId: string): Promise<VaultScanJob>
209
- - flushAuthCache(): Promise<{ flushed: boolean }>
210
- - getAuthCacheStats(): Promise<AuthCacheStats>
211
- - flushSchemaCache(): Promise<{ flushed: boolean }>
212
- - listOwnerRateLimitExemptions(): Promise<Record<string, unknown>[]>
213
- - setOwnerRateLimitExemption(ownerId: string): Promise<Record<string, unknown>>
214
- - deleteOwnerRateLimitExemption(ownerId: string): Promise<Record<string, unknown>>`,
215
-
216
- a2a: `## client.a2a
217
- Agent-to-Agent protocol (A2A). JSON-RPC 2.0 dispatch.
218
- - getAgentCard(): Promise<AgentCard>
219
- - dispatch(request: JsonRpcRequest): Promise<JsonRpcResponse>
220
- - call(method: string, params?: Record<string, unknown>): Promise<JsonRpcResponse>`,
221
-
222
- capabilities: `## client.capabilities
223
- - get(agentId: string): Promise<{ agentId; capabilities: ContractType[] }>
224
- - set(agentId: string, params: SetCapabilitiesParams): Promise<{ agentId; capabilities: ContractType[] }> (PUT — replaces all)`,
225
-
226
- notarize: `## client.notarize
227
- Agent-to-agent agreement notarization (OpenClaw flow).
228
- - createMandate(params: NotarizeMandateParams): Promise<NotarizeMandateResult>
229
- - getMandate(id: string): Promise<NotarizedMandate>
230
- - getHistory(id: string): Promise<NotarizeHistory>
231
- - acceptMandate(id: string): Promise<NotarizedMandate>
232
- - counterPropose(id: string, params: NotarizeCounterProposeParams): Promise<NotarizeMandateResult>
233
- - submitReceipt(id: string, params: NotarizeReceiptParams): Promise<NotarizeReceiptResult>
234
- - renderVerdict(id: string, params: NotarizeVerdictParams): Promise<NotarizedMandate>
235
- - verify(params: NotarizeVerifyParams): Promise<NotarizeVerifyResult>`,
236
-
237
- enterprises: `## client.enterprises
238
- Enterprise agent approval registry.
239
- - approveAgent(enterpriseId: string, agentId: string, params?: ApproveAgentParams): Promise<EnterpriseAgentRecord>
240
- - revokeAgent(enterpriseId: string, agentId: string, params?: RevokeAgentParams): Promise<void>
241
- - updateAgentStatus(enterpriseId: string, agentId: string, params: UpdateAgentStatusParams): Promise<EnterpriseAgentRecord>
242
- - bulkApprove(enterpriseId: string, params: BulkApproveAgentParams): Promise<BulkApproveResult>
243
- - listAgents(enterpriseId: string, params?: ListEnterpriseAgentsParams): Promise<Page<EnterpriseAgentRecord>>
244
- - getAgent(enterpriseId: string, agentId: string): Promise<EnterpriseAgentRecord>
245
- `,
246
-
247
- projects: `## client.projects
248
- - create(params: CreateProjectParams): Promise<Project>
249
- - list(params?: ListParams): Promise<Page<Project>>
250
- - get(projectId: string): Promise<Project>
251
- - update(projectId: string, params: UpdateProjectParams): Promise<Project>
252
- - delete(projectId: string): Promise<void>`,
253
-
254
- federation: `## client.federation
255
- Gateway-facing federation operations. Most methods require a bearer token from register().
256
- - register(params: RegisterGatewayParams): Promise<RegisterGatewayResult> (no auth header)
257
- - heartbeat(params: HeartbeatParams): Promise<HeartbeatResult>
258
- - registerAgent(params: RegisterFederatedAgentParams): Promise<{ registered: boolean }>
259
- - listAgents(params?: ListFederatedAgentsParams): Promise<Page<FederationAgent>>
260
- - submitStateTransition(params: SubmitStateTransitionParams): Promise<StateTransitionResult>
261
- - relaySignal(params: RelaySignalParams): Promise<SignalRelayResult>
262
- - rotateKey(gatewayId: string, params: RotateGatewayKeyParams): Promise<{ rotated: boolean }>
263
- - revoke(gatewayId: string, params: RevokeGatewayParams): Promise<{ revoked; revokedAt }> (no auth header)
264
- - catchUp(params: FederationCatchUpParams): Promise<{ data: FederationAuditEntry[]; hasMore }>
265
- - stream(params?: { since?: string }): Promise<Record<string, unknown>>
266
- - publishSchema(contractType: string, params: SchemaPublishParams): Promise<ContractSchema>
267
- - confirmSchemaPublish(contractType: string, params: SchemaConfirmParams): Promise<ContractSchema>
268
- - listContractTypes(): Promise<ContractSchema[]>
269
- - getContractType(contractType: string): Promise<ContractSchema>
270
- - getMandateCriteria(mandateId: string): Promise<FederationMandateCriteria>
271
- - submitMandateCriteria(mandateId: string, params: SubmitMandateCriteriaParams): Promise<FederationMandateCriteria>
272
- - contributeReputation(params: ContributeReputationParams): Promise<{ contributed: boolean }>
273
- - getAgentReputation(agentId: string): Promise<FederationAgentReputation>
274
- - broadcastRevocations(params: RevocationBroadcastParams): Promise<{ broadcast: boolean }>
275
- - syncAgentDirectory(params: AgentDirectorySyncParams): Promise<{ synced: boolean }>`,
276
-
277
- federationAdmin: `## client.federationAdmin
278
- Platform admin operations for federation. Requires admin:system scope.
279
- - createRegistrationToken(params?: CreateRegistrationTokenParams): Promise<FederationRegistrationToken>
280
- - listGateways(params?: ListFederationGatewaysParams): Promise<Page<FederationGateway>>
281
- - revokeGateway(gatewayId: string, params: AdminRevokeGatewayParams): Promise<{ revoked; nextSteps }>
282
- - queryMandates(params?: QueryFederationMandatesParams): Promise<Page<FederationMandate>>
283
- - getAuditLog(params?: FederationAuditLogParams): Promise<Page<FederationAuditEntry>>
284
- - getHealth(): Promise<FederationHealthSummary>
285
- - resetSequence(gatewayId: string, params?: ResetSequenceParams): Promise<{ reset; nextSteps }>
286
- - listDlq(params?: ListOutboundDlqParams): Promise<Page<FederationDlqEntry>>
287
- - retryDlq(dlqId: string): Promise<{ retried; nextSteps }>
288
- - deleteDlq(dlqId: string): Promise<{ deleted: boolean }>
289
- - rotateHubKey(): Promise<HubSigningKey>
290
- - listHubKeys(): Promise<HubSigningKey[]>
291
- - activateHubKey(keyId: string): Promise<HubSigningKey>
292
- - expireHubKey(keyId: string): Promise<HubSigningKey>
293
- - registerPeer(params: PeerRegistrationParams): Promise<FederationPeer>
294
- - listPeers(): Promise<Page<FederationPeer>>
295
- - getPeer(hubId: string): Promise<FederationPeer>
296
- - revokePeer(hubId: string): Promise<{ revoked: boolean }>
297
- - resyncPeer(hubId: string): Promise<{ synced: boolean }>
298
- - createPeeringToken(): Promise<PeeringToken>
299
- - deleteSchemaVersion(contractType: string, version: string): Promise<{ deleted: boolean }>
300
- - listReputationContributions(agentId: string): Promise<ReputationContribution[]>
301
- - resetReputation(agentId: string): Promise<{ reset: boolean }>
302
- - getMandateCriteriaStatus(mandateId: string): Promise<MandateCriteriaStatus>`,
303
-
304
- agents: `## client.agents
305
- Agent identity management.
306
- - get(agentId: string): Promise<AgentProfile>
307
- - update(agentId: string, params: UpdateAgentParams): Promise<AgentProfile>
308
- - addReferences(agentId: string, references: Record<string, unknown>[]): Promise<Record<string, unknown>>
309
- - getReferences(agentId: string): Promise<Record<string, unknown>>`,
310
-
311
- references: `## client.references
312
- Reverse lookup for external references.
313
- - lookup(params: { system: string; refType: string; refId: string }): Promise<ReferenceLookupResult>
314
- - addMandateReferences(mandateId: string, references: Record<string, unknown>[]): Promise<Record<string, unknown>>
315
- - getMandateReferences(mandateId: string): Promise<Record<string, unknown>>`,
316
-
317
- verificationKeys: `## client.verificationKeys
318
- Public vault signing keys for independent audit chain verification. No auth required.
319
- - list(): Promise<VerificationKeysResponse> — returns { data: VerificationKey[], canonicalization, hashAlgorithm, signatureAlgorithm }`,
320
- };
321
-
322
- const RESOURCE_NAMES = Object.keys(RESOURCE_MANIFEST);
323
-
324
- function buildFullManifest(): string {
325
- const header = `# AGLedger SDK — Resource Manifest
326
- 24 resources, ~200 methods. Use \`sdk_execute\` to call any method.
327
- The \`client\` variable is a pre-configured AgledgerClient instance.
328
-
329
- **Pagination**: \`list()\` returns \`Page<T>\` with \`.data\`, \`.total\`, \`.hasMore\`, \`.cursor\`. Use \`listAll()\` for auto-paginating async iterators.
330
- **Options**: All methods accept an optional trailing \`RequestOptions\` parameter (timeout, idempotencyKey, authOverride).
331
- **Errors**: SDK throws typed errors — \`AgledgerApiError\`, \`AuthenticationError\`, \`PermissionError\`, \`NotFoundError\`, \`RateLimitError\`, etc.
332
-
333
- ---
334
-
335
- `;
336
- return header + RESOURCE_NAMES.map((name) => RESOURCE_MANIFEST[name]).join('\n\n');
337
- }
338
-
339
- const FULL_MANIFEST = buildFullManifest();
340
-
341
- export function registerCodeModeTools(mcp: McpServer, client: AgledgerClient): void {
342
- mcp.registerTool(
343
- 'sdk_execute',
344
- {
345
- title: 'Execute SDK Code',
346
- description: `Execute TypeScript/JavaScript code against the AGLedger SDK client. The \`client\` variable is a pre-configured AgledgerClient instance with all 23 resources available.
347
-
348
- Example usage:
349
- - \`const mandate = await client.mandates.get("mnd-abc123"); return mandate;\`
350
- - \`const page = await client.mandates.list({ status: "ACTIVE", limit: 10 }); return page.data;\`
351
- - \`await client.mandates.transition("mnd-abc123", { action: "register" }); return "done";\`
352
-
353
- The code runs in an async context — use \`await\` freely. Return a value to see it in the response. Use \`sdk_describe\` first to discover available resources and method signatures.
354
-
355
- Available resources: ${RESOURCE_NAMES.join(', ')}.
356
-
357
- SECURITY: This tool executes code in the MCP server process. It is intended for trusted agents only — the caller has the same access as the API key. Do not expose this tool to untrusted clients. A 30-second timeout prevents runaway execution.`,
358
- inputSchema: {
359
- code: z.string().describe('TypeScript/JavaScript code to execute. Use `client` to access the SDK. Return a value to see results.'),
360
- },
361
- outputSchema: z.object({
362
- result: z.unknown().describe('The return value of the executed code'),
363
- executionTimeMs: z.number().describe('Execution time in milliseconds'),
364
- }),
365
- annotations: {
366
- readOnlyHint: false,
367
- destructiveHint: true,
368
- idempotentHint: false,
369
- openWorldHint: true,
370
- },
371
- _meta: toolMeta('sdk_execute'),
372
- },
373
- async (args) => {
374
- const TIMEOUT_MS = 30_000;
375
- const start = Date.now();
376
- try {
377
- // Use AsyncFunction constructor to support top-level await
378
- // NOTE: This executes in the same process as the MCP server — the caller
379
- // (agent) is already trusted with the API key. The timeout prevents runaway
380
- // code from hanging the server. For untrusted execution, use a sandbox.
381
- const AsyncFunction = Object.getPrototypeOf(async function () {}).constructor;
382
- const fn = new AsyncFunction('client', args.code);
383
- const timeout = new Promise((_, reject) =>
384
- setTimeout(() => reject(new Error(`Execution timed out after ${TIMEOUT_MS}ms`)), TIMEOUT_MS),
385
- );
386
- const result = await Promise.race([fn(client), timeout]);
387
- const executionTimeMs = Date.now() - start;
388
- let serialized: string;
389
- try {
390
- serialized = JSON.stringify(result, null, 2) ?? 'undefined';
391
- } catch {
392
- serialized = '[Result contains circular references]';
393
- }
394
- return {
395
- content: [{ type: 'text', text: `Execution completed in ${executionTimeMs}ms.\n\n${serialized}` }],
396
- structuredContent: { result, executionTimeMs },
397
- };
398
- } catch (err) {
399
- const executionTimeMs = Date.now() - start;
400
- if (err instanceof AgledgerApiError) {
401
- return apiErrorResult(err);
402
- }
403
- return {
404
- content: [{ type: 'text', text: `Execution error after ${executionTimeMs}ms: ${err instanceof Error ? err.message : String(err)}` }],
405
- isError: true,
406
- };
407
- }
408
- },
409
- );
410
-
411
- mcp.registerTool(
412
- 'sdk_describe',
413
- {
414
- title: 'Describe SDK Resources',
415
- description: `Returns the AGLedger SDK resource manifest — all 23 resources with method signatures, parameters, and return types. Use this to discover what code to write for \`sdk_execute\`.
416
-
417
- Pass a \`resource\` name (e.g., "mandates", "federation") for detailed info on one resource, or omit it for the full manifest.
418
-
419
- Available resources: ${RESOURCE_NAMES.join(', ')}.`,
420
- inputSchema: {
421
- resource: z.string().optional().describe('Resource name to describe (e.g., "mandates", "federation"). Omit for full manifest.'),
422
- },
423
- outputSchema: z.object({
424
- manifest: z.string().describe('SDK resource manifest with method signatures'),
425
- resourceCount: z.number().describe('Number of resources described'),
426
- }),
427
- annotations: {
428
- readOnlyHint: true,
429
- destructiveHint: false,
430
- idempotentHint: true,
431
- openWorldHint: false,
432
- },
433
- _meta: toolMeta('sdk_describe'),
434
- },
435
- async (args) => {
436
- if (args.resource) {
437
- const name = args.resource.toLowerCase().replace(/[-_\s]/g, '');
438
- // Try exact match first, then normalized match
439
- const key = RESOURCE_NAMES.find(
440
- (k) => k === args.resource || k.toLowerCase().replace(/[-_\s]/g, '') === name,
441
- );
442
- if (!key) {
443
- return {
444
- content: [{ type: 'text', text: `Unknown resource "${args.resource}". Available: ${RESOURCE_NAMES.join(', ')}` }],
445
- isError: true,
446
- };
447
- }
448
- const manifest = RESOURCE_MANIFEST[key];
449
- return {
450
- content: [{ type: 'text', text: manifest }],
451
- structuredContent: { manifest, resourceCount: 1 },
452
- };
453
- }
454
-
455
- return {
456
- content: [{ type: 'text', text: FULL_MANIFEST }],
457
- structuredContent: { manifest: FULL_MANIFEST, resourceCount: RESOURCE_NAMES.length },
458
- };
459
- },
460
- );
461
- }