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