@agledger/mcp-server 1.4.1 → 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.
- package/dist/errors.d.ts +6 -0
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +8 -0
- package/dist/errors.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -2
- package/dist/index.js.map +1 -1
- package/dist/server.d.ts +6 -2
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +71 -76
- package/dist/server.js.map +1 -1
- package/dist/tool-scopes.js +3 -2
- package/dist/tool-scopes.js.map +1 -1
- package/dist/tools/a2a.d.ts.map +1 -1
- package/dist/tools/a2a.js +22 -222
- package/dist/tools/a2a.js.map +1 -1
- package/dist/tools/agent-mandates.d.ts.map +1 -1
- package/dist/tools/agent-mandates.js +11 -75
- package/dist/tools/agent-mandates.js.map +1 -1
- package/dist/tools/agents-refs.d.ts.map +1 -1
- package/dist/tools/agents-refs.js +10 -61
- package/dist/tools/agents-refs.js.map +1 -1
- package/dist/tools/capabilities.d.ts.map +1 -1
- package/dist/tools/capabilities.js +3 -15
- package/dist/tools/capabilities.js.map +1 -1
- package/dist/tools/code-mode.d.ts.map +1 -1
- package/dist/tools/code-mode.js +4 -35
- package/dist/tools/code-mode.js.map +1 -1
- package/dist/tools/compliance.d.ts.map +1 -1
- package/dist/tools/compliance.js +4 -13
- package/dist/tools/compliance.js.map +1 -1
- package/dist/tools/dashboard.d.ts.map +1 -1
- package/dist/tools/dashboard.js +4 -13
- package/dist/tools/dashboard.js.map +1 -1
- package/dist/tools/disputes.d.ts.map +1 -1
- package/dist/tools/disputes.js +5 -37
- package/dist/tools/disputes.js.map +1 -1
- package/dist/tools/enterprises.d.ts.map +1 -1
- package/dist/tools/enterprises.js +7 -39
- package/dist/tools/enterprises.js.map +1 -1
- package/dist/tools/events.d.ts.map +1 -1
- package/dist/tools/events.js +2 -20
- package/dist/tools/events.js.map +1 -1
- package/dist/tools/federation-admin.d.ts.map +1 -1
- package/dist/tools/federation-admin.js +25 -257
- package/dist/tools/federation-admin.js.map +1 -1
- package/dist/tools/federation.d.ts.map +1 -1
- package/dist/tools/federation.js +21 -198
- package/dist/tools/federation.js.map +1 -1
- package/dist/tools/health.d.ts.map +1 -1
- package/dist/tools/health.js +2 -14
- package/dist/tools/health.js.map +1 -1
- package/dist/tools/mandates.d.ts.map +1 -1
- package/dist/tools/mandates.js +11 -83
- package/dist/tools/mandates.js.map +1 -1
- package/dist/tools/openclaw.d.ts.map +1 -1
- package/dist/tools/openclaw.js +6 -33
- package/dist/tools/openclaw.js.map +1 -1
- package/dist/tools/receipts.d.ts.map +1 -1
- package/dist/tools/receipts.js +5 -96
- package/dist/tools/receipts.js.map +1 -1
- package/dist/tools/reputation.d.ts.map +1 -1
- package/dist/tools/reputation.js +4 -13
- package/dist/tools/reputation.js.map +1 -1
- package/dist/tools/schemas.d.ts.map +1 -1
- package/dist/tools/schemas.js +34 -159
- package/dist/tools/schemas.js.map +1 -1
- package/dist/tools/verification-keys.d.ts.map +1 -1
- package/dist/tools/verification-keys.js +2 -23
- package/dist/tools/verification-keys.js.map +1 -1
- package/dist/tools/verification.d.ts.map +1 -1
- package/dist/tools/verification.js +3 -28
- package/dist/tools/verification.js.map +1 -1
- package/package.json +1 -1
- package/src/errors.ts +9 -0
- package/src/index.ts +1 -3
- package/src/server.ts +77 -71
- package/src/tool-scopes.ts +3 -3
- package/src/tools/a2a.ts +22 -235
- package/src/tools/agent-mandates.ts +11 -77
- package/src/tools/agents-refs.ts +10 -65
- package/src/tools/capabilities.ts +3 -16
- package/src/tools/compliance.ts +4 -13
- package/src/tools/dashboard.ts +4 -13
- package/src/tools/disputes.ts +5 -38
- package/src/tools/enterprises.ts +7 -39
- package/src/tools/events.ts +2 -21
- package/src/tools/federation-admin.ts +25 -282
- package/src/tools/federation.ts +21 -218
- package/src/tools/health.ts +2 -15
- package/src/tools/mandates.ts +11 -85
- package/src/tools/openclaw.ts +6 -52
- package/src/tools/receipts.ts +5 -97
- package/src/tools/reputation.ts +4 -13
- package/src/tools/schemas.ts +34 -166
- package/src/tools/verification-keys.ts +2 -25
- package/src/tools/verification.ts +3 -30
- package/tests/conformance.test.ts +197 -0
- package/tests/conformance.ts +65 -0
- package/tests/harness.ts +55 -0
- package/tests/mock-client.ts +71 -0
- package/tests/profiles.test.ts +120 -0
- package/tests/resources/contract-types.test.ts +82 -0
- package/tests/tools/a2a.test.ts +213 -0
- package/tests/tools/agent-mandates.test.ts +196 -0
- package/tests/tools/agents-refs.test.ts +190 -0
- package/tests/tools/capabilities.test.ts +80 -0
- package/tests/tools/compliance.test.ts +123 -0
- package/tests/tools/dashboard.test.ts +111 -0
- package/tests/tools/disputes.test.ts +123 -0
- package/tests/tools/enterprises.test.ts +171 -0
- package/tests/tools/events.test.ts +56 -0
- package/tests/tools/federation-admin.test.ts +468 -0
- package/tests/tools/federation.test.ts +522 -0
- package/tests/tools/health.test.ts +56 -0
- package/tests/tools/mandates.test.ts +143 -0
- package/tests/tools/openclaw.test.ts +148 -0
- package/tests/tools/receipts.test.ts +157 -0
- package/tests/tools/reputation.test.ts +108 -0
- package/tests/tools/schemas.test.ts +374 -0
- package/tests/tools/verification-keys.test.ts +56 -0
- package/tests/tools/verification.test.ts +64 -0
- package/src/tools/code-mode.ts +0 -461
- package/tests/code-mode-manifest.test.ts +0 -144
- package/tests/enterprises.test.ts +0 -96
- package/tests/schemas.test.ts +0 -531
package/src/tools/schemas.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
3
3
|
import type { AgledgerClient } from '@agledger/sdk';
|
|
4
|
-
import { apiErrorResult } from '../errors.js';
|
|
4
|
+
import { apiErrorResult, toStructuredContent } from '../errors.js';
|
|
5
5
|
import { ContractTypeEnum } from '../enums.js';
|
|
6
6
|
import { toolMeta } from '../tool-scopes.js';
|
|
7
7
|
|
|
@@ -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().describe('Human-readable name'),
|
|
94
|
-
description: z.string().describe('Schema description'),
|
|
95
|
-
category: z.string().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,8 +42,8 @@ export function registerSchemaTools(mcp: McpServer, client: AgledgerClient): voi
|
|
|
150
42
|
try {
|
|
151
43
|
const result = await client.schemas.list();
|
|
152
44
|
return {
|
|
153
|
-
content: [
|
|
154
|
-
structuredContent: { contractTypes: result.data }
|
|
45
|
+
content: [],
|
|
46
|
+
structuredContent: toStructuredContent({ contractTypes: result.data }),
|
|
155
47
|
};
|
|
156
48
|
} catch (err) {
|
|
157
49
|
return apiErrorResult(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,8 +71,8 @@ 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: [
|
|
184
|
-
structuredContent: schema
|
|
74
|
+
content: [],
|
|
75
|
+
structuredContent: toStructuredContent(schema),
|
|
185
76
|
};
|
|
186
77
|
} catch (err) {
|
|
187
78
|
return apiErrorResult(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,8 +98,8 @@ export function registerSchemaTools(mcp: McpServer, client: AgledgerClient): voi
|
|
|
208
98
|
try {
|
|
209
99
|
const metaSchema = await client.schemas.getMetaSchema();
|
|
210
100
|
return {
|
|
211
|
-
content: [
|
|
212
|
-
structuredContent: metaSchema
|
|
101
|
+
content: [],
|
|
102
|
+
structuredContent: toStructuredContent(metaSchema),
|
|
213
103
|
};
|
|
214
104
|
} catch (err) {
|
|
215
105
|
return apiErrorResult(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,12 +142,9 @@ 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: [
|
|
261
|
-
structuredContent: result
|
|
146
|
+
content: [],
|
|
147
|
+
structuredContent: toStructuredContent(result),
|
|
262
148
|
};
|
|
263
149
|
} catch (err) {
|
|
264
150
|
return apiErrorResult(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,8 +188,8 @@ export function registerSchemaTools(mcp: McpServer, client: AgledgerClient): voi
|
|
|
303
188
|
compatibilityMode: args.compatibilityMode,
|
|
304
189
|
});
|
|
305
190
|
return {
|
|
306
|
-
content: [
|
|
307
|
-
structuredContent: result
|
|
191
|
+
content: [],
|
|
192
|
+
structuredContent: toStructuredContent(result),
|
|
308
193
|
};
|
|
309
194
|
} catch (err) {
|
|
310
195
|
return apiErrorResult(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: ContractTypeString,
|
|
325
|
-
versions: z.array(SchemaVersionOutputSchema),
|
|
326
|
-
}).describe('All versions of a contract type schema'),
|
|
327
208
|
annotations: {
|
|
328
209
|
readOnlyHint: true,
|
|
329
210
|
destructiveHint: false,
|
|
@@ -334,10 +215,10 @@ export function registerSchemaTools(mcp: McpServer, client: AgledgerClient): voi
|
|
|
334
215
|
},
|
|
335
216
|
async (args) => {
|
|
336
217
|
try {
|
|
337
|
-
const
|
|
218
|
+
const page = await client.schemas.getVersions(args.contractType as Parameters<typeof client.schemas.getVersions>[0]);
|
|
338
219
|
return {
|
|
339
|
-
content: [
|
|
340
|
-
structuredContent: { contractType: args.contractType, versions }
|
|
220
|
+
content: [],
|
|
221
|
+
structuredContent: toStructuredContent({ contractType: args.contractType, versions: page.data }),
|
|
341
222
|
};
|
|
342
223
|
} catch (err) {
|
|
343
224
|
return apiErrorResult(err);
|
|
@@ -355,7 +236,6 @@ export function registerSchemaTools(mcp: McpServer, client: AgledgerClient): voi
|
|
|
355
236
|
from: z.number().int().min(1).describe('Source version number'),
|
|
356
237
|
to: z.number().int().min(1).describe('Target version number'),
|
|
357
238
|
},
|
|
358
|
-
outputSchema: SchemaDiffOutputSchema,
|
|
359
239
|
annotations: {
|
|
360
240
|
readOnlyHint: true,
|
|
361
241
|
destructiveHint: false,
|
|
@@ -371,11 +251,9 @@ export function registerSchemaTools(mcp: McpServer, client: AgledgerClient): voi
|
|
|
371
251
|
args.from,
|
|
372
252
|
args.to,
|
|
373
253
|
);
|
|
374
|
-
const mandateChanges = diff.mandate.changes.length;
|
|
375
|
-
const receiptChanges = diff.receipt.changes.length;
|
|
376
254
|
return {
|
|
377
|
-
content: [
|
|
378
|
-
structuredContent: diff
|
|
255
|
+
content: [],
|
|
256
|
+
structuredContent: toStructuredContent(diff),
|
|
379
257
|
};
|
|
380
258
|
} catch (err) {
|
|
381
259
|
return apiErrorResult(err);
|
|
@@ -403,8 +281,8 @@ export function registerSchemaTools(mcp: McpServer, client: AgledgerClient): voi
|
|
|
403
281
|
try {
|
|
404
282
|
const template = await client.schemas.getTemplate(args.contractType as Parameters<typeof client.schemas.getTemplate>[0]);
|
|
405
283
|
return {
|
|
406
|
-
content: [
|
|
407
|
-
structuredContent: template
|
|
284
|
+
content: [],
|
|
285
|
+
structuredContent: toStructuredContent(template),
|
|
408
286
|
};
|
|
409
287
|
} catch (err) {
|
|
410
288
|
return apiErrorResult(err);
|
|
@@ -430,8 +308,8 @@ export function registerSchemaTools(mcp: McpServer, client: AgledgerClient): voi
|
|
|
430
308
|
try {
|
|
431
309
|
const template = await client.schemas.getBlankTemplate();
|
|
432
310
|
return {
|
|
433
|
-
content: [
|
|
434
|
-
structuredContent: template
|
|
311
|
+
content: [],
|
|
312
|
+
structuredContent: toStructuredContent(template),
|
|
435
313
|
};
|
|
436
314
|
} catch (err) {
|
|
437
315
|
return apiErrorResult(err);
|
|
@@ -464,8 +342,8 @@ export function registerSchemaTools(mcp: McpServer, client: AgledgerClient): voi
|
|
|
464
342
|
{ mandateSchema: args.mandateSchema, receiptSchema: args.receiptSchema },
|
|
465
343
|
);
|
|
466
344
|
return {
|
|
467
|
-
content: [
|
|
468
|
-
structuredContent: result
|
|
345
|
+
content: [],
|
|
346
|
+
structuredContent: toStructuredContent(result),
|
|
469
347
|
};
|
|
470
348
|
} catch (err) {
|
|
471
349
|
return apiErrorResult(err);
|
|
@@ -482,7 +360,6 @@ export function registerSchemaTools(mcp: McpServer, client: AgledgerClient): voi
|
|
|
482
360
|
contractType: ContractTypeString.describe('Contract type to retrieve'),
|
|
483
361
|
version: z.number().int().describe('Version number'),
|
|
484
362
|
},
|
|
485
|
-
outputSchema: SchemaVersionOutputSchema,
|
|
486
363
|
annotations: {
|
|
487
364
|
readOnlyHint: true,
|
|
488
365
|
destructiveHint: false,
|
|
@@ -498,8 +375,8 @@ export function registerSchemaTools(mcp: McpServer, client: AgledgerClient): voi
|
|
|
498
375
|
args.version,
|
|
499
376
|
);
|
|
500
377
|
return {
|
|
501
|
-
content: [
|
|
502
|
-
structuredContent: result
|
|
378
|
+
content: [],
|
|
379
|
+
structuredContent: toStructuredContent(result),
|
|
503
380
|
};
|
|
504
381
|
} catch (err) {
|
|
505
382
|
return apiErrorResult(err);
|
|
@@ -530,17 +407,9 @@ export function registerSchemaTools(mcp: McpServer, client: AgledgerClient): voi
|
|
|
530
407
|
args.contractType as Parameters<typeof client.schemas.validateReceipt>[0],
|
|
531
408
|
args.evidence,
|
|
532
409
|
);
|
|
533
|
-
if (result.valid) {
|
|
534
|
-
return {
|
|
535
|
-
content: [{ type: 'text', text: `Evidence is valid for ${args.contractType}. You can now call submit_receipt.` }],
|
|
536
|
-
structuredContent: result as unknown as Record<string, unknown>,
|
|
537
|
-
};
|
|
538
|
-
}
|
|
539
|
-
const errorCount = result.errors?.length ?? 0;
|
|
540
|
-
const errorDetails = result.errors?.map(e => `- ${e.instancePath ?? '/'}: ${e.message}`).join('\n') ?? '';
|
|
541
410
|
return {
|
|
542
|
-
content: [
|
|
543
|
-
structuredContent: result
|
|
411
|
+
content: [],
|
|
412
|
+
structuredContent: toStructuredContent(result),
|
|
544
413
|
};
|
|
545
414
|
} catch (err) {
|
|
546
415
|
return apiErrorResult(err);
|
|
@@ -567,10 +436,9 @@ export function registerSchemaTools(mcp: McpServer, client: AgledgerClient): voi
|
|
|
567
436
|
async (args) => {
|
|
568
437
|
try {
|
|
569
438
|
const result = await client.schemas.getRules(args.contractType as Parameters<typeof client.schemas.getRules>[0]);
|
|
570
|
-
const total = result.syncRuleIds.length + result.asyncRuleIds.length;
|
|
571
439
|
return {
|
|
572
|
-
content: [
|
|
573
|
-
structuredContent: result
|
|
440
|
+
content: [],
|
|
441
|
+
structuredContent: toStructuredContent(result),
|
|
574
442
|
};
|
|
575
443
|
} catch (err) {
|
|
576
444
|
return apiErrorResult(err);
|
|
@@ -598,8 +466,8 @@ export function registerSchemaTools(mcp: McpServer, client: AgledgerClient): voi
|
|
|
598
466
|
try {
|
|
599
467
|
const result = await client.schemas.delete(args.contractType);
|
|
600
468
|
return {
|
|
601
|
-
content: [
|
|
602
|
-
structuredContent: result
|
|
469
|
+
content: [],
|
|
470
|
+
structuredContent: toStructuredContent(result),
|
|
603
471
|
};
|
|
604
472
|
} catch (err) {
|
|
605
473
|
return apiErrorResult(err);
|
|
@@ -627,8 +495,8 @@ export function registerSchemaTools(mcp: McpServer, client: AgledgerClient): voi
|
|
|
627
495
|
try {
|
|
628
496
|
const bundle = await client.schemas.exportSchema(args.contractType);
|
|
629
497
|
return {
|
|
630
|
-
content: [
|
|
631
|
-
structuredContent: bundle
|
|
498
|
+
content: [],
|
|
499
|
+
structuredContent: toStructuredContent(bundle),
|
|
632
500
|
};
|
|
633
501
|
} catch (err) {
|
|
634
502
|
return apiErrorResult(err);
|
|
@@ -656,8 +524,8 @@ export function registerSchemaTools(mcp: McpServer, client: AgledgerClient): voi
|
|
|
656
524
|
try {
|
|
657
525
|
const result = await client.schemas.importSchema(args.bundle as any);
|
|
658
526
|
return {
|
|
659
|
-
content: [
|
|
660
|
-
structuredContent: result
|
|
527
|
+
content: [],
|
|
528
|
+
structuredContent: toStructuredContent(result),
|
|
661
529
|
};
|
|
662
530
|
} catch (err) {
|
|
663
531
|
return apiErrorResult(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
|
-
import { apiErrorResult } from '../errors.js';
|
|
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
|
-
|
|
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: result as unknown as Record<string, unknown>,
|
|
50
|
-
};
|
|
27
|
+
return { content: [], structuredContent: toStructuredContent(result) };
|
|
51
28
|
} catch (err) {
|
|
52
29
|
return apiErrorResult(err);
|
|
53
30
|
}
|
|
@@ -1,28 +1,9 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
3
3
|
import type { AgledgerClient } from '@agledger/sdk';
|
|
4
|
-
import { apiErrorResult } from '../errors.js';
|
|
5
|
-
import { VerificationOutcomeEnum } from '../enums.js';
|
|
4
|
+
import { apiErrorResult, toStructuredContent } from '../errors.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: result as unknown as Record<string, unknown>,
|
|
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: status as unknown as Record<string, unknown>,
|
|
80
|
-
};
|
|
53
|
+
return { content: [], structuredContent: toStructuredContent(status) };
|
|
81
54
|
} catch (err) {
|
|
82
55
|
return apiErrorResult(err);
|
|
83
56
|
}
|