@agledger/mcp-server 1.2.1 → 1.3.1

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 (131) hide show
  1. package/dist/enums.d.ts +6 -4
  2. package/dist/enums.d.ts.map +1 -1
  3. package/dist/enums.js +2 -2
  4. package/dist/enums.js.map +1 -1
  5. package/dist/errors.d.ts +0 -1
  6. package/dist/errors.d.ts.map +1 -1
  7. package/dist/errors.js +0 -1
  8. package/dist/errors.js.map +1 -1
  9. package/dist/index.d.ts +0 -1
  10. package/dist/index.d.ts.map +1 -1
  11. package/dist/index.js +0 -1
  12. package/dist/index.js.map +1 -1
  13. package/dist/resources/contract-types.d.ts +0 -1
  14. package/dist/resources/contract-types.d.ts.map +1 -1
  15. package/dist/resources/contract-types.js +0 -3
  16. package/dist/resources/contract-types.js.map +1 -1
  17. package/dist/server.d.ts +0 -1
  18. package/dist/server.d.ts.map +1 -1
  19. package/dist/server.js +0 -1
  20. package/dist/server.js.map +1 -1
  21. package/dist/tool-scopes.d.ts +0 -12
  22. package/dist/tool-scopes.d.ts.map +1 -1
  23. package/dist/tool-scopes.js +19 -31
  24. package/dist/tool-scopes.js.map +1 -1
  25. package/dist/tools/a2a.d.ts +0 -1
  26. package/dist/tools/a2a.d.ts.map +1 -1
  27. package/dist/tools/a2a.js +96 -75
  28. package/dist/tools/a2a.js.map +1 -1
  29. package/dist/tools/agent-mandates.d.ts +0 -1
  30. package/dist/tools/agent-mandates.d.ts.map +1 -1
  31. package/dist/tools/agent-mandates.js +0 -10
  32. package/dist/tools/agent-mandates.js.map +1 -1
  33. package/dist/tools/agents-refs.d.ts +0 -1
  34. package/dist/tools/agents-refs.d.ts.map +1 -1
  35. package/dist/tools/agents-refs.js +0 -8
  36. package/dist/tools/agents-refs.js.map +1 -1
  37. package/dist/tools/capabilities.d.ts +0 -1
  38. package/dist/tools/capabilities.d.ts.map +1 -1
  39. package/dist/tools/capabilities.js +0 -3
  40. package/dist/tools/capabilities.js.map +1 -1
  41. package/dist/tools/code-mode.d.ts +0 -1
  42. package/dist/tools/code-mode.d.ts.map +1 -1
  43. package/dist/tools/code-mode.js +0 -9
  44. package/dist/tools/code-mode.js.map +1 -1
  45. package/dist/tools/compliance.d.ts +0 -1
  46. package/dist/tools/compliance.d.ts.map +1 -1
  47. package/dist/tools/compliance.js +0 -1
  48. package/dist/tools/compliance.js.map +1 -1
  49. package/dist/tools/dashboard.d.ts +0 -1
  50. package/dist/tools/dashboard.d.ts.map +1 -1
  51. package/dist/tools/dashboard.js +0 -1
  52. package/dist/tools/dashboard.js.map +1 -1
  53. package/dist/tools/disputes.d.ts +0 -1
  54. package/dist/tools/disputes.d.ts.map +1 -1
  55. package/dist/tools/disputes.js +0 -5
  56. package/dist/tools/disputes.js.map +1 -1
  57. package/dist/tools/enterprises.d.ts +0 -1
  58. package/dist/tools/enterprises.d.ts.map +1 -1
  59. package/dist/tools/enterprises.js +0 -7
  60. package/dist/tools/enterprises.js.map +1 -1
  61. package/dist/tools/events.d.ts +0 -1
  62. package/dist/tools/events.d.ts.map +1 -1
  63. package/dist/tools/events.js +0 -2
  64. package/dist/tools/events.js.map +1 -1
  65. package/dist/tools/federation-admin.d.ts +0 -1
  66. package/dist/tools/federation-admin.d.ts.map +1 -1
  67. package/dist/tools/federation-admin.js +0 -25
  68. package/dist/tools/federation-admin.js.map +1 -1
  69. package/dist/tools/federation.d.ts +0 -1
  70. package/dist/tools/federation.d.ts.map +1 -1
  71. package/dist/tools/federation.js +0 -21
  72. package/dist/tools/federation.js.map +1 -1
  73. package/dist/tools/health.d.ts +0 -1
  74. package/dist/tools/health.d.ts.map +1 -1
  75. package/dist/tools/health.js +0 -2
  76. package/dist/tools/health.js.map +1 -1
  77. package/dist/tools/mandates.d.ts +0 -1
  78. package/dist/tools/mandates.d.ts.map +1 -1
  79. package/dist/tools/mandates.js +0 -11
  80. package/dist/tools/mandates.js.map +1 -1
  81. package/dist/tools/openclaw.d.ts +0 -5
  82. package/dist/tools/openclaw.d.ts.map +1 -1
  83. package/dist/tools/openclaw.js +0 -5
  84. package/dist/tools/openclaw.js.map +1 -1
  85. package/dist/tools/receipts.d.ts +0 -1
  86. package/dist/tools/receipts.d.ts.map +1 -1
  87. package/dist/tools/receipts.js +59 -24
  88. package/dist/tools/receipts.js.map +1 -1
  89. package/dist/tools/reputation.d.ts +0 -1
  90. package/dist/tools/reputation.d.ts.map +1 -1
  91. package/dist/tools/reputation.js +0 -1
  92. package/dist/tools/reputation.js.map +1 -1
  93. package/dist/tools/schemas.d.ts +0 -1
  94. package/dist/tools/schemas.d.ts.map +1 -1
  95. package/dist/tools/schemas.js +0 -17
  96. package/dist/tools/schemas.js.map +1 -1
  97. package/dist/tools/verification-keys.d.ts +0 -1
  98. package/dist/tools/verification-keys.d.ts.map +1 -1
  99. package/dist/tools/verification-keys.js +0 -1
  100. package/dist/tools/verification-keys.js.map +1 -1
  101. package/dist/tools/verification.d.ts +0 -1
  102. package/dist/tools/verification.d.ts.map +1 -1
  103. package/dist/tools/verification.js +2 -4
  104. package/dist/tools/verification.js.map +1 -1
  105. package/package.json +2 -2
  106. package/src/enums.ts +2 -3
  107. package/src/errors.ts +0 -2
  108. package/src/index.ts +0 -2
  109. package/src/resources/contract-types.ts +0 -4
  110. package/src/server.ts +0 -2
  111. package/src/tool-scopes.ts +19 -32
  112. package/src/tools/a2a.ts +158 -113
  113. package/src/tools/agent-mandates.ts +0 -11
  114. package/src/tools/agents-refs.ts +0 -9
  115. package/src/tools/capabilities.ts +0 -4
  116. package/src/tools/code-mode.ts +0 -12
  117. package/src/tools/compliance.ts +0 -2
  118. package/src/tools/dashboard.ts +0 -2
  119. package/src/tools/disputes.ts +0 -6
  120. package/src/tools/enterprises.ts +0 -8
  121. package/src/tools/events.ts +0 -3
  122. package/src/tools/federation-admin.ts +0 -26
  123. package/src/tools/federation.ts +0 -22
  124. package/src/tools/health.ts +0 -3
  125. package/src/tools/mandates.ts +0 -12
  126. package/src/tools/openclaw.ts +0 -6
  127. package/src/tools/receipts.ts +82 -46
  128. package/src/tools/reputation.ts +0 -2
  129. package/src/tools/schemas.ts +0 -18
  130. package/src/tools/verification-keys.ts +0 -2
  131. package/src/tools/verification.ts +2 -5
package/src/tools/a2a.ts CHANGED
@@ -1,5 +1,3 @@
1
- /** AGLedger™ — Focused A2A tool profile (10 tools with closure prompting). Patent Pending. Copyright 2026 AGLedger LLC. All rights reserved. */
2
-
3
1
  import { z } from 'zod';
4
2
  import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
5
3
  import type { AgledgerClient } from '@agledger/sdk';
@@ -12,58 +10,78 @@ export interface A2aToolsConfig {
12
10
  enterpriseId?: string;
13
11
  }
14
12
 
15
- const A2aMandateOutputSchema = z.object({
16
- id: z.string().describe('Mandate ID'),
17
- status: z.string().describe('Mandate lifecycle status'),
18
- contractType: z.string().describe('Contract type identifier'),
19
- principalAgentId: z.string().optional().describe('Agent who proposed the work'),
20
- agentId: z.string().optional().describe('Agent assigned to do the work'),
21
- }).passthrough().describe('Mandate details');
22
-
23
- const ProposalsOutputSchema = z.object({
24
- proposals: z.array(A2aMandateOutputSchema).describe('Pending proposals'),
25
- active: z.array(A2aMandateOutputSchema).describe('Active mandates needing receipts'),
26
- verified: z.array(A2aMandateOutputSchema).describe('Mandates ready to settle'),
27
- }).describe('Current proposals and obligations');
28
-
29
- const ReceiptResultOutputSchema = z.object({
30
- receipt: z.object({
31
- id: z.string().describe('Receipt ID'),
32
- status: z.string().describe('Receipt status'),
33
- }).passthrough().describe('Submitted receipt'),
34
- mandateStatus: z.string().describe('Mandate status after receipt submission'),
35
- }).describe('Receipt submission result');
36
-
37
- const MandateListOutputSchema = z.object({
38
- mandates: z.array(A2aMandateOutputSchema).describe('All mandates'),
39
- byStatus: z.record(z.string(), z.array(A2aMandateOutputSchema)).describe('Mandates grouped by status'),
40
- }).describe('Mandate list grouped by status');
41
-
42
- const ReputationOutputSchema = z.object({
43
- agentId: z.string().describe('Agent ID'),
44
- score: z.number().optional().describe('Reputation score'),
45
- fulfillmentRate: z.number().optional().describe('Fulfillment rate'),
46
- }).passthrough().describe('Agent reputation details');
13
+ const A2aMandateOutputSchema = z
14
+ .object({
15
+ id: z.string().describe('Mandate ID'),
16
+ status: z.string().describe('Mandate lifecycle status'),
17
+ contractType: z.string().describe('Contract type identifier'),
18
+ principalAgentId: z.string().optional().describe('Agent who proposed the work'),
19
+ agentId: z.string().optional().describe('Agent assigned to do the work'),
20
+ })
21
+ .passthrough()
22
+ .describe('Mandate details');
23
+
24
+ const ProposalsOutputSchema = z
25
+ .object({
26
+ proposals: z.array(A2aMandateOutputSchema).describe('Pending proposals'),
27
+ active: z.array(A2aMandateOutputSchema).describe('Active mandates needing receipts'),
28
+ verified: z.array(A2aMandateOutputSchema).describe('Mandates ready to settle'),
29
+ })
30
+ .describe('Current proposals and obligations');
31
+
32
+ const ReceiptResultOutputSchema = z
33
+ .object({
34
+ receipt: z
35
+ .object({
36
+ id: z.string().describe('Receipt ID'),
37
+ status: z.string().describe('Receipt status'),
38
+ })
39
+ .passthrough()
40
+ .describe('Submitted receipt'),
41
+ mandateStatus: z.string().describe('Mandate status after receipt submission'),
42
+ })
43
+ .describe('Receipt submission result');
44
+
45
+ const MandateListOutputSchema = z
46
+ .object({
47
+ mandates: z.array(A2aMandateOutputSchema).describe('All mandates'),
48
+ byStatus: z
49
+ .record(z.string(), z.array(A2aMandateOutputSchema))
50
+ .describe('Mandates grouped by status'),
51
+ })
52
+ .describe('Mandate list grouped by status');
53
+
54
+ const ReputationOutputSchema = z
55
+ .object({
56
+ agentId: z.string().describe('Agent ID'),
57
+ score: z.number().optional().describe('Reputation score'),
58
+ fulfillmentRate: z.number().optional().describe('Fulfillment rate'),
59
+ })
60
+ .passthrough()
61
+ .describe('Agent reputation details');
47
62
 
48
63
  function getEnterpriseId(config: A2aToolsConfig): string {
49
64
  return config.enterpriseId ?? process.env.AGLEDGER_ENTERPRISE_ID ?? '';
50
65
  }
51
66
 
52
- export function registerA2aTools(mcp: McpServer, client: AgledgerClient, config: A2aToolsConfig = {}): void {
53
-
54
- // ═══════════════════════════════════════════════════════════
55
- // 1. propose_mandate — Principal proposes work to a performer
56
- // ═══════════════════════════════════════════════════════════
67
+ export function registerA2aTools(
68
+ mcp: McpServer,
69
+ client: AgledgerClient,
70
+ config: A2aToolsConfig = {},
71
+ ): void {
57
72
  mcp.registerTool(
58
73
  'propose_mandate',
59
74
  {
60
75
  title: 'Propose Mandate',
61
- description: 'Propose accountable work to another agent. performerAgentId must differ from principalAgentId. Criteria: simple key-value pairs (strings, not nested objects).',
76
+ description:
77
+ 'Propose accountable work to another agent. performerAgentId must differ from principalAgentId. Criteria: simple key-value pairs (strings, not nested objects).',
62
78
  inputSchema: {
63
79
  principalAgentId: z.string().describe('Your agent ID'),
64
80
  performerAgentId: z.string().describe('Agent to do the work (must differ from yours)'),
65
81
  contractType: ContractTypeEnum,
66
- criteria: z.record(z.string(), z.unknown()).describe('Acceptance criteria (key-value pairs)'),
82
+ criteria: z
83
+ .record(z.string(), z.unknown())
84
+ .describe('Acceptance criteria (key-value pairs)'),
67
85
  projectRef: z.string().optional().describe('Project grouping ID'),
68
86
  parentMandateId: z.string().optional().describe('Parent mandate if delegating'),
69
87
  deadline: z.string().optional().describe('ISO 8601 future deadline'),
@@ -80,10 +98,14 @@ export function registerA2aTools(mcp: McpServer, client: AgledgerClient, config:
80
98
  async (args) => {
81
99
  try {
82
100
  if (!args.performerAgentId) {
83
- return errorResult('performerAgentId is required — you must specify who should do the work');
101
+ return errorResult(
102
+ 'performerAgentId is required — you must specify who should do the work',
103
+ );
84
104
  }
85
105
  if (args.performerAgentId === args.principalAgentId) {
86
- return errorResult('Cannot assign work to yourself. performerAgentId must be a DIFFERENT agent.');
106
+ return errorResult(
107
+ 'Cannot assign work to yourself. performerAgentId must be a DIFFERENT agent.',
108
+ );
87
109
  }
88
110
  // Validate deadline is in the future, strip if not
89
111
  let deadline = args.deadline;
@@ -93,7 +115,9 @@ export function registerA2aTools(mcp: McpServer, client: AgledgerClient, config:
93
115
  if (isNaN(d.getTime()) || d.getTime() <= Date.now()) {
94
116
  deadline = undefined; // silently drop invalid/past deadlines
95
117
  }
96
- } catch { deadline = undefined; }
118
+ } catch {
119
+ deadline = undefined;
120
+ }
97
121
  }
98
122
  const mandate = await client.mandates.createAgent({
99
123
  principalAgentId: args.principalAgentId,
@@ -106,7 +130,12 @@ export function registerA2aTools(mcp: McpServer, client: AgledgerClient, config:
106
130
  deadline,
107
131
  });
108
132
  return {
109
- content: [{ type: 'text', text: `✓ Mandate ${mandate.id} proposed (${mandate.contractType}). Status: ${mandate.status}. The performer must call accept_mandate to begin. CRITICAL: after work is done, call submit_receipt — this is REQUIRED to close the accountability loop. A mandate without a receipt is an unfulfilled commitment.` }],
133
+ content: [
134
+ {
135
+ type: 'text',
136
+ text: `Mandate ${mandate.id} proposed (${mandate.contractType}). Status: ${mandate.status}. The performer must call accept_mandate to begin. CRITICAL: after work is done, call submit_receipt — this is REQUIRED to close the accountability loop. A mandate without a receipt is an unfulfilled commitment.`,
137
+ },
138
+ ],
110
139
  structuredContent: mandate as unknown as Record<string, unknown>,
111
140
  };
112
141
  } catch (err) {
@@ -115,14 +144,12 @@ export function registerA2aTools(mcp: McpServer, client: AgledgerClient, config:
115
144
  },
116
145
  );
117
146
 
118
- // ═══════════════════════════════════════════════════════════
119
- // 2. accept_mandate — Performer accepts a proposed mandate
120
- // ═══════════════════════════════════════════════════════════
121
147
  mcp.registerTool(
122
148
  'accept_mandate',
123
149
  {
124
150
  title: 'Accept Mandate',
125
- description: 'Accept a proposed mandate. After accepting, do the work, then call submit_receipt.',
151
+ description:
152
+ 'Accept a proposed mandate. After accepting, do the work, then call submit_receipt.',
126
153
  inputSchema: {
127
154
  mandateId: z.string().describe('Mandate ID to accept'),
128
155
  },
@@ -143,17 +170,23 @@ export function registerA2aTools(mcp: McpServer, client: AgledgerClient, config:
143
170
  if (mandate.status === 'CREATED') {
144
171
  try {
145
172
  mandate = await client.mandates.transition(args.mandateId, 'activate');
146
- } catch { /* activation may fail if already active or missing prerequisites */ }
173
+ } catch {
174
+ /* activation may fail if already active or missing prerequisites */
175
+ }
147
176
  }
148
177
 
149
178
  // Include evidence template so models know exactly what to submit
150
179
  const evidenceTemplates: Record<string, string> = {
151
- 'ACH-ANALYZE-v1': '{"deliverable": "your analysis text", "deliverable_type": "report", "summary": "key findings"}',
152
- 'ACH-COORD-v1': '{"deliverable": "coordination outcome", "deliverable_type": "report", "summary": "what was coordinated"}',
180
+ 'ACH-ANALYZE-v1':
181
+ '{"deliverable": "your analysis text", "deliverable_type": "report", "summary": "key findings"}',
182
+ 'ACH-COORD-v1':
183
+ '{"deliverable": "coordination outcome", "deliverable_type": "report", "summary": "what was coordinated"}',
153
184
  'ACH-DATA-v1': '{"deliverable": "data results", "deliverable_type": "report"}',
154
185
  'ACH-DLVR-v1': '{"deliverable": "artifact content", "deliverable_type": "document"}',
155
- 'ACH-PROC-v1': '{"item_secured": "item name", "quantity": 1, "total_cost": {"amount": 100, "currency": "USD"}, "supplier": {"id": "S1", "name": "Supplier"}, "confirmation_ref": "REF-1"}',
156
- 'ACH-TXN-v1': '{"confirmations": [{"ref": "T1", "type": "payment", "provider": "provider", "cost": {"amount": 100, "currency": "USD"}}]}',
186
+ 'ACH-PROC-v1':
187
+ '{"item_secured": "item name", "quantity": 1, "total_cost": {"amount": 100, "currency": "USD"}, "supplier": {"id": "S1", "name": "Supplier"}, "confirmation_ref": "REF-1"}',
188
+ 'ACH-TXN-v1':
189
+ '{"confirmations": [{"ref": "T1", "type": "payment", "provider": "provider", "cost": {"amount": 100, "currency": "USD"}}]}',
157
190
  'ACH-COMM-v1': '{"deliverable": "communication sent", "deliverable_type": "report"}',
158
191
  'ACH-AUTH-v1': '{"deliverable": "auth action completed", "deliverable_type": "report"}',
159
192
  'ACH-INFRA-v1': '{"deliverable": "infrastructure change", "deliverable_type": "report"}',
@@ -161,10 +194,16 @@ export function registerA2aTools(mcp: McpServer, client: AgledgerClient, config:
161
194
  'ACH-ORCH-v1': '{"deliverable": "orchestration result", "deliverable_type": "report"}',
162
195
  };
163
196
  const ct = (mandate as any).contractType as string;
164
- const template = evidenceTemplates[ct] || '{"deliverable": "work result", "deliverable_type": "report"}';
197
+ const template =
198
+ evidenceTemplates[ct] || '{"deliverable": "work result", "deliverable_type": "report"}';
165
199
 
166
200
  return {
167
- content: [{ type: 'text', text: `✓ Mandate ${mandate.id} accepted and activated (${ct}). Status: ${mandate.status}.\n\n⚡ NEXT STEP: Do the work, then call submit_receipt with mandateId="${mandate.id}" and evidence=${template}\n\nThis is REQUIRED — do NOT skip the receipt.` }],
201
+ content: [
202
+ {
203
+ type: 'text',
204
+ text: `Mandate ${mandate.id} accepted and activated (${ct}). Status: ${mandate.status}.\n\nNEXT STEP: Do the work, then call submit_receipt with mandateId="${mandate.id}" and evidence=${template}\n\nThis is REQUIRED — do NOT skip the receipt.`,
205
+ },
206
+ ],
168
207
  structuredContent: mandate as unknown as Record<string, unknown>,
169
208
  };
170
209
  } catch (err) {
@@ -173,9 +212,6 @@ export function registerA2aTools(mcp: McpServer, client: AgledgerClient, config:
173
212
  },
174
213
  );
175
214
 
176
- // ═══════════════════════════════════════════════════════════
177
- // 3. check_proposals — See what's been proposed to you
178
- // ═══════════════════════════════════════════════════════════
179
215
  mcp.registerTool(
180
216
  'check_proposals',
181
217
  {
@@ -215,38 +251,51 @@ export function registerA2aTools(mcp: McpServer, client: AgledgerClient, config:
215
251
  // Filter to this agent if ID provided
216
252
  if (args.agentId) {
217
253
  const id = args.agentId;
218
- allProposals = allProposals.filter((m: any) => m.agentId === id || m.principalAgentId === id);
254
+ allProposals = allProposals.filter(
255
+ (m: any) => m.agentId === id || m.principalAgentId === id,
256
+ );
219
257
  allActive = allActive.filter((m: any) => m.agentId === id || m.principalAgentId === id);
220
- allVerified = allVerified.filter((m: any) => m.agentId === id || m.principalAgentId === id);
258
+ allVerified = allVerified.filter(
259
+ (m: any) => m.agentId === id || m.principalAgentId === id,
260
+ );
221
261
  }
222
262
 
223
- let text = `📋 ${allProposals.length} pending proposal(s)`;
263
+ let text = ` ${allProposals.length} pending proposal(s)`;
224
264
  if (allProposals.length > 0) {
225
- text += ':\n' + allProposals.map((m: any) =>
226
- ` • ${m.id} (${m.contractType}) from ${m.principalAgentId?.slice(0, 8)}... — ${JSON.stringify(m.criteria).slice(0, 100)}`
227
- ).join('\n');
265
+ text +=
266
+ ':\n' +
267
+ allProposals
268
+ .map(
269
+ (m: any) =>
270
+ ` • ${m.id} (${m.contractType}) from ${m.principalAgentId?.slice(0, 8)}... — ${JSON.stringify(m.criteria).slice(0, 100)}`,
271
+ )
272
+ .join('\n');
228
273
  text += '\n\n→ Call accept_mandate with the mandate ID to accept.';
229
274
  }
230
275
 
231
276
  if (allActive.length > 0) {
232
- text += `\n\n⚡ ${allActive.length} ACTIVE mandate(s) need receipts:`;
277
+ text += `\n\n ${allActive.length} ACTIVE mandate(s) need receipts:`;
233
278
  for (const m of allActive.slice(0, 5)) {
234
- text += `\n • ${m.id} (${(m as any).contractType})`;
279
+ text += `\n • ${m.id} (${(m as any).contractType})`;
235
280
  }
236
281
  text += '\n→ Call submit_receipt with evidence of completed work!';
237
282
  }
238
283
 
239
284
  if (allVerified.length > 0) {
240
- text += `\n\n⚡ ${allVerified.length} mandate(s) ready to settle:`;
285
+ text += `\n\n ${allVerified.length} mandate(s) ready to settle:`;
241
286
  for (const m of allVerified.slice(0, 5)) {
242
- text += `\n • ${m.id} (${(m as any).contractType})`;
287
+ text += `\n • ${m.id} (${(m as any).contractType})`;
243
288
  }
244
289
  text += '\n→ These should auto-settle soon, or call settle_mandate to close manually.';
245
290
  }
246
291
 
247
292
  return {
248
293
  content: [{ type: 'text', text }],
249
- structuredContent: { proposals: allProposals, active: allActive, verified: allVerified } as unknown as Record<string, unknown>,
294
+ structuredContent: {
295
+ proposals: allProposals,
296
+ active: allActive,
297
+ verified: allVerified,
298
+ } as unknown as Record<string, unknown>,
250
299
  };
251
300
  } catch (err) {
252
301
  return apiErrorResult(err);
@@ -254,14 +303,12 @@ export function registerA2aTools(mcp: McpServer, client: AgledgerClient, config:
254
303
  },
255
304
  );
256
305
 
257
- // ═══════════════════════════════════════════════════════════
258
- // 4. submit_receipt — Submit evidence of completed work
259
- // ═══════════════════════════════════════════════════════════
260
306
  mcp.registerTool(
261
307
  'submit_receipt',
262
308
  {
263
309
  title: 'Submit Receipt',
264
- description: 'Submit evidence of completed work. REQUIRED to close the accountability loop. Evidence: {"deliverable": "result", "deliverable_type": "report"} for most types. PROC needs item_secured/quantity/total_cost/supplier/confirmation_ref.',
310
+ description:
311
+ 'Submit evidence of completed work. REQUIRED to close the accountability loop. Evidence: {"deliverable": "result", "deliverable_type": "report"} for most types. PROC needs item_secured/quantity/total_cost/supplier/confirmation_ref.',
265
312
  inputSchema: {
266
313
  mandateId: z.string().describe('Mandate ID'),
267
314
  agentId: z.string().describe('Your agent ID'),
@@ -285,18 +332,20 @@ export function registerA2aTools(mcp: McpServer, client: AgledgerClient, config:
285
332
  try {
286
333
  const mandate = await client.mandates.get(mandateId);
287
334
  mandateStatus = mandate.status;
288
- } catch { /* best effort */ }
335
+ } catch {
336
+ /* best effort */
337
+ }
289
338
 
290
- let text = `✓ Receipt ${receipt.id} submitted for mandate ${mandateId}. Validation: ${receipt.structuralValidation}.`;
339
+ let text = `Receipt ${receipt.id} submitted for mandate ${mandateId}. Validation: ${receipt.structuralValidation}.`;
291
340
  if (mandateStatus) {
292
- text += ` Mandate is now: ${mandateStatus}.`;
341
+ text += `Mandate is now: ${mandateStatus}.`;
293
342
  }
294
343
  if (mandateStatus === 'FULFILLED') {
295
- text += `\n\n✅ Mandate auto-settled to FULFILLED! Accountability loop closed.`;
344
+ text += `\n\nMandate auto-settled to FULFILLED! Accountability loop closed.`;
296
345
  } else if (mandateStatus === 'PROCESSING' || mandateStatus === 'PROCESSING') {
297
- text += `\n\n⚡ Call settle_mandate("${mandateId}") to close this mandate (or wait for auto-settle).`;
346
+ text += `\n\nCall settle_mandate("${mandateId}") to close this mandate (or wait for auto-settle).`;
298
347
  } else if (mandateStatus === 'ACTIVE') {
299
- text += ` Evidence is being verified.`;
348
+ text += `Evidence is being verified.`;
300
349
  }
301
350
 
302
351
  return {
@@ -309,14 +358,12 @@ export function registerA2aTools(mcp: McpServer, client: AgledgerClient, config:
309
358
  },
310
359
  );
311
360
 
312
- // ═══════════════════════════════════════════════════════════
313
- // 5. settle_mandate — Close a mandate (final step)
314
- // ═══════════════════════════════════════════════════════════
315
361
  mcp.registerTool(
316
362
  'settle_mandate',
317
363
  {
318
364
  title: 'Settle Mandate',
319
- description: 'Settle a mandate manually. Usually auto-settles — use only if stuck in PROCESSING.',
365
+ description:
366
+ 'Settle a mandate manually. Usually auto-settles — use only if stuck in PROCESSING.',
320
367
  inputSchema: {
321
368
  mandateId: z.string().describe('Mandate ID'),
322
369
  reason: z.string().optional().describe('Settlement reason'),
@@ -334,7 +381,12 @@ export function registerA2aTools(mcp: McpServer, client: AgledgerClient, config:
334
381
  try {
335
382
  const mandate = await client.mandates.transition(args.mandateId, 'settle', args.reason);
336
383
  return {
337
- content: [{ type: 'text', text: `✓ Mandate ${mandate.id} settled. Status: ${mandate.status}. Accountability loop closed.` }],
384
+ content: [
385
+ {
386
+ type: 'text',
387
+ text: `Mandate ${mandate.id} settled. Status: ${mandate.status}. Accountability loop closed.`,
388
+ },
389
+ ],
338
390
  structuredContent: mandate as unknown as Record<string, unknown>,
339
391
  };
340
392
  } catch (err) {
@@ -343,9 +395,6 @@ export function registerA2aTools(mcp: McpServer, client: AgledgerClient, config:
343
395
  },
344
396
  );
345
397
 
346
- // ═══════════════════════════════════════════════════════════
347
- // 6. get_mandate — Check a mandate's status
348
- // ═══════════════════════════════════════════════════════════
349
398
  mcp.registerTool(
350
399
  'get_mandate',
351
400
  {
@@ -367,9 +416,11 @@ export function registerA2aTools(mcp: McpServer, client: AgledgerClient, config:
367
416
  try {
368
417
  const mandate = await client.mandates.get(args.mandateId);
369
418
  let text = `Mandate ${mandate.id}: ${mandate.contractType}, status=${mandate.status}`;
370
- if (mandate.status === 'ACTIVE') text += '\n⚡ This mandate needs a receipt — call submit_receipt!';
371
- if (mandate.status === 'PROCESSING') text += '\n⚡ Should auto-settle to FULFILLED soon. Call settle_mandate if stuck.';
372
- if (mandate.status === 'FULFILLED') text += '\n✅ Accountability loop closed.';
419
+ if (mandate.status === 'ACTIVE')
420
+ text += '\n This mandate needs a receipt — call submit_receipt!';
421
+ if (mandate.status === 'PROCESSING')
422
+ text += '\n Should auto-settle to FULFILLED soon. Call settle_mandate if stuck.';
423
+ if (mandate.status === 'FULFILLED') text += '\n Accountability loop closed.';
373
424
  return {
374
425
  content: [{ type: 'text', text }],
375
426
  structuredContent: mandate as unknown as Record<string, unknown>,
@@ -380,9 +431,6 @@ export function registerA2aTools(mcp: McpServer, client: AgledgerClient, config:
380
431
  },
381
432
  );
382
433
 
383
- // ═══════════════════════════════════════════════════════════
384
- // 7. reject_mandate — Decline a proposed mandate
385
- // ═══════════════════════════════════════════════════════════
386
434
  mcp.registerTool(
387
435
  'reject_mandate',
388
436
  {
@@ -405,7 +453,9 @@ export function registerA2aTools(mcp: McpServer, client: AgledgerClient, config:
405
453
  try {
406
454
  const mandate = await client.mandates.reject(args.mandateId, args.reason);
407
455
  return {
408
- content: [{ type: 'text', text: `Mandate ${mandate.id} rejected. Reason: ${args.reason}` }],
456
+ content: [
457
+ { type: 'text', text: `Mandate ${mandate.id} rejected. Reason: ${args.reason}` },
458
+ ],
409
459
  structuredContent: mandate as unknown as Record<string, unknown>,
410
460
  };
411
461
  } catch (err) {
@@ -414,9 +464,6 @@ export function registerA2aTools(mcp: McpServer, client: AgledgerClient, config:
414
464
  },
415
465
  );
416
466
 
417
- // ═══════════════════════════════════════════════════════════
418
- // 8. my_mandates — See all mandates I'm involved in
419
- // ═══════════════════════════════════════════════════════════
420
467
  mcp.registerTool(
421
468
  'my_mandates',
422
469
  {
@@ -460,16 +507,16 @@ export function registerA2aTools(mcp: McpServer, client: AgledgerClient, config:
460
507
  byStatus[s].push(m);
461
508
  }
462
509
 
463
- let text = `📊 ${filtered.length} mandate(s) total:`;
510
+ let text = ` ${filtered.length} mandate(s) total:`;
464
511
  for (const [status, mandates] of Object.entries(byStatus)) {
465
- text += `\n ${status}: ${mandates.length}`;
466
- if (status === 'ACTIVE') text += ' ⚡ need receipts!';
467
- if (status === 'PROCESSING') text += ' ⚡ ready to settle!';
512
+ text += `\n ${status}: ${mandates.length}`;
513
+ if (status === 'ACTIVE') text += ' need receipts!';
514
+ if (status === 'PROCESSING') text += ' ready to settle!';
468
515
  if (status === 'PROPOSED') text += ' — awaiting response';
469
516
  for (const m of mandates.slice(0, 3)) {
470
- text += `\n • ${m.id.slice(0, 8)}... (${m.contractType})`;
517
+ text += `\n • ${m.id.slice(0, 8)}... (${m.contractType})`;
471
518
  }
472
- if (mandates.length > 3) text += `\n ... and ${mandates.length - 3} more`;
519
+ if (mandates.length > 3) text += `\n ... and ${mandates.length - 3} more`;
473
520
  }
474
521
 
475
522
  return {
@@ -482,9 +529,6 @@ export function registerA2aTools(mcp: McpServer, client: AgledgerClient, config:
482
529
  },
483
530
  );
484
531
 
485
- // ═══════════════════════════════════════════════════════════
486
- // 9. cancel_mandate — Cancel a mandate with reason
487
- // ═══════════════════════════════════════════════════════════
488
532
  mcp.registerTool(
489
533
  'cancel_mandate',
490
534
  {
@@ -507,7 +551,9 @@ export function registerA2aTools(mcp: McpServer, client: AgledgerClient, config:
507
551
  try {
508
552
  const mandate = await client.mandates.cancel(args.mandateId, args.reason);
509
553
  return {
510
- content: [{ type: 'text', text: `Mandate ${mandate.id} cancelled. Reason: ${args.reason}` }],
554
+ content: [
555
+ { type: 'text', text: `Mandate ${mandate.id} cancelled. Reason: ${args.reason}` },
556
+ ],
511
557
  structuredContent: mandate as unknown as Record<string, unknown>,
512
558
  };
513
559
  } catch (err) {
@@ -516,14 +562,11 @@ export function registerA2aTools(mcp: McpServer, client: AgledgerClient, config:
516
562
  },
517
563
  );
518
564
 
519
- // ═══════════════════════════════════════════════════════════
520
- // 10. check_reputation — See an agent's track record
521
- // ═══════════════════════════════════════════════════════════
522
565
  mcp.registerTool(
523
566
  'check_reputation',
524
567
  {
525
568
  title: 'Check Reputation',
526
- description: 'Check an agent\'s reputation score and fulfillment history.',
569
+ description: "Check an agent's reputation score and fulfillment history.",
527
570
  inputSchema: {
528
571
  agentId: z.string().describe('Agent ID'),
529
572
  },
@@ -540,7 +583,9 @@ export function registerA2aTools(mcp: McpServer, client: AgledgerClient, config:
540
583
  try {
541
584
  const rep = await client.reputation.getAgent(args.agentId);
542
585
  return {
543
- content: [{ type: 'text', text: `Agent ${args.agentId} reputation: ${JSON.stringify(rep)}` }],
586
+ content: [
587
+ { type: 'text', text: `Agent ${args.agentId} reputation: ${JSON.stringify(rep)}` },
588
+ ],
544
589
  structuredContent: rep as unknown as Record<string, unknown>,
545
590
  };
546
591
  } catch (err) {
@@ -1,5 +1,3 @@
1
- /** AGLedger™ — Agent-to-agent mandate MCP tools. Patent Pending. Copyright 2026 AGLedger LLC. All rights reserved. */
2
-
3
1
  import { z } from 'zod';
4
2
  import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
5
3
  import type { AgledgerClient } from '@agledger/sdk';
@@ -36,7 +34,6 @@ const PageOutputSchema = z.object({
36
34
  }).describe('Paginated mandate results');
37
35
 
38
36
  export function registerAgentMandateTools(mcp: McpServer, client: AgledgerClient): void {
39
- // --- propose_agent_mandate ---
40
37
  mcp.registerTool(
41
38
  'propose_agent_mandate',
42
39
  {
@@ -76,7 +73,6 @@ export function registerAgentMandateTools(mcp: McpServer, client: AgledgerClient
76
73
  },
77
74
  );
78
75
 
79
- // --- accept_proposal ---
80
76
  mcp.registerTool(
81
77
  'accept_proposal',
82
78
  {
@@ -107,7 +103,6 @@ export function registerAgentMandateTools(mcp: McpServer, client: AgledgerClient
107
103
  },
108
104
  );
109
105
 
110
- // --- reject_proposal ---
111
106
  mcp.registerTool(
112
107
  'reject_proposal',
113
108
  {
@@ -139,7 +134,6 @@ export function registerAgentMandateTools(mcp: McpServer, client: AgledgerClient
139
134
  },
140
135
  );
141
136
 
142
- // --- counter_proposal ---
143
137
  mcp.registerTool(
144
138
  'counter_proposal',
145
139
  {
@@ -181,7 +175,6 @@ export function registerAgentMandateTools(mcp: McpServer, client: AgledgerClient
181
175
  },
182
176
  );
183
177
 
184
- // --- accept_counter_proposal ---
185
178
  mcp.registerTool(
186
179
  'accept_counter_proposal',
187
180
  {
@@ -212,7 +205,6 @@ export function registerAgentMandateTools(mcp: McpServer, client: AgledgerClient
212
205
  },
213
206
  );
214
207
 
215
- // --- list_my_proposals ---
216
208
  mcp.registerTool(
217
209
  'list_my_proposals',
218
210
  {
@@ -241,7 +233,6 @@ export function registerAgentMandateTools(mcp: McpServer, client: AgledgerClient
241
233
  },
242
234
  );
243
235
 
244
- // --- list_principal_mandates ---
245
236
  mcp.registerTool(
246
237
  'list_principal_mandates',
247
238
  {
@@ -270,7 +261,6 @@ export function registerAgentMandateTools(mcp: McpServer, client: AgledgerClient
270
261
  },
271
262
  );
272
263
 
273
- // --- get_delegation_chain ---
274
264
  mcp.registerTool(
275
265
  'get_delegation_chain',
276
266
  {
@@ -303,7 +293,6 @@ export function registerAgentMandateTools(mcp: McpServer, client: AgledgerClient
303
293
  },
304
294
  );
305
295
 
306
- // --- get_sub_mandates ---
307
296
  mcp.registerTool(
308
297
  'get_sub_mandates',
309
298
  {
@@ -1,5 +1,3 @@
1
- /** AGLedger™ — Agents & References MCP tools. Patent Pending. Copyright 2026 AGLedger LLC. All rights reserved. */
2
-
3
1
  import { z } from 'zod';
4
2
  import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
5
3
  import type { AgledgerClient } from '@agledger/sdk';
@@ -34,7 +32,6 @@ const LookupOutputSchema = z.object({
34
32
  }).describe('Reverse lookup result mapping an external reference to an AGLedger entity');
35
33
 
36
34
  export function registerAgentsRefsTools(mcp: McpServer, client: AgledgerClient): void {
37
- // --- get_agent ---
38
35
  mcp.registerTool(
39
36
  'get_agent',
40
37
  {
@@ -67,7 +64,6 @@ export function registerAgentsRefsTools(mcp: McpServer, client: AgledgerClient):
67
64
  },
68
65
  );
69
66
 
70
- // --- update_agent ---
71
67
  mcp.registerTool(
72
68
  'update_agent',
73
69
  {
@@ -110,7 +106,6 @@ export function registerAgentsRefsTools(mcp: McpServer, client: AgledgerClient):
110
106
  },
111
107
  );
112
108
 
113
- // --- add_agent_references ---
114
109
  mcp.registerTool(
115
110
  'add_agent_references',
116
111
  {
@@ -150,7 +145,6 @@ export function registerAgentsRefsTools(mcp: McpServer, client: AgledgerClient):
150
145
  },
151
146
  );
152
147
 
153
- // --- get_agent_references ---
154
148
  mcp.registerTool(
155
149
  'get_agent_references',
156
150
  {
@@ -184,7 +178,6 @@ export function registerAgentsRefsTools(mcp: McpServer, client: AgledgerClient):
184
178
  },
185
179
  );
186
180
 
187
- // --- lookup_reference ---
188
181
  mcp.registerTool(
189
182
  'lookup_reference',
190
183
  {
@@ -220,7 +213,6 @@ export function registerAgentsRefsTools(mcp: McpServer, client: AgledgerClient):
220
213
  },
221
214
  );
222
215
 
223
- // --- add_mandate_references ---
224
216
  mcp.registerTool(
225
217
  'add_mandate_references',
226
218
  {
@@ -260,7 +252,6 @@ export function registerAgentsRefsTools(mcp: McpServer, client: AgledgerClient):
260
252
  },
261
253
  );
262
254
 
263
- // --- get_mandate_references ---
264
255
  mcp.registerTool(
265
256
  'get_mandate_references',
266
257
  {
@@ -1,5 +1,3 @@
1
- /** AGLedger™ — Capability MCP tools (get, declare). Patent Pending. Copyright 2026 AGLedger LLC. All rights reserved. */
2
-
3
1
  import { z } from 'zod';
4
2
  import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
5
3
  import type { AgledgerClient } from '@agledger/sdk';
@@ -13,7 +11,6 @@ const CapabilitiesOutputSchema = z.object({
13
11
  }).describe('Agent capabilities');
14
12
 
15
13
  export function registerCapabilityTools(mcp: McpServer, client: AgledgerClient): void {
16
- // --- get_agent_capabilities ---
17
14
  mcp.registerTool(
18
15
  'get_agent_capabilities',
19
16
  {
@@ -44,7 +41,6 @@ export function registerCapabilityTools(mcp: McpServer, client: AgledgerClient):
44
41
  },
45
42
  );
46
43
 
47
- // --- declare_capabilities ---
48
44
  mcp.registerTool(
49
45
  'declare_capabilities',
50
46
  {