@agledger/mcp-server 1.4.3 → 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (119) hide show
  1. package/dist/index.d.ts.map +1 -1
  2. package/dist/index.js +0 -2
  3. package/dist/index.js.map +1 -1
  4. package/dist/server.d.ts +2 -2
  5. package/dist/server.d.ts.map +1 -1
  6. package/dist/server.js +1 -3
  7. package/dist/server.js.map +1 -1
  8. package/dist/tool-scopes.d.ts.map +1 -1
  9. package/dist/tool-scopes.js +0 -3
  10. package/dist/tool-scopes.js.map +1 -1
  11. package/dist/tools/a2a.d.ts.map +1 -1
  12. package/dist/tools/a2a.js +20 -220
  13. package/dist/tools/a2a.js.map +1 -1
  14. package/dist/tools/agent-mandates.d.ts.map +1 -1
  15. package/dist/tools/agent-mandates.js +10 -74
  16. package/dist/tools/agent-mandates.js.map +1 -1
  17. package/dist/tools/agents-refs.d.ts.map +1 -1
  18. package/dist/tools/agents-refs.js +9 -61
  19. package/dist/tools/agents-refs.js.map +1 -1
  20. package/dist/tools/capabilities.d.ts.map +1 -1
  21. package/dist/tools/capabilities.js +2 -14
  22. package/dist/tools/capabilities.js.map +1 -1
  23. package/dist/tools/code-mode.d.ts.map +1 -1
  24. package/dist/tools/code-mode.js +4 -35
  25. package/dist/tools/code-mode.js.map +1 -1
  26. package/dist/tools/compliance.d.ts.map +1 -1
  27. package/dist/tools/compliance.js +3 -37
  28. package/dist/tools/compliance.js.map +1 -1
  29. package/dist/tools/dashboard.d.ts.map +1 -1
  30. package/dist/tools/dashboard.js +3 -37
  31. package/dist/tools/dashboard.js.map +1 -1
  32. package/dist/tools/disputes.d.ts.map +1 -1
  33. package/dist/tools/disputes.js +4 -41
  34. package/dist/tools/disputes.js.map +1 -1
  35. package/dist/tools/enterprises.d.ts.map +1 -1
  36. package/dist/tools/enterprises.js +6 -62
  37. package/dist/tools/enterprises.js.map +1 -1
  38. package/dist/tools/events.d.ts.map +1 -1
  39. package/dist/tools/events.js +1 -19
  40. package/dist/tools/events.js.map +1 -1
  41. package/dist/tools/federation-admin.d.ts.map +1 -1
  42. package/dist/tools/federation-admin.js +24 -256
  43. package/dist/tools/federation-admin.js.map +1 -1
  44. package/dist/tools/federation.d.ts.map +1 -1
  45. package/dist/tools/federation.js +20 -197
  46. package/dist/tools/federation.js.map +1 -1
  47. package/dist/tools/health.d.ts.map +1 -1
  48. package/dist/tools/health.js +1 -13
  49. package/dist/tools/health.js.map +1 -1
  50. package/dist/tools/mandates.d.ts.map +1 -1
  51. package/dist/tools/mandates.js +10 -93
  52. package/dist/tools/mandates.js.map +1 -1
  53. package/dist/tools/openclaw.d.ts.map +1 -1
  54. package/dist/tools/openclaw.js +5 -32
  55. package/dist/tools/openclaw.js.map +1 -1
  56. package/dist/tools/receipts.d.ts.map +1 -1
  57. package/dist/tools/receipts.js +4 -94
  58. package/dist/tools/receipts.js.map +1 -1
  59. package/dist/tools/reputation.d.ts.map +1 -1
  60. package/dist/tools/reputation.js +3 -33
  61. package/dist/tools/reputation.js.map +1 -1
  62. package/dist/tools/schemas.d.ts.map +1 -1
  63. package/dist/tools/schemas.js +16 -186
  64. package/dist/tools/schemas.js.map +1 -1
  65. package/dist/tools/verification-keys.d.ts.map +1 -1
  66. package/dist/tools/verification-keys.js +1 -22
  67. package/dist/tools/verification-keys.js.map +1 -1
  68. package/dist/tools/verification.d.ts.map +1 -1
  69. package/dist/tools/verification.js +2 -27
  70. package/dist/tools/verification.js.map +1 -1
  71. package/package.json +1 -1
  72. package/src/index.ts +1 -3
  73. package/src/server.ts +3 -5
  74. package/src/tool-scopes.ts +0 -4
  75. package/src/tools/a2a.ts +20 -233
  76. package/src/tools/agent-mandates.ts +10 -76
  77. package/src/tools/agents-refs.ts +9 -65
  78. package/src/tools/capabilities.ts +2 -15
  79. package/src/tools/compliance.ts +3 -37
  80. package/src/tools/dashboard.ts +3 -37
  81. package/src/tools/disputes.ts +4 -42
  82. package/src/tools/enterprises.ts +6 -62
  83. package/src/tools/events.ts +1 -20
  84. package/src/tools/federation-admin.ts +24 -281
  85. package/src/tools/federation.ts +20 -217
  86. package/src/tools/health.ts +1 -14
  87. package/src/tools/mandates.ts +10 -95
  88. package/src/tools/openclaw.ts +5 -51
  89. package/src/tools/receipts.ts +4 -95
  90. package/src/tools/reputation.ts +3 -34
  91. package/src/tools/schemas.ts +16 -194
  92. package/src/tools/verification-keys.ts +1 -24
  93. package/src/tools/verification.ts +2 -29
  94. package/tests/conformance.test.ts +4 -26
  95. package/tests/conformance.ts +3 -13
  96. package/tests/profiles.test.ts +2 -17
  97. package/tests/tools/a2a.test.ts +0 -28
  98. package/tests/tools/agent-mandates.test.ts +0 -10
  99. package/tests/tools/agents-refs.test.ts +0 -9
  100. package/tests/tools/capabilities.test.ts +0 -6
  101. package/tests/tools/compliance.test.ts +0 -8
  102. package/tests/tools/dashboard.test.ts +0 -9
  103. package/tests/tools/disputes.test.ts +0 -8
  104. package/tests/tools/enterprises.test.ts +0 -10
  105. package/tests/tools/events.test.ts +0 -5
  106. package/tests/tools/federation-admin.test.ts +0 -41
  107. package/tests/tools/federation.test.ts +0 -34
  108. package/tests/tools/health.test.ts +1 -12
  109. package/tests/tools/mandates.test.ts +0 -12
  110. package/tests/tools/openclaw.test.ts +0 -12
  111. package/tests/tools/receipts.test.ts +1 -14
  112. package/tests/tools/reputation.test.ts +0 -9
  113. package/tests/tools/schemas.test.ts +0 -23
  114. package/tests/tools/verification-keys.test.ts +0 -6
  115. package/tests/tools/verification.test.ts +1 -11
  116. package/src/tools/code-mode.ts +0 -461
  117. package/tests/drift/code-mode-manifest.test.ts +0 -144
  118. package/tests/integration/output-schema-validation.test.ts +0 -167
  119. package/tests/tools/code-mode.test.ts +0 -168
@@ -20,113 +20,6 @@ const FieldMappingSchema = z.object({
20
20
  expression: z.string().optional().describe('Safe expression string. Required when valueType is "expression"'),
21
21
  }).describe('Field mapping between mandate criteria and receipt evidence for verification');
22
22
 
23
- const ContractTypeListOutputSchema = z.object({
24
- contractTypes: z.array(ContractTypeEnum).describe('Array of all available contract type identifiers'),
25
- }).describe('List of all AGLedger contract types');
26
-
27
- const ContractSchemaOutputSchema = z.object({
28
- contractType: ContractTypeEnum,
29
- mandateSchema: z.record(z.string(), z.unknown()).describe('JSON Schema for mandate criteria of this contract type'),
30
- receiptSchema: z.record(z.string(), z.unknown()).describe('JSON Schema for receipt evidence of this contract type'),
31
- rulesConfig: z.object({
32
- syncRuleIds: z.array(z.string()).describe('Synchronous verification rule IDs'),
33
- asyncRuleIds: z.array(z.string()).describe('Asynchronous verification rule IDs'),
34
- }).passthrough().nullable().optional().describe('Verification rules configuration'),
35
- fieldMappings: z.array(FieldMappingSchema).optional().describe('Field mappings between criteria and evidence, including expression-based rules'),
36
- quickStart: z.object({
37
- criteria: z.record(z.string(), z.unknown()).describe('Example mandate criteria payload — copy-paste ready'),
38
- evidence: z.record(z.string(), z.unknown()).describe('Example receipt evidence payload — copy-paste ready'),
39
- }).optional().describe('Quick-start examples with copy-pasteable payloads for this contract type'),
40
- }).passthrough().describe('Contract type schema with mandate/receipt JSON Schemas, rules, field mappings, and quickStart examples');
41
-
42
- const MetaSchemaOutputSchema = z.object({
43
- constraints: z.object({
44
- maxDepth: z.number().describe('Maximum nesting depth for schema properties'),
45
- maxNodes: z.number().describe('Maximum number of schema nodes'),
46
- maxSizeBytes: z.number().describe('Maximum schema size in bytes'),
47
- maxCombinerEntries: z.number().describe('Maximum entries in anyOf/oneOf/allOf'),
48
- rootTypeMustBe: z.string().describe('Required root type for schemas'),
49
- rootMustHaveRequired: z.boolean().describe('Whether root must have required fields'),
50
- blockedKeywords: z.array(z.string()).describe('Blocked JSON Schema keywords'),
51
- }).passthrough().describe('Schema authoring constraints'),
52
- allowedFormats: z.array(z.string()).describe('Allowed JSON Schema format values'),
53
- allowedRefs: z.array(z.string()).describe('Allowed $ref targets'),
54
- limits: z.object({
55
- contractTypeMaxLength: z.number().describe('Maximum length for contract type identifiers'),
56
- maxFieldMappings: z.number().describe('Maximum number of field mappings per schema'),
57
- ruleIdPattern: z.string().describe('Regex pattern for rule IDs'),
58
- ruleIdMaxLength: z.number().describe('Maximum length for rule IDs'),
59
- reservedPrefixes: z.array(z.string()).describe('Reserved contract type prefixes'),
60
- }).passthrough().describe('Limits for schema registration'),
61
- fieldMappingValueTypes: z.array(z.string()).describe('Allowed field mapping value types including "expression"'),
62
- builtinRuleIds: z.array(z.string()).describe('Built-in verification rule IDs'),
63
- expressionHelpers: z.array(z.string()).optional().describe('Available helper functions for expression-based rules'),
64
- expressionLimits: z.object({
65
- maxLength: z.number().describe('Maximum expression string length'),
66
- maxAstNodes: z.number().describe('Maximum AST nodes in expression'),
67
- maxAstDepth: z.number().describe('Maximum AST nesting depth'),
68
- maxOperations: z.number().describe('Maximum operations in expression'),
69
- allowedContexts: z.array(z.string()).describe('Allowed expression context variables'),
70
- }).optional().describe('Limits for expression-based verification rules'),
71
- sharedSchemas: z.record(z.string(), z.unknown()).describe('Reusable schema definitions'),
72
- examples: z.object({
73
- minimalMandate: z.record(z.string(), z.unknown()).describe('Minimal example mandate schema'),
74
- minimalReceipt: z.record(z.string(), z.unknown()).describe('Minimal example receipt schema'),
75
- }).passthrough().describe('Example schemas for reference'),
76
- }).passthrough().describe('Meta-schema describing constraints and limits for custom schema authoring');
77
-
78
- const SchemaPreviewOutputSchema = z.object({
79
- valid: z.boolean().describe('Whether the schema is valid'),
80
- compiled: z.record(z.string(), z.unknown()).optional().describe('Compiled schema output if valid'),
81
- errors: z.array(z.object({
82
- code: z.string().describe('Error code'),
83
- message: z.string().describe('Error message'),
84
- path: z.string().optional().describe('JSON path to the error location'),
85
- })).optional().describe('Validation errors if invalid'),
86
- }).describe('Schema preview/validation result');
87
-
88
- const SchemaVersionOutputSchema = z.object({
89
- id: z.string().describe('Version record ID'),
90
- contractType: ContractTypeString,
91
- version: z.number().describe('Version number'),
92
- enterpriseId: z.string().nullable().describe('Enterprise ID if enterprise-scoped, null for global'),
93
- displayName: z.string().nullable().optional().describe('Human-readable name'),
94
- description: z.string().nullable().optional().describe('Schema description'),
95
- category: z.string().nullable().optional().describe('Schema category'),
96
- compatibilityMode: z.string().describe('Compatibility mode: FULL, BACKWARD, FORWARD, or NONE'),
97
- status: z.string().describe('Version status: ACTIVE, DEPRECATED, or DRAFT'),
98
- isBuiltin: z.boolean().describe('Whether this is a built-in AGLedger schema'),
99
- createdAt: z.string().describe('ISO 8601 creation timestamp'),
100
- updatedAt: z.string().describe('ISO 8601 last update timestamp'),
101
- }).passthrough().describe('Schema version detail');
102
-
103
- const SchemaDiffChangeSchema = z.object({
104
- type: z.string().describe('Change type: added, removed, modified, renamed'),
105
- path: z.string().describe('JSON path of the changed field'),
106
- before: z.unknown().optional().describe('Previous value'),
107
- after: z.unknown().optional().describe('New value'),
108
- }).describe('A single schema change');
109
-
110
- const SchemaDiffOutputSchema = z.object({
111
- contractType: ContractTypeString,
112
- from: z.object({
113
- version: z.number(),
114
- createdAt: z.string(),
115
- status: z.string(),
116
- }).describe('Source version info'),
117
- to: z.object({
118
- version: z.number(),
119
- createdAt: z.string(),
120
- status: z.string(),
121
- }).describe('Target version info'),
122
- mandate: z.object({
123
- changes: z.array(SchemaDiffChangeSchema),
124
- }).describe('Changes to mandate criteria schema'),
125
- receipt: z.object({
126
- changes: z.array(SchemaDiffChangeSchema),
127
- }).describe('Changes to receipt evidence schema'),
128
- }).passthrough().describe('Diff between two schema versions');
129
-
130
23
  const CompatibilityModeEnum = z.enum(['FULL', 'BACKWARD', 'FORWARD', 'NONE'])
131
24
  .describe('Schema compatibility mode');
132
25
 
@@ -137,7 +30,6 @@ export function registerSchemaTools(mcp: McpServer, client: AgledgerClient): voi
137
30
  title: 'List Contract Schemas',
138
31
  description: 'List all AGLedger contract type identifiers (built-in and custom). Each type now includes quickStart examples. Start here when building a new schema — use the returned types as reference patterns, then call get_contract_schema on a similar type to see its structure and quickStart guide.',
139
32
  inputSchema: {},
140
- outputSchema: ContractTypeListOutputSchema,
141
33
  annotations: {
142
34
  readOnlyHint: true,
143
35
  destructiveHint: false,
@@ -150,7 +42,7 @@ export function registerSchemaTools(mcp: McpServer, client: AgledgerClient): voi
150
42
  try {
151
43
  const result = await client.schemas.list();
152
44
  return {
153
- content: [{ type: 'text', text: `${result.data.length} contract types available: ${result.data.join(', ')}.` }],
45
+ content: [],
154
46
  structuredContent: toStructuredContent({ contractTypes: result.data }),
155
47
  };
156
48
  } catch (err) {
@@ -167,7 +59,6 @@ export function registerSchemaTools(mcp: McpServer, client: AgledgerClient): voi
167
59
  inputSchema: {
168
60
  contractType: ContractTypeEnum.describe('Contract type to retrieve the schema for'),
169
61
  },
170
- outputSchema: ContractSchemaOutputSchema,
171
62
  annotations: {
172
63
  readOnlyHint: true,
173
64
  destructiveHint: false,
@@ -180,7 +71,7 @@ export function registerSchemaTools(mcp: McpServer, client: AgledgerClient): voi
180
71
  try {
181
72
  const schema = await client.schemas.get(args.contractType);
182
73
  return {
183
- content: [{ type: 'text', text: `Schema for ${schema.contractType}: mandate schema has ${Object.keys(schema.mandateSchema).length} fields, receipt schema has ${Object.keys(schema.receiptSchema).length} fields.${(schema as any).quickStart ? ' Includes quickStart examples with copy-pasteable payloads.' : ''}` }],
74
+ content: [],
184
75
  structuredContent: toStructuredContent(schema),
185
76
  };
186
77
  } catch (err) {
@@ -195,7 +86,6 @@ export function registerSchemaTools(mcp: McpServer, client: AgledgerClient): voi
195
86
  title: 'Get Meta-Schema',
196
87
  description: 'Get the meta-schema that defines constraints and limits for custom schema authoring (max depth, allowed formats, field mapping types, expression limits). Review this BEFORE designing a custom schema.',
197
88
  inputSchema: {},
198
- outputSchema: MetaSchemaOutputSchema,
199
89
  annotations: {
200
90
  readOnlyHint: true,
201
91
  destructiveHint: false,
@@ -208,7 +98,7 @@ export function registerSchemaTools(mcp: McpServer, client: AgledgerClient): voi
208
98
  try {
209
99
  const metaSchema = await client.schemas.getMetaSchema();
210
100
  return {
211
- content: [{ type: 'text', text: `Meta-schema: max depth ${metaSchema.constraints.maxDepth}, max nodes ${metaSchema.constraints.maxNodes}, max size ${metaSchema.constraints.maxSizeBytes} bytes. ${metaSchema.allowedFormats.length} allowed formats, max ${metaSchema.limits.maxFieldMappings} field mappings, ${metaSchema.fieldMappingValueTypes.length} value types (${metaSchema.fieldMappingValueTypes.join(', ')}). Next: call get_schema_template or get_blank_schema_template to start building.` }],
101
+ content: [],
212
102
  structuredContent: toStructuredContent(metaSchema),
213
103
  };
214
104
  } catch (err) {
@@ -232,7 +122,6 @@ export function registerSchemaTools(mcp: McpServer, client: AgledgerClient): voi
232
122
  fieldMappings: z.array(FieldMappingSchema).optional().describe('Field mappings for verification rules, including expression-based rules'),
233
123
  compatibilityMode: CompatibilityModeEnum.optional().describe('Compatibility mode for version evolution'),
234
124
  },
235
- outputSchema: SchemaPreviewOutputSchema,
236
125
  annotations: {
237
126
  readOnlyHint: true,
238
127
  destructiveHint: false,
@@ -253,11 +142,8 @@ export function registerSchemaTools(mcp: McpServer, client: AgledgerClient): voi
253
142
  fieldMappings: args.fieldMappings,
254
143
  compatibilityMode: args.compatibilityMode,
255
144
  });
256
- const status = result.valid
257
- ? `valid. Schema is valid. Next: call register_schema to register it.`
258
- : `invalid (${result.errors?.length ?? 0} errors). Fix the errors above, then call preview_schema again.`;
259
145
  return {
260
- content: [{ type: 'text', text: `Schema preview for ${args.contractType}: ${status}` }],
146
+ content: [],
261
147
  structuredContent: toStructuredContent(result),
262
148
  };
263
149
  } catch (err) {
@@ -281,7 +167,6 @@ export function registerSchemaTools(mcp: McpServer, client: AgledgerClient): voi
281
167
  fieldMappings: z.array(FieldMappingSchema).optional().describe('Field mappings for verification rules, including expression-based rules'),
282
168
  compatibilityMode: CompatibilityModeEnum.optional().describe('Compatibility mode for version evolution'),
283
169
  },
284
- outputSchema: SchemaVersionOutputSchema,
285
170
  annotations: {
286
171
  readOnlyHint: false,
287
172
  destructiveHint: false,
@@ -303,7 +188,7 @@ export function registerSchemaTools(mcp: McpServer, client: AgledgerClient): voi
303
188
  compatibilityMode: args.compatibilityMode,
304
189
  });
305
190
  return {
306
- content: [{ type: 'text', text: `Registered ${result.contractType} v${result.version} (${result.status}). Schema registered. Use get_schema_versions to see all versions.` }],
191
+ content: [],
307
192
  structuredContent: toStructuredContent(result),
308
193
  };
309
194
  } catch (err) {
@@ -320,10 +205,6 @@ export function registerSchemaTools(mcp: McpServer, client: AgledgerClient): voi
320
205
  inputSchema: {
321
206
  contractType: ContractTypeString.describe('Contract type to list versions for'),
322
207
  },
323
- outputSchema: z.object({
324
- contractType: z.string().describe('Contract type'),
325
- versions: z.array(SchemaVersionOutputSchema).describe('Version list'),
326
- }).passthrough().describe('All versions of a contract type schema'),
327
208
  annotations: {
328
209
  readOnlyHint: true,
329
210
  destructiveHint: false,
@@ -335,9 +216,8 @@ export function registerSchemaTools(mcp: McpServer, client: AgledgerClient): voi
335
216
  async (args) => {
336
217
  try {
337
218
  const page = await client.schemas.getVersions(args.contractType as Parameters<typeof client.schemas.getVersions>[0]);
338
- const latest = page.data.length > 0 ? page.data[page.data.length - 1].version : 'none';
339
219
  return {
340
- content: [{ type: 'text', text: `${args.contractType}: ${page.data.length} version(s). Latest: v${latest}. Use get_schema_version to inspect a specific version, or diff_schema_versions to compare two.` }],
220
+ content: [],
341
221
  structuredContent: toStructuredContent({ contractType: args.contractType, versions: page.data }),
342
222
  };
343
223
  } catch (err) {
@@ -356,7 +236,6 @@ export function registerSchemaTools(mcp: McpServer, client: AgledgerClient): voi
356
236
  from: z.number().int().min(1).describe('Source version number'),
357
237
  to: z.number().int().min(1).describe('Target version number'),
358
238
  },
359
- outputSchema: SchemaDiffOutputSchema,
360
239
  annotations: {
361
240
  readOnlyHint: true,
362
241
  destructiveHint: false,
@@ -372,10 +251,8 @@ export function registerSchemaTools(mcp: McpServer, client: AgledgerClient): voi
372
251
  args.from,
373
252
  args.to,
374
253
  );
375
- const mandateChanges = diff.mandate.changes.length;
376
- const receiptChanges = diff.receipt.changes.length;
377
254
  return {
378
- content: [{ type: 'text', text: `Diff ${args.contractType} v${args.from} → v${args.to}: ${mandateChanges} mandate change(s), ${receiptChanges} receipt change(s).` }],
255
+ content: [],
379
256
  structuredContent: toStructuredContent(diff),
380
257
  };
381
258
  } catch (err) {
@@ -384,14 +261,6 @@ export function registerSchemaTools(mcp: McpServer, client: AgledgerClient): voi
384
261
  },
385
262
  );
386
263
 
387
- const SchemaTemplateOutputSchema = z.object({
388
- contractType: z.string().optional().describe('Contract type identifier'),
389
- displayName: z.string().nullable().optional().describe('Human-readable name'),
390
- mandateSchema: z.record(z.string(), z.unknown()).optional().describe('Mandate criteria JSON Schema'),
391
- receiptSchema: z.record(z.string(), z.unknown()).optional().describe('Receipt evidence JSON Schema'),
392
- fieldMappings: z.array(z.record(z.string(), z.unknown())).nullable().optional().describe('Field mappings'),
393
- }).passthrough();
394
-
395
264
  mcp.registerTool(
396
265
  'get_schema_template',
397
266
  {
@@ -400,7 +269,6 @@ export function registerSchemaTools(mcp: McpServer, client: AgledgerClient): voi
400
269
  inputSchema: {
401
270
  contractType: ContractTypeString.describe('Contract type to use as template (e.g. ACH-PROC-v1)'),
402
271
  },
403
- outputSchema: SchemaTemplateOutputSchema.describe('Schema template derived from an existing contract type'),
404
272
  annotations: {
405
273
  readOnlyHint: true,
406
274
  destructiveHint: false,
@@ -413,7 +281,7 @@ export function registerSchemaTools(mcp: McpServer, client: AgledgerClient): voi
413
281
  try {
414
282
  const template = await client.schemas.getTemplate(args.contractType as Parameters<typeof client.schemas.getTemplate>[0]);
415
283
  return {
416
- content: [{ type: 'text', text: `Template from ${args.contractType}. Next: modify the template, then call preview_schema to validate before registration.` }],
284
+ content: [],
417
285
  structuredContent: toStructuredContent(template),
418
286
  };
419
287
  } catch (err) {
@@ -428,7 +296,6 @@ export function registerSchemaTools(mcp: McpServer, client: AgledgerClient): voi
428
296
  title: 'Get Blank Schema Template',
429
297
  description: 'Get a blank template for creating a custom contract type from scratch. Returns the minimal valid structure with placeholder fields. After filling in, use preview_schema to validate.',
430
298
  inputSchema: {},
431
- outputSchema: SchemaTemplateOutputSchema.describe('Blank schema template for building a custom contract type from scratch'),
432
299
  annotations: {
433
300
  readOnlyHint: true,
434
301
  destructiveHint: false,
@@ -441,7 +308,7 @@ export function registerSchemaTools(mcp: McpServer, client: AgledgerClient): voi
441
308
  try {
442
309
  const template = await client.schemas.getBlankTemplate();
443
310
  return {
444
- content: [{ type: 'text', text: `Blank schema template ready. Next: fill in contractType, mandateSchema, receiptSchema, then call preview_schema.` }],
311
+ content: [],
445
312
  structuredContent: toStructuredContent(template),
446
313
  };
447
314
  } catch (err) {
@@ -460,14 +327,6 @@ export function registerSchemaTools(mcp: McpServer, client: AgledgerClient): voi
460
327
  mandateSchema: z.record(z.string(), z.unknown()).describe('Proposed mandate criteria JSON Schema'),
461
328
  receiptSchema: z.record(z.string(), z.unknown()).describe('Proposed receipt evidence JSON Schema'),
462
329
  },
463
- outputSchema: z.object({
464
- compatible: z.boolean().describe('Whether the proposed changes are compatible'),
465
- mode: z.string().nullable().optional().describe('Compatibility mode checked against'),
466
- issues: z.array(z.object({
467
- message: z.string().describe('Compatibility issue description'),
468
- path: z.string().nullable().optional().describe('JSON path of the incompatible field'),
469
- })).nullable().optional().describe('List of compatibility issues found'),
470
- }).passthrough().describe('Schema compatibility check result'),
471
330
  annotations: {
472
331
  readOnlyHint: true,
473
332
  destructiveHint: false,
@@ -483,7 +342,7 @@ export function registerSchemaTools(mcp: McpServer, client: AgledgerClient): voi
483
342
  { mandateSchema: args.mandateSchema, receiptSchema: args.receiptSchema },
484
343
  );
485
344
  return {
486
- content: [{ type: 'text', text: `Compatibility check for ${args.contractType}: ${JSON.stringify(result)}.` }],
345
+ content: [],
487
346
  structuredContent: toStructuredContent(result),
488
347
  };
489
348
  } catch (err) {
@@ -501,7 +360,6 @@ export function registerSchemaTools(mcp: McpServer, client: AgledgerClient): voi
501
360
  contractType: ContractTypeString.describe('Contract type to retrieve'),
502
361
  version: z.number().int().describe('Version number'),
503
362
  },
504
- outputSchema: SchemaVersionOutputSchema,
505
363
  annotations: {
506
364
  readOnlyHint: true,
507
365
  destructiveHint: false,
@@ -517,7 +375,7 @@ export function registerSchemaTools(mcp: McpServer, client: AgledgerClient): voi
517
375
  args.version,
518
376
  );
519
377
  return {
520
- content: [{ type: 'text', text: `${result.contractType} v${result.version} (${result.status}), created ${result.createdAt}.` }],
378
+ content: [],
521
379
  structuredContent: toStructuredContent(result),
522
380
  };
523
381
  } catch (err) {
@@ -535,13 +393,6 @@ export function registerSchemaTools(mcp: McpServer, client: AgledgerClient): voi
535
393
  contractType: ContractTypeString.describe('Contract type to validate against (e.g., ACH-PROC-v1)'),
536
394
  evidence: z.record(z.string(), z.unknown()).describe('Evidence object to validate'),
537
395
  },
538
- outputSchema: z.object({
539
- valid: z.boolean().describe('Whether the evidence is valid for the contract type'),
540
- errors: z.array(z.object({
541
- message: z.string().describe('Validation error message'),
542
- instancePath: z.string().nullable().optional().describe('JSON path of the invalid field'),
543
- })).nullable().optional().describe('Validation errors if invalid'),
544
- }).passthrough().describe('Receipt evidence validation result'),
545
396
  annotations: {
546
397
  readOnlyHint: true,
547
398
  destructiveHint: false,
@@ -556,16 +407,8 @@ export function registerSchemaTools(mcp: McpServer, client: AgledgerClient): voi
556
407
  args.contractType as Parameters<typeof client.schemas.validateReceipt>[0],
557
408
  args.evidence,
558
409
  );
559
- if (result.valid) {
560
- return {
561
- content: [{ type: 'text', text: `Evidence is valid for ${args.contractType}. You can now call submit_receipt.` }],
562
- structuredContent: toStructuredContent(result),
563
- };
564
- }
565
- const errorCount = result.errors?.length ?? 0;
566
- const errorDetails = result.errors?.map(e => `- ${e.instancePath ?? '/'}: ${e.message}`).join('\n') ?? '';
567
410
  return {
568
- content: [{ type: 'text', text: `Evidence is invalid for ${args.contractType} (${errorCount} error(s)):\n${errorDetails}\n\nFix the errors and try again.` }],
411
+ content: [],
569
412
  structuredContent: toStructuredContent(result),
570
413
  };
571
414
  } catch (err) {
@@ -582,10 +425,6 @@ export function registerSchemaTools(mcp: McpServer, client: AgledgerClient): voi
582
425
  inputSchema: {
583
426
  contractType: ContractTypeString.describe('Contract type to get rules for'),
584
427
  },
585
- outputSchema: z.object({
586
- syncRuleIds: z.array(z.string()).describe('Synchronous verification rule IDs'),
587
- asyncRuleIds: z.array(z.string()).describe('Asynchronous verification rule IDs'),
588
- }).passthrough().describe('Verification rules configured for the contract type'),
589
428
  annotations: {
590
429
  readOnlyHint: true,
591
430
  destructiveHint: false,
@@ -597,9 +436,8 @@ export function registerSchemaTools(mcp: McpServer, client: AgledgerClient): voi
597
436
  async (args) => {
598
437
  try {
599
438
  const result = await client.schemas.getRules(args.contractType as Parameters<typeof client.schemas.getRules>[0]);
600
- const total = result.syncRuleIds.length + result.asyncRuleIds.length;
601
439
  return {
602
- content: [{ type: 'text', text: `${args.contractType}: ${total} rule(s) — ${result.syncRuleIds.length} sync, ${result.asyncRuleIds.length} async.` }],
440
+ content: [],
603
441
  structuredContent: toStructuredContent(result),
604
442
  };
605
443
  } catch (err) {
@@ -616,10 +454,6 @@ export function registerSchemaTools(mcp: McpServer, client: AgledgerClient): voi
616
454
  inputSchema: {
617
455
  contractType: ContractTypeString.describe('Custom contract type identifier to delete'),
618
456
  },
619
- outputSchema: z.object({
620
- deleted: z.boolean().nullable().optional().describe('Whether the schema was deleted'),
621
- contractType: z.string().nullable().optional().describe('Deleted contract type identifier'),
622
- }).passthrough().describe('Schema deletion confirmation'),
623
457
  annotations: {
624
458
  readOnlyHint: false,
625
459
  destructiveHint: true,
@@ -632,7 +466,7 @@ export function registerSchemaTools(mcp: McpServer, client: AgledgerClient): voi
632
466
  try {
633
467
  const result = await client.schemas.delete(args.contractType);
634
468
  return {
635
- content: [{ type: 'text', text: `Schema ${args.contractType} deleted.` }],
469
+ content: [],
636
470
  structuredContent: toStructuredContent(result),
637
471
  };
638
472
  } catch (err) {
@@ -649,13 +483,6 @@ export function registerSchemaTools(mcp: McpServer, client: AgledgerClient): voi
649
483
  inputSchema: {
650
484
  contractType: ContractTypeString.describe('Contract type to export'),
651
485
  },
652
- outputSchema: z.object({
653
- contractType: z.string().optional().describe('Exported contract type identifier'),
654
- version: z.number().nullable().optional().describe('Schema version number'),
655
- mandateSchema: z.record(z.string(), z.unknown()).nullable().optional().describe('Mandate criteria JSON Schema'),
656
- receiptSchema: z.record(z.string(), z.unknown()).nullable().optional().describe('Receipt evidence JSON Schema'),
657
- fieldMappings: z.array(z.record(z.string(), z.unknown())).nullable().optional().describe('Field mappings'),
658
- }).passthrough().describe('Exported schema bundle for cross-environment promotion'),
659
486
  annotations: {
660
487
  readOnlyHint: true,
661
488
  destructiveHint: false,
@@ -668,7 +495,7 @@ export function registerSchemaTools(mcp: McpServer, client: AgledgerClient): voi
668
495
  try {
669
496
  const bundle = await client.schemas.exportSchema(args.contractType);
670
497
  return {
671
- content: [{ type: 'text', text: `Exported schema bundle for ${args.contractType}. Use import_schema to import into another environment.` }],
498
+ content: [],
672
499
  structuredContent: toStructuredContent(bundle),
673
500
  };
674
501
  } catch (err) {
@@ -685,11 +512,6 @@ export function registerSchemaTools(mcp: McpServer, client: AgledgerClient): voi
685
512
  inputSchema: {
686
513
  bundle: z.record(z.string(), z.unknown()).describe('Schema bundle object from export_schema'),
687
514
  },
688
- outputSchema: z.object({
689
- contractType: z.string().nullable().optional().describe('Imported contract type identifier'),
690
- version: z.number().nullable().optional().describe('Imported schema version number'),
691
- status: z.string().nullable().optional().describe('Import status'),
692
- }).passthrough().describe('Schema import result'),
693
515
  annotations: {
694
516
  readOnlyHint: false,
695
517
  destructiveHint: false,
@@ -702,7 +524,7 @@ export function registerSchemaTools(mcp: McpServer, client: AgledgerClient): voi
702
524
  try {
703
525
  const result = await client.schemas.importSchema(args.bundle as any);
704
526
  return {
705
- content: [{ type: 'text', text: `Schema imported successfully.` }],
527
+ content: [],
706
528
  structuredContent: toStructuredContent(result),
707
529
  };
708
530
  } catch (err) {
@@ -1,25 +1,8 @@
1
- import { z } from 'zod';
2
1
  import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
3
2
  import type { AgledgerClient } from '@agledger/sdk';
4
3
  import { apiErrorResult, toStructuredContent } from '../errors.js';
5
4
  import { toolMeta } from '../tool-scopes.js';
6
5
 
7
- const VerificationKeySchema = z.object({
8
- keyId: z.string().describe('Unique key identifier'),
9
- algorithm: z.string().describe('Signing algorithm (e.g. Ed25519)'),
10
- publicKey: z.string().describe('Base64-encoded public key'),
11
- status: z.string().describe('Key status: active or retired'),
12
- activatedAt: z.string().describe('Date the key was activated (YYYY-MM-DD)'),
13
- retiredAt: z.string().nullable().describe('Date the key was retired, or null if active'),
14
- });
15
-
16
- const VerificationKeysOutputSchema = z.object({
17
- data: z.array(VerificationKeySchema).describe('Vault signing public keys'),
18
- canonicalization: z.string().describe('Canonicalization standard (e.g. RFC8785)'),
19
- hashAlgorithm: z.string().describe('Hash algorithm used in audit chain'),
20
- signatureAlgorithm: z.string().describe('Signature algorithm for audit entries'),
21
- }).describe('Vault signing public keys for independent audit chain verification');
22
-
23
6
  export function registerVerificationKeysTools(mcp: McpServer, client: AgledgerClient): void {
24
7
  mcp.registerTool(
25
8
  'list_verification_keys',
@@ -30,7 +13,6 @@ export function registerVerificationKeysTools(mcp: McpServer, client: AgledgerCl
30
13
  'No authentication required. Use these keys to verify Ed25519 signatures on audit chain exports. ' +
31
14
  'Next step: fetch an audit export with `export_mandate_audit` and verify signatures locally.',
32
15
  inputSchema: {},
33
- outputSchema: VerificationKeysOutputSchema,
34
16
  annotations: {
35
17
  readOnlyHint: true,
36
18
  destructiveHint: false,
@@ -42,12 +24,7 @@ export function registerVerificationKeysTools(mcp: McpServer, client: AgledgerCl
42
24
  async () => {
43
25
  try {
44
26
  const result = await client.verificationKeys.list();
45
- const count = result.data.length;
46
- const active = result.data.filter((k) => k.status === 'active').length;
47
- return {
48
- content: [{ type: 'text', text: `${count} verification key(s): ${active} active, ${count - active} retired. Algorithm: ${result.signatureAlgorithm}.` }],
49
- structuredContent: toStructuredContent(result),
50
- };
27
+ return { content: [], structuredContent: toStructuredContent(result) };
51
28
  } catch (err) {
52
29
  return apiErrorResult(err);
53
30
  }
@@ -2,27 +2,8 @@ import { z } from 'zod';
2
2
  import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
3
3
  import type { AgledgerClient } from '@agledger/sdk';
4
4
  import { apiErrorResult, toStructuredContent } from '../errors.js';
5
- import { VerificationOutcomeEnum } from '../enums.js';
6
5
  import { toolMeta } from '../tool-scopes.js';
7
6
 
8
- const VerificationResultOutputSchema = z.object({
9
- mandateId: z.string().describe('Mandate UUID that was verified'),
10
- receipts: z.array(z.object({
11
- receiptId: z.string().describe('Receipt UUID'),
12
- phase1Result: z.record(z.string(), z.unknown()).optional().describe('Phase 1 (sync) verification result'),
13
- phase2Result: z.record(z.string(), z.unknown()).optional().describe('Phase 2 (async) verification result'),
14
- })).describe('Per-receipt verification results'),
15
- overallStatus: VerificationOutcomeEnum.describe('Overall verification outcome: PASS, FAIL, or REVIEW_REQUIRED'),
16
- }).passthrough().describe('Mandate verification result');
17
-
18
- const VerificationStatusOutputSchema = z.object({
19
- mandateId: z.string().describe('Mandate UUID'),
20
- phase1Status: z.string().describe('Phase 1 (sync rules) verification status'),
21
- phase2Status: z.string().describe('Phase 2 (async rules) verification status'),
22
- lastVerifiedAt: z.string().nullable().optional().describe('ISO 8601 timestamp of last verification'),
23
- pendingRules: z.array(z.string()).nullable().optional().describe('Rule IDs still pending verification'),
24
- }).passthrough().describe('Current verification status for a mandate');
25
-
26
7
  export function registerVerificationTools(mcp: McpServer, client: AgledgerClient): void {
27
8
  mcp.registerTool(
28
9
  'verify_mandate',
@@ -32,7 +13,6 @@ export function registerVerificationTools(mcp: McpServer, client: AgledgerClient
32
13
  inputSchema: {
33
14
  mandateId: z.string().describe('UUID of the mandate to verify'),
34
15
  },
35
- outputSchema: VerificationResultOutputSchema,
36
16
  annotations: {
37
17
  readOnlyHint: false,
38
18
  destructiveHint: false,
@@ -44,10 +24,7 @@ export function registerVerificationTools(mcp: McpServer, client: AgledgerClient
44
24
  async (args) => {
45
25
  try {
46
26
  const result = await client.verification.verify(args.mandateId);
47
- return {
48
- content: [{ type: 'text', text: `Verification for mandate ${result.mandateId}: ${result.overallStatus}. ${result.receipts.length} receipt(s) evaluated.` }],
49
- structuredContent: toStructuredContent(result),
50
- };
27
+ return { content: [], structuredContent: toStructuredContent(result) };
51
28
  } catch (err) {
52
29
  return apiErrorResult(err);
53
30
  }
@@ -62,7 +39,6 @@ export function registerVerificationTools(mcp: McpServer, client: AgledgerClient
62
39
  inputSchema: {
63
40
  mandateId: z.string().describe('UUID of the mandate to check verification status for'),
64
41
  },
65
- outputSchema: VerificationStatusOutputSchema,
66
42
  annotations: {
67
43
  readOnlyHint: true,
68
44
  destructiveHint: false,
@@ -74,10 +50,7 @@ export function registerVerificationTools(mcp: McpServer, client: AgledgerClient
74
50
  async (args) => {
75
51
  try {
76
52
  const status = await client.verification.getStatus(args.mandateId);
77
- return {
78
- content: [{ type: 'text', text: `Verification status for ${status.mandateId}: phase1=${status.phase1Status}, phase2=${status.phase2Status}.` }],
79
- structuredContent: toStructuredContent(status),
80
- };
53
+ return { content: [], structuredContent: toStructuredContent(status) };
81
54
  } catch (err) {
82
55
  return apiErrorResult(err);
83
56
  }
@@ -61,23 +61,6 @@ describe('global conformance', () => {
61
61
  expect(dupes, `Duplicate tools: ${dupes.join(', ')}`).toEqual([]);
62
62
  });
63
63
 
64
- describe('outputSchema', () => {
65
- it('tools with outputSchema have type:"object" at root', () => {
66
- const violations: string[] = [];
67
- for (const tool of tools) {
68
- if (tool.outputSchema && tool.outputSchema.type !== 'object') {
69
- violations.push(`${tool.name}: type="${tool.outputSchema.type}"`);
70
- }
71
- }
72
- expect(violations, `outputSchema type violations: ${violations.join(', ')}`).toEqual([]);
73
- });
74
-
75
- it('every tool has outputSchema', () => {
76
- const missing = tools.filter(t => !t.outputSchema).map(t => t.name);
77
- expect(missing, `Tools missing outputSchema: ${missing.join(', ')}`).toEqual([]);
78
- });
79
- });
80
-
81
64
  describe('inputSchema', () => {
82
65
  it('every tool has an inputSchema', () => {
83
66
  const missing = tools.filter(t => !t.inputSchema).map(t => t.name);
@@ -137,17 +120,12 @@ describe('global conformance', () => {
137
120
  });
138
121
 
139
122
  /**
140
- * Error + outputSchema interaction test.
141
- *
142
- * Known MCP SDK issue: when a tool has outputSchema and returns isError: true,
143
- * the SDK may validate the error content against the outputSchema and block it.
144
- * This test verifies every tool can still surface errors correctly.
123
+ * Error handling test.
145
124
  *
146
125
  * Strategy: create a server where ALL SDK methods throw, then call every tool.
147
- * Every call should return isError: true with a readable error message (not an
148
- * outputSchema validation error or a thrown exception).
126
+ * Every call should return isError: true with a readable error message.
149
127
  */
150
- describe('error + outputSchema interaction', () => {
128
+ describe('error handling', () => {
151
129
  let errorClient: Client;
152
130
  let errorCleanup: () => Promise<void>;
153
131
  let toolNames: string[];
@@ -182,7 +160,7 @@ describe('error + outputSchema interaction', () => {
182
160
 
183
161
  afterAll(async () => { await errorCleanup(); });
184
162
 
185
- it('every tool with outputSchema can return errors without being blocked', async () => {
163
+ it('every tool returns structured errors when SDK throws', async () => {
186
164
  const blocked: string[] = [];
187
165
  const thrown: string[] = [];
188
166
 
@@ -16,17 +16,6 @@ interface CallToolResult {
16
16
  isError?: boolean;
17
17
  }
18
18
 
19
- /**
20
- * Assert a tool's outputSchema is valid:
21
- * - Has type: "object" at root (required by Claude Desktop and other MCP clients)
22
- * - Has at least one property or uses passthrough
23
- */
24
- export function assertOutputSchemaValid(tool: ToolDefinition): void {
25
- expect(tool.outputSchema, `${tool.name}: missing outputSchema`).toBeDefined();
26
- const schema = tool.outputSchema!;
27
- expect(schema.type, `${tool.name}: outputSchema must have type:"object" at root`).toBe('object');
28
- }
29
-
30
19
  /**
31
20
  * Assert tool metadata follows conventions:
32
21
  * - Non-empty description
@@ -70,6 +59,7 @@ export function assertErrorResult(result: CallToolResult): void {
70
59
  */
71
60
  export function assertSuccessResult(result: CallToolResult): void {
72
61
  expect(result.isError).toBeFalsy();
73
- expect(result.content.length).toBeGreaterThan(0);
74
- expect(result.content[0].type).toBe('text');
62
+ const hasContent = result.content.length > 0;
63
+ const hasStructured = result.structuredContent != null;
64
+ expect(hasContent || hasStructured).toBe(true);
75
65
  }