@agledger/mcp-server 1.2.0 → 1.2.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/LICENSE +1 -1
- package/README.md +1 -1
- package/dist/index.js +1 -1
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +6 -2
- package/dist/server.js.map +1 -1
- package/dist/tool-scopes.d.ts.map +1 -1
- package/dist/tool-scopes.js +2 -0
- package/dist/tool-scopes.js.map +1 -1
- package/dist/tools/code-mode.d.ts.map +1 -1
- package/dist/tools/code-mode.js +4 -1
- package/dist/tools/code-mode.js.map +1 -1
- package/dist/tools/verification-keys.d.ts +5 -0
- package/dist/tools/verification-keys.d.ts.map +1 -0
- package/dist/tools/verification-keys.js +49 -0
- package/dist/tools/verification-keys.js.map +1 -0
- package/package.json +1 -6
- package/src/enums.ts +48 -0
- package/src/errors.ts +37 -0
- package/src/index.ts +102 -0
- package/src/resources/contract-types.ts +134 -0
- package/src/server.ts +134 -0
- package/src/tool-scopes.ts +193 -0
- package/src/tools/a2a.ts +551 -0
- package/src/tools/agent-mandates.ts +336 -0
- package/src/tools/agents-refs.ts +296 -0
- package/src/tools/capabilities.ts +80 -0
- package/src/tools/code-mode.ts +473 -0
- package/src/tools/compliance.ts +81 -0
- package/src/tools/dashboard.ts +75 -0
- package/src/tools/disputes.ts +160 -0
- package/src/tools/enterprises.ts +243 -0
- package/src/tools/events.ts +55 -0
- package/src/tools/federation-admin.ts +948 -0
- package/src/tools/federation.ts +806 -0
- package/src/tools/health.ts +46 -0
- package/src/tools/mandates.ts +394 -0
- package/src/tools/openclaw.ts +174 -0
- package/src/tools/receipts.ts +185 -0
- package/src/tools/reputation.ts +80 -0
- package/src/tools/schemas.ts +685 -0
- package/src/tools/verification-keys.ts +58 -0
- package/src/tools/verification.ts +89 -0
- package/tests/code-mode-manifest.test.ts +144 -0
- package/tests/enterprises.test.ts +96 -0
- package/tests/schemas.test.ts +531 -0
- package/tsconfig.json +12 -0
|
@@ -0,0 +1,336 @@
|
|
|
1
|
+
/** AGLedger™ — Agent-to-agent mandate MCP tools. Patent Pending. Copyright 2026 AGLedger LLC. All rights reserved. */
|
|
2
|
+
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
5
|
+
import type { AgledgerClient } from '@agledger/sdk';
|
|
6
|
+
import { apiErrorResult } from '../errors.js';
|
|
7
|
+
import { toolMeta } from '../tool-scopes.js';
|
|
8
|
+
import { ContractTypeEnum, NextStepsField } from '../enums.js';
|
|
9
|
+
|
|
10
|
+
const MandateOutputSchema = z.object({
|
|
11
|
+
id: z.string(),
|
|
12
|
+
enterpriseId: z.string(),
|
|
13
|
+
agentId: z.string().nullable().optional(),
|
|
14
|
+
contractType: ContractTypeEnum,
|
|
15
|
+
contractVersion: z.string(),
|
|
16
|
+
platform: z.string(),
|
|
17
|
+
status: z.string(),
|
|
18
|
+
criteria: z.record(z.string(), z.unknown()),
|
|
19
|
+
tolerance: z.record(z.string(), z.unknown()).nullable().optional(),
|
|
20
|
+
deadline: z.string().nullable().optional(),
|
|
21
|
+
commissionPct: z.number().nullable().optional(),
|
|
22
|
+
parentMandateId: z.string().nullable().optional(),
|
|
23
|
+
rootMandateId: z.string().nullable().optional(),
|
|
24
|
+
chainDepth: z.number().nullable().optional(),
|
|
25
|
+
version: z.number(),
|
|
26
|
+
createdAt: z.string(),
|
|
27
|
+
updatedAt: z.string(),
|
|
28
|
+
nextSteps: NextStepsField,
|
|
29
|
+
}).passthrough().describe('AGLedger mandate object');
|
|
30
|
+
|
|
31
|
+
const PageOutputSchema = z.object({
|
|
32
|
+
data: z.array(MandateOutputSchema),
|
|
33
|
+
hasMore: z.boolean(),
|
|
34
|
+
nextCursor: z.string().nullable().optional(),
|
|
35
|
+
total: z.number().optional(),
|
|
36
|
+
}).describe('Paginated mandate results');
|
|
37
|
+
|
|
38
|
+
export function registerAgentMandateTools(mcp: McpServer, client: AgledgerClient): void {
|
|
39
|
+
// --- propose_agent_mandate ---
|
|
40
|
+
mcp.registerTool(
|
|
41
|
+
'propose_agent_mandate',
|
|
42
|
+
{
|
|
43
|
+
title: 'Propose Agent Mandate',
|
|
44
|
+
description: 'Create a mandate proposal from one agent to another. The mandate starts in PROPOSED status.',
|
|
45
|
+
inputSchema: {
|
|
46
|
+
principalAgentId: z.string().describe('Agent ID of the principal (proposer)'),
|
|
47
|
+
performerAgentId: z.string().optional().describe('Agent ID of the performer (recipient)'),
|
|
48
|
+
contractType: ContractTypeEnum,
|
|
49
|
+
contractVersion: z.string().default('1').describe('Contract version'),
|
|
50
|
+
platform: z.string().optional().describe('Platform identifier'),
|
|
51
|
+
criteria: z.record(z.string(), z.unknown()).describe('Acceptance criteria'),
|
|
52
|
+
tolerance: z.record(z.string(), z.unknown()).optional().describe('Tolerance bands'),
|
|
53
|
+
parentMandateId: z.string().optional().describe('Parent mandate ID for delegation'),
|
|
54
|
+
commissionPct: z.number().optional().describe('Commission percentage (0-100)'),
|
|
55
|
+
deadline: z.string().optional().describe('ISO 8601 deadline'),
|
|
56
|
+
},
|
|
57
|
+
outputSchema: MandateOutputSchema,
|
|
58
|
+
annotations: {
|
|
59
|
+
readOnlyHint: false,
|
|
60
|
+
destructiveHint: false,
|
|
61
|
+
idempotentHint: false,
|
|
62
|
+
openWorldHint: true,
|
|
63
|
+
},
|
|
64
|
+
_meta: toolMeta('propose_agent_mandate'),
|
|
65
|
+
},
|
|
66
|
+
async (args) => {
|
|
67
|
+
try {
|
|
68
|
+
const mandate = await client.mandates.createAgent(args);
|
|
69
|
+
return {
|
|
70
|
+
content: [{ type: 'text', text: `Mandate ${mandate.id} proposed (${mandate.status}).` }],
|
|
71
|
+
structuredContent: mandate as unknown as Record<string, unknown>,
|
|
72
|
+
};
|
|
73
|
+
} catch (err) {
|
|
74
|
+
return apiErrorResult(err);
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
);
|
|
78
|
+
|
|
79
|
+
// --- accept_proposal ---
|
|
80
|
+
mcp.registerTool(
|
|
81
|
+
'accept_proposal',
|
|
82
|
+
{
|
|
83
|
+
title: 'Accept Proposal',
|
|
84
|
+
description: 'Accept a proposed mandate. Moves status from PROPOSED to ACCEPTED.',
|
|
85
|
+
inputSchema: {
|
|
86
|
+
mandateId: z.string().describe('UUID of the proposed mandate'),
|
|
87
|
+
},
|
|
88
|
+
outputSchema: MandateOutputSchema,
|
|
89
|
+
annotations: {
|
|
90
|
+
readOnlyHint: false,
|
|
91
|
+
destructiveHint: false,
|
|
92
|
+
idempotentHint: true,
|
|
93
|
+
openWorldHint: true,
|
|
94
|
+
},
|
|
95
|
+
_meta: toolMeta('accept_proposal'),
|
|
96
|
+
},
|
|
97
|
+
async (args) => {
|
|
98
|
+
try {
|
|
99
|
+
const mandate = await client.mandates.accept(args.mandateId);
|
|
100
|
+
return {
|
|
101
|
+
content: [{ type: 'text', text: `Mandate ${mandate.id} accepted (${mandate.status}).` }],
|
|
102
|
+
structuredContent: mandate as unknown as Record<string, unknown>,
|
|
103
|
+
};
|
|
104
|
+
} catch (err) {
|
|
105
|
+
return apiErrorResult(err);
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
);
|
|
109
|
+
|
|
110
|
+
// --- reject_proposal ---
|
|
111
|
+
mcp.registerTool(
|
|
112
|
+
'reject_proposal',
|
|
113
|
+
{
|
|
114
|
+
title: 'Reject Proposal',
|
|
115
|
+
description: 'Reject a proposed mandate. Moves status to REJECTED.',
|
|
116
|
+
inputSchema: {
|
|
117
|
+
mandateId: z.string().describe('UUID of the proposed mandate'),
|
|
118
|
+
reason: z.string().optional().describe('Reason for rejection'),
|
|
119
|
+
},
|
|
120
|
+
outputSchema: MandateOutputSchema,
|
|
121
|
+
annotations: {
|
|
122
|
+
readOnlyHint: false,
|
|
123
|
+
destructiveHint: true,
|
|
124
|
+
idempotentHint: false,
|
|
125
|
+
openWorldHint: true,
|
|
126
|
+
},
|
|
127
|
+
_meta: toolMeta('reject_proposal'),
|
|
128
|
+
},
|
|
129
|
+
async (args) => {
|
|
130
|
+
try {
|
|
131
|
+
const mandate = await client.mandates.reject(args.mandateId, args.reason);
|
|
132
|
+
return {
|
|
133
|
+
content: [{ type: 'text', text: `Mandate ${mandate.id} rejected (${mandate.status}).` }],
|
|
134
|
+
structuredContent: mandate as unknown as Record<string, unknown>,
|
|
135
|
+
};
|
|
136
|
+
} catch (err) {
|
|
137
|
+
return apiErrorResult(err);
|
|
138
|
+
}
|
|
139
|
+
},
|
|
140
|
+
);
|
|
141
|
+
|
|
142
|
+
// --- counter_proposal ---
|
|
143
|
+
mcp.registerTool(
|
|
144
|
+
'counter_proposal',
|
|
145
|
+
{
|
|
146
|
+
title: 'Counter Proposal',
|
|
147
|
+
description: 'Counter-propose modified terms on a proposed mandate.',
|
|
148
|
+
inputSchema: {
|
|
149
|
+
mandateId: z.string().describe('UUID of the proposed mandate'),
|
|
150
|
+
counterCriteria: z.record(z.string(), z.unknown()).optional().describe('Modified acceptance criteria'),
|
|
151
|
+
counterTolerance: z.record(z.string(), z.unknown()).optional().describe('Modified tolerance bands'),
|
|
152
|
+
counterDeadline: z.string().optional().describe('Modified ISO 8601 deadline'),
|
|
153
|
+
counterCommissionPct: z.number().optional().describe('Modified commission percentage'),
|
|
154
|
+
message: z.string().optional().describe('Message explaining the counter-proposal'),
|
|
155
|
+
},
|
|
156
|
+
outputSchema: MandateOutputSchema,
|
|
157
|
+
annotations: {
|
|
158
|
+
readOnlyHint: false,
|
|
159
|
+
destructiveHint: false,
|
|
160
|
+
idempotentHint: false,
|
|
161
|
+
openWorldHint: true,
|
|
162
|
+
},
|
|
163
|
+
_meta: toolMeta('counter_proposal'),
|
|
164
|
+
},
|
|
165
|
+
async (args) => {
|
|
166
|
+
try {
|
|
167
|
+
const mandate = await client.mandates.counterPropose(args.mandateId, {
|
|
168
|
+
message: args.message,
|
|
169
|
+
counterCriteria: args.counterCriteria,
|
|
170
|
+
counterTolerance: args.counterTolerance,
|
|
171
|
+
counterDeadline: args.counterDeadline,
|
|
172
|
+
counterCommissionPct: args.counterCommissionPct ?? undefined,
|
|
173
|
+
});
|
|
174
|
+
return {
|
|
175
|
+
content: [{ type: 'text', text: `Mandate ${mandate.id} counter-proposed (${mandate.status}).` }],
|
|
176
|
+
structuredContent: mandate as unknown as Record<string, unknown>,
|
|
177
|
+
};
|
|
178
|
+
} catch (err) {
|
|
179
|
+
return apiErrorResult(err);
|
|
180
|
+
}
|
|
181
|
+
},
|
|
182
|
+
);
|
|
183
|
+
|
|
184
|
+
// --- accept_counter_proposal ---
|
|
185
|
+
mcp.registerTool(
|
|
186
|
+
'accept_counter_proposal',
|
|
187
|
+
{
|
|
188
|
+
title: 'Accept Counter Proposal',
|
|
189
|
+
description: 'Accept a counter-proposal on a mandate.',
|
|
190
|
+
inputSchema: {
|
|
191
|
+
mandateId: z.string().describe('UUID of the counter-proposed mandate'),
|
|
192
|
+
},
|
|
193
|
+
outputSchema: MandateOutputSchema,
|
|
194
|
+
annotations: {
|
|
195
|
+
readOnlyHint: false,
|
|
196
|
+
destructiveHint: false,
|
|
197
|
+
idempotentHint: true,
|
|
198
|
+
openWorldHint: true,
|
|
199
|
+
},
|
|
200
|
+
_meta: toolMeta('accept_counter_proposal'),
|
|
201
|
+
},
|
|
202
|
+
async (args) => {
|
|
203
|
+
try {
|
|
204
|
+
const mandate = await client.mandates.acceptCounter(args.mandateId);
|
|
205
|
+
return {
|
|
206
|
+
content: [{ type: 'text', text: `Counter-proposal on ${mandate.id} accepted (${mandate.status}).` }],
|
|
207
|
+
structuredContent: mandate as unknown as Record<string, unknown>,
|
|
208
|
+
};
|
|
209
|
+
} catch (err) {
|
|
210
|
+
return apiErrorResult(err);
|
|
211
|
+
}
|
|
212
|
+
},
|
|
213
|
+
);
|
|
214
|
+
|
|
215
|
+
// --- list_my_proposals ---
|
|
216
|
+
mcp.registerTool(
|
|
217
|
+
'list_my_proposals',
|
|
218
|
+
{
|
|
219
|
+
title: 'List My Proposals',
|
|
220
|
+
description: 'List mandate proposals awaiting my response as performer.',
|
|
221
|
+
inputSchema: {},
|
|
222
|
+
outputSchema: PageOutputSchema,
|
|
223
|
+
annotations: {
|
|
224
|
+
readOnlyHint: true,
|
|
225
|
+
destructiveHint: false,
|
|
226
|
+
idempotentHint: true,
|
|
227
|
+
openWorldHint: true,
|
|
228
|
+
},
|
|
229
|
+
_meta: toolMeta('list_my_proposals'),
|
|
230
|
+
},
|
|
231
|
+
async () => {
|
|
232
|
+
try {
|
|
233
|
+
const result = await client.mandates.listProposals();
|
|
234
|
+
return {
|
|
235
|
+
content: [{ type: 'text', text: `Found ${result.data.length} proposals.` }],
|
|
236
|
+
structuredContent: result as unknown as Record<string, unknown>,
|
|
237
|
+
};
|
|
238
|
+
} catch (err) {
|
|
239
|
+
return apiErrorResult(err);
|
|
240
|
+
}
|
|
241
|
+
},
|
|
242
|
+
);
|
|
243
|
+
|
|
244
|
+
// --- list_principal_mandates ---
|
|
245
|
+
mcp.registerTool(
|
|
246
|
+
'list_principal_mandates',
|
|
247
|
+
{
|
|
248
|
+
title: 'List Principal Mandates',
|
|
249
|
+
description: 'List mandates where I am the principal (the one who proposed/created them).',
|
|
250
|
+
inputSchema: {},
|
|
251
|
+
outputSchema: PageOutputSchema,
|
|
252
|
+
annotations: {
|
|
253
|
+
readOnlyHint: true,
|
|
254
|
+
destructiveHint: false,
|
|
255
|
+
idempotentHint: true,
|
|
256
|
+
openWorldHint: true,
|
|
257
|
+
},
|
|
258
|
+
_meta: toolMeta('list_principal_mandates'),
|
|
259
|
+
},
|
|
260
|
+
async () => {
|
|
261
|
+
try {
|
|
262
|
+
const result = await client.mandates.listAsPrincipal();
|
|
263
|
+
return {
|
|
264
|
+
content: [{ type: 'text', text: `Found ${result.data.length} mandates as principal.` }],
|
|
265
|
+
structuredContent: result as unknown as Record<string, unknown>,
|
|
266
|
+
};
|
|
267
|
+
} catch (err) {
|
|
268
|
+
return apiErrorResult(err);
|
|
269
|
+
}
|
|
270
|
+
},
|
|
271
|
+
);
|
|
272
|
+
|
|
273
|
+
// --- get_delegation_chain ---
|
|
274
|
+
mcp.registerTool(
|
|
275
|
+
'get_delegation_chain',
|
|
276
|
+
{
|
|
277
|
+
title: 'Get Delegation Chain',
|
|
278
|
+
description: 'Get the full delegation chain for a mandate (root to leaf).',
|
|
279
|
+
inputSchema: {
|
|
280
|
+
mandateId: z.string().describe('UUID of any mandate in the chain'),
|
|
281
|
+
},
|
|
282
|
+
outputSchema: z.object({
|
|
283
|
+
chain: z.array(MandateOutputSchema),
|
|
284
|
+
}),
|
|
285
|
+
annotations: {
|
|
286
|
+
readOnlyHint: true,
|
|
287
|
+
destructiveHint: false,
|
|
288
|
+
idempotentHint: true,
|
|
289
|
+
openWorldHint: true,
|
|
290
|
+
},
|
|
291
|
+
_meta: toolMeta('get_delegation_chain'),
|
|
292
|
+
},
|
|
293
|
+
async (args) => {
|
|
294
|
+
try {
|
|
295
|
+
const chain = await client.mandates.getChain(args.mandateId);
|
|
296
|
+
return {
|
|
297
|
+
content: [{ type: 'text', text: `Delegation chain has ${chain.length} mandates.` }],
|
|
298
|
+
structuredContent: { chain } as unknown as Record<string, unknown>,
|
|
299
|
+
};
|
|
300
|
+
} catch (err) {
|
|
301
|
+
return apiErrorResult(err);
|
|
302
|
+
}
|
|
303
|
+
},
|
|
304
|
+
);
|
|
305
|
+
|
|
306
|
+
// --- get_sub_mandates ---
|
|
307
|
+
mcp.registerTool(
|
|
308
|
+
'get_sub_mandates',
|
|
309
|
+
{
|
|
310
|
+
title: 'Get Sub-Mandates',
|
|
311
|
+
description: 'Get direct sub-mandates (children) of a parent mandate.',
|
|
312
|
+
inputSchema: {
|
|
313
|
+
mandateId: z.string().describe('UUID of the parent mandate'),
|
|
314
|
+
},
|
|
315
|
+
outputSchema: PageOutputSchema,
|
|
316
|
+
annotations: {
|
|
317
|
+
readOnlyHint: true,
|
|
318
|
+
destructiveHint: false,
|
|
319
|
+
idempotentHint: true,
|
|
320
|
+
openWorldHint: true,
|
|
321
|
+
},
|
|
322
|
+
_meta: toolMeta('get_sub_mandates'),
|
|
323
|
+
},
|
|
324
|
+
async (args) => {
|
|
325
|
+
try {
|
|
326
|
+
const result = await client.mandates.getSubMandates(args.mandateId);
|
|
327
|
+
return {
|
|
328
|
+
content: [{ type: 'text', text: `Found ${result.data.length} sub-mandates.` }],
|
|
329
|
+
structuredContent: result as unknown as Record<string, unknown>,
|
|
330
|
+
};
|
|
331
|
+
} catch (err) {
|
|
332
|
+
return apiErrorResult(err);
|
|
333
|
+
}
|
|
334
|
+
},
|
|
335
|
+
);
|
|
336
|
+
}
|
|
@@ -0,0 +1,296 @@
|
|
|
1
|
+
/** AGLedger™ — Agents & References MCP tools. Patent Pending. Copyright 2026 AGLedger LLC. All rights reserved. */
|
|
2
|
+
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
5
|
+
import type { AgledgerClient } from '@agledger/sdk';
|
|
6
|
+
import { apiErrorResult } from '../errors.js';
|
|
7
|
+
import { toolMeta } from '../tool-scopes.js';
|
|
8
|
+
|
|
9
|
+
const AgentProfileOutputSchema = z.object({
|
|
10
|
+
agentId: z.string().describe('Unique agent identifier'),
|
|
11
|
+
agentClass: z.string().optional().describe('Agent classification (e.g. "data-processor", "orchestrator")'),
|
|
12
|
+
ownerRef: z.string().optional().describe('Owner or team reference'),
|
|
13
|
+
orgUnit: z.string().optional().describe('Organizational unit'),
|
|
14
|
+
description: z.string().optional().describe('Human-readable agent description'),
|
|
15
|
+
}).describe('Agent profile');
|
|
16
|
+
|
|
17
|
+
const ReferenceSchema = z.object({
|
|
18
|
+
system: z.string().describe('External system name (e.g. "jira", "salesforce", "github")'),
|
|
19
|
+
refType: z.string().describe('Reference type within the system (e.g. "ticket", "case", "issue")'),
|
|
20
|
+
refId: z.string().describe('Identifier in the external system'),
|
|
21
|
+
metadata: z.record(z.string(), z.unknown()).optional().describe('Additional metadata about the reference'),
|
|
22
|
+
}).describe('External reference linking an AGLedger entity to an external system');
|
|
23
|
+
|
|
24
|
+
const ReferencesOutputSchema = z.object({
|
|
25
|
+
references: z.array(ReferenceSchema).describe('List of external references'),
|
|
26
|
+
}).describe('External references for an entity');
|
|
27
|
+
|
|
28
|
+
const LookupOutputSchema = z.object({
|
|
29
|
+
entityType: z.string().optional().describe('Type of entity found (e.g. "agent", "mandate")'),
|
|
30
|
+
entityId: z.string().optional().describe('AGLedger ID of the matched entity'),
|
|
31
|
+
system: z.string().describe('External system name'),
|
|
32
|
+
refType: z.string().describe('Reference type'),
|
|
33
|
+
refId: z.string().describe('External reference ID'),
|
|
34
|
+
}).describe('Reverse lookup result mapping an external reference to an AGLedger entity');
|
|
35
|
+
|
|
36
|
+
export function registerAgentsRefsTools(mcp: McpServer, client: AgledgerClient): void {
|
|
37
|
+
// --- get_agent ---
|
|
38
|
+
mcp.registerTool(
|
|
39
|
+
'get_agent',
|
|
40
|
+
{
|
|
41
|
+
title: 'Get Agent Profile',
|
|
42
|
+
description:
|
|
43
|
+
'Retrieve an agent\'s profile by ID, including identity fields like agentClass, ownerRef, and orgUnit. ' +
|
|
44
|
+
'Use this before update_agent to see current values, or to verify an agent exists before assigning mandates.',
|
|
45
|
+
inputSchema: {
|
|
46
|
+
agentId: z.string().describe('Agent ID to retrieve'),
|
|
47
|
+
},
|
|
48
|
+
outputSchema: AgentProfileOutputSchema,
|
|
49
|
+
annotations: {
|
|
50
|
+
readOnlyHint: true,
|
|
51
|
+
destructiveHint: false,
|
|
52
|
+
idempotentHint: true,
|
|
53
|
+
openWorldHint: true,
|
|
54
|
+
},
|
|
55
|
+
_meta: toolMeta('get_agent'),
|
|
56
|
+
},
|
|
57
|
+
async (args) => {
|
|
58
|
+
try {
|
|
59
|
+
const result = await client.agents.get(args.agentId);
|
|
60
|
+
return {
|
|
61
|
+
content: [{ type: 'text', text: `Agent ${result.id}: class=${result.agentClass ?? 'unset'}, owner=${result.ownerRef ?? 'unset'}.` }],
|
|
62
|
+
structuredContent: result as unknown as Record<string, unknown>,
|
|
63
|
+
};
|
|
64
|
+
} catch (err) {
|
|
65
|
+
return apiErrorResult(err);
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
);
|
|
69
|
+
|
|
70
|
+
// --- update_agent ---
|
|
71
|
+
mcp.registerTool(
|
|
72
|
+
'update_agent',
|
|
73
|
+
{
|
|
74
|
+
title: 'Update Agent Profile',
|
|
75
|
+
description:
|
|
76
|
+
'Update an agent\'s identity fields (agentClass, ownerRef, orgUnit, description). ' +
|
|
77
|
+
'Only provided fields are changed; omitted fields remain unchanged. ' +
|
|
78
|
+
'Use get_agent first to review current values.',
|
|
79
|
+
inputSchema: {
|
|
80
|
+
agentId: z.string().describe('Agent ID to update'),
|
|
81
|
+
agentClass: z.string().optional().describe('Agent classification (e.g. "data-processor", "orchestrator")'),
|
|
82
|
+
ownerRef: z.string().optional().describe('Owner or team reference'),
|
|
83
|
+
orgUnit: z.string().optional().describe('Organizational unit'),
|
|
84
|
+
description: z.string().optional().describe('Human-readable agent description'),
|
|
85
|
+
},
|
|
86
|
+
outputSchema: AgentProfileOutputSchema,
|
|
87
|
+
annotations: {
|
|
88
|
+
readOnlyHint: false,
|
|
89
|
+
destructiveHint: false,
|
|
90
|
+
idempotentHint: true,
|
|
91
|
+
openWorldHint: true,
|
|
92
|
+
},
|
|
93
|
+
_meta: toolMeta('update_agent'),
|
|
94
|
+
},
|
|
95
|
+
async (args) => {
|
|
96
|
+
try {
|
|
97
|
+
const result = await client.agents.update(args.agentId, {
|
|
98
|
+
agentClass: args.agentClass,
|
|
99
|
+
ownerRef: args.ownerRef,
|
|
100
|
+
orgUnit: args.orgUnit,
|
|
101
|
+
description: args.description,
|
|
102
|
+
});
|
|
103
|
+
return {
|
|
104
|
+
content: [{ type: 'text', text: `Agent ${result.id} updated.` }],
|
|
105
|
+
structuredContent: result as unknown as Record<string, unknown>,
|
|
106
|
+
};
|
|
107
|
+
} catch (err) {
|
|
108
|
+
return apiErrorResult(err);
|
|
109
|
+
}
|
|
110
|
+
},
|
|
111
|
+
);
|
|
112
|
+
|
|
113
|
+
// --- add_agent_references ---
|
|
114
|
+
mcp.registerTool(
|
|
115
|
+
'add_agent_references',
|
|
116
|
+
{
|
|
117
|
+
title: 'Add Agent References',
|
|
118
|
+
description:
|
|
119
|
+
'Add external references to an agent, linking it to records in external systems like Jira, Salesforce, or GitHub. ' +
|
|
120
|
+
'References enable reverse lookup via lookup_reference. ' +
|
|
121
|
+
'Use get_agent_references to see existing references before adding.',
|
|
122
|
+
inputSchema: {
|
|
123
|
+
agentId: z.string().describe('Agent ID to add references to'),
|
|
124
|
+
references: z.array(z.object({
|
|
125
|
+
system: z.string().describe('External system name (e.g. "jira", "salesforce", "github")'),
|
|
126
|
+
refType: z.string().describe('Reference type within the system (e.g. "ticket", "case", "issue")'),
|
|
127
|
+
refId: z.string().describe('Identifier in the external system'),
|
|
128
|
+
metadata: z.record(z.string(), z.unknown()).optional().describe('Additional metadata about the reference'),
|
|
129
|
+
})).describe('References to add'),
|
|
130
|
+
},
|
|
131
|
+
outputSchema: ReferencesOutputSchema,
|
|
132
|
+
annotations: {
|
|
133
|
+
readOnlyHint: false,
|
|
134
|
+
destructiveHint: false,
|
|
135
|
+
idempotentHint: false,
|
|
136
|
+
openWorldHint: true,
|
|
137
|
+
},
|
|
138
|
+
_meta: toolMeta('add_agent_references'),
|
|
139
|
+
},
|
|
140
|
+
async (args) => {
|
|
141
|
+
try {
|
|
142
|
+
const result = await client.agents.addReferences(args.agentId, args.references);
|
|
143
|
+
return {
|
|
144
|
+
content: [{ type: 'text', text: `Added ${args.references.length} reference(s) to agent ${args.agentId}.` }],
|
|
145
|
+
structuredContent: result as unknown as Record<string, unknown>,
|
|
146
|
+
};
|
|
147
|
+
} catch (err) {
|
|
148
|
+
return apiErrorResult(err);
|
|
149
|
+
}
|
|
150
|
+
},
|
|
151
|
+
);
|
|
152
|
+
|
|
153
|
+
// --- get_agent_references ---
|
|
154
|
+
mcp.registerTool(
|
|
155
|
+
'get_agent_references',
|
|
156
|
+
{
|
|
157
|
+
title: 'Get Agent References',
|
|
158
|
+
description:
|
|
159
|
+
'Get all external references for an agent. Returns links to external systems like Jira, Salesforce, or GitHub. ' +
|
|
160
|
+
'Use this to audit cross-system linkage or before adding new references.',
|
|
161
|
+
inputSchema: {
|
|
162
|
+
agentId: z.string().describe('Agent ID to get references for'),
|
|
163
|
+
},
|
|
164
|
+
outputSchema: ReferencesOutputSchema,
|
|
165
|
+
annotations: {
|
|
166
|
+
readOnlyHint: true,
|
|
167
|
+
destructiveHint: false,
|
|
168
|
+
idempotentHint: true,
|
|
169
|
+
openWorldHint: true,
|
|
170
|
+
},
|
|
171
|
+
_meta: toolMeta('get_agent_references'),
|
|
172
|
+
},
|
|
173
|
+
async (args) => {
|
|
174
|
+
try {
|
|
175
|
+
const result = await client.agents.getReferences(args.agentId);
|
|
176
|
+
const refs = Array.isArray(result) ? result : (result as Record<string, unknown>).references ?? [];
|
|
177
|
+
return {
|
|
178
|
+
content: [{ type: 'text', text: `Agent ${args.agentId} has ${(refs as unknown[]).length} reference(s).` }],
|
|
179
|
+
structuredContent: (Array.isArray(result) ? { references: result } : result) as unknown as Record<string, unknown>,
|
|
180
|
+
};
|
|
181
|
+
} catch (err) {
|
|
182
|
+
return apiErrorResult(err);
|
|
183
|
+
}
|
|
184
|
+
},
|
|
185
|
+
);
|
|
186
|
+
|
|
187
|
+
// --- lookup_reference ---
|
|
188
|
+
mcp.registerTool(
|
|
189
|
+
'lookup_reference',
|
|
190
|
+
{
|
|
191
|
+
title: 'Lookup by External Reference',
|
|
192
|
+
description:
|
|
193
|
+
'Reverse lookup an AGLedger entity by its external reference. ' +
|
|
194
|
+
'Use this to find mandates by Jira ticket IDs, Salesforce case numbers, GitHub issue URLs, or any other external system identifier. ' +
|
|
195
|
+
'Returns the AGLedger entity type and ID that matches the reference.',
|
|
196
|
+
inputSchema: {
|
|
197
|
+
system: z.string().describe('External system name (e.g. "jira", "salesforce", "github")'),
|
|
198
|
+
refType: z.string().describe('Reference type within the system (e.g. "ticket", "case", "issue")'),
|
|
199
|
+
refId: z.string().describe('Identifier in the external system'),
|
|
200
|
+
},
|
|
201
|
+
outputSchema: LookupOutputSchema,
|
|
202
|
+
annotations: {
|
|
203
|
+
readOnlyHint: true,
|
|
204
|
+
destructiveHint: false,
|
|
205
|
+
idempotentHint: true,
|
|
206
|
+
openWorldHint: true,
|
|
207
|
+
},
|
|
208
|
+
_meta: toolMeta('lookup_reference'),
|
|
209
|
+
},
|
|
210
|
+
async (args) => {
|
|
211
|
+
try {
|
|
212
|
+
const result = await client.references.lookup(args);
|
|
213
|
+
return {
|
|
214
|
+
content: [{ type: 'text', text: `Found ${(result as unknown as Record<string, unknown>).entityType ?? 'entity'} ${(result as unknown as Record<string, unknown>).entityId ?? 'unknown'} for ${args.system}/${args.refType}/${args.refId}.` }],
|
|
215
|
+
structuredContent: result as unknown as Record<string, unknown>,
|
|
216
|
+
};
|
|
217
|
+
} catch (err) {
|
|
218
|
+
return apiErrorResult(err);
|
|
219
|
+
}
|
|
220
|
+
},
|
|
221
|
+
);
|
|
222
|
+
|
|
223
|
+
// --- add_mandate_references ---
|
|
224
|
+
mcp.registerTool(
|
|
225
|
+
'add_mandate_references',
|
|
226
|
+
{
|
|
227
|
+
title: 'Add Mandate References',
|
|
228
|
+
description:
|
|
229
|
+
'Add external references to a mandate, linking it to records in external systems. ' +
|
|
230
|
+
'For example, link a mandate to a Jira ticket, Salesforce opportunity, or GitHub PR. ' +
|
|
231
|
+
'References enable reverse lookup via lookup_reference and cross-system traceability.',
|
|
232
|
+
inputSchema: {
|
|
233
|
+
mandateId: z.string().describe('Mandate ID to add references to'),
|
|
234
|
+
references: z.array(z.object({
|
|
235
|
+
system: z.string().describe('External system name (e.g. "jira", "salesforce", "github")'),
|
|
236
|
+
refType: z.string().describe('Reference type within the system (e.g. "ticket", "case", "pr")'),
|
|
237
|
+
refId: z.string().describe('Identifier in the external system'),
|
|
238
|
+
metadata: z.record(z.string(), z.unknown()).optional().describe('Additional metadata about the reference'),
|
|
239
|
+
})).describe('References to add'),
|
|
240
|
+
},
|
|
241
|
+
outputSchema: ReferencesOutputSchema,
|
|
242
|
+
annotations: {
|
|
243
|
+
readOnlyHint: false,
|
|
244
|
+
destructiveHint: false,
|
|
245
|
+
idempotentHint: false,
|
|
246
|
+
openWorldHint: true,
|
|
247
|
+
},
|
|
248
|
+
_meta: toolMeta('add_mandate_references'),
|
|
249
|
+
},
|
|
250
|
+
async (args) => {
|
|
251
|
+
try {
|
|
252
|
+
const result = await client.references.addMandateReferences(args.mandateId, args.references);
|
|
253
|
+
return {
|
|
254
|
+
content: [{ type: 'text', text: `Added ${args.references.length} reference(s) to mandate ${args.mandateId}.` }],
|
|
255
|
+
structuredContent: result as unknown as Record<string, unknown>,
|
|
256
|
+
};
|
|
257
|
+
} catch (err) {
|
|
258
|
+
return apiErrorResult(err);
|
|
259
|
+
}
|
|
260
|
+
},
|
|
261
|
+
);
|
|
262
|
+
|
|
263
|
+
// --- get_mandate_references ---
|
|
264
|
+
mcp.registerTool(
|
|
265
|
+
'get_mandate_references',
|
|
266
|
+
{
|
|
267
|
+
title: 'Get Mandate References',
|
|
268
|
+
description:
|
|
269
|
+
'Get all external references for a mandate. Returns links to external systems like Jira, Salesforce, or GitHub. ' +
|
|
270
|
+
'Use this for cross-system traceability or to verify linkage before adding new references.',
|
|
271
|
+
inputSchema: {
|
|
272
|
+
mandateId: z.string().describe('Mandate ID to get references for'),
|
|
273
|
+
},
|
|
274
|
+
outputSchema: ReferencesOutputSchema,
|
|
275
|
+
annotations: {
|
|
276
|
+
readOnlyHint: true,
|
|
277
|
+
destructiveHint: false,
|
|
278
|
+
idempotentHint: true,
|
|
279
|
+
openWorldHint: true,
|
|
280
|
+
},
|
|
281
|
+
_meta: toolMeta('get_mandate_references'),
|
|
282
|
+
},
|
|
283
|
+
async (args) => {
|
|
284
|
+
try {
|
|
285
|
+
const result = await client.references.getMandateReferences(args.mandateId);
|
|
286
|
+
const refs = Array.isArray(result) ? result : (result as Record<string, unknown>).references ?? [];
|
|
287
|
+
return {
|
|
288
|
+
content: [{ type: 'text', text: `Mandate ${args.mandateId} has ${(refs as unknown[]).length} reference(s).` }],
|
|
289
|
+
structuredContent: (Array.isArray(result) ? { references: result } : result) as unknown as Record<string, unknown>,
|
|
290
|
+
};
|
|
291
|
+
} catch (err) {
|
|
292
|
+
return apiErrorResult(err);
|
|
293
|
+
}
|
|
294
|
+
},
|
|
295
|
+
);
|
|
296
|
+
}
|