@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.
- package/dist/enums.d.ts +6 -4
- package/dist/enums.d.ts.map +1 -1
- package/dist/enums.js +2 -2
- package/dist/enums.js.map +1 -1
- package/dist/errors.d.ts +0 -1
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +0 -1
- package/dist/errors.js.map +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -1
- package/dist/index.js.map +1 -1
- package/dist/resources/contract-types.d.ts +0 -1
- package/dist/resources/contract-types.d.ts.map +1 -1
- package/dist/resources/contract-types.js +0 -3
- package/dist/resources/contract-types.js.map +1 -1
- package/dist/server.d.ts +0 -1
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +0 -1
- package/dist/server.js.map +1 -1
- package/dist/tool-scopes.d.ts +0 -12
- package/dist/tool-scopes.d.ts.map +1 -1
- package/dist/tool-scopes.js +19 -31
- package/dist/tool-scopes.js.map +1 -1
- package/dist/tools/a2a.d.ts +0 -1
- package/dist/tools/a2a.d.ts.map +1 -1
- package/dist/tools/a2a.js +96 -75
- package/dist/tools/a2a.js.map +1 -1
- package/dist/tools/agent-mandates.d.ts +0 -1
- package/dist/tools/agent-mandates.d.ts.map +1 -1
- package/dist/tools/agent-mandates.js +0 -10
- package/dist/tools/agent-mandates.js.map +1 -1
- package/dist/tools/agents-refs.d.ts +0 -1
- package/dist/tools/agents-refs.d.ts.map +1 -1
- package/dist/tools/agents-refs.js +0 -8
- package/dist/tools/agents-refs.js.map +1 -1
- package/dist/tools/capabilities.d.ts +0 -1
- package/dist/tools/capabilities.d.ts.map +1 -1
- package/dist/tools/capabilities.js +0 -3
- package/dist/tools/capabilities.js.map +1 -1
- package/dist/tools/code-mode.d.ts +0 -1
- package/dist/tools/code-mode.d.ts.map +1 -1
- package/dist/tools/code-mode.js +0 -9
- package/dist/tools/code-mode.js.map +1 -1
- package/dist/tools/compliance.d.ts +0 -1
- package/dist/tools/compliance.d.ts.map +1 -1
- package/dist/tools/compliance.js +0 -1
- package/dist/tools/compliance.js.map +1 -1
- package/dist/tools/dashboard.d.ts +0 -1
- package/dist/tools/dashboard.d.ts.map +1 -1
- package/dist/tools/dashboard.js +0 -1
- package/dist/tools/dashboard.js.map +1 -1
- package/dist/tools/disputes.d.ts +0 -1
- package/dist/tools/disputes.d.ts.map +1 -1
- package/dist/tools/disputes.js +0 -5
- package/dist/tools/disputes.js.map +1 -1
- package/dist/tools/enterprises.d.ts +0 -1
- package/dist/tools/enterprises.d.ts.map +1 -1
- package/dist/tools/enterprises.js +0 -7
- package/dist/tools/enterprises.js.map +1 -1
- package/dist/tools/events.d.ts +0 -1
- package/dist/tools/events.d.ts.map +1 -1
- package/dist/tools/events.js +0 -2
- package/dist/tools/events.js.map +1 -1
- package/dist/tools/federation-admin.d.ts +0 -1
- package/dist/tools/federation-admin.d.ts.map +1 -1
- package/dist/tools/federation-admin.js +0 -25
- package/dist/tools/federation-admin.js.map +1 -1
- package/dist/tools/federation.d.ts +0 -1
- package/dist/tools/federation.d.ts.map +1 -1
- package/dist/tools/federation.js +0 -21
- package/dist/tools/federation.js.map +1 -1
- package/dist/tools/health.d.ts +0 -1
- package/dist/tools/health.d.ts.map +1 -1
- package/dist/tools/health.js +0 -2
- package/dist/tools/health.js.map +1 -1
- package/dist/tools/mandates.d.ts +0 -1
- package/dist/tools/mandates.d.ts.map +1 -1
- package/dist/tools/mandates.js +0 -11
- package/dist/tools/mandates.js.map +1 -1
- package/dist/tools/openclaw.d.ts +0 -5
- package/dist/tools/openclaw.d.ts.map +1 -1
- package/dist/tools/openclaw.js +0 -5
- package/dist/tools/openclaw.js.map +1 -1
- package/dist/tools/receipts.d.ts +0 -1
- package/dist/tools/receipts.d.ts.map +1 -1
- package/dist/tools/receipts.js +59 -24
- package/dist/tools/receipts.js.map +1 -1
- package/dist/tools/reputation.d.ts +0 -1
- package/dist/tools/reputation.d.ts.map +1 -1
- package/dist/tools/reputation.js +0 -1
- package/dist/tools/reputation.js.map +1 -1
- package/dist/tools/schemas.d.ts +0 -1
- package/dist/tools/schemas.d.ts.map +1 -1
- package/dist/tools/schemas.js +0 -17
- package/dist/tools/schemas.js.map +1 -1
- package/dist/tools/verification-keys.d.ts +0 -1
- package/dist/tools/verification-keys.d.ts.map +1 -1
- package/dist/tools/verification-keys.js +0 -1
- package/dist/tools/verification-keys.js.map +1 -1
- package/dist/tools/verification.d.ts +0 -1
- package/dist/tools/verification.d.ts.map +1 -1
- package/dist/tools/verification.js +2 -4
- package/dist/tools/verification.js.map +1 -1
- package/package.json +2 -2
- package/src/enums.ts +2 -3
- package/src/errors.ts +0 -2
- package/src/index.ts +0 -2
- package/src/resources/contract-types.ts +0 -4
- package/src/server.ts +0 -2
- package/src/tool-scopes.ts +19 -32
- package/src/tools/a2a.ts +158 -113
- package/src/tools/agent-mandates.ts +0 -11
- package/src/tools/agents-refs.ts +0 -9
- package/src/tools/capabilities.ts +0 -4
- package/src/tools/code-mode.ts +0 -12
- package/src/tools/compliance.ts +0 -2
- package/src/tools/dashboard.ts +0 -2
- package/src/tools/disputes.ts +0 -6
- package/src/tools/enterprises.ts +0 -8
- package/src/tools/events.ts +0 -3
- package/src/tools/federation-admin.ts +0 -26
- package/src/tools/federation.ts +0 -22
- package/src/tools/health.ts +0 -3
- package/src/tools/mandates.ts +0 -12
- package/src/tools/openclaw.ts +0 -6
- package/src/tools/receipts.ts +82 -46
- package/src/tools/reputation.ts +0 -2
- package/src/tools/schemas.ts +0 -18
- package/src/tools/verification-keys.ts +0 -2
- 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
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
})
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
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(
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
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:
|
|
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
|
|
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(
|
|
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(
|
|
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 {
|
|
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: [
|
|
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:
|
|
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 {
|
|
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':
|
|
152
|
-
|
|
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':
|
|
156
|
-
|
|
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 =
|
|
197
|
+
const template =
|
|
198
|
+
evidenceTemplates[ct] || '{"deliverable": "work result", "deliverable_type": "report"}';
|
|
165
199
|
|
|
166
200
|
return {
|
|
167
|
-
content: [
|
|
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(
|
|
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(
|
|
258
|
+
allVerified = allVerified.filter(
|
|
259
|
+
(m: any) => m.agentId === id || m.principalAgentId === id,
|
|
260
|
+
);
|
|
221
261
|
}
|
|
222
262
|
|
|
223
|
-
let text =
|
|
263
|
+
let text = ` ${allProposals.length} pending proposal(s)`;
|
|
224
264
|
if (allProposals.length > 0) {
|
|
225
|
-
text +=
|
|
226
|
-
|
|
227
|
-
|
|
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
|
|
277
|
+
text += `\n\n ${allActive.length} ACTIVE mandate(s) need receipts:`;
|
|
233
278
|
for (const m of allActive.slice(0, 5)) {
|
|
234
|
-
text += `\n
|
|
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
|
|
285
|
+
text += `\n\n ${allVerified.length} mandate(s) ready to settle:`;
|
|
241
286
|
for (const m of allVerified.slice(0, 5)) {
|
|
242
|
-
text += `\n
|
|
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: {
|
|
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:
|
|
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 {
|
|
335
|
+
} catch {
|
|
336
|
+
/* best effort */
|
|
337
|
+
}
|
|
289
338
|
|
|
290
|
-
let text =
|
|
339
|
+
let text = `Receipt ${receipt.id} submitted for mandate ${mandateId}. Validation: ${receipt.structuralValidation}.`;
|
|
291
340
|
if (mandateStatus) {
|
|
292
|
-
text += `
|
|
341
|
+
text += `Mandate is now: ${mandateStatus}.`;
|
|
293
342
|
}
|
|
294
343
|
if (mandateStatus === 'FULFILLED') {
|
|
295
|
-
text += `\n\
|
|
344
|
+
text += `\n\nMandate auto-settled to FULFILLED! Accountability loop closed.`;
|
|
296
345
|
} else if (mandateStatus === 'PROCESSING' || mandateStatus === 'PROCESSING') {
|
|
297
|
-
text += `\n\
|
|
346
|
+
text += `\n\nCall settle_mandate("${mandateId}") to close this mandate (or wait for auto-settle).`;
|
|
298
347
|
} else if (mandateStatus === 'ACTIVE') {
|
|
299
|
-
text += `
|
|
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:
|
|
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: [
|
|
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')
|
|
371
|
-
|
|
372
|
-
if (mandate.status === '
|
|
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: [
|
|
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 =
|
|
510
|
+
let text = ` ${filtered.length} mandate(s) total:`;
|
|
464
511
|
for (const [status, mandates] of Object.entries(byStatus)) {
|
|
465
|
-
text += `\n
|
|
466
|
-
if (status === 'ACTIVE') text += '
|
|
467
|
-
if (status === 'PROCESSING') text += '
|
|
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
|
|
517
|
+
text += `\n • ${m.id.slice(0, 8)}... (${m.contractType})`;
|
|
471
518
|
}
|
|
472
|
-
if (mandates.length > 3) text += `\n
|
|
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: [
|
|
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:
|
|
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: [
|
|
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
|
{
|
package/src/tools/agents-refs.ts
CHANGED
|
@@ -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
|
{
|