@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.
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -2
- package/dist/index.js.map +1 -1
- package/dist/server.d.ts +2 -2
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +1 -3
- package/dist/server.js.map +1 -1
- package/dist/tool-scopes.d.ts.map +1 -1
- package/dist/tool-scopes.js +0 -3
- package/dist/tool-scopes.js.map +1 -1
- package/dist/tools/a2a.d.ts.map +1 -1
- package/dist/tools/a2a.js +20 -220
- package/dist/tools/a2a.js.map +1 -1
- package/dist/tools/agent-mandates.d.ts.map +1 -1
- package/dist/tools/agent-mandates.js +10 -74
- package/dist/tools/agent-mandates.js.map +1 -1
- package/dist/tools/agents-refs.d.ts.map +1 -1
- package/dist/tools/agents-refs.js +9 -61
- package/dist/tools/agents-refs.js.map +1 -1
- package/dist/tools/capabilities.d.ts.map +1 -1
- package/dist/tools/capabilities.js +2 -14
- package/dist/tools/capabilities.js.map +1 -1
- package/dist/tools/code-mode.d.ts.map +1 -1
- package/dist/tools/code-mode.js +4 -35
- package/dist/tools/code-mode.js.map +1 -1
- package/dist/tools/compliance.d.ts.map +1 -1
- package/dist/tools/compliance.js +3 -37
- package/dist/tools/compliance.js.map +1 -1
- package/dist/tools/dashboard.d.ts.map +1 -1
- package/dist/tools/dashboard.js +3 -37
- package/dist/tools/dashboard.js.map +1 -1
- package/dist/tools/disputes.d.ts.map +1 -1
- package/dist/tools/disputes.js +4 -41
- package/dist/tools/disputes.js.map +1 -1
- package/dist/tools/enterprises.d.ts.map +1 -1
- package/dist/tools/enterprises.js +6 -62
- package/dist/tools/enterprises.js.map +1 -1
- package/dist/tools/events.d.ts.map +1 -1
- package/dist/tools/events.js +1 -19
- package/dist/tools/events.js.map +1 -1
- package/dist/tools/federation-admin.d.ts.map +1 -1
- package/dist/tools/federation-admin.js +24 -256
- package/dist/tools/federation-admin.js.map +1 -1
- package/dist/tools/federation.d.ts.map +1 -1
- package/dist/tools/federation.js +20 -197
- package/dist/tools/federation.js.map +1 -1
- package/dist/tools/health.d.ts.map +1 -1
- package/dist/tools/health.js +1 -13
- package/dist/tools/health.js.map +1 -1
- package/dist/tools/mandates.d.ts.map +1 -1
- package/dist/tools/mandates.js +10 -93
- package/dist/tools/mandates.js.map +1 -1
- package/dist/tools/openclaw.d.ts.map +1 -1
- package/dist/tools/openclaw.js +5 -32
- package/dist/tools/openclaw.js.map +1 -1
- package/dist/tools/receipts.d.ts.map +1 -1
- package/dist/tools/receipts.js +4 -94
- package/dist/tools/receipts.js.map +1 -1
- package/dist/tools/reputation.d.ts.map +1 -1
- package/dist/tools/reputation.js +3 -33
- package/dist/tools/reputation.js.map +1 -1
- package/dist/tools/schemas.d.ts.map +1 -1
- package/dist/tools/schemas.js +16 -186
- package/dist/tools/schemas.js.map +1 -1
- package/dist/tools/verification-keys.d.ts.map +1 -1
- package/dist/tools/verification-keys.js +1 -22
- package/dist/tools/verification-keys.js.map +1 -1
- package/dist/tools/verification.d.ts.map +1 -1
- package/dist/tools/verification.js +2 -27
- package/dist/tools/verification.js.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +1 -3
- package/src/server.ts +3 -5
- package/src/tool-scopes.ts +0 -4
- package/src/tools/a2a.ts +20 -233
- package/src/tools/agent-mandates.ts +10 -76
- package/src/tools/agents-refs.ts +9 -65
- package/src/tools/capabilities.ts +2 -15
- package/src/tools/compliance.ts +3 -37
- package/src/tools/dashboard.ts +3 -37
- package/src/tools/disputes.ts +4 -42
- package/src/tools/enterprises.ts +6 -62
- package/src/tools/events.ts +1 -20
- package/src/tools/federation-admin.ts +24 -281
- package/src/tools/federation.ts +20 -217
- package/src/tools/health.ts +1 -14
- package/src/tools/mandates.ts +10 -95
- package/src/tools/openclaw.ts +5 -51
- package/src/tools/receipts.ts +4 -95
- package/src/tools/reputation.ts +3 -34
- package/src/tools/schemas.ts +16 -194
- package/src/tools/verification-keys.ts +1 -24
- package/src/tools/verification.ts +2 -29
- package/tests/conformance.test.ts +4 -26
- package/tests/conformance.ts +3 -13
- package/tests/profiles.test.ts +2 -17
- package/tests/tools/a2a.test.ts +0 -28
- package/tests/tools/agent-mandates.test.ts +0 -10
- package/tests/tools/agents-refs.test.ts +0 -9
- package/tests/tools/capabilities.test.ts +0 -6
- package/tests/tools/compliance.test.ts +0 -8
- package/tests/tools/dashboard.test.ts +0 -9
- package/tests/tools/disputes.test.ts +0 -8
- package/tests/tools/enterprises.test.ts +0 -10
- package/tests/tools/events.test.ts +0 -5
- package/tests/tools/federation-admin.test.ts +0 -41
- package/tests/tools/federation.test.ts +0 -34
- package/tests/tools/health.test.ts +1 -12
- package/tests/tools/mandates.test.ts +0 -12
- package/tests/tools/openclaw.test.ts +0 -12
- package/tests/tools/receipts.test.ts +1 -14
- package/tests/tools/reputation.test.ts +0 -9
- package/tests/tools/schemas.test.ts +0 -23
- package/tests/tools/verification-keys.test.ts +0 -6
- package/tests/tools/verification.test.ts +1 -11
- package/src/tools/code-mode.ts +0 -461
- package/tests/drift/code-mode-manifest.test.ts +0 -144
- package/tests/integration/output-schema-validation.test.ts +0 -167
- package/tests/tools/code-mode.test.ts +0 -168
package/src/tools/mandates.ts
CHANGED
|
@@ -2,47 +2,9 @@ import { z } from 'zod';
|
|
|
2
2
|
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
3
3
|
import type { AgledgerClient } from '@agledger/sdk';
|
|
4
4
|
import { apiErrorResult, toStructuredContent } from '../errors.js';
|
|
5
|
-
import { ContractTypeEnum, MandateStatusEnum
|
|
5
|
+
import { ContractTypeEnum, MandateStatusEnum } from '../enums.js';
|
|
6
6
|
import { toolMeta } from '../tool-scopes.js';
|
|
7
7
|
|
|
8
|
-
const MandateOutputSchema = z.object({
|
|
9
|
-
id: z.string().describe('Mandate UUID'),
|
|
10
|
-
enterpriseId: z.string().describe('Enterprise that owns this mandate'),
|
|
11
|
-
agentId: z.string().nullable().optional().describe('Assigned agent ID'),
|
|
12
|
-
contractType: ContractTypeEnum,
|
|
13
|
-
contractVersion: z.string().describe('Contract version string'),
|
|
14
|
-
platform: z.string().describe('Platform identifier'),
|
|
15
|
-
platformRef: z.string().nullable().optional().describe('Platform-specific reference'),
|
|
16
|
-
status: MandateStatusEnum,
|
|
17
|
-
criteria: z.record(z.string(), z.unknown()).describe('Acceptance criteria object'),
|
|
18
|
-
tolerance: z.record(z.string(), z.unknown()).nullable().optional().describe('Tolerance bands'),
|
|
19
|
-
deadline: z.string().nullable().optional().describe('ISO 8601 deadline'),
|
|
20
|
-
commissionPct: z.number().nullable().optional().describe('Commission percentage'),
|
|
21
|
-
operatingMode: OperatingModeEnum.nullable().optional(),
|
|
22
|
-
verificationMode: z.enum(['auto', 'principal', 'gated']).nullable().optional().describe('Verification mode'),
|
|
23
|
-
riskClassification: RiskClassificationEnum.nullable().optional(),
|
|
24
|
-
euAiActDomain: z.string().nullable().optional().describe('EU AI Act domain'),
|
|
25
|
-
humanOversight: z.record(z.string(), z.unknown()).nullable().optional().describe('Human oversight configuration'),
|
|
26
|
-
parentMandateId: z.string().nullable().optional().describe('Parent mandate ID for delegation chains'),
|
|
27
|
-
rootMandateId: z.string().nullable().optional().describe('Root mandate ID in delegation chain'),
|
|
28
|
-
chainDepth: z.number().nullable().optional().describe('Depth in delegation chain'),
|
|
29
|
-
version: z.number().describe('Optimistic concurrency version'),
|
|
30
|
-
createdAt: z.string().describe('ISO 8601 creation timestamp'),
|
|
31
|
-
updatedAt: z.string().describe('ISO 8601 last update timestamp'),
|
|
32
|
-
activatedAt: z.string().nullable().optional().describe('ISO 8601 activation timestamp'),
|
|
33
|
-
fulfilledAt: z.string().nullable().optional().describe('ISO 8601 fulfillment timestamp'),
|
|
34
|
-
lastVerdictReason: z.string().nullable().optional().describe('Reason from the most recent principal verdict'),
|
|
35
|
-
lastVerdictAt: z.string().nullable().optional().describe('ISO 8601 timestamp of the most recent verdict'),
|
|
36
|
-
nextSteps: NextStepsField,
|
|
37
|
-
}).passthrough().describe('AGLedger mandate object');
|
|
38
|
-
|
|
39
|
-
const SearchResultOutputSchema = z.object({
|
|
40
|
-
data: z.array(MandateOutputSchema).describe('Array of matching mandates'),
|
|
41
|
-
total: z.number().optional().describe('Total count of matching mandates'),
|
|
42
|
-
limit: z.number().optional().describe('Page size'),
|
|
43
|
-
offset: z.number().optional().describe('Page offset'),
|
|
44
|
-
}).passthrough().describe('Paginated mandate search results');
|
|
45
|
-
|
|
46
8
|
export function registerMandateTools(mcp: McpServer, client: AgledgerClient): void {
|
|
47
9
|
mcp.registerTool(
|
|
48
10
|
'get_mandate',
|
|
@@ -52,7 +14,6 @@ export function registerMandateTools(mcp: McpServer, client: AgledgerClient): vo
|
|
|
52
14
|
inputSchema: {
|
|
53
15
|
mandateId: z.string().describe('UUID of the mandate to retrieve'),
|
|
54
16
|
},
|
|
55
|
-
outputSchema: MandateOutputSchema,
|
|
56
17
|
annotations: {
|
|
57
18
|
readOnlyHint: true,
|
|
58
19
|
destructiveHint: false,
|
|
@@ -64,10 +25,7 @@ export function registerMandateTools(mcp: McpServer, client: AgledgerClient): vo
|
|
|
64
25
|
async (args) => {
|
|
65
26
|
try {
|
|
66
27
|
const mandate = await client.mandates.get(args.mandateId);
|
|
67
|
-
return {
|
|
68
|
-
content: [{ type: 'text', text: `Mandate ${mandate.id}: status=${mandate.status}, type=${mandate.contractType}.` }],
|
|
69
|
-
structuredContent: toStructuredContent(mandate),
|
|
70
|
-
};
|
|
28
|
+
return { content: [], structuredContent: toStructuredContent(mandate) };
|
|
71
29
|
} catch (err) {
|
|
72
30
|
return apiErrorResult(err);
|
|
73
31
|
}
|
|
@@ -91,7 +49,6 @@ export function registerMandateTools(mcp: McpServer, client: AgledgerClient): vo
|
|
|
91
49
|
limit: z.number().optional().describe('Page size (default: 20)'),
|
|
92
50
|
offset: z.number().optional().describe('Page offset (default: 0)'),
|
|
93
51
|
},
|
|
94
|
-
outputSchema: SearchResultOutputSchema,
|
|
95
52
|
annotations: {
|
|
96
53
|
readOnlyHint: true,
|
|
97
54
|
destructiveHint: false,
|
|
@@ -103,10 +60,7 @@ export function registerMandateTools(mcp: McpServer, client: AgledgerClient): vo
|
|
|
103
60
|
async (args) => {
|
|
104
61
|
try {
|
|
105
62
|
const result = await client.mandates.search(args);
|
|
106
|
-
return {
|
|
107
|
-
content: [{ type: 'text', text: `Found ${result.total} mandates (showing ${result.data.length}).` }],
|
|
108
|
-
structuredContent: toStructuredContent(result),
|
|
109
|
-
};
|
|
63
|
+
return { content: [], structuredContent: toStructuredContent(result) };
|
|
110
64
|
} catch (err) {
|
|
111
65
|
return apiErrorResult(err);
|
|
112
66
|
}
|
|
@@ -121,7 +75,6 @@ export function registerMandateTools(mcp: McpServer, client: AgledgerClient): vo
|
|
|
121
75
|
inputSchema: {
|
|
122
76
|
mandateId: z.string().describe('UUID of the mandate to activate'),
|
|
123
77
|
},
|
|
124
|
-
outputSchema: MandateOutputSchema,
|
|
125
78
|
annotations: {
|
|
126
79
|
readOnlyHint: false,
|
|
127
80
|
destructiveHint: false,
|
|
@@ -133,10 +86,7 @@ export function registerMandateTools(mcp: McpServer, client: AgledgerClient): vo
|
|
|
133
86
|
async (args) => {
|
|
134
87
|
try {
|
|
135
88
|
const mandate = await client.mandates.transition(args.mandateId, 'activate');
|
|
136
|
-
return {
|
|
137
|
-
content: [{ type: 'text', text: `Mandate ${mandate.id} activated. Status is now ${mandate.status}.` }],
|
|
138
|
-
structuredContent: toStructuredContent(mandate),
|
|
139
|
-
};
|
|
89
|
+
return { content: [], structuredContent: toStructuredContent(mandate) };
|
|
140
90
|
} catch (err) {
|
|
141
91
|
return apiErrorResult(err);
|
|
142
92
|
}
|
|
@@ -152,7 +102,6 @@ export function registerMandateTools(mcp: McpServer, client: AgledgerClient): vo
|
|
|
152
102
|
mandateId: z.string().describe('UUID of the mandate to cancel'),
|
|
153
103
|
reason: z.string().optional().describe('Reason for cancellation'),
|
|
154
104
|
},
|
|
155
|
-
outputSchema: MandateOutputSchema,
|
|
156
105
|
annotations: {
|
|
157
106
|
readOnlyHint: false,
|
|
158
107
|
destructiveHint: true,
|
|
@@ -164,10 +113,7 @@ export function registerMandateTools(mcp: McpServer, client: AgledgerClient): vo
|
|
|
164
113
|
async (args) => {
|
|
165
114
|
try {
|
|
166
115
|
const mandate = await client.mandates.cancel(args.mandateId, args.reason);
|
|
167
|
-
return {
|
|
168
|
-
content: [{ type: 'text', text: `Mandate ${mandate.id} cancelled. Status is now ${mandate.status}.` }],
|
|
169
|
-
structuredContent: toStructuredContent(mandate),
|
|
170
|
-
};
|
|
116
|
+
return { content: [], structuredContent: toStructuredContent(mandate) };
|
|
171
117
|
} catch (err) {
|
|
172
118
|
return apiErrorResult(err);
|
|
173
119
|
}
|
|
@@ -183,7 +129,6 @@ export function registerMandateTools(mcp: McpServer, client: AgledgerClient): vo
|
|
|
183
129
|
mandateId: z.string().describe('UUID of the mandate to update'),
|
|
184
130
|
updates: z.record(z.string(), z.unknown()).describe('Fields to update (criteria, deadline, etc.)'),
|
|
185
131
|
},
|
|
186
|
-
outputSchema: MandateOutputSchema,
|
|
187
132
|
annotations: {
|
|
188
133
|
readOnlyHint: false,
|
|
189
134
|
destructiveHint: false,
|
|
@@ -195,10 +140,7 @@ export function registerMandateTools(mcp: McpServer, client: AgledgerClient): vo
|
|
|
195
140
|
async (args) => {
|
|
196
141
|
try {
|
|
197
142
|
const mandate = await client.mandates.update(args.mandateId, args.updates);
|
|
198
|
-
return {
|
|
199
|
-
content: [{ type: 'text', text: `Mandate ${mandate.id} updated. Status: ${mandate.status}.` }],
|
|
200
|
-
structuredContent: toStructuredContent(mandate),
|
|
201
|
-
};
|
|
143
|
+
return { content: [], structuredContent: toStructuredContent(mandate) };
|
|
202
144
|
} catch (err) {
|
|
203
145
|
return apiErrorResult(err);
|
|
204
146
|
}
|
|
@@ -214,7 +156,6 @@ export function registerMandateTools(mcp: McpServer, client: AgledgerClient): vo
|
|
|
214
156
|
mandateId: z.string().describe('UUID of the mandate to request revision for'),
|
|
215
157
|
reason: z.string().optional().describe('Why revision is needed'),
|
|
216
158
|
},
|
|
217
|
-
outputSchema: MandateOutputSchema,
|
|
218
159
|
annotations: {
|
|
219
160
|
readOnlyHint: false,
|
|
220
161
|
destructiveHint: false,
|
|
@@ -226,10 +167,7 @@ export function registerMandateTools(mcp: McpServer, client: AgledgerClient): vo
|
|
|
226
167
|
async (args) => {
|
|
227
168
|
try {
|
|
228
169
|
const mandate = await client.mandates.requestRevision(args.mandateId, args.reason);
|
|
229
|
-
return {
|
|
230
|
-
content: [{ type: 'text', text: `Mandate ${mandate.id} moved to REVISION_REQUESTED. The performer should submit a new receipt.` }],
|
|
231
|
-
structuredContent: toStructuredContent(mandate),
|
|
232
|
-
};
|
|
170
|
+
return { content: [], structuredContent: toStructuredContent(mandate) };
|
|
233
171
|
} catch (err) {
|
|
234
172
|
return apiErrorResult(err);
|
|
235
173
|
}
|
|
@@ -246,7 +184,6 @@ export function registerMandateTools(mcp: McpServer, client: AgledgerClient): vo
|
|
|
246
184
|
agentId: z.string().describe('Agent ID of the performer to delegate to'),
|
|
247
185
|
commissionPct: z.number().optional().describe('Commission percentage for the delegated agent'),
|
|
248
186
|
},
|
|
249
|
-
outputSchema: MandateOutputSchema,
|
|
250
187
|
annotations: {
|
|
251
188
|
readOnlyHint: false,
|
|
252
189
|
destructiveHint: false,
|
|
@@ -268,10 +205,7 @@ export function registerMandateTools(mcp: McpServer, client: AgledgerClient): vo
|
|
|
268
205
|
criteria: parent.criteria,
|
|
269
206
|
commissionPct: args.commissionPct,
|
|
270
207
|
});
|
|
271
|
-
return {
|
|
272
|
-
content: [{ type: 'text', text: `Mandate ${args.mandateId} delegated to agent ${args.agentId}. Child mandate: ${childMandate.id}.` }],
|
|
273
|
-
structuredContent: toStructuredContent(childMandate),
|
|
274
|
-
};
|
|
208
|
+
return { content: [], structuredContent: toStructuredContent(childMandate) };
|
|
275
209
|
} catch (err) {
|
|
276
210
|
return apiErrorResult(err);
|
|
277
211
|
}
|
|
@@ -286,10 +220,6 @@ export function registerMandateTools(mcp: McpServer, client: AgledgerClient): vo
|
|
|
286
220
|
inputSchema: {
|
|
287
221
|
mandateId: z.string().describe('UUID of the mandate to get the delegation graph for'),
|
|
288
222
|
},
|
|
289
|
-
outputSchema: z.object({
|
|
290
|
-
nodes: z.array(z.record(z.string(), z.unknown())).describe('Graph nodes (mandates)'),
|
|
291
|
-
edges: z.array(z.record(z.string(), z.unknown())).describe('Graph edges (delegation links)'),
|
|
292
|
-
}).passthrough().describe('Mandate delegation graph'),
|
|
293
223
|
annotations: {
|
|
294
224
|
readOnlyHint: true,
|
|
295
225
|
destructiveHint: false,
|
|
@@ -301,12 +231,7 @@ export function registerMandateTools(mcp: McpServer, client: AgledgerClient): vo
|
|
|
301
231
|
async (args) => {
|
|
302
232
|
try {
|
|
303
233
|
const graph = await client.mandates.getGraph(args.mandateId);
|
|
304
|
-
|
|
305
|
-
const edges = (graph as any).edges?.length ?? 0;
|
|
306
|
-
return {
|
|
307
|
-
content: [{ type: 'text', text: `Delegation graph for mandate ${args.mandateId}: ${nodes} node(s), ${edges} edge(s).` }],
|
|
308
|
-
structuredContent: toStructuredContent(graph),
|
|
309
|
-
};
|
|
234
|
+
return { content: [], structuredContent: toStructuredContent(graph) };
|
|
310
235
|
} catch (err) {
|
|
311
236
|
return apiErrorResult(err);
|
|
312
237
|
}
|
|
@@ -319,13 +244,6 @@ export function registerMandateTools(mcp: McpServer, client: AgledgerClient): vo
|
|
|
319
244
|
title: 'Get Mandate Summary',
|
|
320
245
|
description: 'Get mandate counts grouped by status. Use for dashboard-level visibility.',
|
|
321
246
|
inputSchema: {},
|
|
322
|
-
outputSchema: z.object({
|
|
323
|
-
CREATED: z.number().optional().describe('Count of CREATED mandates'),
|
|
324
|
-
ACTIVE: z.number().optional().describe('Count of ACTIVE mandates'),
|
|
325
|
-
PROCESSING: z.number().optional().describe('Count of PROCESSING mandates'),
|
|
326
|
-
FULFILLED: z.number().optional().describe('Count of FULFILLED mandates'),
|
|
327
|
-
FAILED: z.number().optional().describe('Count of FAILED mandates'),
|
|
328
|
-
}).passthrough().describe('Mandate counts grouped by status'),
|
|
329
247
|
annotations: {
|
|
330
248
|
readOnlyHint: true,
|
|
331
249
|
destructiveHint: false,
|
|
@@ -337,10 +255,7 @@ export function registerMandateTools(mcp: McpServer, client: AgledgerClient): vo
|
|
|
337
255
|
async () => {
|
|
338
256
|
try {
|
|
339
257
|
const summary = await client.mandates.getSummary();
|
|
340
|
-
return {
|
|
341
|
-
content: [{ type: 'text', text: `Mandate summary: ${JSON.stringify(summary)}.` }],
|
|
342
|
-
structuredContent: toStructuredContent(summary),
|
|
343
|
-
};
|
|
258
|
+
return { content: [], structuredContent: toStructuredContent(summary) };
|
|
344
259
|
} catch (err) {
|
|
345
260
|
return apiErrorResult(err);
|
|
346
261
|
}
|
package/src/tools/openclaw.ts
CHANGED
|
@@ -1,34 +1,9 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
3
3
|
import type { AgledgerClient } from '@agledger/sdk';
|
|
4
|
-
import type { CallToolResult } from '@modelcontextprotocol/sdk/types.js';
|
|
5
4
|
import { apiErrorResult, toStructuredContent } from '../errors.js';
|
|
6
5
|
import { toolMeta } from '../tool-scopes.js';
|
|
7
6
|
|
|
8
|
-
const NotarizeOutputSchema = z.object({
|
|
9
|
-
id: z.string().describe('Mandate ID'),
|
|
10
|
-
payloadHash: z.string().describe('Integrity hash'),
|
|
11
|
-
status: z.string().describe('Mandate status'),
|
|
12
|
-
contractType: z.string().describe('Contract type'),
|
|
13
|
-
}).passthrough().describe('Notarization result');
|
|
14
|
-
|
|
15
|
-
const MandateOutputSchema = z.object({
|
|
16
|
-
id: z.string().describe('Mandate ID'),
|
|
17
|
-
status: z.string().describe('Current status'),
|
|
18
|
-
contractType: z.string().describe('Contract type'),
|
|
19
|
-
}).passthrough().describe('Mandate details');
|
|
20
|
-
|
|
21
|
-
const ReceiptOutputSchema = z.object({
|
|
22
|
-
id: z.string().describe('Receipt ID'),
|
|
23
|
-
payloadHash: z.string().describe('Integrity hash'),
|
|
24
|
-
}).passthrough().describe('Receipt submission result');
|
|
25
|
-
|
|
26
|
-
function ok(text: string, data?: Record<string, unknown>): CallToolResult {
|
|
27
|
-
const result: CallToolResult = { content: [{ type: 'text', text }] };
|
|
28
|
-
if (data) result.structuredContent = data;
|
|
29
|
-
return result;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
7
|
export function registerOpenClawTools(mcp: McpServer, client: AgledgerClient): void {
|
|
33
8
|
|
|
34
9
|
// 1. Notarize — create an agreement
|
|
@@ -42,7 +17,6 @@ export function registerOpenClawTools(mcp: McpServer, client: AgledgerClient): v
|
|
|
42
17
|
payload: z.record(z.string(), z.unknown()).describe('Agreement criteria'),
|
|
43
18
|
performerHint: z.string().optional().describe('Who should do the work'),
|
|
44
19
|
},
|
|
45
|
-
outputSchema: NotarizeOutputSchema,
|
|
46
20
|
annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: true },
|
|
47
21
|
_meta: toolMeta('agledger_notarize'),
|
|
48
22
|
},
|
|
@@ -53,10 +27,7 @@ export function registerOpenClawTools(mcp: McpServer, client: AgledgerClient): v
|
|
|
53
27
|
payload: args.payload,
|
|
54
28
|
performerHint: args.performerHint,
|
|
55
29
|
});
|
|
56
|
-
return
|
|
57
|
-
`Agreement ${result.id} notarized (${args.contractType}). Hash: ${result.payloadHash}. Send mandate ID + payload to performer, then call agledger_verdict after delivery.`,
|
|
58
|
-
toStructuredContent(result),
|
|
59
|
-
);
|
|
30
|
+
return { content: [], structuredContent: toStructuredContent(result) };
|
|
60
31
|
} catch (e) { return apiErrorResult(e); }
|
|
61
32
|
},
|
|
62
33
|
);
|
|
@@ -70,17 +41,13 @@ export function registerOpenClawTools(mcp: McpServer, client: AgledgerClient): v
|
|
|
70
41
|
inputSchema: {
|
|
71
42
|
mandateId: z.string().describe('Mandate ID to accept'),
|
|
72
43
|
},
|
|
73
|
-
outputSchema: MandateOutputSchema,
|
|
74
44
|
annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: true, openWorldHint: true },
|
|
75
45
|
_meta: toolMeta('agledger_accept'),
|
|
76
46
|
},
|
|
77
47
|
async (args) => {
|
|
78
48
|
try {
|
|
79
49
|
const mandate = await client.notarize.acceptMandate(args.mandateId);
|
|
80
|
-
return
|
|
81
|
-
`Agreement ${mandate.id} accepted. Do the work, then call agledger_receipt.`,
|
|
82
|
-
toStructuredContent(mandate),
|
|
83
|
-
);
|
|
50
|
+
return { content: [], structuredContent: toStructuredContent(mandate) };
|
|
84
51
|
} catch (e) { return apiErrorResult(e); }
|
|
85
52
|
},
|
|
86
53
|
);
|
|
@@ -95,7 +62,6 @@ export function registerOpenClawTools(mcp: McpServer, client: AgledgerClient): v
|
|
|
95
62
|
mandateId: z.string().describe('Mandate ID this receipt is for'),
|
|
96
63
|
payload: z.record(z.string(), z.unknown()).describe('Evidence of completion'),
|
|
97
64
|
},
|
|
98
|
-
outputSchema: ReceiptOutputSchema,
|
|
99
65
|
annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: true },
|
|
100
66
|
_meta: toolMeta('agledger_receipt'),
|
|
101
67
|
},
|
|
@@ -104,10 +70,7 @@ export function registerOpenClawTools(mcp: McpServer, client: AgledgerClient): v
|
|
|
104
70
|
const result = await client.notarize.submitReceipt(args.mandateId, {
|
|
105
71
|
payload: args.payload,
|
|
106
72
|
});
|
|
107
|
-
return
|
|
108
|
-
`Receipt ${result.id} submitted for ${args.mandateId}. Hash: ${result.payloadHash}. Principal should call agledger_verdict.`,
|
|
109
|
-
toStructuredContent(result),
|
|
110
|
-
);
|
|
73
|
+
return { content: [], structuredContent: toStructuredContent(result) };
|
|
111
74
|
} catch (e) { return apiErrorResult(e); }
|
|
112
75
|
},
|
|
113
76
|
);
|
|
@@ -123,7 +86,6 @@ export function registerOpenClawTools(mcp: McpServer, client: AgledgerClient): v
|
|
|
123
86
|
verdict: z.enum(['PASS', 'FAIL']).describe('PASS to accept, FAIL to reject'),
|
|
124
87
|
reason: z.string().optional().describe('Why'),
|
|
125
88
|
},
|
|
126
|
-
outputSchema: MandateOutputSchema,
|
|
127
89
|
annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: true, openWorldHint: true },
|
|
128
90
|
_meta: toolMeta('agledger_verdict'),
|
|
129
91
|
},
|
|
@@ -133,11 +95,7 @@ export function registerOpenClawTools(mcp: McpServer, client: AgledgerClient): v
|
|
|
133
95
|
verdict: args.verdict,
|
|
134
96
|
reason: args.reason,
|
|
135
97
|
});
|
|
136
|
-
|
|
137
|
-
return ok(
|
|
138
|
-
`Agreement ${mandate.id} ${verb}. Status: ${mandate.status}.`,
|
|
139
|
-
toStructuredContent(mandate),
|
|
140
|
-
);
|
|
98
|
+
return { content: [], structuredContent: toStructuredContent(mandate) };
|
|
141
99
|
} catch (e) { return apiErrorResult(e); }
|
|
142
100
|
},
|
|
143
101
|
);
|
|
@@ -151,17 +109,13 @@ export function registerOpenClawTools(mcp: McpServer, client: AgledgerClient): v
|
|
|
151
109
|
inputSchema: {
|
|
152
110
|
mandateId: z.string().describe('Mandate ID'),
|
|
153
111
|
},
|
|
154
|
-
outputSchema: MandateOutputSchema,
|
|
155
112
|
annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: true },
|
|
156
113
|
_meta: toolMeta('agledger_status'),
|
|
157
114
|
},
|
|
158
115
|
async (args) => {
|
|
159
116
|
try {
|
|
160
117
|
const mandate = await client.notarize.getMandate(args.mandateId);
|
|
161
|
-
return
|
|
162
|
-
`Agreement ${mandate.id}: ${mandate.status} (${mandate.contractType})`,
|
|
163
|
-
toStructuredContent(mandate),
|
|
164
|
-
);
|
|
118
|
+
return { content: [], structuredContent: toStructuredContent(mandate) };
|
|
165
119
|
} catch (e) { return apiErrorResult(e); }
|
|
166
120
|
},
|
|
167
121
|
);
|
package/src/tools/receipts.ts
CHANGED
|
@@ -2,51 +2,8 @@ import { z } from 'zod';
|
|
|
2
2
|
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
3
3
|
import type { AgledgerClient } from '@agledger/sdk';
|
|
4
4
|
import { apiErrorResult, toStructuredContent } from '../errors.js';
|
|
5
|
-
import { NextStepsField, StructuralValidationEnum } from '../enums.js';
|
|
6
5
|
import { toolMeta } from '../tool-scopes.js';
|
|
7
6
|
|
|
8
|
-
const ReceiptOutputSchema = z
|
|
9
|
-
.object({
|
|
10
|
-
id: z.string().describe('Receipt UUID'),
|
|
11
|
-
mandateId: z.string().describe('Associated mandate UUID'),
|
|
12
|
-
agentId: z.string().describe('Agent that submitted the receipt'),
|
|
13
|
-
structuralValidation: StructuralValidationEnum.nullable()
|
|
14
|
-
.optional()
|
|
15
|
-
.describe('Structural validation result'),
|
|
16
|
-
evidence: z.record(z.string(), z.unknown()).describe('Evidence payload'),
|
|
17
|
-
evidenceHash: z.string().nullable().optional().describe('SHA-256 hash of evidence'),
|
|
18
|
-
notes: z.string().nullable().optional().describe('Human-readable notes'),
|
|
19
|
-
verificationPhase: z.string().nullable().optional().describe('Current verification phase'),
|
|
20
|
-
verificationResult: z
|
|
21
|
-
.record(z.string(), z.unknown())
|
|
22
|
-
.nullable()
|
|
23
|
-
.optional()
|
|
24
|
-
.describe('Verification result details'),
|
|
25
|
-
validationErrors: z
|
|
26
|
-
.array(z.string())
|
|
27
|
-
.nullable()
|
|
28
|
-
.optional()
|
|
29
|
-
.describe('Validation errors if any'),
|
|
30
|
-
idempotencyKey: z.string().nullable().optional().describe('Idempotency key for deduplication'),
|
|
31
|
-
createdAt: z.string().describe('ISO 8601 creation timestamp'),
|
|
32
|
-
updatedAt: z.string().nullable().optional().describe('ISO 8601 last update timestamp'),
|
|
33
|
-
nextSteps: NextStepsField,
|
|
34
|
-
})
|
|
35
|
-
.passthrough()
|
|
36
|
-
.describe('AGLedger receipt (task attestation) object');
|
|
37
|
-
|
|
38
|
-
const ReceiptListOutputSchema = z
|
|
39
|
-
.object({
|
|
40
|
-
data: z.array(ReceiptOutputSchema).describe('Array of receipts for the mandate'),
|
|
41
|
-
nextCursor: z
|
|
42
|
-
.string()
|
|
43
|
-
.nullable()
|
|
44
|
-
.optional()
|
|
45
|
-
.describe('Cursor for the next page (null if no more results)'),
|
|
46
|
-
})
|
|
47
|
-
.passthrough()
|
|
48
|
-
.describe('List of receipts for a mandate');
|
|
49
|
-
|
|
50
7
|
export interface ReceiptToolsOptions {
|
|
51
8
|
/** Skip submit_receipt (e.g. when a2a tools already provide it). */
|
|
52
9
|
skipSubmit?: boolean;
|
|
@@ -66,7 +23,6 @@ export function registerReceiptTools(mcp: McpServer, client: AgledgerClient, opt
|
|
|
66
23
|
.describe('Evidence JSON object proving task completion'),
|
|
67
24
|
notes: z.string().optional().describe('Human-readable notes about the submission'),
|
|
68
25
|
},
|
|
69
|
-
outputSchema: ReceiptOutputSchema,
|
|
70
26
|
annotations: {
|
|
71
27
|
readOnlyHint: false,
|
|
72
28
|
destructiveHint: false,
|
|
@@ -79,18 +35,7 @@ export function registerReceiptTools(mcp: McpServer, client: AgledgerClient, opt
|
|
|
79
35
|
try {
|
|
80
36
|
const { mandateId, ...submitParams } = args;
|
|
81
37
|
const receipt = await client.receipts.submit(mandateId, submitParams);
|
|
82
|
-
|
|
83
|
-
// Use denormalized mandateStatus from receipt response (no extra API call)
|
|
84
|
-
const ms = receipt.mandateStatus;
|
|
85
|
-
if (ms === 'FULFILLED') {
|
|
86
|
-
text += '\n\nMandate settled to FULFILLED. Accountability loop closed.';
|
|
87
|
-
} else if (ms === 'PROCESSING') {
|
|
88
|
-
text += '\n\nEvidence is being verified. The principal will accept or reject.';
|
|
89
|
-
}
|
|
90
|
-
return {
|
|
91
|
-
content: [{ type: 'text', text }],
|
|
92
|
-
structuredContent: toStructuredContent(receipt),
|
|
93
|
-
};
|
|
38
|
+
return { content: [], structuredContent: toStructuredContent(receipt) };
|
|
94
39
|
} catch (err) {
|
|
95
40
|
return apiErrorResult(err);
|
|
96
41
|
}
|
|
@@ -112,18 +57,6 @@ export function registerReceiptTools(mcp: McpServer, client: AgledgerClient, opt
|
|
|
112
57
|
.optional()
|
|
113
58
|
.describe('Optional per-field check results'),
|
|
114
59
|
},
|
|
115
|
-
outputSchema: z
|
|
116
|
-
.object({
|
|
117
|
-
mandateId: z.string().describe('Mandate UUID'),
|
|
118
|
-
receiptId: z.string().describe('Receipt UUID'),
|
|
119
|
-
outcome: z.enum(['PASS', 'FAIL']).describe('Reported outcome'),
|
|
120
|
-
signal: z.string().describe('Settlement signal: SETTLE, HOLD, or RELEASE'),
|
|
121
|
-
reporterType: z.string().describe('Who reported: principal'),
|
|
122
|
-
reportedAt: z.string().describe('ISO 8601 timestamp'),
|
|
123
|
-
nextSteps: NextStepsField,
|
|
124
|
-
})
|
|
125
|
-
.passthrough()
|
|
126
|
-
.describe('Outcome result'),
|
|
127
60
|
annotations: {
|
|
128
61
|
readOnlyHint: false,
|
|
129
62
|
destructiveHint: false,
|
|
@@ -136,13 +69,7 @@ export function registerReceiptTools(mcp: McpServer, client: AgledgerClient, opt
|
|
|
136
69
|
try {
|
|
137
70
|
const { mandateId, ...outcomeParams } = args;
|
|
138
71
|
const result = await client.mandates.reportOutcome(mandateId, outcomeParams);
|
|
139
|
-
|
|
140
|
-
return {
|
|
141
|
-
content: [
|
|
142
|
-
{ type: 'text', text: `Receipt ${args.receiptId} ${verb}. Signal: ${result.signal}.` },
|
|
143
|
-
],
|
|
144
|
-
structuredContent: toStructuredContent(result),
|
|
145
|
-
};
|
|
72
|
+
return { content: [], structuredContent: toStructuredContent(result) };
|
|
146
73
|
} catch (err) {
|
|
147
74
|
return apiErrorResult(err);
|
|
148
75
|
}
|
|
@@ -158,7 +85,6 @@ export function registerReceiptTools(mcp: McpServer, client: AgledgerClient, opt
|
|
|
158
85
|
mandateId: z.string().describe('UUID of the associated mandate'),
|
|
159
86
|
receiptId: z.string().describe('UUID of the receipt to retrieve'),
|
|
160
87
|
},
|
|
161
|
-
outputSchema: ReceiptOutputSchema,
|
|
162
88
|
annotations: {
|
|
163
89
|
readOnlyHint: true,
|
|
164
90
|
destructiveHint: false,
|
|
@@ -170,15 +96,7 @@ export function registerReceiptTools(mcp: McpServer, client: AgledgerClient, opt
|
|
|
170
96
|
async (args) => {
|
|
171
97
|
try {
|
|
172
98
|
const receipt = await client.receipts.get(args.mandateId, args.receiptId);
|
|
173
|
-
return {
|
|
174
|
-
content: [
|
|
175
|
-
{
|
|
176
|
-
type: 'text',
|
|
177
|
-
text: `Receipt ${receipt.id}: status=${receipt.structuralValidation}, mandate=${receipt.mandateId}.`,
|
|
178
|
-
},
|
|
179
|
-
],
|
|
180
|
-
structuredContent: toStructuredContent(receipt),
|
|
181
|
-
};
|
|
99
|
+
return { content: [], structuredContent: toStructuredContent(receipt) };
|
|
182
100
|
} catch (err) {
|
|
183
101
|
return apiErrorResult(err);
|
|
184
102
|
}
|
|
@@ -195,7 +113,6 @@ export function registerReceiptTools(mcp: McpServer, client: AgledgerClient, opt
|
|
|
195
113
|
limit: z.number().optional().describe('Page size (default: 20)'),
|
|
196
114
|
offset: z.number().optional().describe('Page offset (default: 0)'),
|
|
197
115
|
},
|
|
198
|
-
outputSchema: ReceiptListOutputSchema,
|
|
199
116
|
annotations: {
|
|
200
117
|
readOnlyHint: true,
|
|
201
118
|
destructiveHint: false,
|
|
@@ -208,15 +125,7 @@ export function registerReceiptTools(mcp: McpServer, client: AgledgerClient, opt
|
|
|
208
125
|
try {
|
|
209
126
|
const { mandateId, ...paginationParams } = args;
|
|
210
127
|
const result = await client.receipts.list(mandateId, paginationParams);
|
|
211
|
-
return {
|
|
212
|
-
content: [
|
|
213
|
-
{
|
|
214
|
-
type: 'text',
|
|
215
|
-
text: `Found ${result.data.length} receipts for mandate ${mandateId}.`,
|
|
216
|
-
},
|
|
217
|
-
],
|
|
218
|
-
structuredContent: toStructuredContent(result),
|
|
219
|
-
};
|
|
128
|
+
return { content: [], structuredContent: toStructuredContent(result) };
|
|
220
129
|
} catch (err) {
|
|
221
130
|
return apiErrorResult(err);
|
|
222
131
|
}
|
package/src/tools/reputation.ts
CHANGED
|
@@ -4,14 +4,6 @@ import type { AgledgerClient } from '@agledger/sdk';
|
|
|
4
4
|
import { apiErrorResult, toStructuredContent } from '../errors.js';
|
|
5
5
|
import { toolMeta } from '../tool-scopes.js';
|
|
6
6
|
|
|
7
|
-
const ReputationScoreSchema = z.object({
|
|
8
|
-
contractType: z.string().optional().describe('Contract type identifier'),
|
|
9
|
-
compositeScore: z.number().optional().describe('Overall composite reputation score'),
|
|
10
|
-
reliabilityScore: z.number().optional().describe('Reliability score'),
|
|
11
|
-
accuracyScore: z.number().optional().describe('Accuracy score'),
|
|
12
|
-
efficiencyScore: z.number().optional().describe('Efficiency score'),
|
|
13
|
-
}).passthrough();
|
|
14
|
-
|
|
15
7
|
export function registerReputationTools(mcp: McpServer, client: AgledgerClient): void {
|
|
16
8
|
mcp.registerTool(
|
|
17
9
|
'get_agent_reputation',
|
|
@@ -21,20 +13,13 @@ export function registerReputationTools(mcp: McpServer, client: AgledgerClient):
|
|
|
21
13
|
inputSchema: {
|
|
22
14
|
agentId: z.string().describe('UUID of the agent'),
|
|
23
15
|
},
|
|
24
|
-
outputSchema: z.object({
|
|
25
|
-
data: z.array(ReputationScoreSchema).describe('Per-contract-type reputation scores'),
|
|
26
|
-
total: z.number().nullable().optional().describe('Total count'),
|
|
27
|
-
}).passthrough().describe('Agent reputation scores by contract type'),
|
|
28
16
|
annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: true },
|
|
29
17
|
_meta: toolMeta('get_agent_reputation'),
|
|
30
18
|
},
|
|
31
19
|
async (args) => {
|
|
32
20
|
try {
|
|
33
21
|
const page = await client.reputation.getAgent(args.agentId);
|
|
34
|
-
return {
|
|
35
|
-
content: [{ type: 'text', text: `Agent ${args.agentId}: ${page.data.length} contract type score(s).` }],
|
|
36
|
-
structuredContent: toStructuredContent(page),
|
|
37
|
-
};
|
|
22
|
+
return { content: [], structuredContent: toStructuredContent(page) };
|
|
38
23
|
} catch (err) { return apiErrorResult(err); }
|
|
39
24
|
},
|
|
40
25
|
);
|
|
@@ -48,17 +33,13 @@ export function registerReputationTools(mcp: McpServer, client: AgledgerClient):
|
|
|
48
33
|
agentId: z.string().describe('UUID of the agent'),
|
|
49
34
|
contractType: z.string().describe('Contract type (e.g., ACH-PROC-v1)'),
|
|
50
35
|
},
|
|
51
|
-
outputSchema: ReputationScoreSchema.describe('Agent reputation score for a specific contract type'),
|
|
52
36
|
annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: true },
|
|
53
37
|
_meta: toolMeta('get_reputation_by_type'),
|
|
54
38
|
},
|
|
55
39
|
async (args) => {
|
|
56
40
|
try {
|
|
57
41
|
const score = await client.reputation.getByContractType(args.agentId, args.contractType);
|
|
58
|
-
return {
|
|
59
|
-
content: [{ type: 'text', text: `Agent ${args.agentId} [${args.contractType}]: composite=${score.compositeScore}, reliability=${score.reliabilityScore}, accuracy=${score.accuracyScore}, efficiency=${score.efficiencyScore}.` }],
|
|
60
|
-
structuredContent: toStructuredContent(score),
|
|
61
|
-
};
|
|
42
|
+
return { content: [], structuredContent: toStructuredContent(score) };
|
|
62
43
|
} catch (err) { return apiErrorResult(err); }
|
|
63
44
|
},
|
|
64
45
|
);
|
|
@@ -74,15 +55,6 @@ export function registerReputationTools(mcp: McpServer, client: AgledgerClient):
|
|
|
74
55
|
outcome: z.enum(['PASS', 'FAIL']).optional().describe('Filter by verdict outcome'),
|
|
75
56
|
limit: z.number().optional().describe('Page size'),
|
|
76
57
|
},
|
|
77
|
-
outputSchema: z.object({
|
|
78
|
-
data: z.array(z.object({
|
|
79
|
-
mandateId: z.string().optional().describe('Mandate UUID'),
|
|
80
|
-
contractType: z.string().optional().describe('Contract type'),
|
|
81
|
-
outcome: z.string().nullable().optional().describe('Verdict outcome (PASS/FAIL)'),
|
|
82
|
-
completedAt: z.string().nullable().optional().describe('ISO 8601 completion timestamp'),
|
|
83
|
-
}).passthrough()).describe('Transaction history entries'),
|
|
84
|
-
total: z.number().nullable().optional().describe('Total count'),
|
|
85
|
-
}).passthrough().describe('Agent transaction history'),
|
|
86
58
|
annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: true },
|
|
87
59
|
_meta: toolMeta('get_agent_history'),
|
|
88
60
|
},
|
|
@@ -90,10 +62,7 @@ export function registerReputationTools(mcp: McpServer, client: AgledgerClient):
|
|
|
90
62
|
try {
|
|
91
63
|
const { agentId, ...params } = args;
|
|
92
64
|
const page = await client.reputation.getHistory(agentId, params);
|
|
93
|
-
return {
|
|
94
|
-
content: [{ type: 'text', text: `Agent ${agentId}: ${page.data.length} transaction(s).` }],
|
|
95
|
-
structuredContent: toStructuredContent(page),
|
|
96
|
-
};
|
|
65
|
+
return { content: [], structuredContent: toStructuredContent(page) };
|
|
97
66
|
} catch (err) { return apiErrorResult(err); }
|
|
98
67
|
},
|
|
99
68
|
);
|