@crediolabs/policy-builder-mcp 0.1.6 → 0.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +7 -2
- package/dist/src/index.d.ts +2 -2
- package/dist/src/index.js +2 -2
- package/dist/src/schemas.d.ts +58 -2058
- package/dist/src/schemas.js +26 -213
- package/dist/src/server.js +3 -3
- package/dist-cjs/package.json +3 -0
- package/dist-cjs/src/index.d.ts +7 -0
- package/dist-cjs/src/index.js +20 -0
- package/dist-cjs/src/schemas.d.ts +447 -0
- package/dist-cjs/src/schemas.js +58 -0
- package/dist-cjs/src/server.d.ts +6 -0
- package/dist-cjs/src/server.js +42 -0
- package/dist-cjs/src/tools/result.d.ts +24 -0
- package/dist-cjs/src/tools/result.js +39 -0
- package/dist-cjs/src/transports/http.d.ts +15 -0
- package/dist-cjs/src/transports/http.js +140 -0
- package/dist-cjs/src/transports/stdio.d.ts +1 -0
- package/dist-cjs/src/transports/stdio.js +18 -0
- package/package.json +36 -3
- package/src/index.ts +6 -10
- package/src/schemas.ts +47 -239
- package/src/server.ts +3 -3
- package/dist/src/tools/run.d.ts +0 -15
- package/dist/src/tools/run.js +0 -98
- package/src/tools/run.ts +0 -134
|
@@ -0,0 +1,447 @@
|
|
|
1
|
+
import { ComposeUserResponsesSchema, InterpreterOptionsSchema, MandateSpecSchema, NetworkSchema, OzAdapterConfigSchema, RecordedTransactionSchema, RecordTransactionInputSchema, SynthesizePolicyInputSchema, ToolErrorSchema } from '@crediolabs/policy-synth/run';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
export { ComposeUserResponsesSchema, InterpreterOptionsSchema, MandateSpecSchema, NetworkSchema, OzAdapterConfigSchema, RecordedTransactionSchema, RecordTransactionInputSchema, SynthesizePolicyInputSchema, ToolErrorSchema, };
|
|
4
|
+
/** Flat ZodRawShape used for the MCP SDK tool registration. The body
|
|
5
|
+
* re-validates against `RecordTransactionInputSchema` so the mutual-exclusion
|
|
6
|
+
* rule still fires (the SDK does not invoke `.refine()` at registration time). */
|
|
7
|
+
export declare const RecordTransactionToolShape: {
|
|
8
|
+
readonly hash: z.ZodOptional<z.ZodString>;
|
|
9
|
+
readonly xdr: z.ZodOptional<z.ZodString>;
|
|
10
|
+
readonly network: z.ZodEnum<["mainnet", "testnet"]>;
|
|
11
|
+
readonly confidenceOverride: z.ZodOptional<z.ZodNumber>;
|
|
12
|
+
};
|
|
13
|
+
/** Flat ZodRawShape used for MCP tool registration. Every field is optional
|
|
14
|
+
* so the JSON-Schema the SDK exposes to clients does not forbid either
|
|
15
|
+
* front-end; the body re-validates against the discriminated union. */
|
|
16
|
+
export declare const SynthesizePolicyToolShape: {
|
|
17
|
+
readonly source: z.ZodOptional<z.ZodEnum<["mandate", "recording"]>>;
|
|
18
|
+
readonly mandate: z.ZodOptional<z.ZodObject<{
|
|
19
|
+
chain: z.ZodLiteral<"stellar">;
|
|
20
|
+
contract: z.ZodString;
|
|
21
|
+
method: z.ZodOptional<z.ZodString>;
|
|
22
|
+
spendingLimit: z.ZodOptional<z.ZodObject<{
|
|
23
|
+
token: z.ZodString;
|
|
24
|
+
limit: z.ZodString;
|
|
25
|
+
windowSeconds: z.ZodNumber;
|
|
26
|
+
}, "strip", z.ZodTypeAny, {
|
|
27
|
+
token: string;
|
|
28
|
+
limit: string;
|
|
29
|
+
windowSeconds: number;
|
|
30
|
+
}, {
|
|
31
|
+
token: string;
|
|
32
|
+
limit: string;
|
|
33
|
+
windowSeconds: number;
|
|
34
|
+
}>>;
|
|
35
|
+
approvalThreshold: z.ZodOptional<z.ZodNumber>;
|
|
36
|
+
recipients: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
37
|
+
expiry: z.ZodOptional<z.ZodObject<{
|
|
38
|
+
validUntilLedger: z.ZodOptional<z.ZodNumber>;
|
|
39
|
+
validUntilUnixSeconds: z.ZodOptional<z.ZodNumber>;
|
|
40
|
+
}, "strip", z.ZodTypeAny, {
|
|
41
|
+
validUntilLedger?: number | undefined;
|
|
42
|
+
validUntilUnixSeconds?: number | undefined;
|
|
43
|
+
}, {
|
|
44
|
+
validUntilLedger?: number | undefined;
|
|
45
|
+
validUntilUnixSeconds?: number | undefined;
|
|
46
|
+
}>>;
|
|
47
|
+
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
48
|
+
chain: z.ZodLiteral<"stellar">;
|
|
49
|
+
contract: z.ZodString;
|
|
50
|
+
method: z.ZodOptional<z.ZodString>;
|
|
51
|
+
spendingLimit: z.ZodOptional<z.ZodObject<{
|
|
52
|
+
token: z.ZodString;
|
|
53
|
+
limit: z.ZodString;
|
|
54
|
+
windowSeconds: z.ZodNumber;
|
|
55
|
+
}, "strip", z.ZodTypeAny, {
|
|
56
|
+
token: string;
|
|
57
|
+
limit: string;
|
|
58
|
+
windowSeconds: number;
|
|
59
|
+
}, {
|
|
60
|
+
token: string;
|
|
61
|
+
limit: string;
|
|
62
|
+
windowSeconds: number;
|
|
63
|
+
}>>;
|
|
64
|
+
approvalThreshold: z.ZodOptional<z.ZodNumber>;
|
|
65
|
+
recipients: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
66
|
+
expiry: z.ZodOptional<z.ZodObject<{
|
|
67
|
+
validUntilLedger: z.ZodOptional<z.ZodNumber>;
|
|
68
|
+
validUntilUnixSeconds: z.ZodOptional<z.ZodNumber>;
|
|
69
|
+
}, "strip", z.ZodTypeAny, {
|
|
70
|
+
validUntilLedger?: number | undefined;
|
|
71
|
+
validUntilUnixSeconds?: number | undefined;
|
|
72
|
+
}, {
|
|
73
|
+
validUntilLedger?: number | undefined;
|
|
74
|
+
validUntilUnixSeconds?: number | undefined;
|
|
75
|
+
}>>;
|
|
76
|
+
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
77
|
+
chain: z.ZodLiteral<"stellar">;
|
|
78
|
+
contract: z.ZodString;
|
|
79
|
+
method: z.ZodOptional<z.ZodString>;
|
|
80
|
+
spendingLimit: z.ZodOptional<z.ZodObject<{
|
|
81
|
+
token: z.ZodString;
|
|
82
|
+
limit: z.ZodString;
|
|
83
|
+
windowSeconds: z.ZodNumber;
|
|
84
|
+
}, "strip", z.ZodTypeAny, {
|
|
85
|
+
token: string;
|
|
86
|
+
limit: string;
|
|
87
|
+
windowSeconds: number;
|
|
88
|
+
}, {
|
|
89
|
+
token: string;
|
|
90
|
+
limit: string;
|
|
91
|
+
windowSeconds: number;
|
|
92
|
+
}>>;
|
|
93
|
+
approvalThreshold: z.ZodOptional<z.ZodNumber>;
|
|
94
|
+
recipients: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
95
|
+
expiry: z.ZodOptional<z.ZodObject<{
|
|
96
|
+
validUntilLedger: z.ZodOptional<z.ZodNumber>;
|
|
97
|
+
validUntilUnixSeconds: z.ZodOptional<z.ZodNumber>;
|
|
98
|
+
}, "strip", z.ZodTypeAny, {
|
|
99
|
+
validUntilLedger?: number | undefined;
|
|
100
|
+
validUntilUnixSeconds?: number | undefined;
|
|
101
|
+
}, {
|
|
102
|
+
validUntilLedger?: number | undefined;
|
|
103
|
+
validUntilUnixSeconds?: number | undefined;
|
|
104
|
+
}>>;
|
|
105
|
+
}, z.ZodTypeAny, "passthrough">>>;
|
|
106
|
+
readonly recordedTx: z.ZodOptional<z.ZodObject<{
|
|
107
|
+
network: z.ZodEnum<["mainnet", "testnet"]>;
|
|
108
|
+
signers: z.ZodArray<z.ZodString, "many">;
|
|
109
|
+
invocations: z.ZodArray<z.ZodType<unknown, z.ZodTypeDef, unknown>, "many">;
|
|
110
|
+
tokenMovements: z.ZodArray<z.ZodObject<{
|
|
111
|
+
token: z.ZodString;
|
|
112
|
+
from: z.ZodString;
|
|
113
|
+
to: z.ZodString;
|
|
114
|
+
amount: z.ZodString;
|
|
115
|
+
}, "strip", z.ZodTypeAny, {
|
|
116
|
+
amount: string;
|
|
117
|
+
token: string;
|
|
118
|
+
from: string;
|
|
119
|
+
to: string;
|
|
120
|
+
}, {
|
|
121
|
+
amount: string;
|
|
122
|
+
token: string;
|
|
123
|
+
from: string;
|
|
124
|
+
to: string;
|
|
125
|
+
}>, "many">;
|
|
126
|
+
events: z.ZodArray<z.ZodObject<{
|
|
127
|
+
contract: z.ZodString;
|
|
128
|
+
topics: z.ZodArray<z.ZodString, "many">;
|
|
129
|
+
data: z.ZodType<unknown, z.ZodTypeDef, unknown>;
|
|
130
|
+
}, "strip", z.ZodTypeAny, {
|
|
131
|
+
contract: string;
|
|
132
|
+
topics: string[];
|
|
133
|
+
data?: unknown;
|
|
134
|
+
}, {
|
|
135
|
+
contract: string;
|
|
136
|
+
topics: string[];
|
|
137
|
+
data?: unknown;
|
|
138
|
+
}>, "many">;
|
|
139
|
+
authEntries: z.ZodArray<z.ZodUnknown, "many">;
|
|
140
|
+
ledgerSequence: z.ZodNumber;
|
|
141
|
+
fetchedAt: z.ZodNumber;
|
|
142
|
+
parseConfidence: z.ZodObject<{
|
|
143
|
+
overall: z.ZodNumber;
|
|
144
|
+
knownContracts: z.ZodArray<z.ZodString, "many">;
|
|
145
|
+
unknownContracts: z.ZodArray<z.ZodObject<{
|
|
146
|
+
contract: z.ZodString;
|
|
147
|
+
reason: z.ZodEnum<["no-abi", "version-mismatch", "opaque-result"]>;
|
|
148
|
+
}, "strip", z.ZodTypeAny, {
|
|
149
|
+
contract: string;
|
|
150
|
+
reason: "no-abi" | "version-mismatch" | "opaque-result";
|
|
151
|
+
}, {
|
|
152
|
+
contract: string;
|
|
153
|
+
reason: "no-abi" | "version-mismatch" | "opaque-result";
|
|
154
|
+
}>, "many">;
|
|
155
|
+
opaqueScVals: z.ZodArray<z.ZodObject<{
|
|
156
|
+
path: z.ZodString;
|
|
157
|
+
type: z.ZodString;
|
|
158
|
+
}, "strip", z.ZodTypeAny, {
|
|
159
|
+
type: string;
|
|
160
|
+
path: string;
|
|
161
|
+
}, {
|
|
162
|
+
type: string;
|
|
163
|
+
path: string;
|
|
164
|
+
}>, "many">;
|
|
165
|
+
thresholdUsed: z.ZodNumber;
|
|
166
|
+
}, "strip", z.ZodTypeAny, {
|
|
167
|
+
opaqueScVals: {
|
|
168
|
+
type: string;
|
|
169
|
+
path: string;
|
|
170
|
+
}[];
|
|
171
|
+
unknownContracts: {
|
|
172
|
+
contract: string;
|
|
173
|
+
reason: "no-abi" | "version-mismatch" | "opaque-result";
|
|
174
|
+
}[];
|
|
175
|
+
overall: number;
|
|
176
|
+
knownContracts: string[];
|
|
177
|
+
thresholdUsed: number;
|
|
178
|
+
}, {
|
|
179
|
+
opaqueScVals: {
|
|
180
|
+
type: string;
|
|
181
|
+
path: string;
|
|
182
|
+
}[];
|
|
183
|
+
unknownContracts: {
|
|
184
|
+
contract: string;
|
|
185
|
+
reason: "no-abi" | "version-mismatch" | "opaque-result";
|
|
186
|
+
}[];
|
|
187
|
+
overall: number;
|
|
188
|
+
knownContracts: string[];
|
|
189
|
+
thresholdUsed: number;
|
|
190
|
+
}>;
|
|
191
|
+
sourceAccount: z.ZodString;
|
|
192
|
+
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
193
|
+
network: z.ZodEnum<["mainnet", "testnet"]>;
|
|
194
|
+
signers: z.ZodArray<z.ZodString, "many">;
|
|
195
|
+
invocations: z.ZodArray<z.ZodType<unknown, z.ZodTypeDef, unknown>, "many">;
|
|
196
|
+
tokenMovements: z.ZodArray<z.ZodObject<{
|
|
197
|
+
token: z.ZodString;
|
|
198
|
+
from: z.ZodString;
|
|
199
|
+
to: z.ZodString;
|
|
200
|
+
amount: z.ZodString;
|
|
201
|
+
}, "strip", z.ZodTypeAny, {
|
|
202
|
+
amount: string;
|
|
203
|
+
token: string;
|
|
204
|
+
from: string;
|
|
205
|
+
to: string;
|
|
206
|
+
}, {
|
|
207
|
+
amount: string;
|
|
208
|
+
token: string;
|
|
209
|
+
from: string;
|
|
210
|
+
to: string;
|
|
211
|
+
}>, "many">;
|
|
212
|
+
events: z.ZodArray<z.ZodObject<{
|
|
213
|
+
contract: z.ZodString;
|
|
214
|
+
topics: z.ZodArray<z.ZodString, "many">;
|
|
215
|
+
data: z.ZodType<unknown, z.ZodTypeDef, unknown>;
|
|
216
|
+
}, "strip", z.ZodTypeAny, {
|
|
217
|
+
contract: string;
|
|
218
|
+
topics: string[];
|
|
219
|
+
data?: unknown;
|
|
220
|
+
}, {
|
|
221
|
+
contract: string;
|
|
222
|
+
topics: string[];
|
|
223
|
+
data?: unknown;
|
|
224
|
+
}>, "many">;
|
|
225
|
+
authEntries: z.ZodArray<z.ZodUnknown, "many">;
|
|
226
|
+
ledgerSequence: z.ZodNumber;
|
|
227
|
+
fetchedAt: z.ZodNumber;
|
|
228
|
+
parseConfidence: z.ZodObject<{
|
|
229
|
+
overall: z.ZodNumber;
|
|
230
|
+
knownContracts: z.ZodArray<z.ZodString, "many">;
|
|
231
|
+
unknownContracts: z.ZodArray<z.ZodObject<{
|
|
232
|
+
contract: z.ZodString;
|
|
233
|
+
reason: z.ZodEnum<["no-abi", "version-mismatch", "opaque-result"]>;
|
|
234
|
+
}, "strip", z.ZodTypeAny, {
|
|
235
|
+
contract: string;
|
|
236
|
+
reason: "no-abi" | "version-mismatch" | "opaque-result";
|
|
237
|
+
}, {
|
|
238
|
+
contract: string;
|
|
239
|
+
reason: "no-abi" | "version-mismatch" | "opaque-result";
|
|
240
|
+
}>, "many">;
|
|
241
|
+
opaqueScVals: z.ZodArray<z.ZodObject<{
|
|
242
|
+
path: z.ZodString;
|
|
243
|
+
type: z.ZodString;
|
|
244
|
+
}, "strip", z.ZodTypeAny, {
|
|
245
|
+
type: string;
|
|
246
|
+
path: string;
|
|
247
|
+
}, {
|
|
248
|
+
type: string;
|
|
249
|
+
path: string;
|
|
250
|
+
}>, "many">;
|
|
251
|
+
thresholdUsed: z.ZodNumber;
|
|
252
|
+
}, "strip", z.ZodTypeAny, {
|
|
253
|
+
opaqueScVals: {
|
|
254
|
+
type: string;
|
|
255
|
+
path: string;
|
|
256
|
+
}[];
|
|
257
|
+
unknownContracts: {
|
|
258
|
+
contract: string;
|
|
259
|
+
reason: "no-abi" | "version-mismatch" | "opaque-result";
|
|
260
|
+
}[];
|
|
261
|
+
overall: number;
|
|
262
|
+
knownContracts: string[];
|
|
263
|
+
thresholdUsed: number;
|
|
264
|
+
}, {
|
|
265
|
+
opaqueScVals: {
|
|
266
|
+
type: string;
|
|
267
|
+
path: string;
|
|
268
|
+
}[];
|
|
269
|
+
unknownContracts: {
|
|
270
|
+
contract: string;
|
|
271
|
+
reason: "no-abi" | "version-mismatch" | "opaque-result";
|
|
272
|
+
}[];
|
|
273
|
+
overall: number;
|
|
274
|
+
knownContracts: string[];
|
|
275
|
+
thresholdUsed: number;
|
|
276
|
+
}>;
|
|
277
|
+
sourceAccount: z.ZodString;
|
|
278
|
+
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
279
|
+
network: z.ZodEnum<["mainnet", "testnet"]>;
|
|
280
|
+
signers: z.ZodArray<z.ZodString, "many">;
|
|
281
|
+
invocations: z.ZodArray<z.ZodType<unknown, z.ZodTypeDef, unknown>, "many">;
|
|
282
|
+
tokenMovements: z.ZodArray<z.ZodObject<{
|
|
283
|
+
token: z.ZodString;
|
|
284
|
+
from: z.ZodString;
|
|
285
|
+
to: z.ZodString;
|
|
286
|
+
amount: z.ZodString;
|
|
287
|
+
}, "strip", z.ZodTypeAny, {
|
|
288
|
+
amount: string;
|
|
289
|
+
token: string;
|
|
290
|
+
from: string;
|
|
291
|
+
to: string;
|
|
292
|
+
}, {
|
|
293
|
+
amount: string;
|
|
294
|
+
token: string;
|
|
295
|
+
from: string;
|
|
296
|
+
to: string;
|
|
297
|
+
}>, "many">;
|
|
298
|
+
events: z.ZodArray<z.ZodObject<{
|
|
299
|
+
contract: z.ZodString;
|
|
300
|
+
topics: z.ZodArray<z.ZodString, "many">;
|
|
301
|
+
data: z.ZodType<unknown, z.ZodTypeDef, unknown>;
|
|
302
|
+
}, "strip", z.ZodTypeAny, {
|
|
303
|
+
contract: string;
|
|
304
|
+
topics: string[];
|
|
305
|
+
data?: unknown;
|
|
306
|
+
}, {
|
|
307
|
+
contract: string;
|
|
308
|
+
topics: string[];
|
|
309
|
+
data?: unknown;
|
|
310
|
+
}>, "many">;
|
|
311
|
+
authEntries: z.ZodArray<z.ZodUnknown, "many">;
|
|
312
|
+
ledgerSequence: z.ZodNumber;
|
|
313
|
+
fetchedAt: z.ZodNumber;
|
|
314
|
+
parseConfidence: z.ZodObject<{
|
|
315
|
+
overall: z.ZodNumber;
|
|
316
|
+
knownContracts: z.ZodArray<z.ZodString, "many">;
|
|
317
|
+
unknownContracts: z.ZodArray<z.ZodObject<{
|
|
318
|
+
contract: z.ZodString;
|
|
319
|
+
reason: z.ZodEnum<["no-abi", "version-mismatch", "opaque-result"]>;
|
|
320
|
+
}, "strip", z.ZodTypeAny, {
|
|
321
|
+
contract: string;
|
|
322
|
+
reason: "no-abi" | "version-mismatch" | "opaque-result";
|
|
323
|
+
}, {
|
|
324
|
+
contract: string;
|
|
325
|
+
reason: "no-abi" | "version-mismatch" | "opaque-result";
|
|
326
|
+
}>, "many">;
|
|
327
|
+
opaqueScVals: z.ZodArray<z.ZodObject<{
|
|
328
|
+
path: z.ZodString;
|
|
329
|
+
type: z.ZodString;
|
|
330
|
+
}, "strip", z.ZodTypeAny, {
|
|
331
|
+
type: string;
|
|
332
|
+
path: string;
|
|
333
|
+
}, {
|
|
334
|
+
type: string;
|
|
335
|
+
path: string;
|
|
336
|
+
}>, "many">;
|
|
337
|
+
thresholdUsed: z.ZodNumber;
|
|
338
|
+
}, "strip", z.ZodTypeAny, {
|
|
339
|
+
opaqueScVals: {
|
|
340
|
+
type: string;
|
|
341
|
+
path: string;
|
|
342
|
+
}[];
|
|
343
|
+
unknownContracts: {
|
|
344
|
+
contract: string;
|
|
345
|
+
reason: "no-abi" | "version-mismatch" | "opaque-result";
|
|
346
|
+
}[];
|
|
347
|
+
overall: number;
|
|
348
|
+
knownContracts: string[];
|
|
349
|
+
thresholdUsed: number;
|
|
350
|
+
}, {
|
|
351
|
+
opaqueScVals: {
|
|
352
|
+
type: string;
|
|
353
|
+
path: string;
|
|
354
|
+
}[];
|
|
355
|
+
unknownContracts: {
|
|
356
|
+
contract: string;
|
|
357
|
+
reason: "no-abi" | "version-mismatch" | "opaque-result";
|
|
358
|
+
}[];
|
|
359
|
+
overall: number;
|
|
360
|
+
knownContracts: string[];
|
|
361
|
+
thresholdUsed: number;
|
|
362
|
+
}>;
|
|
363
|
+
sourceAccount: z.ZodString;
|
|
364
|
+
}, z.ZodTypeAny, "passthrough">>>;
|
|
365
|
+
readonly network: z.ZodOptional<z.ZodEnum<["mainnet", "testnet"]>>;
|
|
366
|
+
readonly userResponses: z.ZodOptional<z.ZodObject<{
|
|
367
|
+
windowSeconds: z.ZodOptional<z.ZodNumber>;
|
|
368
|
+
validUntilLedger: z.ZodOptional<z.ZodNumber>;
|
|
369
|
+
limitAmount: z.ZodOptional<z.ZodString>;
|
|
370
|
+
invocationLimit: z.ZodOptional<z.ZodNumber>;
|
|
371
|
+
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
372
|
+
windowSeconds: z.ZodOptional<z.ZodNumber>;
|
|
373
|
+
validUntilLedger: z.ZodOptional<z.ZodNumber>;
|
|
374
|
+
limitAmount: z.ZodOptional<z.ZodString>;
|
|
375
|
+
invocationLimit: z.ZodOptional<z.ZodNumber>;
|
|
376
|
+
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
377
|
+
windowSeconds: z.ZodOptional<z.ZodNumber>;
|
|
378
|
+
validUntilLedger: z.ZodOptional<z.ZodNumber>;
|
|
379
|
+
limitAmount: z.ZodOptional<z.ZodString>;
|
|
380
|
+
invocationLimit: z.ZodOptional<z.ZodNumber>;
|
|
381
|
+
}, z.ZodTypeAny, "passthrough">>>;
|
|
382
|
+
readonly confidenceOverride: z.ZodOptional<z.ZodObject<{
|
|
383
|
+
threshold: z.ZodNumber;
|
|
384
|
+
}, "strip", z.ZodTypeAny, {
|
|
385
|
+
threshold: number;
|
|
386
|
+
}, {
|
|
387
|
+
threshold: number;
|
|
388
|
+
}>>;
|
|
389
|
+
readonly interpreter: z.ZodOptional<z.ZodObject<{
|
|
390
|
+
smartAccountAddress: z.ZodString;
|
|
391
|
+
installNonce: z.ZodOptional<z.ZodNumber>;
|
|
392
|
+
oracleParams: z.ZodOptional<z.ZodObject<{
|
|
393
|
+
maxStalenessSeconds: z.ZodOptional<z.ZodNumber>;
|
|
394
|
+
maxDeviationBps: z.ZodOptional<z.ZodNumber>;
|
|
395
|
+
}, "strip", z.ZodTypeAny, {
|
|
396
|
+
maxStalenessSeconds?: number | undefined;
|
|
397
|
+
maxDeviationBps?: number | undefined;
|
|
398
|
+
}, {
|
|
399
|
+
maxStalenessSeconds?: number | undefined;
|
|
400
|
+
maxDeviationBps?: number | undefined;
|
|
401
|
+
}>>;
|
|
402
|
+
}, "strip", z.ZodTypeAny, {
|
|
403
|
+
smartAccountAddress: string;
|
|
404
|
+
oracleParams?: {
|
|
405
|
+
maxStalenessSeconds?: number | undefined;
|
|
406
|
+
maxDeviationBps?: number | undefined;
|
|
407
|
+
} | undefined;
|
|
408
|
+
installNonce?: number | undefined;
|
|
409
|
+
}, {
|
|
410
|
+
smartAccountAddress: string;
|
|
411
|
+
oracleParams?: {
|
|
412
|
+
maxStalenessSeconds?: number | undefined;
|
|
413
|
+
maxDeviationBps?: number | undefined;
|
|
414
|
+
} | undefined;
|
|
415
|
+
installNonce?: number | undefined;
|
|
416
|
+
}>>;
|
|
417
|
+
readonly ozConfig: z.ZodOptional<z.ZodObject<{
|
|
418
|
+
network: z.ZodEnum<["mainnet", "testnet"]>;
|
|
419
|
+
instances: z.ZodObject<{
|
|
420
|
+
spending_limit: z.ZodString;
|
|
421
|
+
simple_threshold: z.ZodString;
|
|
422
|
+
weighted_threshold: z.ZodString;
|
|
423
|
+
}, "strip", z.ZodTypeAny, {
|
|
424
|
+
spending_limit: string;
|
|
425
|
+
simple_threshold: string;
|
|
426
|
+
weighted_threshold: string;
|
|
427
|
+
}, {
|
|
428
|
+
spending_limit: string;
|
|
429
|
+
simple_threshold: string;
|
|
430
|
+
weighted_threshold: string;
|
|
431
|
+
}>;
|
|
432
|
+
}, "strip", z.ZodTypeAny, {
|
|
433
|
+
network: "mainnet" | "testnet";
|
|
434
|
+
instances: {
|
|
435
|
+
spending_limit: string;
|
|
436
|
+
simple_threshold: string;
|
|
437
|
+
weighted_threshold: string;
|
|
438
|
+
};
|
|
439
|
+
}, {
|
|
440
|
+
network: "mainnet" | "testnet";
|
|
441
|
+
instances: {
|
|
442
|
+
spending_limit: string;
|
|
443
|
+
simple_threshold: string;
|
|
444
|
+
weighted_threshold: string;
|
|
445
|
+
};
|
|
446
|
+
}>>;
|
|
447
|
+
};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// apps/policy-builder-mcp/src/schemas.ts
|
|
3
|
+
//
|
|
4
|
+
// MCP-only tool shapes. The CORE input/output schemas and the MCP server
|
|
5
|
+
// registrations all live on `@crediolabs/policy-synth` (the tool-body glue
|
|
6
|
+
// sits at `@crediolabs/policy-synth/run`; the underlying Zod input schemas
|
|
7
|
+
// live at `@crediolabs/policy-synth/run`). What stays here is just the flat
|
|
8
|
+
// `ZodRawShape` needed by `@modelcontextprotocol/sdk`'s `tool()` registration
|
|
9
|
+
// API, which does not accept the strict discriminated union `synthesize_policy`
|
|
10
|
+
// needs.
|
|
11
|
+
//
|
|
12
|
+
// The body of every tool call re-validates against the strict schemas via
|
|
13
|
+
// `runRecordTransaction` / `runSynthesizePolicy`, so wire inputs still
|
|
14
|
+
// fail closed. The mutual-exclusion rules (e.g. exactly-one-of hash/xdr)
|
|
15
|
+
// live on the strict schemas, NOT on the tool shape; the SDK does not
|
|
16
|
+
// invoke `.refine()` at registration time, so any refined rule must be
|
|
17
|
+
// re-checked in the body.
|
|
18
|
+
//
|
|
19
|
+
// The tool-shape fields below are hand-rolled simple types rather than
|
|
20
|
+
// references into the refined strict schemas (`.refine()` returns
|
|
21
|
+
// `ZodEffects`, which has no `.shape`). They MUST stay in lockstep with
|
|
22
|
+
// the strict schemas - a drift in field type or optionality breaks the
|
|
23
|
+
// SDK's emitted JSON Schema.
|
|
24
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
+
exports.SynthesizePolicyToolShape = exports.RecordTransactionToolShape = exports.ToolErrorSchema = exports.SynthesizePolicyInputSchema = exports.RecordTransactionInputSchema = exports.RecordedTransactionSchema = exports.OzAdapterConfigSchema = exports.NetworkSchema = exports.MandateSpecSchema = exports.InterpreterOptionsSchema = exports.ComposeUserResponsesSchema = void 0;
|
|
26
|
+
const run_1 = require("@crediolabs/policy-synth/run");
|
|
27
|
+
Object.defineProperty(exports, "ComposeUserResponsesSchema", { enumerable: true, get: function () { return run_1.ComposeUserResponsesSchema; } });
|
|
28
|
+
Object.defineProperty(exports, "InterpreterOptionsSchema", { enumerable: true, get: function () { return run_1.InterpreterOptionsSchema; } });
|
|
29
|
+
Object.defineProperty(exports, "MandateSpecSchema", { enumerable: true, get: function () { return run_1.MandateSpecSchema; } });
|
|
30
|
+
Object.defineProperty(exports, "NetworkSchema", { enumerable: true, get: function () { return run_1.NetworkSchema; } });
|
|
31
|
+
Object.defineProperty(exports, "OzAdapterConfigSchema", { enumerable: true, get: function () { return run_1.OzAdapterConfigSchema; } });
|
|
32
|
+
Object.defineProperty(exports, "RecordedTransactionSchema", { enumerable: true, get: function () { return run_1.RecordedTransactionSchema; } });
|
|
33
|
+
Object.defineProperty(exports, "RecordTransactionInputSchema", { enumerable: true, get: function () { return run_1.RecordTransactionInputSchema; } });
|
|
34
|
+
Object.defineProperty(exports, "SynthesizePolicyInputSchema", { enumerable: true, get: function () { return run_1.SynthesizePolicyInputSchema; } });
|
|
35
|
+
Object.defineProperty(exports, "ToolErrorSchema", { enumerable: true, get: function () { return run_1.ToolErrorSchema; } });
|
|
36
|
+
const zod_1 = require("zod");
|
|
37
|
+
/** Flat ZodRawShape used for the MCP SDK tool registration. The body
|
|
38
|
+
* re-validates against `RecordTransactionInputSchema` so the mutual-exclusion
|
|
39
|
+
* rule still fires (the SDK does not invoke `.refine()` at registration time). */
|
|
40
|
+
exports.RecordTransactionToolShape = {
|
|
41
|
+
hash: zod_1.z.string().min(1).optional(),
|
|
42
|
+
xdr: zod_1.z.string().min(1).optional(),
|
|
43
|
+
network: run_1.NetworkSchema,
|
|
44
|
+
confidenceOverride: zod_1.z.number().min(0).max(1).optional(),
|
|
45
|
+
};
|
|
46
|
+
/** Flat ZodRawShape used for MCP tool registration. Every field is optional
|
|
47
|
+
* so the JSON-Schema the SDK exposes to clients does not forbid either
|
|
48
|
+
* front-end; the body re-validates against the discriminated union. */
|
|
49
|
+
exports.SynthesizePolicyToolShape = {
|
|
50
|
+
source: zod_1.z.enum(['mandate', 'recording']).optional(),
|
|
51
|
+
mandate: run_1.MandateSpecSchema.optional(),
|
|
52
|
+
recordedTx: run_1.RecordedTransactionSchema.optional(),
|
|
53
|
+
network: run_1.NetworkSchema.optional(),
|
|
54
|
+
userResponses: run_1.ComposeUserResponsesSchema.optional(),
|
|
55
|
+
confidenceOverride: zod_1.z.object({ threshold: zod_1.z.number().min(0).max(1) }).optional(),
|
|
56
|
+
interpreter: run_1.InterpreterOptionsSchema.optional(),
|
|
57
|
+
ozConfig: run_1.OzAdapterConfigSchema.optional(),
|
|
58
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
+
/** Build a fresh, stateless MCP server. The caller owns the returned object
|
|
3
|
+
* and connects it to a single transport (stdio or Streamable HTTP). */
|
|
4
|
+
export declare function createMcpServer(): McpServer;
|
|
5
|
+
/** Idempotent registration of the T1 tool set on the given server. */
|
|
6
|
+
export declare function registerTools(server: McpServer): void;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// apps/policy-builder-mcp/src/server.ts
|
|
3
|
+
//
|
|
4
|
+
// Registers the T1 tool surface on a fresh McpServer instance. The
|
|
5
|
+
// registration uses the official MCP SDK's `tool()` API with ZodRawShape
|
|
6
|
+
// schemas (the SDK does not accept ZodEffects / discriminated unions at the
|
|
7
|
+
// tool registration boundary - the known gotcha). The body re-validates
|
|
8
|
+
// against the strict discriminated union in `@crediolabs/policy-synth/run`
|
|
9
|
+
// so wire inputs still fail closed.
|
|
10
|
+
//
|
|
11
|
+
// Stateless: a fresh McpServer is constructed per transport (stdio/HTTP). No
|
|
12
|
+
// shared mutable state across calls; nothing here caches, queues, or holds
|
|
13
|
+
// key material.
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.createMcpServer = createMcpServer;
|
|
16
|
+
exports.registerTools = registerTools;
|
|
17
|
+
const run_1 = require("@crediolabs/policy-synth/run");
|
|
18
|
+
const mcp_js_1 = require("@modelcontextprotocol/sdk/server/mcp.js");
|
|
19
|
+
const schemas_ts_1 = require("./schemas.js");
|
|
20
|
+
const result_ts_1 = require("./tools/result.js");
|
|
21
|
+
/** Build a fresh, stateless MCP server. The caller owns the returned object
|
|
22
|
+
* and connects it to a single transport (stdio or Streamable HTTP). */
|
|
23
|
+
function createMcpServer() {
|
|
24
|
+
const server = new mcp_js_1.McpServer({ name: 'policy-builder-mcp', version: '0.0.0' }, { capabilities: { tools: {} } });
|
|
25
|
+
registerTools(server);
|
|
26
|
+
return server;
|
|
27
|
+
}
|
|
28
|
+
/** Idempotent registration of the T1 tool set on the given server. */
|
|
29
|
+
function registerTools(server) {
|
|
30
|
+
server.tool('record_transaction', 'Decode a Soroban transaction (on-chain hash OR base64 envelope XDR) into a RecordedTransaction. Returns a machine-readable ToolError on validation failure.', schemas_ts_1.RecordTransactionToolShape, async (args) => {
|
|
31
|
+
const res = await (0, run_1.runRecordTransaction)(args);
|
|
32
|
+
// Our envelope types `structuredContent` precisely (T / ToolError); the
|
|
33
|
+
// SDK's CallToolResult widens it to Record<string, unknown>, so the
|
|
34
|
+
// nominal types do not overlap. The runtime shapes match, so assert
|
|
35
|
+
// through `unknown` at this transport boundary.
|
|
36
|
+
return (0, result_ts_1.mcpResultFromCore)(res);
|
|
37
|
+
});
|
|
38
|
+
server.tool('synthesize_policy', 'Synthesize a ProposedPolicy from either a deterministic MandateSpec (`source: mandate`) or a RecordedTransaction (`source: recording`). The discriminated `source` field selects the front-end.', schemas_ts_1.SynthesizePolicyToolShape, async (args) => {
|
|
39
|
+
const res = await (0, run_1.runSynthesizePolicy)(args);
|
|
40
|
+
return (0, result_ts_1.mcpResultFromCore)(res);
|
|
41
|
+
});
|
|
42
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { ToolError, ToolResponse } from '@crediolabs/policy-synth';
|
|
2
|
+
export interface McpToolSuccess<T> {
|
|
3
|
+
isError: false;
|
|
4
|
+
content: Array<{
|
|
5
|
+
type: 'text';
|
|
6
|
+
text: string;
|
|
7
|
+
}>;
|
|
8
|
+
structuredContent: T;
|
|
9
|
+
}
|
|
10
|
+
export interface McpToolError {
|
|
11
|
+
isError: true;
|
|
12
|
+
content: Array<{
|
|
13
|
+
type: 'text';
|
|
14
|
+
text: string;
|
|
15
|
+
}>;
|
|
16
|
+
structuredContent: ToolError;
|
|
17
|
+
}
|
|
18
|
+
export type McpToolResult<T> = McpToolSuccess<T> | McpToolError;
|
|
19
|
+
/** Map a core ToolResponse<T> to the MCP result envelope. The handler in
|
|
20
|
+
* src/server.ts wraps this in the SDK's `{ content, isError }` shape. */
|
|
21
|
+
export declare function mcpResultFromCore<T>(res: ToolResponse<T>): McpToolResult<T>;
|
|
22
|
+
/** Map a core ToolError directly (for inputs that already failed validation
|
|
23
|
+
* inside the handler). */
|
|
24
|
+
export declare function mcpErrorFromCore(err: ToolError): McpToolError;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// apps/policy-builder-mcp/src/tools/result.ts
|
|
3
|
+
//
|
|
4
|
+
// Transport-layer mapping between the core's ToolResponse<T> envelope and the
|
|
5
|
+
// MCP result envelope. This is the ONLY place the two envelopes meet; no
|
|
6
|
+
// business logic lives here. The shapes follow the MCP spec for the
|
|
7
|
+
// `CallToolResult` type:
|
|
8
|
+
//
|
|
9
|
+
// success: { content: [{ type: 'text', text: JSON.stringify(data) }], isError: false }
|
|
10
|
+
// failure: { content: [{ type: 'text', text: JSON.stringify(error) }], isError: true }
|
|
11
|
+
//
|
|
12
|
+
// Both branches carry the structured content as a single JSON-encoded text
|
|
13
|
+
// block so clients that do not parse `structuredContent` still see a usable
|
|
14
|
+
// payload. The shape is intentionally tiny - any extra keys belong in the
|
|
15
|
+
// core, not here.
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.mcpResultFromCore = mcpResultFromCore;
|
|
18
|
+
exports.mcpErrorFromCore = mcpErrorFromCore;
|
|
19
|
+
/** Map a core ToolResponse<T> to the MCP result envelope. The handler in
|
|
20
|
+
* src/server.ts wraps this in the SDK's `{ content, isError }` shape. */
|
|
21
|
+
function mcpResultFromCore(res) {
|
|
22
|
+
if (res.ok) {
|
|
23
|
+
return {
|
|
24
|
+
isError: false,
|
|
25
|
+
content: [{ type: 'text', text: JSON.stringify(res.data) }],
|
|
26
|
+
structuredContent: res.data,
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
return mcpErrorFromCore(res.error);
|
|
30
|
+
}
|
|
31
|
+
/** Map a core ToolError directly (for inputs that already failed validation
|
|
32
|
+
* inside the handler). */
|
|
33
|
+
function mcpErrorFromCore(err) {
|
|
34
|
+
return {
|
|
35
|
+
isError: true,
|
|
36
|
+
content: [{ type: 'text', text: JSON.stringify(err) }],
|
|
37
|
+
structuredContent: err,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export interface StartHttpServerOptions {
|
|
2
|
+
port: number;
|
|
3
|
+
host?: string;
|
|
4
|
+
/** Path the server mounts the MCP endpoint at. Default `/mcp`. */
|
|
5
|
+
path?: string;
|
|
6
|
+
}
|
|
7
|
+
export interface RunningHttpServer {
|
|
8
|
+
port: number;
|
|
9
|
+
host: string;
|
|
10
|
+
path: string;
|
|
11
|
+
close: () => Promise<void>;
|
|
12
|
+
}
|
|
13
|
+
/** Stateless Streamable HTTP server. Resolves once the server is listening.
|
|
14
|
+
* The returned handle exposes `close()` for tests + clean shutdown. */
|
|
15
|
+
export declare function startHttpServer(opts: StartHttpServerOptions): Promise<RunningHttpServer>;
|