@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,948 @@
|
|
|
1
|
+
/** AGLedger™ — Federation admin 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 { HubStateEnum, GatewayStatusEnum } from '../enums.js';
|
|
9
|
+
import type { FederationAuditEntryType } from '@agledger/sdk';
|
|
10
|
+
|
|
11
|
+
const RegistrationTokenOutputSchema = z.object({
|
|
12
|
+
token: z.string().describe('Registration token string'),
|
|
13
|
+
label: z.string().optional().describe('Human-readable label for the token'),
|
|
14
|
+
expiresAt: z.string().optional().describe('ISO 8601 expiration timestamp'),
|
|
15
|
+
allowedContractTypes: z.array(z.string()).optional().describe('Contract types this token permits'),
|
|
16
|
+
createdAt: z.string().describe('ISO 8601 creation timestamp'),
|
|
17
|
+
}).passthrough().describe('Federation registration token');
|
|
18
|
+
|
|
19
|
+
const GatewayOutputSchema = z.object({
|
|
20
|
+
id: z.string().describe('Gateway UUID'),
|
|
21
|
+
name: z.string().optional().describe('Gateway display name'),
|
|
22
|
+
status: z.string().describe('Gateway status (active, suspended, revoked)'),
|
|
23
|
+
createdAt: z.string().describe('ISO 8601 creation timestamp'),
|
|
24
|
+
updatedAt: z.string().optional().describe('ISO 8601 last update timestamp'),
|
|
25
|
+
}).passthrough().describe('Federation gateway object');
|
|
26
|
+
|
|
27
|
+
const GatewayListOutputSchema = z.object({
|
|
28
|
+
gateways: z.array(GatewayOutputSchema).describe('List of federation gateways'),
|
|
29
|
+
total: z.number().optional().describe('Total number of gateways matching the query'),
|
|
30
|
+
}).passthrough().describe('Paginated list of federation gateways');
|
|
31
|
+
|
|
32
|
+
const FederationMandateOutputSchema = z.object({
|
|
33
|
+
id: z.string().describe('Federation mandate UUID'),
|
|
34
|
+
gatewayId: z.string().describe('Originating gateway UUID'),
|
|
35
|
+
hubState: z.string().describe('Hub-side mandate state'),
|
|
36
|
+
contractType: z.string().optional().describe('Contract type identifier'),
|
|
37
|
+
createdAt: z.string().describe('ISO 8601 creation timestamp'),
|
|
38
|
+
}).passthrough().describe('Federation mandate object');
|
|
39
|
+
|
|
40
|
+
const FederationMandateListOutputSchema = z.object({
|
|
41
|
+
mandates: z.array(FederationMandateOutputSchema).describe('List of federation mandates'),
|
|
42
|
+
total: z.number().optional().describe('Total number of mandates matching the query'),
|
|
43
|
+
}).passthrough().describe('Paginated list of federation mandates');
|
|
44
|
+
|
|
45
|
+
const AuditLogEntrySchema = z.object({
|
|
46
|
+
id: z.string().describe('Audit log entry UUID'),
|
|
47
|
+
gatewayId: z.string().optional().describe('Gateway UUID associated with the entry'),
|
|
48
|
+
entryType: z.string().describe('Type of audit log entry'),
|
|
49
|
+
mandateId: z.string().optional().describe('Associated mandate UUID'),
|
|
50
|
+
timestamp: z.string().describe('ISO 8601 timestamp of the entry'),
|
|
51
|
+
details: z.record(z.string(), z.unknown()).optional().describe('Entry-specific details'),
|
|
52
|
+
}).passthrough().describe('Federation audit log entry');
|
|
53
|
+
|
|
54
|
+
const AuditLogOutputSchema = z.object({
|
|
55
|
+
entries: z.array(AuditLogEntrySchema).describe('List of audit log entries'),
|
|
56
|
+
total: z.number().optional().describe('Total number of entries matching the query'),
|
|
57
|
+
}).passthrough().describe('Paginated federation audit log');
|
|
58
|
+
|
|
59
|
+
const FederationHealthOutputSchema = z.object({
|
|
60
|
+
status: z.string().describe('Overall federation health status'),
|
|
61
|
+
activeGateways: z.number().optional().describe('Number of active gateways'),
|
|
62
|
+
pendingMandates: z.number().optional().describe('Number of pending federation mandates'),
|
|
63
|
+
dlqDepth: z.number().optional().describe('Number of entries in the dead letter queue'),
|
|
64
|
+
timestamp: z.string().describe('ISO 8601 timestamp of the health check'),
|
|
65
|
+
}).passthrough().describe('Federation health summary');
|
|
66
|
+
|
|
67
|
+
const SequenceResetOutputSchema = z.object({
|
|
68
|
+
gatewayId: z.string().describe('Gateway UUID'),
|
|
69
|
+
previousSeq: z.number().optional().describe('Previous sequence number'),
|
|
70
|
+
newSeq: z.number().describe('New sequence number after reset'),
|
|
71
|
+
}).passthrough().describe('Sequence reset result');
|
|
72
|
+
|
|
73
|
+
const DlqEntrySchema = z.object({
|
|
74
|
+
id: z.string().describe('DLQ entry UUID'),
|
|
75
|
+
payload: z.record(z.string(), z.unknown()).optional().describe('Original message payload'),
|
|
76
|
+
error: z.string().optional().describe('Error that caused the entry to be dead-lettered'),
|
|
77
|
+
createdAt: z.string().describe('ISO 8601 timestamp when the entry was dead-lettered'),
|
|
78
|
+
retryCount: z.number().optional().describe('Number of retry attempts'),
|
|
79
|
+
}).passthrough().describe('Dead letter queue entry');
|
|
80
|
+
|
|
81
|
+
const DlqListOutputSchema = z.object({
|
|
82
|
+
entries: z.array(DlqEntrySchema).describe('List of DLQ entries'),
|
|
83
|
+
cursor: z.string().optional().describe('Cursor for the next page of results'),
|
|
84
|
+
}).passthrough().describe('Paginated dead letter queue entries');
|
|
85
|
+
|
|
86
|
+
const DlqRetryOutputSchema = z.object({
|
|
87
|
+
dlqId: z.string().describe('DLQ entry UUID that was retried'),
|
|
88
|
+
status: z.string().describe('Result of the retry attempt'),
|
|
89
|
+
}).passthrough().describe('DLQ retry result');
|
|
90
|
+
|
|
91
|
+
const DlqDeleteOutputSchema = z.object({
|
|
92
|
+
dlqId: z.string().describe('DLQ entry UUID that was deleted'),
|
|
93
|
+
deleted: z.boolean().describe('Whether the entry was successfully deleted'),
|
|
94
|
+
}).passthrough().describe('DLQ deletion result');
|
|
95
|
+
|
|
96
|
+
const RevokeOutputSchema = z.object({
|
|
97
|
+
gatewayId: z.string().describe('Revoked gateway UUID'),
|
|
98
|
+
status: z.string().describe('New gateway status after revocation'),
|
|
99
|
+
revokedAt: z.string().optional().describe('ISO 8601 revocation timestamp'),
|
|
100
|
+
}).passthrough().describe('Gateway revocation result');
|
|
101
|
+
|
|
102
|
+
const HubKeyOutputSchema = z.object({
|
|
103
|
+
keyId: z.string().optional().describe('New hub signing key UUID'),
|
|
104
|
+
publicKey: z.string().optional().describe('New Ed25519 public key (base64)'),
|
|
105
|
+
status: z.string().optional().describe('Key status (pending, active, expired)'),
|
|
106
|
+
createdAt: z.string().optional().describe('ISO 8601 creation timestamp'),
|
|
107
|
+
}).passthrough().describe('Hub signing key rotation result');
|
|
108
|
+
|
|
109
|
+
const HubKeyListOutputSchema = z.object({
|
|
110
|
+
keys: z.array(z.object({
|
|
111
|
+
keyId: z.string().describe('Hub key UUID'),
|
|
112
|
+
status: z.string().describe('Key status (pending, active, expired)'),
|
|
113
|
+
createdAt: z.string().describe('ISO 8601 creation timestamp'),
|
|
114
|
+
}).passthrough()).optional().describe('List of hub signing keys'),
|
|
115
|
+
}).passthrough().describe('Hub signing key list');
|
|
116
|
+
|
|
117
|
+
const HubKeyActionOutputSchema = z.object({
|
|
118
|
+
keyId: z.string().describe('Hub key UUID'),
|
|
119
|
+
status: z.string().optional().describe('New key status'),
|
|
120
|
+
}).passthrough().describe('Hub key action result');
|
|
121
|
+
|
|
122
|
+
const PeerOutputSchema = z.object({
|
|
123
|
+
hubId: z.string().optional().describe('Peer hub UUID'),
|
|
124
|
+
name: z.string().optional().describe('Peer hub name'),
|
|
125
|
+
endpoint: z.string().optional().describe('Peer hub API endpoint'),
|
|
126
|
+
status: z.string().optional().describe('Peer connection status'),
|
|
127
|
+
lastSyncAt: z.string().optional().describe('ISO 8601 last sync timestamp'),
|
|
128
|
+
}).passthrough().describe('Peer federation hub');
|
|
129
|
+
|
|
130
|
+
const PeerListOutputSchema = z.object({
|
|
131
|
+
peers: z.array(PeerOutputSchema).optional().describe('List of peer hubs'),
|
|
132
|
+
}).passthrough().describe('List of peer federation hubs');
|
|
133
|
+
|
|
134
|
+
const PeerActionOutputSchema = z.object({
|
|
135
|
+
hubId: z.string().describe('Peer hub UUID'),
|
|
136
|
+
status: z.string().optional().describe('Action result status'),
|
|
137
|
+
}).passthrough().describe('Peer hub action result');
|
|
138
|
+
|
|
139
|
+
const PeeringTokenOutputSchema = z.object({
|
|
140
|
+
token: z.string().optional().describe('One-time peering token'),
|
|
141
|
+
expiresAt: z.string().optional().describe('ISO 8601 token expiry'),
|
|
142
|
+
}).passthrough().describe('Peering token for cross-hub registration');
|
|
143
|
+
|
|
144
|
+
const SchemaVersionDeleteOutputSchema = z.object({
|
|
145
|
+
contractType: z.string().describe('Contract type identifier'),
|
|
146
|
+
version: z.string().describe('Deleted schema version'),
|
|
147
|
+
deleted: z.boolean().optional().describe('Whether the version was deleted'),
|
|
148
|
+
}).passthrough().describe('Schema version deletion result');
|
|
149
|
+
|
|
150
|
+
const ReputationContributionListOutputSchema = z.object({
|
|
151
|
+
contributions: z.array(z.object({
|
|
152
|
+
agentId: z.string().describe('Federated agent ID'),
|
|
153
|
+
contractType: z.string().describe('Contract type'),
|
|
154
|
+
outcome: z.string().describe('Mandate outcome'),
|
|
155
|
+
gatewayId: z.string().optional().describe('Contributing gateway ID'),
|
|
156
|
+
timestamp: z.string().optional().describe('ISO 8601 contribution timestamp'),
|
|
157
|
+
}).passthrough()).optional().describe('List of reputation contributions'),
|
|
158
|
+
}).passthrough().describe('Reputation contributions for an agent');
|
|
159
|
+
|
|
160
|
+
const ReputationResetOutputSchema = z.object({
|
|
161
|
+
agentId: z.string().describe('Federated agent ID'),
|
|
162
|
+
reset: z.boolean().optional().describe('Whether the reputation was reset'),
|
|
163
|
+
}).passthrough().describe('Reputation reset result');
|
|
164
|
+
|
|
165
|
+
const MandateCriteriaStatusOutputSchema = z.object({
|
|
166
|
+
mandateId: z.string().describe('Federation mandate ID'),
|
|
167
|
+
status: z.string().optional().describe('Criteria exchange status'),
|
|
168
|
+
principalSubmitted: z.boolean().optional().describe('Whether the principal has submitted criteria'),
|
|
169
|
+
performerAcknowledged: z.boolean().optional().describe('Whether the performer has acknowledged criteria'),
|
|
170
|
+
}).passthrough().describe('Cross-boundary criteria exchange status');
|
|
171
|
+
|
|
172
|
+
export function registerFederationAdminTools(mcp: McpServer, client: AgledgerClient): void {
|
|
173
|
+
// --- federation_create_token ---
|
|
174
|
+
mcp.registerTool(
|
|
175
|
+
'federation_create_token',
|
|
176
|
+
{
|
|
177
|
+
title: 'Create Federation Registration Token',
|
|
178
|
+
description: 'Create a registration token that a gateway can use to join the federation. Optionally restrict to specific contract types or set an expiry.',
|
|
179
|
+
inputSchema: {
|
|
180
|
+
label: z.string().optional().describe('Human-readable label for the token'),
|
|
181
|
+
expiresInHours: z.number().optional().describe('Hours until the token expires'),
|
|
182
|
+
allowedContractTypes: z.array(z.string()).optional().describe('Contract types this token permits'),
|
|
183
|
+
},
|
|
184
|
+
outputSchema: RegistrationTokenOutputSchema,
|
|
185
|
+
annotations: {
|
|
186
|
+
readOnlyHint: false,
|
|
187
|
+
destructiveHint: false,
|
|
188
|
+
idempotentHint: false,
|
|
189
|
+
openWorldHint: true,
|
|
190
|
+
},
|
|
191
|
+
_meta: toolMeta('federation_create_token'),
|
|
192
|
+
},
|
|
193
|
+
async (args) => {
|
|
194
|
+
try {
|
|
195
|
+
const result = await client.federationAdmin.createRegistrationToken({
|
|
196
|
+
label: args.label,
|
|
197
|
+
expiresInHours: args.expiresInHours,
|
|
198
|
+
allowedContractTypes: args.allowedContractTypes,
|
|
199
|
+
});
|
|
200
|
+
return {
|
|
201
|
+
content: [{ type: 'text', text: `Registration token created. Expires: ${result.expiresAt}.` }],
|
|
202
|
+
structuredContent: result as unknown as Record<string, unknown>,
|
|
203
|
+
};
|
|
204
|
+
} catch (err) {
|
|
205
|
+
return apiErrorResult(err);
|
|
206
|
+
}
|
|
207
|
+
},
|
|
208
|
+
);
|
|
209
|
+
|
|
210
|
+
// --- federation_list_gateways ---
|
|
211
|
+
mcp.registerTool(
|
|
212
|
+
'federation_list_gateways',
|
|
213
|
+
{
|
|
214
|
+
title: 'List Federation Gateways',
|
|
215
|
+
description: 'List federation gateways with optional status filter and pagination.',
|
|
216
|
+
inputSchema: {
|
|
217
|
+
status: GatewayStatusEnum.optional().describe('Filter gateways by status'),
|
|
218
|
+
limit: z.number().optional().describe('Maximum number of results to return'),
|
|
219
|
+
offset: z.number().optional().describe('Number of results to skip for pagination'),
|
|
220
|
+
},
|
|
221
|
+
outputSchema: GatewayListOutputSchema,
|
|
222
|
+
annotations: {
|
|
223
|
+
readOnlyHint: true,
|
|
224
|
+
destructiveHint: false,
|
|
225
|
+
idempotentHint: true,
|
|
226
|
+
openWorldHint: true,
|
|
227
|
+
},
|
|
228
|
+
_meta: toolMeta('federation_list_gateways'),
|
|
229
|
+
},
|
|
230
|
+
async (args) => {
|
|
231
|
+
try {
|
|
232
|
+
const result = await client.federationAdmin.listGateways({
|
|
233
|
+
status: args.status,
|
|
234
|
+
limit: args.limit,
|
|
235
|
+
offset: args.offset,
|
|
236
|
+
});
|
|
237
|
+
return {
|
|
238
|
+
content: [{ type: 'text', text: `Found ${result.data.length} gateway(s).${result.total != null ? ` Total: ${result.total}.` : ''}` }],
|
|
239
|
+
structuredContent: result as unknown as Record<string, unknown>,
|
|
240
|
+
};
|
|
241
|
+
} catch (err) {
|
|
242
|
+
return apiErrorResult(err);
|
|
243
|
+
}
|
|
244
|
+
},
|
|
245
|
+
);
|
|
246
|
+
|
|
247
|
+
// --- federation_admin_revoke ---
|
|
248
|
+
mcp.registerTool(
|
|
249
|
+
'federation_admin_revoke',
|
|
250
|
+
{
|
|
251
|
+
title: 'Revoke Federation Gateway',
|
|
252
|
+
description: 'Permanently revoke a federation gateway. This is destructive and cannot be undone. Requires a reason for the audit trail.',
|
|
253
|
+
inputSchema: {
|
|
254
|
+
gatewayId: z.string().describe('UUID of the gateway to revoke'),
|
|
255
|
+
reason: z.string().describe('Reason for revocation (recorded in audit log)'),
|
|
256
|
+
},
|
|
257
|
+
outputSchema: RevokeOutputSchema,
|
|
258
|
+
annotations: {
|
|
259
|
+
readOnlyHint: false,
|
|
260
|
+
destructiveHint: true,
|
|
261
|
+
idempotentHint: false,
|
|
262
|
+
openWorldHint: true,
|
|
263
|
+
},
|
|
264
|
+
_meta: toolMeta('federation_admin_revoke'),
|
|
265
|
+
},
|
|
266
|
+
async (args) => {
|
|
267
|
+
try {
|
|
268
|
+
const result = await client.federationAdmin.revokeGateway(args.gatewayId, { reason: args.reason });
|
|
269
|
+
return {
|
|
270
|
+
content: [{ type: 'text', text: `Gateway ${args.gatewayId} revoked. Reason: ${args.reason}.` }],
|
|
271
|
+
structuredContent: result as unknown as Record<string, unknown>,
|
|
272
|
+
};
|
|
273
|
+
} catch (err) {
|
|
274
|
+
return apiErrorResult(err);
|
|
275
|
+
}
|
|
276
|
+
},
|
|
277
|
+
);
|
|
278
|
+
|
|
279
|
+
// --- federation_query_mandates ---
|
|
280
|
+
mcp.registerTool(
|
|
281
|
+
'federation_query_mandates',
|
|
282
|
+
{
|
|
283
|
+
title: 'Query Federation Mandates',
|
|
284
|
+
description: 'Query federation mandates with optional filters by gateway, hub state, and contract type.',
|
|
285
|
+
inputSchema: {
|
|
286
|
+
gatewayId: z.string().optional().describe('Filter by originating gateway UUID'),
|
|
287
|
+
hubState: HubStateEnum.optional().describe('Filter by hub-side mandate state'),
|
|
288
|
+
contractType: z.string().optional().describe('Filter by contract type identifier'),
|
|
289
|
+
limit: z.number().optional().describe('Maximum number of results to return'),
|
|
290
|
+
offset: z.number().optional().describe('Number of results to skip for pagination'),
|
|
291
|
+
},
|
|
292
|
+
outputSchema: FederationMandateListOutputSchema,
|
|
293
|
+
annotations: {
|
|
294
|
+
readOnlyHint: true,
|
|
295
|
+
destructiveHint: false,
|
|
296
|
+
idempotentHint: true,
|
|
297
|
+
openWorldHint: true,
|
|
298
|
+
},
|
|
299
|
+
_meta: toolMeta('federation_query_mandates'),
|
|
300
|
+
},
|
|
301
|
+
async (args) => {
|
|
302
|
+
try {
|
|
303
|
+
const result = await client.federationAdmin.queryMandates({
|
|
304
|
+
gatewayId: args.gatewayId,
|
|
305
|
+
hubState: args.hubState,
|
|
306
|
+
contractType: args.contractType,
|
|
307
|
+
limit: args.limit,
|
|
308
|
+
offset: args.offset,
|
|
309
|
+
});
|
|
310
|
+
return {
|
|
311
|
+
content: [{ type: 'text', text: `Found ${result.data.length} federation mandate(s).${result.total != null ? ` Total: ${result.total}.` : ''}` }],
|
|
312
|
+
structuredContent: result as unknown as Record<string, unknown>,
|
|
313
|
+
};
|
|
314
|
+
} catch (err) {
|
|
315
|
+
return apiErrorResult(err);
|
|
316
|
+
}
|
|
317
|
+
},
|
|
318
|
+
);
|
|
319
|
+
|
|
320
|
+
// --- federation_audit_log ---
|
|
321
|
+
mcp.registerTool(
|
|
322
|
+
'federation_audit_log',
|
|
323
|
+
{
|
|
324
|
+
title: 'Get Federation Audit Log',
|
|
325
|
+
description: 'Retrieve the federation audit log. Filter by gateway, entry type, or mandate.',
|
|
326
|
+
inputSchema: {
|
|
327
|
+
gatewayId: z.string().optional().describe('Filter by gateway UUID'),
|
|
328
|
+
entryType: z.string().optional().describe('Filter by audit entry type'),
|
|
329
|
+
mandateId: z.string().optional().describe('Filter by associated mandate UUID'),
|
|
330
|
+
limit: z.number().optional().describe('Maximum number of results to return'),
|
|
331
|
+
offset: z.number().optional().describe('Number of results to skip for pagination'),
|
|
332
|
+
},
|
|
333
|
+
outputSchema: AuditLogOutputSchema,
|
|
334
|
+
annotations: {
|
|
335
|
+
readOnlyHint: true,
|
|
336
|
+
destructiveHint: false,
|
|
337
|
+
idempotentHint: true,
|
|
338
|
+
openWorldHint: true,
|
|
339
|
+
},
|
|
340
|
+
_meta: toolMeta('federation_audit_log'),
|
|
341
|
+
},
|
|
342
|
+
async (args) => {
|
|
343
|
+
try {
|
|
344
|
+
const result = await client.federationAdmin.getAuditLog({
|
|
345
|
+
gatewayId: args.gatewayId,
|
|
346
|
+
entryType: args.entryType as FederationAuditEntryType | undefined,
|
|
347
|
+
mandateId: args.mandateId,
|
|
348
|
+
limit: args.limit,
|
|
349
|
+
offset: args.offset,
|
|
350
|
+
});
|
|
351
|
+
return {
|
|
352
|
+
content: [{ type: 'text', text: `Retrieved ${result.data.length} audit log entry(ies).${result.total != null ? ` Total: ${result.total}.` : ''}` }],
|
|
353
|
+
structuredContent: result as unknown as Record<string, unknown>,
|
|
354
|
+
};
|
|
355
|
+
} catch (err) {
|
|
356
|
+
return apiErrorResult(err);
|
|
357
|
+
}
|
|
358
|
+
},
|
|
359
|
+
);
|
|
360
|
+
|
|
361
|
+
// --- federation_health ---
|
|
362
|
+
mcp.registerTool(
|
|
363
|
+
'federation_health',
|
|
364
|
+
{
|
|
365
|
+
title: 'Federation Health Summary',
|
|
366
|
+
description: 'Get the overall federation health summary, including active gateway count, pending mandates, and DLQ depth.',
|
|
367
|
+
inputSchema: {},
|
|
368
|
+
outputSchema: FederationHealthOutputSchema,
|
|
369
|
+
annotations: {
|
|
370
|
+
readOnlyHint: true,
|
|
371
|
+
destructiveHint: false,
|
|
372
|
+
idempotentHint: true,
|
|
373
|
+
openWorldHint: true,
|
|
374
|
+
},
|
|
375
|
+
_meta: toolMeta('federation_health'),
|
|
376
|
+
},
|
|
377
|
+
async () => {
|
|
378
|
+
try {
|
|
379
|
+
const result = await client.federationAdmin.getHealth();
|
|
380
|
+
return {
|
|
381
|
+
content: [{ type: 'text', text: `Federation health: ${result.gateways.active} active gateways, ${result.gateways.suspended} suspended, ${result.gateways.revoked} revoked. Audit chain length: ${result.auditChainLength}.` }],
|
|
382
|
+
structuredContent: result as unknown as Record<string, unknown>,
|
|
383
|
+
};
|
|
384
|
+
} catch (err) {
|
|
385
|
+
return apiErrorResult(err);
|
|
386
|
+
}
|
|
387
|
+
},
|
|
388
|
+
);
|
|
389
|
+
|
|
390
|
+
// --- federation_reset_sequence ---
|
|
391
|
+
mcp.registerTool(
|
|
392
|
+
'federation_reset_sequence',
|
|
393
|
+
{
|
|
394
|
+
title: 'Reset Gateway Sequence',
|
|
395
|
+
description: 'Reset the sequence number for a federation gateway. This is destructive — use only to recover from sequence drift.',
|
|
396
|
+
inputSchema: {
|
|
397
|
+
gatewayId: z.string().describe('UUID of the gateway whose sequence to reset'),
|
|
398
|
+
newSeq: z.number().optional().describe('New sequence number (defaults to server-determined value if omitted)'),
|
|
399
|
+
},
|
|
400
|
+
outputSchema: SequenceResetOutputSchema,
|
|
401
|
+
annotations: {
|
|
402
|
+
readOnlyHint: false,
|
|
403
|
+
destructiveHint: true,
|
|
404
|
+
idempotentHint: false,
|
|
405
|
+
openWorldHint: true,
|
|
406
|
+
},
|
|
407
|
+
_meta: toolMeta('federation_reset_sequence'),
|
|
408
|
+
},
|
|
409
|
+
async (args) => {
|
|
410
|
+
try {
|
|
411
|
+
const result = await client.federationAdmin.resetSequence(args.gatewayId, { newSeq: args.newSeq });
|
|
412
|
+
return {
|
|
413
|
+
content: [{ type: 'text', text: `Sequence reset for gateway ${args.gatewayId}: ${result.reset ? 'success' : 'failed'}.` }],
|
|
414
|
+
structuredContent: result as unknown as Record<string, unknown>,
|
|
415
|
+
};
|
|
416
|
+
} catch (err) {
|
|
417
|
+
return apiErrorResult(err);
|
|
418
|
+
}
|
|
419
|
+
},
|
|
420
|
+
);
|
|
421
|
+
|
|
422
|
+
// --- federation_list_dlq ---
|
|
423
|
+
mcp.registerTool(
|
|
424
|
+
'federation_list_dlq',
|
|
425
|
+
{
|
|
426
|
+
title: 'List DLQ Entries',
|
|
427
|
+
description: 'List entries in the federation dead letter queue. Use cursor-based pagination for large queues.',
|
|
428
|
+
inputSchema: {
|
|
429
|
+
limit: z.number().optional().describe('Maximum number of results to return'),
|
|
430
|
+
cursor: z.string().optional().describe('Cursor for the next page of results'),
|
|
431
|
+
},
|
|
432
|
+
outputSchema: DlqListOutputSchema,
|
|
433
|
+
annotations: {
|
|
434
|
+
readOnlyHint: true,
|
|
435
|
+
destructiveHint: false,
|
|
436
|
+
idempotentHint: true,
|
|
437
|
+
openWorldHint: true,
|
|
438
|
+
},
|
|
439
|
+
_meta: toolMeta('federation_list_dlq'),
|
|
440
|
+
},
|
|
441
|
+
async (args) => {
|
|
442
|
+
try {
|
|
443
|
+
const result = await client.federationAdmin.listDlq({
|
|
444
|
+
limit: args.limit,
|
|
445
|
+
cursor: args.cursor,
|
|
446
|
+
});
|
|
447
|
+
return {
|
|
448
|
+
content: [{ type: 'text', text: `Found ${result.data.length} DLQ entry(ies).${result.hasMore ? ' More available.' : ''}` }],
|
|
449
|
+
structuredContent: result as unknown as Record<string, unknown>,
|
|
450
|
+
};
|
|
451
|
+
} catch (err) {
|
|
452
|
+
return apiErrorResult(err);
|
|
453
|
+
}
|
|
454
|
+
},
|
|
455
|
+
);
|
|
456
|
+
|
|
457
|
+
// --- federation_retry_dlq ---
|
|
458
|
+
mcp.registerTool(
|
|
459
|
+
'federation_retry_dlq',
|
|
460
|
+
{
|
|
461
|
+
title: 'Retry DLQ Entry',
|
|
462
|
+
description: 'Retry processing a dead letter queue entry. Safe to call multiple times — idempotent.',
|
|
463
|
+
inputSchema: {
|
|
464
|
+
dlqId: z.string().describe('UUID of the DLQ entry to retry'),
|
|
465
|
+
},
|
|
466
|
+
outputSchema: DlqRetryOutputSchema,
|
|
467
|
+
annotations: {
|
|
468
|
+
readOnlyHint: false,
|
|
469
|
+
destructiveHint: false,
|
|
470
|
+
idempotentHint: true,
|
|
471
|
+
openWorldHint: true,
|
|
472
|
+
},
|
|
473
|
+
_meta: toolMeta('federation_retry_dlq'),
|
|
474
|
+
},
|
|
475
|
+
async (args) => {
|
|
476
|
+
try {
|
|
477
|
+
const result = await client.federationAdmin.retryDlq(args.dlqId);
|
|
478
|
+
return {
|
|
479
|
+
content: [{ type: 'text', text: `DLQ entry ${args.dlqId} retried: ${result.retried ? 'success' : 'failed'}.` }],
|
|
480
|
+
structuredContent: result as unknown as Record<string, unknown>,
|
|
481
|
+
};
|
|
482
|
+
} catch (err) {
|
|
483
|
+
return apiErrorResult(err);
|
|
484
|
+
}
|
|
485
|
+
},
|
|
486
|
+
);
|
|
487
|
+
|
|
488
|
+
// --- federation_delete_dlq ---
|
|
489
|
+
mcp.registerTool(
|
|
490
|
+
'federation_delete_dlq',
|
|
491
|
+
{
|
|
492
|
+
title: 'Delete DLQ Entry',
|
|
493
|
+
description: 'Permanently delete a dead letter queue entry. This is destructive and cannot be undone.',
|
|
494
|
+
inputSchema: {
|
|
495
|
+
dlqId: z.string().describe('UUID of the DLQ entry to delete'),
|
|
496
|
+
},
|
|
497
|
+
outputSchema: DlqDeleteOutputSchema,
|
|
498
|
+
annotations: {
|
|
499
|
+
readOnlyHint: false,
|
|
500
|
+
destructiveHint: true,
|
|
501
|
+
idempotentHint: false,
|
|
502
|
+
openWorldHint: true,
|
|
503
|
+
},
|
|
504
|
+
_meta: toolMeta('federation_delete_dlq'),
|
|
505
|
+
},
|
|
506
|
+
async (args) => {
|
|
507
|
+
try {
|
|
508
|
+
const result = await client.federationAdmin.deleteDlq(args.dlqId);
|
|
509
|
+
return {
|
|
510
|
+
content: [{ type: 'text', text: `DLQ entry ${args.dlqId} deleted.` }],
|
|
511
|
+
structuredContent: result as unknown as Record<string, unknown>,
|
|
512
|
+
};
|
|
513
|
+
} catch (err) {
|
|
514
|
+
return apiErrorResult(err);
|
|
515
|
+
}
|
|
516
|
+
},
|
|
517
|
+
);
|
|
518
|
+
|
|
519
|
+
// --- federation_rotate_hub_key ---
|
|
520
|
+
mcp.registerTool(
|
|
521
|
+
'federation_rotate_hub_key',
|
|
522
|
+
{
|
|
523
|
+
title: 'Rotate Hub Signing Key',
|
|
524
|
+
description: 'Rotate the federation hub signing key. This is destructive — generates a new key pair and transitions gateways to use it. Old key remains valid until explicitly expired via federation_expire_hub_key.',
|
|
525
|
+
inputSchema: {},
|
|
526
|
+
outputSchema: HubKeyOutputSchema,
|
|
527
|
+
annotations: {
|
|
528
|
+
readOnlyHint: false,
|
|
529
|
+
destructiveHint: true,
|
|
530
|
+
idempotentHint: false,
|
|
531
|
+
openWorldHint: true,
|
|
532
|
+
},
|
|
533
|
+
_meta: toolMeta('federation_rotate_hub_key'),
|
|
534
|
+
},
|
|
535
|
+
async () => {
|
|
536
|
+
try {
|
|
537
|
+
const result = await client.federationAdmin.rotateHubKey();
|
|
538
|
+
return {
|
|
539
|
+
content: [{ type: 'text', text: `Hub key rotated. New key ID: ${result.id}. Use federation_activate_hub_key to make it active.` }],
|
|
540
|
+
structuredContent: result as unknown as Record<string, unknown>,
|
|
541
|
+
};
|
|
542
|
+
} catch (err) {
|
|
543
|
+
return apiErrorResult(err);
|
|
544
|
+
}
|
|
545
|
+
},
|
|
546
|
+
);
|
|
547
|
+
|
|
548
|
+
// --- federation_list_hub_keys ---
|
|
549
|
+
mcp.registerTool(
|
|
550
|
+
'federation_list_hub_keys',
|
|
551
|
+
{
|
|
552
|
+
title: 'List Hub Signing Keys',
|
|
553
|
+
description: 'List all hub signing keys including active, pending, and expired keys. Use this to audit key rotation history and identify which key is currently active.',
|
|
554
|
+
inputSchema: {},
|
|
555
|
+
outputSchema: HubKeyListOutputSchema,
|
|
556
|
+
annotations: {
|
|
557
|
+
readOnlyHint: true,
|
|
558
|
+
destructiveHint: false,
|
|
559
|
+
idempotentHint: true,
|
|
560
|
+
openWorldHint: true,
|
|
561
|
+
},
|
|
562
|
+
_meta: toolMeta('federation_list_hub_keys'),
|
|
563
|
+
},
|
|
564
|
+
async () => {
|
|
565
|
+
try {
|
|
566
|
+
const result = await client.federationAdmin.listHubKeys();
|
|
567
|
+
return {
|
|
568
|
+
content: [{ type: 'text', text: `Found ${Array.isArray(result) ? result.length : 0} hub signing key(s).` }],
|
|
569
|
+
structuredContent: { keys: result } as unknown as Record<string, unknown>,
|
|
570
|
+
};
|
|
571
|
+
} catch (err) {
|
|
572
|
+
return apiErrorResult(err);
|
|
573
|
+
}
|
|
574
|
+
},
|
|
575
|
+
);
|
|
576
|
+
|
|
577
|
+
// --- federation_activate_hub_key ---
|
|
578
|
+
mcp.registerTool(
|
|
579
|
+
'federation_activate_hub_key',
|
|
580
|
+
{
|
|
581
|
+
title: 'Activate Hub Signing Key',
|
|
582
|
+
description: 'Activate a pending hub signing key. After rotating, the new key must be explicitly activated. Only one key can be active at a time.',
|
|
583
|
+
inputSchema: {
|
|
584
|
+
keyId: z.string().describe('UUID of the hub key to activate'),
|
|
585
|
+
},
|
|
586
|
+
outputSchema: HubKeyActionOutputSchema,
|
|
587
|
+
annotations: {
|
|
588
|
+
readOnlyHint: false,
|
|
589
|
+
destructiveHint: false,
|
|
590
|
+
idempotentHint: true,
|
|
591
|
+
openWorldHint: true,
|
|
592
|
+
},
|
|
593
|
+
_meta: toolMeta('federation_activate_hub_key'),
|
|
594
|
+
},
|
|
595
|
+
async (args) => {
|
|
596
|
+
try {
|
|
597
|
+
const result = await client.federationAdmin.activateHubKey(args.keyId);
|
|
598
|
+
return {
|
|
599
|
+
content: [{ type: 'text', text: `Hub key ${args.keyId} activated. All gateways will now use this key for signature verification.` }],
|
|
600
|
+
structuredContent: result as unknown as Record<string, unknown>,
|
|
601
|
+
};
|
|
602
|
+
} catch (err) {
|
|
603
|
+
return apiErrorResult(err);
|
|
604
|
+
}
|
|
605
|
+
},
|
|
606
|
+
);
|
|
607
|
+
|
|
608
|
+
// --- federation_expire_hub_key ---
|
|
609
|
+
mcp.registerTool(
|
|
610
|
+
'federation_expire_hub_key',
|
|
611
|
+
{
|
|
612
|
+
title: 'Expire Hub Signing Key',
|
|
613
|
+
description: 'Expire a hub signing key so it is no longer accepted for verification. Use after rotating and activating a new key to retire the old one.',
|
|
614
|
+
inputSchema: {
|
|
615
|
+
keyId: z.string().describe('UUID of the hub key to expire'),
|
|
616
|
+
},
|
|
617
|
+
outputSchema: HubKeyActionOutputSchema,
|
|
618
|
+
annotations: {
|
|
619
|
+
readOnlyHint: false,
|
|
620
|
+
destructiveHint: false,
|
|
621
|
+
idempotentHint: true,
|
|
622
|
+
openWorldHint: true,
|
|
623
|
+
},
|
|
624
|
+
_meta: toolMeta('federation_expire_hub_key'),
|
|
625
|
+
},
|
|
626
|
+
async (args) => {
|
|
627
|
+
try {
|
|
628
|
+
const result = await client.federationAdmin.expireHubKey(args.keyId);
|
|
629
|
+
return {
|
|
630
|
+
content: [{ type: 'text', text: `Hub key ${args.keyId} expired. It will no longer be accepted for signature verification.` }],
|
|
631
|
+
structuredContent: result as unknown as Record<string, unknown>,
|
|
632
|
+
};
|
|
633
|
+
} catch (err) {
|
|
634
|
+
return apiErrorResult(err);
|
|
635
|
+
}
|
|
636
|
+
},
|
|
637
|
+
);
|
|
638
|
+
|
|
639
|
+
// --- federation_register_peer ---
|
|
640
|
+
mcp.registerTool(
|
|
641
|
+
'federation_register_peer',
|
|
642
|
+
{
|
|
643
|
+
title: 'Register Peer Hub',
|
|
644
|
+
description: 'Register a peer federation hub for cross-hub communication. Requires a peering token from the peer hub. After registration, use federation_resync_peer to synchronize state.',
|
|
645
|
+
inputSchema: {
|
|
646
|
+
name: z.string().describe('Human-readable name for the peer hub'),
|
|
647
|
+
endpoint: z.string().describe('Peer hub API endpoint URL'),
|
|
648
|
+
publicKey: z.string().describe('Peer hub Ed25519 public key (base64)'),
|
|
649
|
+
peeringToken: z.string().describe('One-time peering token from the peer hub'),
|
|
650
|
+
},
|
|
651
|
+
outputSchema: PeerOutputSchema,
|
|
652
|
+
annotations: {
|
|
653
|
+
readOnlyHint: false,
|
|
654
|
+
destructiveHint: false,
|
|
655
|
+
idempotentHint: false,
|
|
656
|
+
openWorldHint: true,
|
|
657
|
+
},
|
|
658
|
+
_meta: toolMeta('federation_register_peer'),
|
|
659
|
+
},
|
|
660
|
+
async (args) => {
|
|
661
|
+
try {
|
|
662
|
+
const result = await client.federationAdmin.registerPeer(args);
|
|
663
|
+
return {
|
|
664
|
+
content: [{ type: 'text', text: `Peer hub "${args.name}" registered. Hub ID: ${result.hubId ?? 'n/a'}. Use federation_resync_peer to synchronize state.` }],
|
|
665
|
+
structuredContent: result as unknown as Record<string, unknown>,
|
|
666
|
+
};
|
|
667
|
+
} catch (err) {
|
|
668
|
+
return apiErrorResult(err);
|
|
669
|
+
}
|
|
670
|
+
},
|
|
671
|
+
);
|
|
672
|
+
|
|
673
|
+
// --- federation_list_peers ---
|
|
674
|
+
mcp.registerTool(
|
|
675
|
+
'federation_list_peers',
|
|
676
|
+
{
|
|
677
|
+
title: 'List Peer Hubs',
|
|
678
|
+
description: 'List all registered peer federation hubs. Shows connection status and last sync timestamp for each peer.',
|
|
679
|
+
inputSchema: {},
|
|
680
|
+
outputSchema: PeerListOutputSchema,
|
|
681
|
+
annotations: {
|
|
682
|
+
readOnlyHint: true,
|
|
683
|
+
destructiveHint: false,
|
|
684
|
+
idempotentHint: true,
|
|
685
|
+
openWorldHint: true,
|
|
686
|
+
},
|
|
687
|
+
_meta: toolMeta('federation_list_peers'),
|
|
688
|
+
},
|
|
689
|
+
async () => {
|
|
690
|
+
try {
|
|
691
|
+
const result = await client.federationAdmin.listPeers();
|
|
692
|
+
return {
|
|
693
|
+
content: [{ type: 'text', text: `Found ${result.data.length} peer hub(s).` }],
|
|
694
|
+
structuredContent: result as unknown as Record<string, unknown>,
|
|
695
|
+
};
|
|
696
|
+
} catch (err) {
|
|
697
|
+
return apiErrorResult(err);
|
|
698
|
+
}
|
|
699
|
+
},
|
|
700
|
+
);
|
|
701
|
+
|
|
702
|
+
// --- federation_get_peer ---
|
|
703
|
+
mcp.registerTool(
|
|
704
|
+
'federation_get_peer',
|
|
705
|
+
{
|
|
706
|
+
title: 'Get Peer Hub Details',
|
|
707
|
+
description: 'Get details for a specific peer federation hub, including connection status, last sync, and supported contract types.',
|
|
708
|
+
inputSchema: {
|
|
709
|
+
hubId: z.string().describe('Peer hub UUID'),
|
|
710
|
+
},
|
|
711
|
+
outputSchema: PeerOutputSchema,
|
|
712
|
+
annotations: {
|
|
713
|
+
readOnlyHint: true,
|
|
714
|
+
destructiveHint: false,
|
|
715
|
+
idempotentHint: true,
|
|
716
|
+
openWorldHint: true,
|
|
717
|
+
},
|
|
718
|
+
_meta: toolMeta('federation_get_peer'),
|
|
719
|
+
},
|
|
720
|
+
async (args) => {
|
|
721
|
+
try {
|
|
722
|
+
const result = await client.federationAdmin.getPeer(args.hubId);
|
|
723
|
+
return {
|
|
724
|
+
content: [{ type: 'text', text: `Peer hub ${args.hubId}: ${result.name ?? 'unnamed'}. Status: ${result.status ?? 'unknown'}.` }],
|
|
725
|
+
structuredContent: result as unknown as Record<string, unknown>,
|
|
726
|
+
};
|
|
727
|
+
} catch (err) {
|
|
728
|
+
return apiErrorResult(err);
|
|
729
|
+
}
|
|
730
|
+
},
|
|
731
|
+
);
|
|
732
|
+
|
|
733
|
+
// --- federation_revoke_peer ---
|
|
734
|
+
mcp.registerTool(
|
|
735
|
+
'federation_revoke_peer',
|
|
736
|
+
{
|
|
737
|
+
title: 'Revoke Peer Hub',
|
|
738
|
+
description: 'Permanently revoke a peer federation hub. This is destructive — the peer will no longer be able to communicate with this hub. Use only for compromised or decommissioned peers.',
|
|
739
|
+
inputSchema: {
|
|
740
|
+
hubId: z.string().describe('Peer hub UUID to revoke'),
|
|
741
|
+
},
|
|
742
|
+
outputSchema: PeerActionOutputSchema,
|
|
743
|
+
annotations: {
|
|
744
|
+
readOnlyHint: false,
|
|
745
|
+
destructiveHint: true,
|
|
746
|
+
idempotentHint: false,
|
|
747
|
+
openWorldHint: true,
|
|
748
|
+
},
|
|
749
|
+
_meta: toolMeta('federation_revoke_peer'),
|
|
750
|
+
},
|
|
751
|
+
async (args) => {
|
|
752
|
+
try {
|
|
753
|
+
const result = await client.federationAdmin.revokePeer(args.hubId);
|
|
754
|
+
return {
|
|
755
|
+
content: [{ type: 'text', text: `Peer hub ${args.hubId} revoked. It can no longer communicate with this federation hub.` }],
|
|
756
|
+
structuredContent: result as unknown as Record<string, unknown>,
|
|
757
|
+
};
|
|
758
|
+
} catch (err) {
|
|
759
|
+
return apiErrorResult(err);
|
|
760
|
+
}
|
|
761
|
+
},
|
|
762
|
+
);
|
|
763
|
+
|
|
764
|
+
// --- federation_resync_peer ---
|
|
765
|
+
mcp.registerTool(
|
|
766
|
+
'federation_resync_peer',
|
|
767
|
+
{
|
|
768
|
+
title: 'Resync Peer Hub',
|
|
769
|
+
description: 'Trigger a full state resynchronization with a peer hub. Use after registration or when state drift is suspected.',
|
|
770
|
+
inputSchema: {
|
|
771
|
+
hubId: z.string().describe('Peer hub UUID to resync'),
|
|
772
|
+
},
|
|
773
|
+
outputSchema: PeerActionOutputSchema,
|
|
774
|
+
annotations: {
|
|
775
|
+
readOnlyHint: false,
|
|
776
|
+
destructiveHint: false,
|
|
777
|
+
idempotentHint: true,
|
|
778
|
+
openWorldHint: true,
|
|
779
|
+
},
|
|
780
|
+
_meta: toolMeta('federation_resync_peer'),
|
|
781
|
+
},
|
|
782
|
+
async (args) => {
|
|
783
|
+
try {
|
|
784
|
+
const result = await client.federationAdmin.resyncPeer(args.hubId);
|
|
785
|
+
return {
|
|
786
|
+
content: [{ type: 'text', text: `Resync initiated for peer hub ${args.hubId}. Synced: ${result.synced}.` }],
|
|
787
|
+
structuredContent: result as unknown as Record<string, unknown>,
|
|
788
|
+
};
|
|
789
|
+
} catch (err) {
|
|
790
|
+
return apiErrorResult(err);
|
|
791
|
+
}
|
|
792
|
+
},
|
|
793
|
+
);
|
|
794
|
+
|
|
795
|
+
// --- federation_create_peering_token ---
|
|
796
|
+
mcp.registerTool(
|
|
797
|
+
'federation_create_peering_token',
|
|
798
|
+
{
|
|
799
|
+
title: 'Create Peering Token',
|
|
800
|
+
description: 'Create a one-time peering token that another hub can use to register as a peer. Share this token securely with the remote hub administrator.',
|
|
801
|
+
inputSchema: {},
|
|
802
|
+
outputSchema: PeeringTokenOutputSchema,
|
|
803
|
+
annotations: {
|
|
804
|
+
readOnlyHint: false,
|
|
805
|
+
destructiveHint: false,
|
|
806
|
+
idempotentHint: false,
|
|
807
|
+
openWorldHint: true,
|
|
808
|
+
},
|
|
809
|
+
_meta: toolMeta('federation_create_peering_token'),
|
|
810
|
+
},
|
|
811
|
+
async () => {
|
|
812
|
+
try {
|
|
813
|
+
const result = await client.federationAdmin.createPeeringToken();
|
|
814
|
+
return {
|
|
815
|
+
content: [{ type: 'text', text: `Peering token created. Expires: ${result.expiresAt ?? 'n/a'}. Share securely with the remote hub administrator.` }],
|
|
816
|
+
structuredContent: result as unknown as Record<string, unknown>,
|
|
817
|
+
};
|
|
818
|
+
} catch (err) {
|
|
819
|
+
return apiErrorResult(err);
|
|
820
|
+
}
|
|
821
|
+
},
|
|
822
|
+
);
|
|
823
|
+
|
|
824
|
+
// --- federation_delete_schema_version ---
|
|
825
|
+
mcp.registerTool(
|
|
826
|
+
'federation_delete_schema_version',
|
|
827
|
+
{
|
|
828
|
+
title: 'Delete Schema Version',
|
|
829
|
+
description: 'Delete a specific version of a federated contract type schema. This is destructive — gateways using this version will need to upgrade. Use only for removing broken or deprecated schema versions.',
|
|
830
|
+
inputSchema: {
|
|
831
|
+
contractType: z.string().describe('Contract type identifier'),
|
|
832
|
+
version: z.string().describe('Schema version to delete'),
|
|
833
|
+
},
|
|
834
|
+
outputSchema: SchemaVersionDeleteOutputSchema,
|
|
835
|
+
annotations: {
|
|
836
|
+
readOnlyHint: false,
|
|
837
|
+
destructiveHint: true,
|
|
838
|
+
idempotentHint: false,
|
|
839
|
+
openWorldHint: true,
|
|
840
|
+
},
|
|
841
|
+
_meta: toolMeta('federation_delete_schema_version'),
|
|
842
|
+
},
|
|
843
|
+
async (args) => {
|
|
844
|
+
try {
|
|
845
|
+
const result = await client.federationAdmin.deleteSchemaVersion(args.contractType, args.version);
|
|
846
|
+
return {
|
|
847
|
+
content: [{ type: 'text', text: `Schema version ${args.version} deleted for ${args.contractType}. Gateways using this version must upgrade.` }],
|
|
848
|
+
structuredContent: result as unknown as Record<string, unknown>,
|
|
849
|
+
};
|
|
850
|
+
} catch (err) {
|
|
851
|
+
return apiErrorResult(err);
|
|
852
|
+
}
|
|
853
|
+
},
|
|
854
|
+
);
|
|
855
|
+
|
|
856
|
+
// --- federation_list_reputation_contributions ---
|
|
857
|
+
mcp.registerTool(
|
|
858
|
+
'federation_list_reputation_contributions',
|
|
859
|
+
{
|
|
860
|
+
title: 'List Reputation Contributions',
|
|
861
|
+
description: 'List all reputation contributions for a specific agent across all gateways. Use this to audit the data behind an agent\'s federated reputation score.',
|
|
862
|
+
inputSchema: {
|
|
863
|
+
agentId: z.string().describe('Federated agent ID'),
|
|
864
|
+
},
|
|
865
|
+
outputSchema: ReputationContributionListOutputSchema,
|
|
866
|
+
annotations: {
|
|
867
|
+
readOnlyHint: true,
|
|
868
|
+
destructiveHint: false,
|
|
869
|
+
idempotentHint: true,
|
|
870
|
+
openWorldHint: true,
|
|
871
|
+
},
|
|
872
|
+
_meta: toolMeta('federation_list_reputation_contributions'),
|
|
873
|
+
},
|
|
874
|
+
async (args) => {
|
|
875
|
+
try {
|
|
876
|
+
const result = await client.federationAdmin.listReputationContributions(args.agentId);
|
|
877
|
+
return {
|
|
878
|
+
content: [{ type: 'text', text: `Found ${result.length} reputation contribution(s) for agent ${args.agentId}.` }],
|
|
879
|
+
structuredContent: { contributions: result } as unknown as Record<string, unknown>,
|
|
880
|
+
};
|
|
881
|
+
} catch (err) {
|
|
882
|
+
return apiErrorResult(err);
|
|
883
|
+
}
|
|
884
|
+
},
|
|
885
|
+
);
|
|
886
|
+
|
|
887
|
+
// --- federation_reset_reputation ---
|
|
888
|
+
mcp.registerTool(
|
|
889
|
+
'federation_reset_reputation',
|
|
890
|
+
{
|
|
891
|
+
title: 'Reset Agent Reputation',
|
|
892
|
+
description: 'Reset the federated reputation for an agent. This is destructive — all historical reputation data is cleared. Use only for testing or when an agent identity is being recycled.',
|
|
893
|
+
inputSchema: {
|
|
894
|
+
agentId: z.string().describe('Federated agent ID whose reputation to reset'),
|
|
895
|
+
},
|
|
896
|
+
outputSchema: ReputationResetOutputSchema,
|
|
897
|
+
annotations: {
|
|
898
|
+
readOnlyHint: false,
|
|
899
|
+
destructiveHint: true,
|
|
900
|
+
idempotentHint: false,
|
|
901
|
+
openWorldHint: true,
|
|
902
|
+
},
|
|
903
|
+
_meta: toolMeta('federation_reset_reputation'),
|
|
904
|
+
},
|
|
905
|
+
async (args) => {
|
|
906
|
+
try {
|
|
907
|
+
const result = await client.federationAdmin.resetReputation(args.agentId);
|
|
908
|
+
return {
|
|
909
|
+
content: [{ type: 'text', text: `Reputation reset for agent ${args.agentId}. All historical data cleared.` }],
|
|
910
|
+
structuredContent: result as unknown as Record<string, unknown>,
|
|
911
|
+
};
|
|
912
|
+
} catch (err) {
|
|
913
|
+
return apiErrorResult(err);
|
|
914
|
+
}
|
|
915
|
+
},
|
|
916
|
+
);
|
|
917
|
+
|
|
918
|
+
// --- federation_get_mandate_criteria_status ---
|
|
919
|
+
mcp.registerTool(
|
|
920
|
+
'federation_get_mandate_criteria_status',
|
|
921
|
+
{
|
|
922
|
+
title: 'Get Mandate Criteria Status',
|
|
923
|
+
description: 'Get the status of cross-boundary criteria exchange for a federation mandate. Shows whether criteria have been submitted, acknowledged, and validated by both gateways.',
|
|
924
|
+
inputSchema: {
|
|
925
|
+
mandateId: z.string().describe('Federation mandate ID'),
|
|
926
|
+
},
|
|
927
|
+
outputSchema: MandateCriteriaStatusOutputSchema,
|
|
928
|
+
annotations: {
|
|
929
|
+
readOnlyHint: true,
|
|
930
|
+
destructiveHint: false,
|
|
931
|
+
idempotentHint: true,
|
|
932
|
+
openWorldHint: true,
|
|
933
|
+
},
|
|
934
|
+
_meta: toolMeta('federation_get_mandate_criteria_status'),
|
|
935
|
+
},
|
|
936
|
+
async (args) => {
|
|
937
|
+
try {
|
|
938
|
+
const result = await client.federationAdmin.getMandateCriteriaStatus(args.mandateId);
|
|
939
|
+
return {
|
|
940
|
+
content: [{ type: 'text', text: `Criteria status for mandate ${result.mandateId}: principal submitted: ${result.principalSubmitted}, performer submitted: ${result.performerSubmitted}, agreement reached: ${result.agreementReached}.` }],
|
|
941
|
+
structuredContent: result as unknown as Record<string, unknown>,
|
|
942
|
+
};
|
|
943
|
+
} catch (err) {
|
|
944
|
+
return apiErrorResult(err);
|
|
945
|
+
}
|
|
946
|
+
},
|
|
947
|
+
);
|
|
948
|
+
}
|