@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/dist/tools/receipts.js
CHANGED
|
@@ -1,47 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { apiErrorResult } from '../errors.js';
|
|
3
|
-
import { NextStepsField, StructuralValidationEnum } from '../enums.js';
|
|
2
|
+
import { apiErrorResult, toStructuredContent } from '../errors.js';
|
|
4
3
|
import { toolMeta } from '../tool-scopes.js';
|
|
5
|
-
const ReceiptOutputSchema = z
|
|
6
|
-
.object({
|
|
7
|
-
id: z.string().describe('Receipt UUID'),
|
|
8
|
-
mandateId: z.string().describe('Associated mandate UUID'),
|
|
9
|
-
agentId: z.string().describe('Agent that submitted the receipt'),
|
|
10
|
-
structuralValidation: StructuralValidationEnum.nullable()
|
|
11
|
-
.optional()
|
|
12
|
-
.describe('Structural validation result'),
|
|
13
|
-
evidence: z.record(z.string(), z.unknown()).describe('Evidence payload'),
|
|
14
|
-
evidenceHash: z.string().nullable().optional().describe('SHA-256 hash of evidence'),
|
|
15
|
-
notes: z.string().nullable().optional().describe('Human-readable notes'),
|
|
16
|
-
verificationPhase: z.string().nullable().optional().describe('Current verification phase'),
|
|
17
|
-
verificationResult: z
|
|
18
|
-
.record(z.string(), z.unknown())
|
|
19
|
-
.nullable()
|
|
20
|
-
.optional()
|
|
21
|
-
.describe('Verification result details'),
|
|
22
|
-
validationErrors: z
|
|
23
|
-
.array(z.string())
|
|
24
|
-
.nullable()
|
|
25
|
-
.optional()
|
|
26
|
-
.describe('Validation errors if any'),
|
|
27
|
-
idempotencyKey: z.string().nullable().optional().describe('Idempotency key for deduplication'),
|
|
28
|
-
createdAt: z.string().describe('ISO 8601 creation timestamp'),
|
|
29
|
-
updatedAt: z.string().nullable().optional().describe('ISO 8601 last update timestamp'),
|
|
30
|
-
nextSteps: NextStepsField,
|
|
31
|
-
})
|
|
32
|
-
.passthrough()
|
|
33
|
-
.describe('AGLedger receipt (task attestation) object');
|
|
34
|
-
const ReceiptListOutputSchema = z
|
|
35
|
-
.object({
|
|
36
|
-
data: z.array(ReceiptOutputSchema).describe('Array of receipts for the mandate'),
|
|
37
|
-
nextCursor: z
|
|
38
|
-
.string()
|
|
39
|
-
.nullable()
|
|
40
|
-
.optional()
|
|
41
|
-
.describe('Cursor for the next page (null if no more results)'),
|
|
42
|
-
})
|
|
43
|
-
.passthrough()
|
|
44
|
-
.describe('List of receipts for a mandate');
|
|
45
4
|
export function registerReceiptTools(mcp, client, options) {
|
|
46
5
|
if (!options?.skipSubmit)
|
|
47
6
|
mcp.registerTool('submit_receipt', {
|
|
@@ -49,13 +8,11 @@ export function registerReceiptTools(mcp, client, options) {
|
|
|
49
8
|
description: 'Submit a task attestation (receipt) with evidence against a mandate. REQUIRED to close the accountability loop — do NOT skip this step after completing work.',
|
|
50
9
|
inputSchema: {
|
|
51
10
|
mandateId: z.string().describe('UUID of the mandate this receipt is for'),
|
|
52
|
-
agentId: z.string().describe('Agent ID submitting the receipt'),
|
|
53
11
|
evidence: z
|
|
54
12
|
.record(z.string(), z.unknown())
|
|
55
13
|
.describe('Evidence JSON object proving task completion'),
|
|
56
14
|
notes: z.string().optional().describe('Human-readable notes about the submission'),
|
|
57
15
|
},
|
|
58
|
-
outputSchema: ReceiptOutputSchema,
|
|
59
16
|
annotations: {
|
|
60
17
|
readOnlyHint: false,
|
|
61
18
|
destructiveHint: false,
|
|
@@ -67,19 +24,7 @@ export function registerReceiptTools(mcp, client, options) {
|
|
|
67
24
|
try {
|
|
68
25
|
const { mandateId, ...submitParams } = args;
|
|
69
26
|
const receipt = await client.receipts.submit(mandateId, submitParams);
|
|
70
|
-
|
|
71
|
-
// Use denormalized mandateStatus from receipt response (no extra API call)
|
|
72
|
-
const ms = receipt.mandateStatus;
|
|
73
|
-
if (ms === 'FULFILLED') {
|
|
74
|
-
text += '\n\nMandate settled to FULFILLED. Accountability loop closed.';
|
|
75
|
-
}
|
|
76
|
-
else if (ms === 'PROCESSING') {
|
|
77
|
-
text += '\n\nEvidence is being verified. The principal will accept or reject.';
|
|
78
|
-
}
|
|
79
|
-
return {
|
|
80
|
-
content: [{ type: 'text', text }],
|
|
81
|
-
structuredContent: receipt,
|
|
82
|
-
};
|
|
27
|
+
return { content: [], structuredContent: toStructuredContent(receipt) };
|
|
83
28
|
}
|
|
84
29
|
catch (err) {
|
|
85
30
|
return apiErrorResult(err);
|
|
@@ -97,18 +42,6 @@ export function registerReceiptTools(mcp, client, options) {
|
|
|
97
42
|
.optional()
|
|
98
43
|
.describe('Optional per-field check results'),
|
|
99
44
|
},
|
|
100
|
-
outputSchema: z
|
|
101
|
-
.object({
|
|
102
|
-
mandateId: z.string().describe('Mandate UUID'),
|
|
103
|
-
receiptId: z.string().describe('Receipt UUID'),
|
|
104
|
-
outcome: z.enum(['PASS', 'FAIL']).describe('Reported outcome'),
|
|
105
|
-
signal: z.string().describe('Settlement signal: SETTLE, HOLD, or RELEASE'),
|
|
106
|
-
reporterType: z.string().describe('Who reported: principal'),
|
|
107
|
-
reportedAt: z.string().describe('ISO 8601 timestamp'),
|
|
108
|
-
nextSteps: NextStepsField,
|
|
109
|
-
})
|
|
110
|
-
.passthrough()
|
|
111
|
-
.describe('Outcome result'),
|
|
112
45
|
annotations: {
|
|
113
46
|
readOnlyHint: false,
|
|
114
47
|
destructiveHint: false,
|
|
@@ -120,13 +53,7 @@ export function registerReceiptTools(mcp, client, options) {
|
|
|
120
53
|
try {
|
|
121
54
|
const { mandateId, ...outcomeParams } = args;
|
|
122
55
|
const result = await client.mandates.reportOutcome(mandateId, outcomeParams);
|
|
123
|
-
|
|
124
|
-
return {
|
|
125
|
-
content: [
|
|
126
|
-
{ type: 'text', text: `Receipt ${args.receiptId} ${verb}. Signal: ${result.signal}.` },
|
|
127
|
-
],
|
|
128
|
-
structuredContent: result,
|
|
129
|
-
};
|
|
56
|
+
return { content: [], structuredContent: toStructuredContent(result) };
|
|
130
57
|
}
|
|
131
58
|
catch (err) {
|
|
132
59
|
return apiErrorResult(err);
|
|
@@ -139,7 +66,6 @@ export function registerReceiptTools(mcp, client, options) {
|
|
|
139
66
|
mandateId: z.string().describe('UUID of the associated mandate'),
|
|
140
67
|
receiptId: z.string().describe('UUID of the receipt to retrieve'),
|
|
141
68
|
},
|
|
142
|
-
outputSchema: ReceiptOutputSchema,
|
|
143
69
|
annotations: {
|
|
144
70
|
readOnlyHint: true,
|
|
145
71
|
destructiveHint: false,
|
|
@@ -150,15 +76,7 @@ export function registerReceiptTools(mcp, client, options) {
|
|
|
150
76
|
}, async (args) => {
|
|
151
77
|
try {
|
|
152
78
|
const receipt = await client.receipts.get(args.mandateId, args.receiptId);
|
|
153
|
-
return {
|
|
154
|
-
content: [
|
|
155
|
-
{
|
|
156
|
-
type: 'text',
|
|
157
|
-
text: `Receipt ${receipt.id}: status=${receipt.structuralValidation}, mandate=${receipt.mandateId}.`,
|
|
158
|
-
},
|
|
159
|
-
],
|
|
160
|
-
structuredContent: receipt,
|
|
161
|
-
};
|
|
79
|
+
return { content: [], structuredContent: toStructuredContent(receipt) };
|
|
162
80
|
}
|
|
163
81
|
catch (err) {
|
|
164
82
|
return apiErrorResult(err);
|
|
@@ -172,7 +90,6 @@ export function registerReceiptTools(mcp, client, options) {
|
|
|
172
90
|
limit: z.number().optional().describe('Page size (default: 20)'),
|
|
173
91
|
offset: z.number().optional().describe('Page offset (default: 0)'),
|
|
174
92
|
},
|
|
175
|
-
outputSchema: ReceiptListOutputSchema,
|
|
176
93
|
annotations: {
|
|
177
94
|
readOnlyHint: true,
|
|
178
95
|
destructiveHint: false,
|
|
@@ -184,15 +101,7 @@ export function registerReceiptTools(mcp, client, options) {
|
|
|
184
101
|
try {
|
|
185
102
|
const { mandateId, ...paginationParams } = args;
|
|
186
103
|
const result = await client.receipts.list(mandateId, paginationParams);
|
|
187
|
-
return {
|
|
188
|
-
content: [
|
|
189
|
-
{
|
|
190
|
-
type: 'text',
|
|
191
|
-
text: `Found ${result.data.length} receipts for mandate ${mandateId}.`,
|
|
192
|
-
},
|
|
193
|
-
],
|
|
194
|
-
structuredContent: result,
|
|
195
|
-
};
|
|
104
|
+
return { content: [], structuredContent: toStructuredContent(result) };
|
|
196
105
|
}
|
|
197
106
|
catch (err) {
|
|
198
107
|
return apiErrorResult(err);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"receipts.js","sourceRoot":"","sources":["../../src/tools/receipts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,EAAE,cAAc,EAAE,
|
|
1
|
+
{"version":3,"file":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QACD,WAAW,EAAE;YACX,YAAY,EAAE,IAAI;YAClB,eAAe,EAAE,KAAK;YACtB,cAAc,EAAE,IAAI;YACpB,aAAa,EAAE,IAAI;SACpB;QACD,KAAK,EAAE,QAAQ,CAAC,eAAe,CAAC;KACjC,EACD,KAAK,EAAE,IAAI,EAAE,EAAE;QACb,IAAI,CAAC;YACH,MAAM,EAAE,SAAS,EAAE,GAAG,gBAAgB,EAAE,GAAG,IAAI,CAAC;YAChD,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,SAAS,EAAE,gBAAgB,CAAC,CAAC;YACvE,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,iBAAiB,EAAE,mBAAmB,CAAC,MAAM,CAAC,EAAE,CAAC;QACzE,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,OAAO,cAAc,CAAC,GAAG,CAAC,CAAC;QAC7B,CAAC;IACH,CAAC,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reputation.d.ts","sourceRoot":"","sources":["../../src/tools/reputation.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACzE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAIpD,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,SAAS,EAAE,MAAM,EAAE,cAAc,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"reputation.d.ts","sourceRoot":"","sources":["../../src/tools/reputation.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACzE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAIpD,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,SAAS,EAAE,MAAM,EAAE,cAAc,GAAG,IAAI,CA8DpF"}
|
package/dist/tools/reputation.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { apiErrorResult } from '../errors.js';
|
|
2
|
+
import { apiErrorResult, toStructuredContent } from '../errors.js';
|
|
3
3
|
import { toolMeta } from '../tool-scopes.js';
|
|
4
4
|
export function registerReputationTools(mcp, client) {
|
|
5
5
|
mcp.registerTool('get_agent_reputation', {
|
|
@@ -13,10 +13,7 @@ export function registerReputationTools(mcp, client) {
|
|
|
13
13
|
}, async (args) => {
|
|
14
14
|
try {
|
|
15
15
|
const page = await client.reputation.getAgent(args.agentId);
|
|
16
|
-
return {
|
|
17
|
-
content: [{ type: 'text', text: `Agent ${args.agentId}: ${page.data.length} contract type score(s).` }],
|
|
18
|
-
structuredContent: page,
|
|
19
|
-
};
|
|
16
|
+
return { content: [], structuredContent: toStructuredContent(page) };
|
|
20
17
|
}
|
|
21
18
|
catch (err) {
|
|
22
19
|
return apiErrorResult(err);
|
|
@@ -34,10 +31,7 @@ export function registerReputationTools(mcp, client) {
|
|
|
34
31
|
}, async (args) => {
|
|
35
32
|
try {
|
|
36
33
|
const score = await client.reputation.getByContractType(args.agentId, args.contractType);
|
|
37
|
-
return {
|
|
38
|
-
content: [{ type: 'text', text: `Agent ${args.agentId} [${args.contractType}]: composite=${score.compositeScore}, reliability=${score.reliabilityScore}, accuracy=${score.accuracyScore}, efficiency=${score.efficiencyScore}.` }],
|
|
39
|
-
structuredContent: score,
|
|
40
|
-
};
|
|
34
|
+
return { content: [], structuredContent: toStructuredContent(score) };
|
|
41
35
|
}
|
|
42
36
|
catch (err) {
|
|
43
37
|
return apiErrorResult(err);
|
|
@@ -58,10 +52,7 @@ export function registerReputationTools(mcp, client) {
|
|
|
58
52
|
try {
|
|
59
53
|
const { agentId, ...params } = args;
|
|
60
54
|
const page = await client.reputation.getHistory(agentId, params);
|
|
61
|
-
return {
|
|
62
|
-
content: [{ type: 'text', text: `Agent ${agentId}: ${page.data.length} transaction(s).` }],
|
|
63
|
-
structuredContent: page,
|
|
64
|
-
};
|
|
55
|
+
return { content: [], structuredContent: toStructuredContent(page) };
|
|
65
56
|
}
|
|
66
57
|
catch (err) {
|
|
67
58
|
return apiErrorResult(err);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reputation.js","sourceRoot":"","sources":["../../src/tools/reputation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"reputation.js","sourceRoot":"","sources":["../../src/tools/reputation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AACnE,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE7C,MAAM,UAAU,uBAAuB,CAAC,GAAc,EAAE,MAAsB;IAC5E,GAAG,CAAC,YAAY,CACd,sBAAsB,EACtB;QACE,KAAK,EAAE,sBAAsB;QAC7B,WAAW,EAAE,mKAAmK;QAChL,WAAW,EAAE;YACX,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,mBAAmB,CAAC;SAClD;QACD,WAAW,EAAE,EAAE,YAAY,EAAE,IAAI,EAAE,eAAe,EAAE,KAAK,EAAE,cAAc,EAAE,IAAI,EAAE,aAAa,EAAE,IAAI,EAAE;QACtG,KAAK,EAAE,QAAQ,CAAC,sBAAsB,CAAC;KACxC,EACD,KAAK,EAAE,IAAI,EAAE,EAAE;QACb,IAAI,CAAC;YACH,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;YAC5D,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,iBAAiB,EAAE,mBAAmB,CAAC,IAAI,CAAC,EAAE,CAAC;QACvE,CAAC;QA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,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,2BAA2B,CAAC;YAClF,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,WAAW,CAAC;SACnD;QACD,WAAW,EAAE,EAAE,YAAY,EAAE,IAAI,EAAE,eAAe,EAAE,KAAK,EAAE,cAAc,EAAE,IAAI,EAAE,aAAa,EAAE,IAAI,EAAE;QACtG,KAAK,EAAE,QAAQ,CAAC,mBAAmB,CAAC;KACrC,EACD,KAAK,EAAE,IAAI,EAAE,EAAE;QACb,IAAI,CAAC;YACH,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,EAAE,GAAG,IAAI,CAAC;YACpC,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,UAAU,CAAC,UAAU,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;YACjE,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,iBAAiB,EAAE,mBAAmB,CAAC,IAAI,CAAC,EAAE,CAAC;QACvE,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YAAC,OAAO,cAAc,CAAC,GAAG,CAAC,CAAC;QAAC,CAAC;IAC/C,CAAC,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../src/tools/schemas.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACzE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../src/tools/schemas.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACzE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAuBpD,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,SAAS,EAAE,MAAM,EAAE,cAAc,GAAG,IAAI,CA6fhF"}
|
package/dist/tools/schemas.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { apiErrorResult } from '../errors.js';
|
|
2
|
+
import { apiErrorResult, toStructuredContent } from '../errors.js';
|
|
3
3
|
import { ContractTypeEnum } from '../enums.js';
|
|
4
4
|
import { toolMeta } from '../tool-scopes.js';
|
|
5
5
|
/** Accepts both standard and custom contract type identifiers. */
|
|
@@ -14,106 +14,6 @@ const FieldMappingSchema = z.object({
|
|
|
14
14
|
valueType: FieldMappingValueType,
|
|
15
15
|
expression: z.string().optional().describe('Safe expression string. Required when valueType is "expression"'),
|
|
16
16
|
}).describe('Field mapping between mandate criteria and receipt evidence for verification');
|
|
17
|
-
const ContractTypeListOutputSchema = z.object({
|
|
18
|
-
contractTypes: z.array(ContractTypeEnum).describe('Array of all available contract type identifiers'),
|
|
19
|
-
}).describe('List of all AGLedger contract types');
|
|
20
|
-
const ContractSchemaOutputSchema = z.object({
|
|
21
|
-
contractType: ContractTypeEnum,
|
|
22
|
-
mandateSchema: z.record(z.string(), z.unknown()).describe('JSON Schema for mandate criteria of this contract type'),
|
|
23
|
-
receiptSchema: z.record(z.string(), z.unknown()).describe('JSON Schema for receipt evidence of this contract type'),
|
|
24
|
-
rulesConfig: z.object({
|
|
25
|
-
syncRuleIds: z.array(z.string()).describe('Synchronous verification rule IDs'),
|
|
26
|
-
asyncRuleIds: z.array(z.string()).describe('Asynchronous verification rule IDs'),
|
|
27
|
-
}).passthrough().nullable().optional().describe('Verification rules configuration'),
|
|
28
|
-
fieldMappings: z.array(FieldMappingSchema).optional().describe('Field mappings between criteria and evidence, including expression-based rules'),
|
|
29
|
-
quickStart: z.object({
|
|
30
|
-
criteria: z.record(z.string(), z.unknown()).describe('Example mandate criteria payload — copy-paste ready'),
|
|
31
|
-
evidence: z.record(z.string(), z.unknown()).describe('Example receipt evidence payload — copy-paste ready'),
|
|
32
|
-
}).optional().describe('Quick-start examples with copy-pasteable payloads for this contract type'),
|
|
33
|
-
}).passthrough().describe('Contract type schema with mandate/receipt JSON Schemas, rules, field mappings, and quickStart examples');
|
|
34
|
-
const MetaSchemaOutputSchema = z.object({
|
|
35
|
-
constraints: z.object({
|
|
36
|
-
maxDepth: z.number().describe('Maximum nesting depth for schema properties'),
|
|
37
|
-
maxNodes: z.number().describe('Maximum number of schema nodes'),
|
|
38
|
-
maxSizeBytes: z.number().describe('Maximum schema size in bytes'),
|
|
39
|
-
maxCombinerEntries: z.number().describe('Maximum entries in anyOf/oneOf/allOf'),
|
|
40
|
-
rootTypeMustBe: z.string().describe('Required root type for schemas'),
|
|
41
|
-
rootMustHaveRequired: z.boolean().describe('Whether root must have required fields'),
|
|
42
|
-
blockedKeywords: z.array(z.string()).describe('Blocked JSON Schema keywords'),
|
|
43
|
-
}).passthrough().describe('Schema authoring constraints'),
|
|
44
|
-
allowedFormats: z.array(z.string()).describe('Allowed JSON Schema format values'),
|
|
45
|
-
allowedRefs: z.array(z.string()).describe('Allowed $ref targets'),
|
|
46
|
-
limits: z.object({
|
|
47
|
-
contractTypeMaxLength: z.number().describe('Maximum length for contract type identifiers'),
|
|
48
|
-
maxFieldMappings: z.number().describe('Maximum number of field mappings per schema'),
|
|
49
|
-
ruleIdPattern: z.string().describe('Regex pattern for rule IDs'),
|
|
50
|
-
ruleIdMaxLength: z.number().describe('Maximum length for rule IDs'),
|
|
51
|
-
reservedPrefixes: z.array(z.string()).describe('Reserved contract type prefixes'),
|
|
52
|
-
}).passthrough().describe('Limits for schema registration'),
|
|
53
|
-
fieldMappingValueTypes: z.array(z.string()).describe('Allowed field mapping value types including "expression"'),
|
|
54
|
-
builtinRuleIds: z.array(z.string()).describe('Built-in verification rule IDs'),
|
|
55
|
-
expressionHelpers: z.array(z.string()).optional().describe('Available helper functions for expression-based rules'),
|
|
56
|
-
expressionLimits: z.object({
|
|
57
|
-
maxLength: z.number().describe('Maximum expression string length'),
|
|
58
|
-
maxAstNodes: z.number().describe('Maximum AST nodes in expression'),
|
|
59
|
-
maxAstDepth: z.number().describe('Maximum AST nesting depth'),
|
|
60
|
-
maxOperations: z.number().describe('Maximum operations in expression'),
|
|
61
|
-
allowedContexts: z.array(z.string()).describe('Allowed expression context variables'),
|
|
62
|
-
}).optional().describe('Limits for expression-based verification rules'),
|
|
63
|
-
sharedSchemas: z.record(z.string(), z.unknown()).describe('Reusable schema definitions'),
|
|
64
|
-
examples: z.object({
|
|
65
|
-
minimalMandate: z.record(z.string(), z.unknown()).describe('Minimal example mandate schema'),
|
|
66
|
-
minimalReceipt: z.record(z.string(), z.unknown()).describe('Minimal example receipt schema'),
|
|
67
|
-
}).passthrough().describe('Example schemas for reference'),
|
|
68
|
-
}).passthrough().describe('Meta-schema describing constraints and limits for custom schema authoring');
|
|
69
|
-
const SchemaPreviewOutputSchema = z.object({
|
|
70
|
-
valid: z.boolean().describe('Whether the schema is valid'),
|
|
71
|
-
compiled: z.record(z.string(), z.unknown()).optional().describe('Compiled schema output if valid'),
|
|
72
|
-
errors: z.array(z.object({
|
|
73
|
-
code: z.string().describe('Error code'),
|
|
74
|
-
message: z.string().describe('Error message'),
|
|
75
|
-
path: z.string().optional().describe('JSON path to the error location'),
|
|
76
|
-
})).optional().describe('Validation errors if invalid'),
|
|
77
|
-
}).describe('Schema preview/validation result');
|
|
78
|
-
const SchemaVersionOutputSchema = z.object({
|
|
79
|
-
id: z.string().describe('Version record ID'),
|
|
80
|
-
contractType: ContractTypeString,
|
|
81
|
-
version: z.number().describe('Version number'),
|
|
82
|
-
enterpriseId: z.string().nullable().describe('Enterprise ID if enterprise-scoped, null for global'),
|
|
83
|
-
displayName: z.string().describe('Human-readable name'),
|
|
84
|
-
description: z.string().describe('Schema description'),
|
|
85
|
-
category: z.string().describe('Schema category'),
|
|
86
|
-
compatibilityMode: z.string().describe('Compatibility mode: FULL, BACKWARD, FORWARD, or NONE'),
|
|
87
|
-
status: z.string().describe('Version status: ACTIVE, DEPRECATED, or DRAFT'),
|
|
88
|
-
isBuiltin: z.boolean().describe('Whether this is a built-in AGLedger schema'),
|
|
89
|
-
createdAt: z.string().describe('ISO 8601 creation timestamp'),
|
|
90
|
-
updatedAt: z.string().describe('ISO 8601 last update timestamp'),
|
|
91
|
-
}).passthrough().describe('Schema version detail');
|
|
92
|
-
const SchemaDiffChangeSchema = z.object({
|
|
93
|
-
type: z.string().describe('Change type: added, removed, modified, renamed'),
|
|
94
|
-
path: z.string().describe('JSON path of the changed field'),
|
|
95
|
-
before: z.unknown().optional().describe('Previous value'),
|
|
96
|
-
after: z.unknown().optional().describe('New value'),
|
|
97
|
-
}).describe('A single schema change');
|
|
98
|
-
const SchemaDiffOutputSchema = z.object({
|
|
99
|
-
contractType: ContractTypeString,
|
|
100
|
-
from: z.object({
|
|
101
|
-
version: z.number(),
|
|
102
|
-
createdAt: z.string(),
|
|
103
|
-
status: z.string(),
|
|
104
|
-
}).describe('Source version info'),
|
|
105
|
-
to: z.object({
|
|
106
|
-
version: z.number(),
|
|
107
|
-
createdAt: z.string(),
|
|
108
|
-
status: z.string(),
|
|
109
|
-
}).describe('Target version info'),
|
|
110
|
-
mandate: z.object({
|
|
111
|
-
changes: z.array(SchemaDiffChangeSchema),
|
|
112
|
-
}).describe('Changes to mandate criteria schema'),
|
|
113
|
-
receipt: z.object({
|
|
114
|
-
changes: z.array(SchemaDiffChangeSchema),
|
|
115
|
-
}).describe('Changes to receipt evidence schema'),
|
|
116
|
-
}).passthrough().describe('Diff between two schema versions');
|
|
117
17
|
const CompatibilityModeEnum = z.enum(['FULL', 'BACKWARD', 'FORWARD', 'NONE'])
|
|
118
18
|
.describe('Schema compatibility mode');
|
|
119
19
|
export function registerSchemaTools(mcp, client) {
|
|
@@ -121,7 +21,6 @@ export function registerSchemaTools(mcp, client) {
|
|
|
121
21
|
title: 'List Contract Schemas',
|
|
122
22
|
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.',
|
|
123
23
|
inputSchema: {},
|
|
124
|
-
outputSchema: ContractTypeListOutputSchema,
|
|
125
24
|
annotations: {
|
|
126
25
|
readOnlyHint: true,
|
|
127
26
|
destructiveHint: false,
|
|
@@ -133,8 +32,8 @@ export function registerSchemaTools(mcp, client) {
|
|
|
133
32
|
try {
|
|
134
33
|
const result = await client.schemas.list();
|
|
135
34
|
return {
|
|
136
|
-
content: [
|
|
137
|
-
structuredContent: { contractTypes: result.data },
|
|
35
|
+
content: [],
|
|
36
|
+
structuredContent: toStructuredContent({ contractTypes: result.data }),
|
|
138
37
|
};
|
|
139
38
|
}
|
|
140
39
|
catch (err) {
|
|
@@ -147,7 +46,6 @@ export function registerSchemaTools(mcp, client) {
|
|
|
147
46
|
inputSchema: {
|
|
148
47
|
contractType: ContractTypeEnum.describe('Contract type to retrieve the schema for'),
|
|
149
48
|
},
|
|
150
|
-
outputSchema: ContractSchemaOutputSchema,
|
|
151
49
|
annotations: {
|
|
152
50
|
readOnlyHint: true,
|
|
153
51
|
destructiveHint: false,
|
|
@@ -159,8 +57,8 @@ export function registerSchemaTools(mcp, client) {
|
|
|
159
57
|
try {
|
|
160
58
|
const schema = await client.schemas.get(args.contractType);
|
|
161
59
|
return {
|
|
162
|
-
content: [
|
|
163
|
-
structuredContent: schema,
|
|
60
|
+
content: [],
|
|
61
|
+
structuredContent: toStructuredContent(schema),
|
|
164
62
|
};
|
|
165
63
|
}
|
|
166
64
|
catch (err) {
|
|
@@ -171,7 +69,6 @@ export function registerSchemaTools(mcp, client) {
|
|
|
171
69
|
title: 'Get Meta-Schema',
|
|
172
70
|
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.',
|
|
173
71
|
inputSchema: {},
|
|
174
|
-
outputSchema: MetaSchemaOutputSchema,
|
|
175
72
|
annotations: {
|
|
176
73
|
readOnlyHint: true,
|
|
177
74
|
destructiveHint: false,
|
|
@@ -183,8 +80,8 @@ export function registerSchemaTools(mcp, client) {
|
|
|
183
80
|
try {
|
|
184
81
|
const metaSchema = await client.schemas.getMetaSchema();
|
|
185
82
|
return {
|
|
186
|
-
content: [
|
|
187
|
-
structuredContent: metaSchema,
|
|
83
|
+
content: [],
|
|
84
|
+
structuredContent: toStructuredContent(metaSchema),
|
|
188
85
|
};
|
|
189
86
|
}
|
|
190
87
|
catch (err) {
|
|
@@ -204,7 +101,6 @@ export function registerSchemaTools(mcp, client) {
|
|
|
204
101
|
fieldMappings: z.array(FieldMappingSchema).optional().describe('Field mappings for verification rules, including expression-based rules'),
|
|
205
102
|
compatibilityMode: CompatibilityModeEnum.optional().describe('Compatibility mode for version evolution'),
|
|
206
103
|
},
|
|
207
|
-
outputSchema: SchemaPreviewOutputSchema,
|
|
208
104
|
annotations: {
|
|
209
105
|
readOnlyHint: true,
|
|
210
106
|
destructiveHint: false,
|
|
@@ -224,12 +120,9 @@ export function registerSchemaTools(mcp, client) {
|
|
|
224
120
|
fieldMappings: args.fieldMappings,
|
|
225
121
|
compatibilityMode: args.compatibilityMode,
|
|
226
122
|
});
|
|
227
|
-
const status = result.valid
|
|
228
|
-
? `valid. Schema is valid. Next: call register_schema to register it.`
|
|
229
|
-
: `invalid (${result.errors?.length ?? 0} errors). Fix the errors above, then call preview_schema again.`;
|
|
230
123
|
return {
|
|
231
|
-
content: [
|
|
232
|
-
structuredContent: result,
|
|
124
|
+
content: [],
|
|
125
|
+
structuredContent: toStructuredContent(result),
|
|
233
126
|
};
|
|
234
127
|
}
|
|
235
128
|
catch (err) {
|
|
@@ -249,7 +142,6 @@ export function registerSchemaTools(mcp, client) {
|
|
|
249
142
|
fieldMappings: z.array(FieldMappingSchema).optional().describe('Field mappings for verification rules, including expression-based rules'),
|
|
250
143
|
compatibilityMode: CompatibilityModeEnum.optional().describe('Compatibility mode for version evolution'),
|
|
251
144
|
},
|
|
252
|
-
outputSchema: SchemaVersionOutputSchema,
|
|
253
145
|
annotations: {
|
|
254
146
|
readOnlyHint: false,
|
|
255
147
|
destructiveHint: false,
|
|
@@ -270,8 +162,8 @@ export function registerSchemaTools(mcp, client) {
|
|
|
270
162
|
compatibilityMode: args.compatibilityMode,
|
|
271
163
|
});
|
|
272
164
|
return {
|
|
273
|
-
content: [
|
|
274
|
-
structuredContent: result,
|
|
165
|
+
content: [],
|
|
166
|
+
structuredContent: toStructuredContent(result),
|
|
275
167
|
};
|
|
276
168
|
}
|
|
277
169
|
catch (err) {
|
|
@@ -284,10 +176,6 @@ export function registerSchemaTools(mcp, client) {
|
|
|
284
176
|
inputSchema: {
|
|
285
177
|
contractType: ContractTypeString.describe('Contract type to list versions for'),
|
|
286
178
|
},
|
|
287
|
-
outputSchema: z.object({
|
|
288
|
-
contractType: ContractTypeString,
|
|
289
|
-
versions: z.array(SchemaVersionOutputSchema),
|
|
290
|
-
}).describe('All versions of a contract type schema'),
|
|
291
179
|
annotations: {
|
|
292
180
|
readOnlyHint: true,
|
|
293
181
|
destructiveHint: false,
|
|
@@ -297,10 +185,10 @@ export function registerSchemaTools(mcp, client) {
|
|
|
297
185
|
_meta: toolMeta('get_schema_versions'),
|
|
298
186
|
}, async (args) => {
|
|
299
187
|
try {
|
|
300
|
-
const
|
|
188
|
+
const page = await client.schemas.getVersions(args.contractType);
|
|
301
189
|
return {
|
|
302
|
-
content: [
|
|
303
|
-
structuredContent: { contractType: args.contractType, versions },
|
|
190
|
+
content: [],
|
|
191
|
+
structuredContent: toStructuredContent({ contractType: args.contractType, versions: page.data }),
|
|
304
192
|
};
|
|
305
193
|
}
|
|
306
194
|
catch (err) {
|
|
@@ -315,7 +203,6 @@ export function registerSchemaTools(mcp, client) {
|
|
|
315
203
|
from: z.number().int().min(1).describe('Source version number'),
|
|
316
204
|
to: z.number().int().min(1).describe('Target version number'),
|
|
317
205
|
},
|
|
318
|
-
outputSchema: SchemaDiffOutputSchema,
|
|
319
206
|
annotations: {
|
|
320
207
|
readOnlyHint: true,
|
|
321
208
|
destructiveHint: false,
|
|
@@ -326,11 +213,9 @@ export function registerSchemaTools(mcp, client) {
|
|
|
326
213
|
}, async (args) => {
|
|
327
214
|
try {
|
|
328
215
|
const diff = await client.schemas.diff(args.contractType, args.from, args.to);
|
|
329
|
-
const mandateChanges = diff.mandate.changes.length;
|
|
330
|
-
const receiptChanges = diff.receipt.changes.length;
|
|
331
216
|
return {
|
|
332
|
-
content: [
|
|
333
|
-
structuredContent: diff,
|
|
217
|
+
content: [],
|
|
218
|
+
structuredContent: toStructuredContent(diff),
|
|
334
219
|
};
|
|
335
220
|
}
|
|
336
221
|
catch (err) {
|
|
@@ -354,8 +239,8 @@ export function registerSchemaTools(mcp, client) {
|
|
|
354
239
|
try {
|
|
355
240
|
const template = await client.schemas.getTemplate(args.contractType);
|
|
356
241
|
return {
|
|
357
|
-
content: [
|
|
358
|
-
structuredContent: template,
|
|
242
|
+
content: [],
|
|
243
|
+
structuredContent: toStructuredContent(template),
|
|
359
244
|
};
|
|
360
245
|
}
|
|
361
246
|
catch (err) {
|
|
@@ -377,8 +262,8 @@ export function registerSchemaTools(mcp, client) {
|
|
|
377
262
|
try {
|
|
378
263
|
const template = await client.schemas.getBlankTemplate();
|
|
379
264
|
return {
|
|
380
|
-
content: [
|
|
381
|
-
structuredContent: template,
|
|
265
|
+
content: [],
|
|
266
|
+
structuredContent: toStructuredContent(template),
|
|
382
267
|
};
|
|
383
268
|
}
|
|
384
269
|
catch (err) {
|
|
@@ -404,8 +289,8 @@ export function registerSchemaTools(mcp, client) {
|
|
|
404
289
|
try {
|
|
405
290
|
const result = await client.schemas.checkCompatibility(args.contractType, { mandateSchema: args.mandateSchema, receiptSchema: args.receiptSchema });
|
|
406
291
|
return {
|
|
407
|
-
content: [
|
|
408
|
-
structuredContent: result,
|
|
292
|
+
content: [],
|
|
293
|
+
structuredContent: toStructuredContent(result),
|
|
409
294
|
};
|
|
410
295
|
}
|
|
411
296
|
catch (err) {
|
|
@@ -419,7 +304,6 @@ export function registerSchemaTools(mcp, client) {
|
|
|
419
304
|
contractType: ContractTypeString.describe('Contract type to retrieve'),
|
|
420
305
|
version: z.number().int().describe('Version number'),
|
|
421
306
|
},
|
|
422
|
-
outputSchema: SchemaVersionOutputSchema,
|
|
423
307
|
annotations: {
|
|
424
308
|
readOnlyHint: true,
|
|
425
309
|
destructiveHint: false,
|
|
@@ -431,8 +315,8 @@ export function registerSchemaTools(mcp, client) {
|
|
|
431
315
|
try {
|
|
432
316
|
const result = await client.schemas.getVersion(args.contractType, args.version);
|
|
433
317
|
return {
|
|
434
|
-
content: [
|
|
435
|
-
structuredContent: result,
|
|
318
|
+
content: [],
|
|
319
|
+
structuredContent: toStructuredContent(result),
|
|
436
320
|
};
|
|
437
321
|
}
|
|
438
322
|
catch (err) {
|
|
@@ -456,17 +340,9 @@ export function registerSchemaTools(mcp, client) {
|
|
|
456
340
|
}, async (args) => {
|
|
457
341
|
try {
|
|
458
342
|
const result = await client.schemas.validateReceipt(args.contractType, args.evidence);
|
|
459
|
-
if (result.valid) {
|
|
460
|
-
return {
|
|
461
|
-
content: [{ type: 'text', text: `Evidence is valid for ${args.contractType}. You can now call submit_receipt.` }],
|
|
462
|
-
structuredContent: result,
|
|
463
|
-
};
|
|
464
|
-
}
|
|
465
|
-
const errorCount = result.errors?.length ?? 0;
|
|
466
|
-
const errorDetails = result.errors?.map(e => `- ${e.instancePath ?? '/'}: ${e.message}`).join('\n') ?? '';
|
|
467
343
|
return {
|
|
468
|
-
content: [
|
|
469
|
-
structuredContent: result,
|
|
344
|
+
content: [],
|
|
345
|
+
structuredContent: toStructuredContent(result),
|
|
470
346
|
};
|
|
471
347
|
}
|
|
472
348
|
catch (err) {
|
|
@@ -489,10 +365,9 @@ export function registerSchemaTools(mcp, client) {
|
|
|
489
365
|
}, async (args) => {
|
|
490
366
|
try {
|
|
491
367
|
const result = await client.schemas.getRules(args.contractType);
|
|
492
|
-
const total = result.syncRuleIds.length + result.asyncRuleIds.length;
|
|
493
368
|
return {
|
|
494
|
-
content: [
|
|
495
|
-
structuredContent: result,
|
|
369
|
+
content: [],
|
|
370
|
+
structuredContent: toStructuredContent(result),
|
|
496
371
|
};
|
|
497
372
|
}
|
|
498
373
|
catch (err) {
|
|
@@ -516,8 +391,8 @@ export function registerSchemaTools(mcp, client) {
|
|
|
516
391
|
try {
|
|
517
392
|
const result = await client.schemas.delete(args.contractType);
|
|
518
393
|
return {
|
|
519
|
-
content: [
|
|
520
|
-
structuredContent: result,
|
|
394
|
+
content: [],
|
|
395
|
+
structuredContent: toStructuredContent(result),
|
|
521
396
|
};
|
|
522
397
|
}
|
|
523
398
|
catch (err) {
|
|
@@ -541,8 +416,8 @@ export function registerSchemaTools(mcp, client) {
|
|
|
541
416
|
try {
|
|
542
417
|
const bundle = await client.schemas.exportSchema(args.contractType);
|
|
543
418
|
return {
|
|
544
|
-
content: [
|
|
545
|
-
structuredContent: bundle,
|
|
419
|
+
content: [],
|
|
420
|
+
structuredContent: toStructuredContent(bundle),
|
|
546
421
|
};
|
|
547
422
|
}
|
|
548
423
|
catch (err) {
|
|
@@ -566,8 +441,8 @@ export function registerSchemaTools(mcp, client) {
|
|
|
566
441
|
try {
|
|
567
442
|
const result = await client.schemas.importSchema(args.bundle);
|
|
568
443
|
return {
|
|
569
|
-
content: [
|
|
570
|
-
structuredContent: result,
|
|
444
|
+
content: [],
|
|
445
|
+
structuredContent: toStructuredContent(result),
|
|
571
446
|
};
|
|
572
447
|
}
|
|
573
448
|
catch (err) {
|