@agledger/mcp-server 1.4.3 → 2.0.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/api-client.d.ts +16 -0
- package/dist/api-client.d.ts.map +1 -0
- package/dist/api-client.js +52 -0
- package/dist/api-client.js.map +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +17 -60
- package/dist/index.js.map +1 -1
- package/dist/server.d.ts +2 -13
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +113 -111
- 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 +2 -3
- package/src/api-client.ts +72 -0
- package/src/index.ts +27 -62
- package/src/server.ts +136 -122
- package/tests/api-client.test.ts +147 -0
- package/tests/harness.ts +8 -35
- package/tests/integration.test.ts +373 -0
- package/tests/server.test.ts +286 -0
- package/src/enums.ts +0 -47
- package/src/errors.ts +0 -44
- package/src/resources/contract-types.ts +0 -130
- package/src/tool-scopes.ts +0 -184
- package/src/tools/a2a.ts +0 -643
- package/src/tools/agent-mandates.ts +0 -325
- package/src/tools/agents-refs.ts +0 -288
- package/src/tools/capabilities.ts +0 -76
- package/src/tools/code-mode.ts +0 -461
- package/src/tools/compliance.ts +0 -104
- package/src/tools/dashboard.ts +0 -98
- package/src/tools/disputes.ts +0 -159
- package/src/tools/enterprises.ts +0 -259
- package/src/tools/events.ts +0 -52
- package/src/tools/federation-admin.ts +0 -922
- package/src/tools/federation.ts +0 -784
- package/src/tools/health.ts +0 -43
- package/src/tools/mandates.ts +0 -349
- package/src/tools/openclaw.ts +0 -168
- package/src/tools/receipts.ts +0 -225
- package/src/tools/reputation.ts +0 -100
- package/src/tools/schemas.ts +0 -713
- package/src/tools/verification-keys.ts +0 -56
- package/src/tools/verification.ts +0 -86
- package/tests/conformance.test.ts +0 -219
- package/tests/conformance.ts +0 -75
- package/tests/drift/code-mode-manifest.test.ts +0 -144
- package/tests/integration/output-schema-validation.test.ts +0 -167
- package/tests/mock-client.ts +0 -71
- package/tests/profiles.test.ts +0 -135
- package/tests/resources/contract-types.test.ts +0 -82
- package/tests/tools/a2a.test.ts +0 -241
- package/tests/tools/agent-mandates.test.ts +0 -206
- package/tests/tools/agents-refs.test.ts +0 -199
- package/tests/tools/capabilities.test.ts +0 -86
- package/tests/tools/code-mode.test.ts +0 -168
- package/tests/tools/compliance.test.ts +0 -131
- package/tests/tools/dashboard.test.ts +0 -120
- package/tests/tools/disputes.test.ts +0 -131
- package/tests/tools/enterprises.test.ts +0 -181
- package/tests/tools/events.test.ts +0 -61
- package/tests/tools/federation-admin.test.ts +0 -509
- package/tests/tools/federation.test.ts +0 -556
- package/tests/tools/health.test.ts +0 -67
- package/tests/tools/mandates.test.ts +0 -155
- package/tests/tools/openclaw.test.ts +0 -160
- package/tests/tools/receipts.test.ts +0 -170
- package/tests/tools/reputation.test.ts +0 -117
- package/tests/tools/schemas.test.ts +0 -397
- package/tests/tools/verification-keys.test.ts +0 -62
- package/tests/tools/verification.test.ts +0 -74
package/src/tools/health.ts
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
3
|
-
import type { AgledgerClient } from '@agledger/sdk';
|
|
4
|
-
import { apiErrorResult, toStructuredContent } from '../errors.js';
|
|
5
|
-
import { toolMeta } from '../tool-scopes.js';
|
|
6
|
-
|
|
7
|
-
const HealthOutputSchema = z.object({
|
|
8
|
-
status: z.string().describe('API health status (e.g. "ok", "degraded")'),
|
|
9
|
-
version: z.string().optional().describe('API version string'),
|
|
10
|
-
uptime: z.number().optional().describe('API uptime in seconds'),
|
|
11
|
-
database: z.string().optional().describe('Database connection status'),
|
|
12
|
-
timestamp: z.string().describe('ISO 8601 timestamp of the health check'),
|
|
13
|
-
}).describe('AGLedger API health check response');
|
|
14
|
-
|
|
15
|
-
export function registerHealthTools(mcp: McpServer, client: AgledgerClient): void {
|
|
16
|
-
mcp.registerTool(
|
|
17
|
-
'check_api_health',
|
|
18
|
-
{
|
|
19
|
-
title: 'Check API Health',
|
|
20
|
-
description: 'Check the health status of the AGLedger API, including database connectivity and uptime.',
|
|
21
|
-
inputSchema: {},
|
|
22
|
-
outputSchema: HealthOutputSchema,
|
|
23
|
-
annotations: {
|
|
24
|
-
readOnlyHint: true,
|
|
25
|
-
destructiveHint: false,
|
|
26
|
-
idempotentHint: true,
|
|
27
|
-
openWorldHint: true,
|
|
28
|
-
},
|
|
29
|
-
_meta: toolMeta('check_api_health'),
|
|
30
|
-
},
|
|
31
|
-
async () => {
|
|
32
|
-
try {
|
|
33
|
-
const health = await client.health.check();
|
|
34
|
-
return {
|
|
35
|
-
content: [{ type: 'text', text: `API health: status=${health.status}${health.version ? `, version=${health.version}` : ''}${health.database ? `, db=${health.database}` : ''}.` }],
|
|
36
|
-
structuredContent: toStructuredContent(health),
|
|
37
|
-
};
|
|
38
|
-
} catch (err) {
|
|
39
|
-
return apiErrorResult(err);
|
|
40
|
-
}
|
|
41
|
-
},
|
|
42
|
-
);
|
|
43
|
-
}
|
package/src/tools/mandates.ts
DELETED
|
@@ -1,349 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
3
|
-
import type { AgledgerClient } from '@agledger/sdk';
|
|
4
|
-
import { apiErrorResult, toStructuredContent } from '../errors.js';
|
|
5
|
-
import { ContractTypeEnum, MandateStatusEnum, NextStepsField, OperatingModeEnum, RiskClassificationEnum } from '../enums.js';
|
|
6
|
-
import { toolMeta } from '../tool-scopes.js';
|
|
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
|
-
export function registerMandateTools(mcp: McpServer, client: AgledgerClient): void {
|
|
47
|
-
mcp.registerTool(
|
|
48
|
-
'get_mandate',
|
|
49
|
-
{
|
|
50
|
-
title: 'Get Mandate',
|
|
51
|
-
description: 'Retrieve an AGLedger mandate by its ID.',
|
|
52
|
-
inputSchema: {
|
|
53
|
-
mandateId: z.string().describe('UUID of the mandate to retrieve'),
|
|
54
|
-
},
|
|
55
|
-
outputSchema: MandateOutputSchema,
|
|
56
|
-
annotations: {
|
|
57
|
-
readOnlyHint: true,
|
|
58
|
-
destructiveHint: false,
|
|
59
|
-
idempotentHint: true,
|
|
60
|
-
openWorldHint: true,
|
|
61
|
-
},
|
|
62
|
-
_meta: toolMeta('get_mandate'),
|
|
63
|
-
},
|
|
64
|
-
async (args) => {
|
|
65
|
-
try {
|
|
66
|
-
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
|
-
};
|
|
71
|
-
} catch (err) {
|
|
72
|
-
return apiErrorResult(err);
|
|
73
|
-
}
|
|
74
|
-
},
|
|
75
|
-
);
|
|
76
|
-
|
|
77
|
-
mcp.registerTool(
|
|
78
|
-
'search_mandates',
|
|
79
|
-
{
|
|
80
|
-
title: 'Search Mandates',
|
|
81
|
-
description: 'Search AGLedger mandates with filters (status, contract type, agent, date range).',
|
|
82
|
-
inputSchema: {
|
|
83
|
-
enterpriseId: z.string().describe('Enterprise ID to search within (required)'),
|
|
84
|
-
status: MandateStatusEnum.optional().describe('Filter by mandate status'),
|
|
85
|
-
contractType: ContractTypeEnum.optional().describe('Filter by contract type'),
|
|
86
|
-
agentId: z.string().optional().describe('Filter by assigned agent ID'),
|
|
87
|
-
from: z.string().optional().describe('ISO 8601 start date filter'),
|
|
88
|
-
to: z.string().optional().describe('ISO 8601 end date filter'),
|
|
89
|
-
sort: z.string().optional().describe('Sort field (e.g. "createdAt")'),
|
|
90
|
-
order: z.enum(['asc', 'desc']).optional().describe('Sort order'),
|
|
91
|
-
limit: z.number().optional().describe('Page size (default: 20)'),
|
|
92
|
-
offset: z.number().optional().describe('Page offset (default: 0)'),
|
|
93
|
-
},
|
|
94
|
-
outputSchema: SearchResultOutputSchema,
|
|
95
|
-
annotations: {
|
|
96
|
-
readOnlyHint: true,
|
|
97
|
-
destructiveHint: false,
|
|
98
|
-
idempotentHint: true,
|
|
99
|
-
openWorldHint: true,
|
|
100
|
-
},
|
|
101
|
-
_meta: toolMeta('search_mandates'),
|
|
102
|
-
},
|
|
103
|
-
async (args) => {
|
|
104
|
-
try {
|
|
105
|
-
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
|
-
};
|
|
110
|
-
} catch (err) {
|
|
111
|
-
return apiErrorResult(err);
|
|
112
|
-
}
|
|
113
|
-
},
|
|
114
|
-
);
|
|
115
|
-
|
|
116
|
-
mcp.registerTool(
|
|
117
|
-
'activate_mandate',
|
|
118
|
-
{
|
|
119
|
-
title: 'Activate Mandate',
|
|
120
|
-
description: 'Transition a mandate to ACTIVE status. The mandate must be in CREATED status.',
|
|
121
|
-
inputSchema: {
|
|
122
|
-
mandateId: z.string().describe('UUID of the mandate to activate'),
|
|
123
|
-
},
|
|
124
|
-
outputSchema: MandateOutputSchema,
|
|
125
|
-
annotations: {
|
|
126
|
-
readOnlyHint: false,
|
|
127
|
-
destructiveHint: false,
|
|
128
|
-
idempotentHint: true,
|
|
129
|
-
openWorldHint: true,
|
|
130
|
-
},
|
|
131
|
-
_meta: toolMeta('activate_mandate'),
|
|
132
|
-
},
|
|
133
|
-
async (args) => {
|
|
134
|
-
try {
|
|
135
|
-
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
|
-
};
|
|
140
|
-
} catch (err) {
|
|
141
|
-
return apiErrorResult(err);
|
|
142
|
-
}
|
|
143
|
-
},
|
|
144
|
-
);
|
|
145
|
-
|
|
146
|
-
mcp.registerTool(
|
|
147
|
-
'cancel_mandate',
|
|
148
|
-
{
|
|
149
|
-
title: 'Cancel Mandate',
|
|
150
|
-
description: 'Cancel an AGLedger mandate. This is a destructive operation.',
|
|
151
|
-
inputSchema: {
|
|
152
|
-
mandateId: z.string().describe('UUID of the mandate to cancel'),
|
|
153
|
-
reason: z.string().optional().describe('Reason for cancellation'),
|
|
154
|
-
},
|
|
155
|
-
outputSchema: MandateOutputSchema,
|
|
156
|
-
annotations: {
|
|
157
|
-
readOnlyHint: false,
|
|
158
|
-
destructiveHint: true,
|
|
159
|
-
idempotentHint: false,
|
|
160
|
-
openWorldHint: true,
|
|
161
|
-
},
|
|
162
|
-
_meta: toolMeta('cancel_mandate'),
|
|
163
|
-
},
|
|
164
|
-
async (args) => {
|
|
165
|
-
try {
|
|
166
|
-
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
|
-
};
|
|
171
|
-
} catch (err) {
|
|
172
|
-
return apiErrorResult(err);
|
|
173
|
-
}
|
|
174
|
-
},
|
|
175
|
-
);
|
|
176
|
-
|
|
177
|
-
mcp.registerTool(
|
|
178
|
-
'update_mandate',
|
|
179
|
-
{
|
|
180
|
-
title: 'Update Mandate',
|
|
181
|
-
description: 'Update mutable fields on a CREATED mandate (criteria, deadline, commission). Cannot update after activation.',
|
|
182
|
-
inputSchema: {
|
|
183
|
-
mandateId: z.string().describe('UUID of the mandate to update'),
|
|
184
|
-
updates: z.record(z.string(), z.unknown()).describe('Fields to update (criteria, deadline, etc.)'),
|
|
185
|
-
},
|
|
186
|
-
outputSchema: MandateOutputSchema,
|
|
187
|
-
annotations: {
|
|
188
|
-
readOnlyHint: false,
|
|
189
|
-
destructiveHint: false,
|
|
190
|
-
idempotentHint: true,
|
|
191
|
-
openWorldHint: true,
|
|
192
|
-
},
|
|
193
|
-
_meta: toolMeta('update_mandate'),
|
|
194
|
-
},
|
|
195
|
-
async (args) => {
|
|
196
|
-
try {
|
|
197
|
-
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
|
-
};
|
|
202
|
-
} catch (err) {
|
|
203
|
-
return apiErrorResult(err);
|
|
204
|
-
}
|
|
205
|
-
},
|
|
206
|
-
);
|
|
207
|
-
|
|
208
|
-
mcp.registerTool(
|
|
209
|
-
'request_revision',
|
|
210
|
-
{
|
|
211
|
-
title: 'Request Revision',
|
|
212
|
-
description: 'Request the performer to revise their submitted work. Use when a receipt was submitted but the evidence is insufficient. The performer can then submit a new receipt.',
|
|
213
|
-
inputSchema: {
|
|
214
|
-
mandateId: z.string().describe('UUID of the mandate to request revision for'),
|
|
215
|
-
reason: z.string().optional().describe('Why revision is needed'),
|
|
216
|
-
},
|
|
217
|
-
outputSchema: MandateOutputSchema,
|
|
218
|
-
annotations: {
|
|
219
|
-
readOnlyHint: false,
|
|
220
|
-
destructiveHint: false,
|
|
221
|
-
idempotentHint: false,
|
|
222
|
-
openWorldHint: true,
|
|
223
|
-
},
|
|
224
|
-
_meta: toolMeta('request_revision'),
|
|
225
|
-
},
|
|
226
|
-
async (args) => {
|
|
227
|
-
try {
|
|
228
|
-
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
|
-
};
|
|
233
|
-
} catch (err) {
|
|
234
|
-
return apiErrorResult(err);
|
|
235
|
-
}
|
|
236
|
-
},
|
|
237
|
-
);
|
|
238
|
-
|
|
239
|
-
mcp.registerTool(
|
|
240
|
-
'delegate_mandate',
|
|
241
|
-
{
|
|
242
|
-
title: 'Delegate Mandate',
|
|
243
|
-
description: 'Delegate a mandate to another agent by creating a child mandate in the delegation chain.',
|
|
244
|
-
inputSchema: {
|
|
245
|
-
mandateId: z.string().describe('UUID of the parent mandate to delegate from'),
|
|
246
|
-
agentId: z.string().describe('Agent ID of the performer to delegate to'),
|
|
247
|
-
commissionPct: z.number().optional().describe('Commission percentage for the delegated agent'),
|
|
248
|
-
},
|
|
249
|
-
outputSchema: MandateOutputSchema,
|
|
250
|
-
annotations: {
|
|
251
|
-
readOnlyHint: false,
|
|
252
|
-
destructiveHint: false,
|
|
253
|
-
idempotentHint: false,
|
|
254
|
-
openWorldHint: true,
|
|
255
|
-
},
|
|
256
|
-
_meta: toolMeta('delegate_mandate'),
|
|
257
|
-
},
|
|
258
|
-
async (args) => {
|
|
259
|
-
try {
|
|
260
|
-
// Fetch the parent mandate to get contract details for delegation
|
|
261
|
-
const parent = await client.mandates.get(args.mandateId);
|
|
262
|
-
const childMandate = await client.mandates.delegate(args.mandateId, {
|
|
263
|
-
principalAgentId: parent.agentId ?? '',
|
|
264
|
-
performerAgentId: args.agentId,
|
|
265
|
-
contractType: parent.contractType,
|
|
266
|
-
contractVersion: parent.contractVersion,
|
|
267
|
-
platform: parent.platform,
|
|
268
|
-
criteria: parent.criteria,
|
|
269
|
-
commissionPct: args.commissionPct,
|
|
270
|
-
});
|
|
271
|
-
return {
|
|
272
|
-
content: [{ type: 'text', text: `Mandate ${args.mandateId} delegated to agent ${args.agentId}. Child mandate: ${childMandate.id}.` }],
|
|
273
|
-
structuredContent: toStructuredContent(childMandate),
|
|
274
|
-
};
|
|
275
|
-
} catch (err) {
|
|
276
|
-
return apiErrorResult(err);
|
|
277
|
-
}
|
|
278
|
-
},
|
|
279
|
-
);
|
|
280
|
-
|
|
281
|
-
mcp.registerTool(
|
|
282
|
-
'get_mandate_graph',
|
|
283
|
-
{
|
|
284
|
-
title: 'Get Mandate Graph',
|
|
285
|
-
description: 'Get the delegation graph for a mandate. Returns nodes and edges representing the full delegation tree.',
|
|
286
|
-
inputSchema: {
|
|
287
|
-
mandateId: z.string().describe('UUID of the mandate to get the delegation graph for'),
|
|
288
|
-
},
|
|
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
|
-
annotations: {
|
|
294
|
-
readOnlyHint: true,
|
|
295
|
-
destructiveHint: false,
|
|
296
|
-
idempotentHint: true,
|
|
297
|
-
openWorldHint: true,
|
|
298
|
-
},
|
|
299
|
-
_meta: toolMeta('get_mandate_graph'),
|
|
300
|
-
},
|
|
301
|
-
async (args) => {
|
|
302
|
-
try {
|
|
303
|
-
const graph = await client.mandates.getGraph(args.mandateId);
|
|
304
|
-
const nodes = (graph as any).nodes?.length ?? 0;
|
|
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
|
-
};
|
|
310
|
-
} catch (err) {
|
|
311
|
-
return apiErrorResult(err);
|
|
312
|
-
}
|
|
313
|
-
},
|
|
314
|
-
);
|
|
315
|
-
|
|
316
|
-
mcp.registerTool(
|
|
317
|
-
'get_mandate_summary',
|
|
318
|
-
{
|
|
319
|
-
title: 'Get Mandate Summary',
|
|
320
|
-
description: 'Get mandate counts grouped by status. Use for dashboard-level visibility.',
|
|
321
|
-
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
|
-
annotations: {
|
|
330
|
-
readOnlyHint: true,
|
|
331
|
-
destructiveHint: false,
|
|
332
|
-
idempotentHint: true,
|
|
333
|
-
openWorldHint: true,
|
|
334
|
-
},
|
|
335
|
-
_meta: toolMeta('get_mandate_summary'),
|
|
336
|
-
},
|
|
337
|
-
async () => {
|
|
338
|
-
try {
|
|
339
|
-
const summary = await client.mandates.getSummary();
|
|
340
|
-
return {
|
|
341
|
-
content: [{ type: 'text', text: `Mandate summary: ${JSON.stringify(summary)}.` }],
|
|
342
|
-
structuredContent: toStructuredContent(summary),
|
|
343
|
-
};
|
|
344
|
-
} catch (err) {
|
|
345
|
-
return apiErrorResult(err);
|
|
346
|
-
}
|
|
347
|
-
},
|
|
348
|
-
);
|
|
349
|
-
}
|
package/src/tools/openclaw.ts
DELETED
|
@@ -1,168 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
3
|
-
import type { AgledgerClient } from '@agledger/sdk';
|
|
4
|
-
import type { CallToolResult } from '@modelcontextprotocol/sdk/types.js';
|
|
5
|
-
import { apiErrorResult, toStructuredContent } from '../errors.js';
|
|
6
|
-
import { toolMeta } from '../tool-scopes.js';
|
|
7
|
-
|
|
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
|
-
export function registerOpenClawTools(mcp: McpServer, client: AgledgerClient): void {
|
|
33
|
-
|
|
34
|
-
// 1. Notarize — create an agreement
|
|
35
|
-
mcp.registerTool(
|
|
36
|
-
'agledger_notarize',
|
|
37
|
-
{
|
|
38
|
-
title: 'Notarize Agreement',
|
|
39
|
-
description: 'Create a notarized agreement. Returns mandate ID + hash. You keep the payload.',
|
|
40
|
-
inputSchema: {
|
|
41
|
-
contractType: z.string().describe('e.g. ACH-DLVR-v1, ACH-DATA-v1, ACH-ORCH-v1'),
|
|
42
|
-
payload: z.record(z.string(), z.unknown()).describe('Agreement criteria'),
|
|
43
|
-
performerHint: z.string().optional().describe('Who should do the work'),
|
|
44
|
-
},
|
|
45
|
-
outputSchema: NotarizeOutputSchema,
|
|
46
|
-
annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: true },
|
|
47
|
-
_meta: toolMeta('agledger_notarize'),
|
|
48
|
-
},
|
|
49
|
-
async (args) => {
|
|
50
|
-
try {
|
|
51
|
-
const result = await client.notarize.createMandate({
|
|
52
|
-
contractType: args.contractType as any,
|
|
53
|
-
payload: args.payload,
|
|
54
|
-
performerHint: args.performerHint,
|
|
55
|
-
});
|
|
56
|
-
return ok(
|
|
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
|
-
);
|
|
60
|
-
} catch (e) { return apiErrorResult(e); }
|
|
61
|
-
},
|
|
62
|
-
);
|
|
63
|
-
|
|
64
|
-
// 2. Accept — performer commits to the agreement
|
|
65
|
-
mcp.registerTool(
|
|
66
|
-
'agledger_accept',
|
|
67
|
-
{
|
|
68
|
-
title: 'Accept Agreement',
|
|
69
|
-
description: 'Accept a notarized agreement. Signals commitment to deliver.',
|
|
70
|
-
inputSchema: {
|
|
71
|
-
mandateId: z.string().describe('Mandate ID to accept'),
|
|
72
|
-
},
|
|
73
|
-
outputSchema: MandateOutputSchema,
|
|
74
|
-
annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: true, openWorldHint: true },
|
|
75
|
-
_meta: toolMeta('agledger_accept'),
|
|
76
|
-
},
|
|
77
|
-
async (args) => {
|
|
78
|
-
try {
|
|
79
|
-
const mandate = await client.notarize.acceptMandate(args.mandateId);
|
|
80
|
-
return ok(
|
|
81
|
-
`Agreement ${mandate.id} accepted. Do the work, then call agledger_receipt.`,
|
|
82
|
-
toStructuredContent(mandate),
|
|
83
|
-
);
|
|
84
|
-
} catch (e) { return apiErrorResult(e); }
|
|
85
|
-
},
|
|
86
|
-
);
|
|
87
|
-
|
|
88
|
-
// 3. Receipt — performer submits evidence of completion
|
|
89
|
-
mcp.registerTool(
|
|
90
|
-
'agledger_receipt',
|
|
91
|
-
{
|
|
92
|
-
title: 'Submit Receipt',
|
|
93
|
-
description: 'Submit evidence of completed work. Returns receipt hash.',
|
|
94
|
-
inputSchema: {
|
|
95
|
-
mandateId: z.string().describe('Mandate ID this receipt is for'),
|
|
96
|
-
payload: z.record(z.string(), z.unknown()).describe('Evidence of completion'),
|
|
97
|
-
},
|
|
98
|
-
outputSchema: ReceiptOutputSchema,
|
|
99
|
-
annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: true },
|
|
100
|
-
_meta: toolMeta('agledger_receipt'),
|
|
101
|
-
},
|
|
102
|
-
async (args) => {
|
|
103
|
-
try {
|
|
104
|
-
const result = await client.notarize.submitReceipt(args.mandateId, {
|
|
105
|
-
payload: args.payload,
|
|
106
|
-
});
|
|
107
|
-
return ok(
|
|
108
|
-
`Receipt ${result.id} submitted for ${args.mandateId}. Hash: ${result.payloadHash}. Principal should call agledger_verdict.`,
|
|
109
|
-
toStructuredContent(result),
|
|
110
|
-
);
|
|
111
|
-
} catch (e) { return apiErrorResult(e); }
|
|
112
|
-
},
|
|
113
|
-
);
|
|
114
|
-
|
|
115
|
-
// 4. Verdict — principal accepts or rejects delivery
|
|
116
|
-
mcp.registerTool(
|
|
117
|
-
'agledger_verdict',
|
|
118
|
-
{
|
|
119
|
-
title: 'Render Verdict',
|
|
120
|
-
description: 'Accept or reject delivered work. Closes the agreement.',
|
|
121
|
-
inputSchema: {
|
|
122
|
-
mandateId: z.string().describe('Mandate ID'),
|
|
123
|
-
verdict: z.enum(['PASS', 'FAIL']).describe('PASS to accept, FAIL to reject'),
|
|
124
|
-
reason: z.string().optional().describe('Why'),
|
|
125
|
-
},
|
|
126
|
-
outputSchema: MandateOutputSchema,
|
|
127
|
-
annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: true, openWorldHint: true },
|
|
128
|
-
_meta: toolMeta('agledger_verdict'),
|
|
129
|
-
},
|
|
130
|
-
async (args) => {
|
|
131
|
-
try {
|
|
132
|
-
const mandate = await client.notarize.renderVerdict(args.mandateId, {
|
|
133
|
-
verdict: args.verdict,
|
|
134
|
-
reason: args.reason,
|
|
135
|
-
});
|
|
136
|
-
const verb = args.verdict === 'PASS' ? 'accepted' : 'rejected';
|
|
137
|
-
return ok(
|
|
138
|
-
`Agreement ${mandate.id} ${verb}. Status: ${mandate.status}.`,
|
|
139
|
-
toStructuredContent(mandate),
|
|
140
|
-
);
|
|
141
|
-
} catch (e) { return apiErrorResult(e); }
|
|
142
|
-
},
|
|
143
|
-
);
|
|
144
|
-
|
|
145
|
-
// 5. Status — check agreement state
|
|
146
|
-
mcp.registerTool(
|
|
147
|
-
'agledger_status',
|
|
148
|
-
{
|
|
149
|
-
title: 'Agreement Status',
|
|
150
|
-
description: 'Check current state of an agreement.',
|
|
151
|
-
inputSchema: {
|
|
152
|
-
mandateId: z.string().describe('Mandate ID'),
|
|
153
|
-
},
|
|
154
|
-
outputSchema: MandateOutputSchema,
|
|
155
|
-
annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: true },
|
|
156
|
-
_meta: toolMeta('agledger_status'),
|
|
157
|
-
},
|
|
158
|
-
async (args) => {
|
|
159
|
-
try {
|
|
160
|
-
const mandate = await client.notarize.getMandate(args.mandateId);
|
|
161
|
-
return ok(
|
|
162
|
-
`Agreement ${mandate.id}: ${mandate.status} (${mandate.contractType})`,
|
|
163
|
-
toStructuredContent(mandate),
|
|
164
|
-
);
|
|
165
|
-
} catch (e) { return apiErrorResult(e); }
|
|
166
|
-
},
|
|
167
|
-
);
|
|
168
|
-
}
|