fixparser-plugin-mcp 9.1.7-71fc8a2b → 9.1.7-8fdb1e41

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.
@@ -26,1268 +26,172 @@ module.exports = __toCommonJS(MCPLocal_exports);
26
26
  var import_server = require("@modelcontextprotocol/sdk/server/index.js");
27
27
  var import_stdio = require("@modelcontextprotocol/sdk/server/stdio.js");
28
28
  var import_types = require("@modelcontextprotocol/sdk/types.js");
29
- var import_zod5 = require("zod");
30
-
31
- // ../../node_modules/zod-to-json-schema/dist/esm/Options.js
32
- var ignoreOverride = Symbol("Let zodToJsonSchema decide on which parser to use");
33
- var defaultOptions = {
34
- name: void 0,
35
- $refStrategy: "root",
36
- basePath: ["#"],
37
- effectStrategy: "input",
38
- pipeStrategy: "all",
39
- dateStrategy: "format:date-time",
40
- mapStrategy: "entries",
41
- removeAdditionalStrategy: "passthrough",
42
- allowedAdditionalProperties: true,
43
- rejectedAdditionalProperties: false,
44
- definitionPath: "definitions",
45
- target: "jsonSchema7",
46
- strictUnions: false,
47
- definitions: {},
48
- errorMessages: false,
49
- markdownDescription: false,
50
- patternStrategy: "escape",
51
- applyRegexFlags: false,
52
- emailStrategy: "format:email",
53
- base64Strategy: "contentEncoding:base64",
54
- nameStrategy: "ref"
55
- };
56
- var getDefaultOptions = (options) => typeof options === "string" ? {
57
- ...defaultOptions,
58
- name: options
59
- } : {
60
- ...defaultOptions,
61
- ...options
62
- };
63
-
64
- // ../../node_modules/zod-to-json-schema/dist/esm/Refs.js
65
- var getRefs = (options) => {
66
- const _options = getDefaultOptions(options);
67
- const currentPath = _options.name !== void 0 ? [..._options.basePath, _options.definitionPath, _options.name] : _options.basePath;
68
- return {
69
- ..._options,
70
- currentPath,
71
- propertyPath: void 0,
72
- seen: new Map(Object.entries(_options.definitions).map(([name, def]) => [
73
- def._def,
74
- {
75
- def: def._def,
76
- path: [..._options.basePath, _options.definitionPath, name],
77
- // Resolution of references will be forced even though seen, so it's ok that the schema is undefined here for now.
78
- jsonSchema: void 0
79
- }
80
- ]))
81
- };
82
- };
83
-
84
- // ../../node_modules/zod-to-json-schema/dist/esm/errorMessages.js
85
- function addErrorMessage(res, key, errorMessage, refs) {
86
- if (!refs?.errorMessages)
87
- return;
88
- if (errorMessage) {
89
- res.errorMessage = {
90
- ...res.errorMessage,
91
- [key]: errorMessage
92
- };
93
- }
94
- }
95
- function setResponseValueAndErrors(res, key, value, errorMessage, refs) {
96
- res[key] = value;
97
- addErrorMessage(res, key, errorMessage, refs);
98
- }
99
-
100
- // ../../node_modules/zod-to-json-schema/dist/esm/selectParser.js
101
- var import_zod4 = require("zod");
102
-
103
- // ../../node_modules/zod-to-json-schema/dist/esm/parsers/any.js
104
- function parseAnyDef() {
105
- return {};
106
- }
107
-
108
- // ../../node_modules/zod-to-json-schema/dist/esm/parsers/array.js
109
- var import_zod = require("zod");
110
- function parseArrayDef(def, refs) {
111
- const res = {
112
- type: "array"
113
- };
114
- if (def.type?._def && def.type?._def?.typeName !== import_zod.ZodFirstPartyTypeKind.ZodAny) {
115
- res.items = parseDef(def.type._def, {
116
- ...refs,
117
- currentPath: [...refs.currentPath, "items"]
118
- });
119
- }
120
- if (def.minLength) {
121
- setResponseValueAndErrors(res, "minItems", def.minLength.value, def.minLength.message, refs);
122
- }
123
- if (def.maxLength) {
124
- setResponseValueAndErrors(res, "maxItems", def.maxLength.value, def.maxLength.message, refs);
125
- }
126
- if (def.exactLength) {
127
- setResponseValueAndErrors(res, "minItems", def.exactLength.value, def.exactLength.message, refs);
128
- setResponseValueAndErrors(res, "maxItems", def.exactLength.value, def.exactLength.message, refs);
129
- }
130
- return res;
131
- }
132
-
133
- // ../../node_modules/zod-to-json-schema/dist/esm/parsers/bigint.js
134
- function parseBigintDef(def, refs) {
135
- const res = {
136
- type: "integer",
137
- format: "int64"
138
- };
139
- if (!def.checks)
140
- return res;
141
- for (const check of def.checks) {
142
- switch (check.kind) {
143
- case "min":
144
- if (refs.target === "jsonSchema7") {
145
- if (check.inclusive) {
146
- setResponseValueAndErrors(res, "minimum", check.value, check.message, refs);
147
- } else {
148
- setResponseValueAndErrors(res, "exclusiveMinimum", check.value, check.message, refs);
149
- }
150
- } else {
151
- if (!check.inclusive) {
152
- res.exclusiveMinimum = true;
153
- }
154
- setResponseValueAndErrors(res, "minimum", check.value, check.message, refs);
155
- }
156
- break;
157
- case "max":
158
- if (refs.target === "jsonSchema7") {
159
- if (check.inclusive) {
160
- setResponseValueAndErrors(res, "maximum", check.value, check.message, refs);
161
- } else {
162
- setResponseValueAndErrors(res, "exclusiveMaximum", check.value, check.message, refs);
163
- }
164
- } else {
165
- if (!check.inclusive) {
166
- res.exclusiveMaximum = true;
167
- }
168
- setResponseValueAndErrors(res, "maximum", check.value, check.message, refs);
169
- }
170
- break;
171
- case "multipleOf":
172
- setResponseValueAndErrors(res, "multipleOf", check.value, check.message, refs);
173
- break;
174
- }
175
- }
176
- return res;
177
- }
178
-
179
- // ../../node_modules/zod-to-json-schema/dist/esm/parsers/boolean.js
180
- function parseBooleanDef() {
181
- return {
182
- type: "boolean"
183
- };
184
- }
185
-
186
- // ../../node_modules/zod-to-json-schema/dist/esm/parsers/branded.js
187
- function parseBrandedDef(_def, refs) {
188
- return parseDef(_def.type._def, refs);
189
- }
190
-
191
- // ../../node_modules/zod-to-json-schema/dist/esm/parsers/catch.js
192
- var parseCatchDef = (def, refs) => {
193
- return parseDef(def.innerType._def, refs);
194
- };
195
-
196
- // ../../node_modules/zod-to-json-schema/dist/esm/parsers/date.js
197
- function parseDateDef(def, refs, overrideDateStrategy) {
198
- const strategy = overrideDateStrategy ?? refs.dateStrategy;
199
- if (Array.isArray(strategy)) {
200
- return {
201
- anyOf: strategy.map((item, i) => parseDateDef(def, refs, item))
202
- };
203
- }
204
- switch (strategy) {
205
- case "string":
206
- case "format:date-time":
207
- return {
208
- type: "string",
209
- format: "date-time"
210
- };
211
- case "format:date":
212
- return {
213
- type: "string",
214
- format: "date"
215
- };
216
- case "integer":
217
- return integerDateParser(def, refs);
218
- }
219
- }
220
- var integerDateParser = (def, refs) => {
221
- const res = {
222
- type: "integer",
223
- format: "unix-time"
224
- };
225
- if (refs.target === "openApi3") {
226
- return res;
227
- }
228
- for (const check of def.checks) {
229
- switch (check.kind) {
230
- case "min":
231
- setResponseValueAndErrors(
232
- res,
233
- "minimum",
234
- check.value,
235
- // This is in milliseconds
236
- check.message,
237
- refs
238
- );
239
- break;
240
- case "max":
241
- setResponseValueAndErrors(
242
- res,
243
- "maximum",
244
- check.value,
245
- // This is in milliseconds
246
- check.message,
247
- refs
248
- );
249
- break;
250
- }
251
- }
252
- return res;
253
- };
254
-
255
- // ../../node_modules/zod-to-json-schema/dist/esm/parsers/default.js
256
- function parseDefaultDef(_def, refs) {
257
- return {
258
- ...parseDef(_def.innerType._def, refs),
259
- default: _def.defaultValue()
260
- };
261
- }
262
-
263
- // ../../node_modules/zod-to-json-schema/dist/esm/parsers/effects.js
264
- function parseEffectsDef(_def, refs) {
265
- return refs.effectStrategy === "input" ? parseDef(_def.schema._def, refs) : {};
266
- }
267
-
268
- // ../../node_modules/zod-to-json-schema/dist/esm/parsers/enum.js
269
- function parseEnumDef(def) {
270
- return {
271
- type: "string",
272
- enum: Array.from(def.values)
273
- };
274
- }
275
-
276
- // ../../node_modules/zod-to-json-schema/dist/esm/parsers/intersection.js
277
- var isJsonSchema7AllOfType = (type) => {
278
- if ("type" in type && type.type === "string")
279
- return false;
280
- return "allOf" in type;
281
- };
282
- function parseIntersectionDef(def, refs) {
283
- const allOf = [
284
- parseDef(def.left._def, {
285
- ...refs,
286
- currentPath: [...refs.currentPath, "allOf", "0"]
287
- }),
288
- parseDef(def.right._def, {
289
- ...refs,
290
- currentPath: [...refs.currentPath, "allOf", "1"]
291
- })
292
- ].filter((x) => !!x);
293
- let unevaluatedProperties = refs.target === "jsonSchema2019-09" ? { unevaluatedProperties: false } : void 0;
294
- const mergedAllOf = [];
295
- allOf.forEach((schema) => {
296
- if (isJsonSchema7AllOfType(schema)) {
297
- mergedAllOf.push(...schema.allOf);
298
- if (schema.unevaluatedProperties === void 0) {
299
- unevaluatedProperties = void 0;
300
- }
301
- } else {
302
- let nestedSchema = schema;
303
- if ("additionalProperties" in schema && schema.additionalProperties === false) {
304
- const { additionalProperties, ...rest } = schema;
305
- nestedSchema = rest;
306
- } else {
307
- unevaluatedProperties = void 0;
308
- }
309
- mergedAllOf.push(nestedSchema);
310
- }
311
- });
312
- return mergedAllOf.length ? {
313
- allOf: mergedAllOf,
314
- ...unevaluatedProperties
315
- } : void 0;
316
- }
317
-
318
- // ../../node_modules/zod-to-json-schema/dist/esm/parsers/literal.js
319
- function parseLiteralDef(def, refs) {
320
- const parsedType = typeof def.value;
321
- if (parsedType !== "bigint" && parsedType !== "number" && parsedType !== "boolean" && parsedType !== "string") {
322
- return {
323
- type: Array.isArray(def.value) ? "array" : "object"
324
- };
325
- }
326
- if (refs.target === "openApi3") {
327
- return {
328
- type: parsedType === "bigint" ? "integer" : parsedType,
329
- enum: [def.value]
330
- };
331
- }
332
- return {
333
- type: parsedType === "bigint" ? "integer" : parsedType,
334
- const: def.value
335
- };
336
- }
337
-
338
- // ../../node_modules/zod-to-json-schema/dist/esm/parsers/record.js
339
- var import_zod2 = require("zod");
340
-
341
- // ../../node_modules/zod-to-json-schema/dist/esm/parsers/string.js
342
- var emojiRegex = void 0;
343
- var zodPatterns = {
344
- /**
345
- * `c` was changed to `[cC]` to replicate /i flag
346
- */
347
- cuid: /^[cC][^\s-]{8,}$/,
348
- cuid2: /^[0-9a-z]+$/,
349
- ulid: /^[0-9A-HJKMNP-TV-Z]{26}$/,
350
- /**
351
- * `a-z` was added to replicate /i flag
352
- */
353
- email: /^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-\.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9\-]*\.)+[a-zA-Z]{2,}$/,
354
- /**
355
- * Constructed a valid Unicode RegExp
356
- *
357
- * Lazily instantiate since this type of regex isn't supported
358
- * in all envs (e.g. React Native).
359
- *
360
- * See:
361
- * https://github.com/colinhacks/zod/issues/2433
362
- * Fix in Zod:
363
- * https://github.com/colinhacks/zod/commit/9340fd51e48576a75adc919bff65dbc4a5d4c99b
364
- */
365
- emoji: () => {
366
- if (emojiRegex === void 0) {
367
- emojiRegex = RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$", "u");
29
+ var import_fixparser = require("fixparser");
30
+ var parseInputSchema = {
31
+ type: "object",
32
+ properties: {
33
+ fixString: {
34
+ type: "string",
35
+ description: "FIX message string to parse"
368
36
  }
369
- return emojiRegex;
370
37
  },
371
- /**
372
- * Unused
373
- */
374
- uuid: /^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/,
375
- /**
376
- * Unused
377
- */
378
- ipv4: /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,
379
- ipv4Cidr: /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,
380
- /**
381
- * Unused
382
- */
383
- ipv6: /^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,
384
- ipv6Cidr: /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,
385
- base64: /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,
386
- base64url: /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,
387
- nanoid: /^[a-zA-Z0-9_-]{21}$/,
388
- jwt: /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/
389
- };
390
- function parseStringDef(def, refs) {
391
- const res = {
392
- type: "string"
393
- };
394
- if (def.checks) {
395
- for (const check of def.checks) {
396
- switch (check.kind) {
397
- case "min":
398
- setResponseValueAndErrors(res, "minLength", typeof res.minLength === "number" ? Math.max(res.minLength, check.value) : check.value, check.message, refs);
399
- break;
400
- case "max":
401
- setResponseValueAndErrors(res, "maxLength", typeof res.maxLength === "number" ? Math.min(res.maxLength, check.value) : check.value, check.message, refs);
402
- break;
403
- case "email":
404
- switch (refs.emailStrategy) {
405
- case "format:email":
406
- addFormat(res, "email", check.message, refs);
407
- break;
408
- case "format:idn-email":
409
- addFormat(res, "idn-email", check.message, refs);
410
- break;
411
- case "pattern:zod":
412
- addPattern(res, zodPatterns.email, check.message, refs);
413
- break;
414
- }
415
- break;
416
- case "url":
417
- addFormat(res, "uri", check.message, refs);
418
- break;
419
- case "uuid":
420
- addFormat(res, "uuid", check.message, refs);
421
- break;
422
- case "regex":
423
- addPattern(res, check.regex, check.message, refs);
424
- break;
425
- case "cuid":
426
- addPattern(res, zodPatterns.cuid, check.message, refs);
427
- break;
428
- case "cuid2":
429
- addPattern(res, zodPatterns.cuid2, check.message, refs);
430
- break;
431
- case "startsWith":
432
- addPattern(res, RegExp(`^${escapeLiteralCheckValue(check.value, refs)}`), check.message, refs);
433
- break;
434
- case "endsWith":
435
- addPattern(res, RegExp(`${escapeLiteralCheckValue(check.value, refs)}$`), check.message, refs);
436
- break;
437
- case "datetime":
438
- addFormat(res, "date-time", check.message, refs);
439
- break;
440
- case "date":
441
- addFormat(res, "date", check.message, refs);
442
- break;
443
- case "time":
444
- addFormat(res, "time", check.message, refs);
445
- break;
446
- case "duration":
447
- addFormat(res, "duration", check.message, refs);
448
- break;
449
- case "length":
450
- setResponseValueAndErrors(res, "minLength", typeof res.minLength === "number" ? Math.max(res.minLength, check.value) : check.value, check.message, refs);
451
- setResponseValueAndErrors(res, "maxLength", typeof res.maxLength === "number" ? Math.min(res.maxLength, check.value) : check.value, check.message, refs);
452
- break;
453
- case "includes": {
454
- addPattern(res, RegExp(escapeLiteralCheckValue(check.value, refs)), check.message, refs);
455
- break;
456
- }
457
- case "ip": {
458
- if (check.version !== "v6") {
459
- addFormat(res, "ipv4", check.message, refs);
460
- }
461
- if (check.version !== "v4") {
462
- addFormat(res, "ipv6", check.message, refs);
463
- }
464
- break;
465
- }
466
- case "base64url":
467
- addPattern(res, zodPatterns.base64url, check.message, refs);
468
- break;
469
- case "jwt":
470
- addPattern(res, zodPatterns.jwt, check.message, refs);
471
- break;
472
- case "cidr": {
473
- if (check.version !== "v6") {
474
- addPattern(res, zodPatterns.ipv4Cidr, check.message, refs);
475
- }
476
- if (check.version !== "v4") {
477
- addPattern(res, zodPatterns.ipv6Cidr, check.message, refs);
478
- }
479
- break;
480
- }
481
- case "emoji":
482
- addPattern(res, zodPatterns.emoji(), check.message, refs);
483
- break;
484
- case "ulid": {
485
- addPattern(res, zodPatterns.ulid, check.message, refs);
486
- break;
487
- }
488
- case "base64": {
489
- switch (refs.base64Strategy) {
490
- case "format:binary": {
491
- addFormat(res, "binary", check.message, refs);
492
- break;
493
- }
494
- case "contentEncoding:base64": {
495
- setResponseValueAndErrors(res, "contentEncoding", "base64", check.message, refs);
496
- break;
497
- }
498
- case "pattern:zod": {
499
- addPattern(res, zodPatterns.base64, check.message, refs);
500
- break;
501
- }
502
- }
503
- break;
504
- }
505
- case "nanoid": {
506
- addPattern(res, zodPatterns.nanoid, check.message, refs);
507
- }
508
- case "toLowerCase":
509
- case "toUpperCase":
510
- case "trim":
511
- break;
512
- default:
513
- /* @__PURE__ */ ((_) => {
514
- })(check);
515
- }
516
- }
517
- }
518
- return res;
519
- }
520
- function escapeLiteralCheckValue(literal, refs) {
521
- return refs.patternStrategy === "escape" ? escapeNonAlphaNumeric(literal) : literal;
522
- }
523
- var ALPHA_NUMERIC = new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");
524
- function escapeNonAlphaNumeric(source) {
525
- let result = "";
526
- for (let i = 0; i < source.length; i++) {
527
- if (!ALPHA_NUMERIC.has(source[i])) {
528
- result += "\\";
529
- }
530
- result += source[i];
531
- }
532
- return result;
533
- }
534
- function addFormat(schema, value, message, refs) {
535
- if (schema.format || schema.anyOf?.some((x) => x.format)) {
536
- if (!schema.anyOf) {
537
- schema.anyOf = [];
538
- }
539
- if (schema.format) {
540
- schema.anyOf.push({
541
- format: schema.format,
542
- ...schema.errorMessage && refs.errorMessages && {
543
- errorMessage: { format: schema.errorMessage.format }
544
- }
545
- });
546
- delete schema.format;
547
- if (schema.errorMessage) {
548
- delete schema.errorMessage.format;
549
- if (Object.keys(schema.errorMessage).length === 0) {
550
- delete schema.errorMessage;
551
- }
552
- }
553
- }
554
- schema.anyOf.push({
555
- format: value,
556
- ...message && refs.errorMessages && { errorMessage: { format: message } }
557
- });
558
- } else {
559
- setResponseValueAndErrors(schema, "format", value, message, refs);
560
- }
561
- }
562
- function addPattern(schema, regex, message, refs) {
563
- if (schema.pattern || schema.allOf?.some((x) => x.pattern)) {
564
- if (!schema.allOf) {
565
- schema.allOf = [];
566
- }
567
- if (schema.pattern) {
568
- schema.allOf.push({
569
- pattern: schema.pattern,
570
- ...schema.errorMessage && refs.errorMessages && {
571
- errorMessage: { pattern: schema.errorMessage.pattern }
572
- }
573
- });
574
- delete schema.pattern;
575
- if (schema.errorMessage) {
576
- delete schema.errorMessage.pattern;
577
- if (Object.keys(schema.errorMessage).length === 0) {
578
- delete schema.errorMessage;
579
- }
580
- }
581
- }
582
- schema.allOf.push({
583
- pattern: stringifyRegExpWithFlags(regex, refs),
584
- ...message && refs.errorMessages && { errorMessage: { pattern: message } }
585
- });
586
- } else {
587
- setResponseValueAndErrors(schema, "pattern", stringifyRegExpWithFlags(regex, refs), message, refs);
588
- }
589
- }
590
- function stringifyRegExpWithFlags(regex, refs) {
591
- if (!refs.applyRegexFlags || !regex.flags) {
592
- return regex.source;
593
- }
594
- const flags = {
595
- i: regex.flags.includes("i"),
596
- m: regex.flags.includes("m"),
597
- s: regex.flags.includes("s")
598
- // `.` matches newlines
599
- };
600
- const source = flags.i ? regex.source.toLowerCase() : regex.source;
601
- let pattern = "";
602
- let isEscaped = false;
603
- let inCharGroup = false;
604
- let inCharRange = false;
605
- for (let i = 0; i < source.length; i++) {
606
- if (isEscaped) {
607
- pattern += source[i];
608
- isEscaped = false;
609
- continue;
610
- }
611
- if (flags.i) {
612
- if (inCharGroup) {
613
- if (source[i].match(/[a-z]/)) {
614
- if (inCharRange) {
615
- pattern += source[i];
616
- pattern += `${source[i - 2]}-${source[i]}`.toUpperCase();
617
- inCharRange = false;
618
- } else if (source[i + 1] === "-" && source[i + 2]?.match(/[a-z]/)) {
619
- pattern += source[i];
620
- inCharRange = true;
621
- } else {
622
- pattern += `${source[i]}${source[i].toUpperCase()}`;
623
- }
624
- continue;
625
- }
626
- } else if (source[i].match(/[a-z]/)) {
627
- pattern += `[${source[i]}${source[i].toUpperCase()}]`;
628
- continue;
629
- }
630
- }
631
- if (flags.m) {
632
- if (source[i] === "^") {
633
- pattern += `(^|(?<=[\r
634
- ]))`;
635
- continue;
636
- } else if (source[i] === "$") {
637
- pattern += `($|(?=[\r
638
- ]))`;
639
- continue;
640
- }
641
- }
642
- if (flags.s && source[i] === ".") {
643
- pattern += inCharGroup ? `${source[i]}\r
644
- ` : `[${source[i]}\r
645
- ]`;
646
- continue;
647
- }
648
- pattern += source[i];
649
- if (source[i] === "\\") {
650
- isEscaped = true;
651
- } else if (inCharGroup && source[i] === "]") {
652
- inCharGroup = false;
653
- } else if (!inCharGroup && source[i] === "[") {
654
- inCharGroup = true;
655
- }
656
- }
657
- try {
658
- new RegExp(pattern);
659
- } catch {
660
- console.warn(`Could not convert regex pattern at ${refs.currentPath.join("/")} to a flag-independent form! Falling back to the flag-ignorant source`);
661
- return regex.source;
662
- }
663
- return pattern;
664
- }
665
-
666
- // ../../node_modules/zod-to-json-schema/dist/esm/parsers/record.js
667
- function parseRecordDef(def, refs) {
668
- if (refs.target === "openAi") {
669
- console.warn("Warning: OpenAI may not support records in schemas! Try an array of key-value pairs instead.");
670
- }
671
- if (refs.target === "openApi3" && def.keyType?._def.typeName === import_zod2.ZodFirstPartyTypeKind.ZodEnum) {
672
- return {
673
- type: "object",
674
- required: def.keyType._def.values,
675
- properties: def.keyType._def.values.reduce((acc, key) => ({
676
- ...acc,
677
- [key]: parseDef(def.valueType._def, {
678
- ...refs,
679
- currentPath: [...refs.currentPath, "properties", key]
680
- }) ?? {}
681
- }), {}),
682
- additionalProperties: refs.rejectedAdditionalProperties
683
- };
684
- }
685
- const schema = {
686
- type: "object",
687
- additionalProperties: parseDef(def.valueType._def, {
688
- ...refs,
689
- currentPath: [...refs.currentPath, "additionalProperties"]
690
- }) ?? refs.allowedAdditionalProperties
691
- };
692
- if (refs.target === "openApi3") {
693
- return schema;
694
- }
695
- if (def.keyType?._def.typeName === import_zod2.ZodFirstPartyTypeKind.ZodString && def.keyType._def.checks?.length) {
696
- const { type, ...keyType } = parseStringDef(def.keyType._def, refs);
697
- return {
698
- ...schema,
699
- propertyNames: keyType
700
- };
701
- } else if (def.keyType?._def.typeName === import_zod2.ZodFirstPartyTypeKind.ZodEnum) {
702
- return {
703
- ...schema,
704
- propertyNames: {
705
- enum: def.keyType._def.values
706
- }
707
- };
708
- } else if (def.keyType?._def.typeName === import_zod2.ZodFirstPartyTypeKind.ZodBranded && def.keyType._def.type._def.typeName === import_zod2.ZodFirstPartyTypeKind.ZodString && def.keyType._def.type._def.checks?.length) {
709
- const { type, ...keyType } = parseBrandedDef(def.keyType._def, refs);
710
- return {
711
- ...schema,
712
- propertyNames: keyType
713
- };
714
- }
715
- return schema;
716
- }
717
-
718
- // ../../node_modules/zod-to-json-schema/dist/esm/parsers/map.js
719
- function parseMapDef(def, refs) {
720
- if (refs.mapStrategy === "record") {
721
- return parseRecordDef(def, refs);
722
- }
723
- const keys = parseDef(def.keyType._def, {
724
- ...refs,
725
- currentPath: [...refs.currentPath, "items", "items", "0"]
726
- }) || {};
727
- const values = parseDef(def.valueType._def, {
728
- ...refs,
729
- currentPath: [...refs.currentPath, "items", "items", "1"]
730
- }) || {};
731
- return {
732
- type: "array",
733
- maxItems: 125,
734
- items: {
735
- type: "array",
736
- items: [keys, values],
737
- minItems: 2,
738
- maxItems: 2
739
- }
740
- };
741
- }
742
-
743
- // ../../node_modules/zod-to-json-schema/dist/esm/parsers/nativeEnum.js
744
- function parseNativeEnumDef(def) {
745
- const object = def.values;
746
- const actualKeys = Object.keys(def.values).filter((key) => {
747
- return typeof object[object[key]] !== "number";
748
- });
749
- const actualValues = actualKeys.map((key) => object[key]);
750
- const parsedTypes = Array.from(new Set(actualValues.map((values) => typeof values)));
751
- return {
752
- type: parsedTypes.length === 1 ? parsedTypes[0] === "string" ? "string" : "number" : ["string", "number"],
753
- enum: actualValues
754
- };
755
- }
756
-
757
- // ../../node_modules/zod-to-json-schema/dist/esm/parsers/never.js
758
- function parseNeverDef() {
759
- return {
760
- not: {}
761
- };
762
- }
763
-
764
- // ../../node_modules/zod-to-json-schema/dist/esm/parsers/null.js
765
- function parseNullDef(refs) {
766
- return refs.target === "openApi3" ? {
767
- enum: ["null"],
768
- nullable: true
769
- } : {
770
- type: "null"
771
- };
772
- }
773
-
774
- // ../../node_modules/zod-to-json-schema/dist/esm/parsers/union.js
775
- var primitiveMappings = {
776
- ZodString: "string",
777
- ZodNumber: "number",
778
- ZodBigInt: "integer",
779
- ZodBoolean: "boolean",
780
- ZodNull: "null"
38
+ required: ["fixString"]
781
39
  };
782
- function parseUnionDef(def, refs) {
783
- if (refs.target === "openApi3")
784
- return asAnyOf(def, refs);
785
- const options = def.options instanceof Map ? Array.from(def.options.values()) : def.options;
786
- if (options.every((x) => x._def.typeName in primitiveMappings && (!x._def.checks || !x._def.checks.length))) {
787
- const types = options.reduce((types2, x) => {
788
- const type = primitiveMappings[x._def.typeName];
789
- return type && !types2.includes(type) ? [...types2, type] : types2;
790
- }, []);
791
- return {
792
- type: types.length > 1 ? types : types[0]
793
- };
794
- } else if (options.every((x) => x._def.typeName === "ZodLiteral" && !x.description)) {
795
- const types = options.reduce((acc, x) => {
796
- const type = typeof x._def.value;
797
- switch (type) {
798
- case "string":
799
- case "number":
800
- case "boolean":
801
- return [...acc, type];
802
- case "bigint":
803
- return [...acc, "integer"];
804
- case "object":
805
- if (x._def.value === null)
806
- return [...acc, "null"];
807
- case "symbol":
808
- case "undefined":
809
- case "function":
810
- default:
811
- return acc;
812
- }
813
- }, []);
814
- if (types.length === options.length) {
815
- const uniqueTypes = types.filter((x, i, a) => a.indexOf(x) === i);
816
- return {
817
- type: uniqueTypes.length > 1 ? uniqueTypes : uniqueTypes[0],
818
- enum: options.reduce((acc, x) => {
819
- return acc.includes(x._def.value) ? acc : [...acc, x._def.value];
820
- }, [])
821
- };
822
- }
823
- } else if (options.every((x) => x._def.typeName === "ZodEnum")) {
824
- return {
40
+ var parseToJSONInputSchema = {
41
+ type: "object",
42
+ properties: {
43
+ fixString: {
825
44
  type: "string",
826
- enum: options.reduce((acc, x) => [
827
- ...acc,
828
- ...x._def.values.filter((x2) => !acc.includes(x2))
829
- ], [])
830
- };
831
- }
832
- return asAnyOf(def, refs);
833
- }
834
- var asAnyOf = (def, refs) => {
835
- const anyOf = (def.options instanceof Map ? Array.from(def.options.values()) : def.options).map((x, i) => parseDef(x._def, {
836
- ...refs,
837
- currentPath: [...refs.currentPath, "anyOf", `${i}`]
838
- })).filter((x) => !!x && (!refs.strictUnions || typeof x === "object" && Object.keys(x).length > 0));
839
- return anyOf.length ? { anyOf } : void 0;
840
- };
841
-
842
- // ../../node_modules/zod-to-json-schema/dist/esm/parsers/nullable.js
843
- function parseNullableDef(def, refs) {
844
- if (["ZodString", "ZodNumber", "ZodBigInt", "ZodBoolean", "ZodNull"].includes(def.innerType._def.typeName) && (!def.innerType._def.checks || !def.innerType._def.checks.length)) {
845
- if (refs.target === "openApi3") {
846
- return {
847
- type: primitiveMappings[def.innerType._def.typeName],
848
- nullable: true
849
- };
45
+ description: "FIX message string to parse"
850
46
  }
851
- return {
852
- type: [
853
- primitiveMappings[def.innerType._def.typeName],
854
- "null"
855
- ]
856
- };
857
- }
858
- if (refs.target === "openApi3") {
859
- const base2 = parseDef(def.innerType._def, {
860
- ...refs,
861
- currentPath: [...refs.currentPath]
862
- });
863
- if (base2 && "$ref" in base2)
864
- return { allOf: [base2], nullable: true };
865
- return base2 && { ...base2, nullable: true };
866
- }
867
- const base = parseDef(def.innerType._def, {
868
- ...refs,
869
- currentPath: [...refs.currentPath, "anyOf", "0"]
870
- });
871
- return base && { anyOf: [base, { type: "null" }] };
872
- }
873
-
874
- // ../../node_modules/zod-to-json-schema/dist/esm/parsers/number.js
875
- function parseNumberDef(def, refs) {
876
- const res = {
877
- type: "number"
878
- };
879
- if (!def.checks)
880
- return res;
881
- for (const check of def.checks) {
882
- switch (check.kind) {
883
- case "int":
884
- res.type = "integer";
885
- addErrorMessage(res, "type", check.message, refs);
886
- break;
887
- case "min":
888
- if (refs.target === "jsonSchema7") {
889
- if (check.inclusive) {
890
- setResponseValueAndErrors(res, "minimum", check.value, check.message, refs);
891
- } else {
892
- setResponseValueAndErrors(res, "exclusiveMinimum", check.value, check.message, refs);
893
- }
894
- } else {
895
- if (!check.inclusive) {
896
- res.exclusiveMinimum = true;
897
- }
898
- setResponseValueAndErrors(res, "minimum", check.value, check.message, refs);
899
- }
900
- break;
901
- case "max":
902
- if (refs.target === "jsonSchema7") {
903
- if (check.inclusive) {
904
- setResponseValueAndErrors(res, "maximum", check.value, check.message, refs);
905
- } else {
906
- setResponseValueAndErrors(res, "exclusiveMaximum", check.value, check.message, refs);
907
- }
908
- } else {
909
- if (!check.inclusive) {
910
- res.exclusiveMaximum = true;
911
- }
912
- setResponseValueAndErrors(res, "maximum", check.value, check.message, refs);
913
- }
914
- break;
915
- case "multipleOf":
916
- setResponseValueAndErrors(res, "multipleOf", check.value, check.message, refs);
917
- break;
918
- }
919
- }
920
- return res;
921
- }
922
-
923
- // ../../node_modules/zod-to-json-schema/dist/esm/parsers/object.js
924
- var import_zod3 = require("zod");
925
- function parseObjectDef(def, refs) {
926
- const forceOptionalIntoNullable = refs.target === "openAi";
927
- const result = {
928
- type: "object",
929
- properties: {}
930
- };
931
- const required = [];
932
- const shape = def.shape();
933
- for (const propName in shape) {
934
- let propDef = shape[propName];
935
- if (propDef === void 0 || propDef._def === void 0) {
936
- continue;
937
- }
938
- let propOptional = safeIsOptional(propDef);
939
- if (propOptional && forceOptionalIntoNullable) {
940
- if (propDef instanceof import_zod3.ZodOptional) {
941
- propDef = propDef._def.innerType;
942
- }
943
- if (!propDef.isNullable()) {
944
- propDef = propDef.nullable();
945
- }
946
- propOptional = false;
947
- }
948
- const parsedDef = parseDef(propDef._def, {
949
- ...refs,
950
- currentPath: [...refs.currentPath, "properties", propName],
951
- propertyPath: [...refs.currentPath, "properties", propName]
952
- });
953
- if (parsedDef === void 0) {
954
- continue;
955
- }
956
- result.properties[propName] = parsedDef;
957
- if (!propOptional) {
958
- required.push(propName);
959
- }
960
- }
961
- if (required.length) {
962
- result.required = required;
963
- }
964
- const additionalProperties = decideAdditionalProperties(def, refs);
965
- if (additionalProperties !== void 0) {
966
- result.additionalProperties = additionalProperties;
967
- }
968
- return result;
969
- }
970
- function decideAdditionalProperties(def, refs) {
971
- if (def.catchall._def.typeName !== "ZodNever") {
972
- return parseDef(def.catchall._def, {
973
- ...refs,
974
- currentPath: [...refs.currentPath, "additionalProperties"]
975
- });
976
- }
977
- switch (def.unknownKeys) {
978
- case "passthrough":
979
- return refs.allowedAdditionalProperties;
980
- case "strict":
981
- return refs.rejectedAdditionalProperties;
982
- case "strip":
983
- return refs.removeAdditionalStrategy === "strict" ? refs.allowedAdditionalProperties : refs.rejectedAdditionalProperties;
984
- }
985
- }
986
- function safeIsOptional(schema) {
987
- try {
988
- return schema.isOptional();
989
- } catch {
990
- return true;
991
- }
992
- }
993
-
994
- // ../../node_modules/zod-to-json-schema/dist/esm/parsers/optional.js
995
- var parseOptionalDef = (def, refs) => {
996
- if (refs.currentPath.toString() === refs.propertyPath?.toString()) {
997
- return parseDef(def.innerType._def, refs);
998
- }
999
- const innerSchema = parseDef(def.innerType._def, {
1000
- ...refs,
1001
- currentPath: [...refs.currentPath, "anyOf", "1"]
1002
- });
1003
- return innerSchema ? {
1004
- anyOf: [
1005
- {
1006
- not: {}
1007
- },
1008
- innerSchema
1009
- ]
1010
- } : {};
1011
- };
1012
-
1013
- // ../../node_modules/zod-to-json-schema/dist/esm/parsers/pipeline.js
1014
- var parsePipelineDef = (def, refs) => {
1015
- if (refs.pipeStrategy === "input") {
1016
- return parseDef(def.in._def, refs);
1017
- } else if (refs.pipeStrategy === "output") {
1018
- return parseDef(def.out._def, refs);
1019
- }
1020
- const a = parseDef(def.in._def, {
1021
- ...refs,
1022
- currentPath: [...refs.currentPath, "allOf", "0"]
1023
- });
1024
- const b = parseDef(def.out._def, {
1025
- ...refs,
1026
- currentPath: [...refs.currentPath, "allOf", a ? "1" : "0"]
1027
- });
1028
- return {
1029
- allOf: [a, b].filter((x) => x !== void 0)
1030
- };
1031
- };
1032
-
1033
- // ../../node_modules/zod-to-json-schema/dist/esm/parsers/promise.js
1034
- function parsePromiseDef(def, refs) {
1035
- return parseDef(def.type._def, refs);
1036
- }
1037
-
1038
- // ../../node_modules/zod-to-json-schema/dist/esm/parsers/set.js
1039
- function parseSetDef(def, refs) {
1040
- const items = parseDef(def.valueType._def, {
1041
- ...refs,
1042
- currentPath: [...refs.currentPath, "items"]
1043
- });
1044
- const schema = {
1045
- type: "array",
1046
- uniqueItems: true,
1047
- items
1048
- };
1049
- if (def.minSize) {
1050
- setResponseValueAndErrors(schema, "minItems", def.minSize.value, def.minSize.message, refs);
1051
- }
1052
- if (def.maxSize) {
1053
- setResponseValueAndErrors(schema, "maxItems", def.maxSize.value, def.maxSize.message, refs);
1054
- }
1055
- return schema;
1056
- }
1057
-
1058
- // ../../node_modules/zod-to-json-schema/dist/esm/parsers/tuple.js
1059
- function parseTupleDef(def, refs) {
1060
- if (def.rest) {
1061
- return {
1062
- type: "array",
1063
- minItems: def.items.length,
1064
- items: def.items.map((x, i) => parseDef(x._def, {
1065
- ...refs,
1066
- currentPath: [...refs.currentPath, "items", `${i}`]
1067
- })).reduce((acc, x) => x === void 0 ? acc : [...acc, x], []),
1068
- additionalItems: parseDef(def.rest._def, {
1069
- ...refs,
1070
- currentPath: [...refs.currentPath, "additionalItems"]
1071
- })
1072
- };
1073
- } else {
1074
- return {
1075
- type: "array",
1076
- minItems: def.items.length,
1077
- maxItems: def.items.length,
1078
- items: def.items.map((x, i) => parseDef(x._def, {
1079
- ...refs,
1080
- currentPath: [...refs.currentPath, "items", `${i}`]
1081
- })).reduce((acc, x) => x === void 0 ? acc : [...acc, x], [])
1082
- };
1083
- }
1084
- }
1085
-
1086
- // ../../node_modules/zod-to-json-schema/dist/esm/parsers/undefined.js
1087
- function parseUndefinedDef() {
1088
- return {
1089
- not: {}
1090
- };
1091
- }
1092
-
1093
- // ../../node_modules/zod-to-json-schema/dist/esm/parsers/unknown.js
1094
- function parseUnknownDef() {
1095
- return {};
1096
- }
1097
-
1098
- // ../../node_modules/zod-to-json-schema/dist/esm/parsers/readonly.js
1099
- var parseReadonlyDef = (def, refs) => {
1100
- return parseDef(def.innerType._def, refs);
1101
- };
1102
-
1103
- // ../../node_modules/zod-to-json-schema/dist/esm/selectParser.js
1104
- var selectParser = (def, typeName, refs) => {
1105
- switch (typeName) {
1106
- case import_zod4.ZodFirstPartyTypeKind.ZodString:
1107
- return parseStringDef(def, refs);
1108
- case import_zod4.ZodFirstPartyTypeKind.ZodNumber:
1109
- return parseNumberDef(def, refs);
1110
- case import_zod4.ZodFirstPartyTypeKind.ZodObject:
1111
- return parseObjectDef(def, refs);
1112
- case import_zod4.ZodFirstPartyTypeKind.ZodBigInt:
1113
- return parseBigintDef(def, refs);
1114
- case import_zod4.ZodFirstPartyTypeKind.ZodBoolean:
1115
- return parseBooleanDef();
1116
- case import_zod4.ZodFirstPartyTypeKind.ZodDate:
1117
- return parseDateDef(def, refs);
1118
- case import_zod4.ZodFirstPartyTypeKind.ZodUndefined:
1119
- return parseUndefinedDef();
1120
- case import_zod4.ZodFirstPartyTypeKind.ZodNull:
1121
- return parseNullDef(refs);
1122
- case import_zod4.ZodFirstPartyTypeKind.ZodArray:
1123
- return parseArrayDef(def, refs);
1124
- case import_zod4.ZodFirstPartyTypeKind.ZodUnion:
1125
- case import_zod4.ZodFirstPartyTypeKind.ZodDiscriminatedUnion:
1126
- return parseUnionDef(def, refs);
1127
- case import_zod4.ZodFirstPartyTypeKind.ZodIntersection:
1128
- return parseIntersectionDef(def, refs);
1129
- case import_zod4.ZodFirstPartyTypeKind.ZodTuple:
1130
- return parseTupleDef(def, refs);
1131
- case import_zod4.ZodFirstPartyTypeKind.ZodRecord:
1132
- return parseRecordDef(def, refs);
1133
- case import_zod4.ZodFirstPartyTypeKind.ZodLiteral:
1134
- return parseLiteralDef(def, refs);
1135
- case import_zod4.ZodFirstPartyTypeKind.ZodEnum:
1136
- return parseEnumDef(def);
1137
- case import_zod4.ZodFirstPartyTypeKind.ZodNativeEnum:
1138
- return parseNativeEnumDef(def);
1139
- case import_zod4.ZodFirstPartyTypeKind.ZodNullable:
1140
- return parseNullableDef(def, refs);
1141
- case import_zod4.ZodFirstPartyTypeKind.ZodOptional:
1142
- return parseOptionalDef(def, refs);
1143
- case import_zod4.ZodFirstPartyTypeKind.ZodMap:
1144
- return parseMapDef(def, refs);
1145
- case import_zod4.ZodFirstPartyTypeKind.ZodSet:
1146
- return parseSetDef(def, refs);
1147
- case import_zod4.ZodFirstPartyTypeKind.ZodLazy:
1148
- return () => def.getter()._def;
1149
- case import_zod4.ZodFirstPartyTypeKind.ZodPromise:
1150
- return parsePromiseDef(def, refs);
1151
- case import_zod4.ZodFirstPartyTypeKind.ZodNaN:
1152
- case import_zod4.ZodFirstPartyTypeKind.ZodNever:
1153
- return parseNeverDef();
1154
- case import_zod4.ZodFirstPartyTypeKind.ZodEffects:
1155
- return parseEffectsDef(def, refs);
1156
- case import_zod4.ZodFirstPartyTypeKind.ZodAny:
1157
- return parseAnyDef();
1158
- case import_zod4.ZodFirstPartyTypeKind.ZodUnknown:
1159
- return parseUnknownDef();
1160
- case import_zod4.ZodFirstPartyTypeKind.ZodDefault:
1161
- return parseDefaultDef(def, refs);
1162
- case import_zod4.ZodFirstPartyTypeKind.ZodBranded:
1163
- return parseBrandedDef(def, refs);
1164
- case import_zod4.ZodFirstPartyTypeKind.ZodReadonly:
1165
- return parseReadonlyDef(def, refs);
1166
- case import_zod4.ZodFirstPartyTypeKind.ZodCatch:
1167
- return parseCatchDef(def, refs);
1168
- case import_zod4.ZodFirstPartyTypeKind.ZodPipeline:
1169
- return parsePipelineDef(def, refs);
1170
- case import_zod4.ZodFirstPartyTypeKind.ZodFunction:
1171
- case import_zod4.ZodFirstPartyTypeKind.ZodVoid:
1172
- case import_zod4.ZodFirstPartyTypeKind.ZodSymbol:
1173
- return void 0;
1174
- default:
1175
- return /* @__PURE__ */ ((_) => void 0)(typeName);
1176
- }
1177
- };
1178
-
1179
- // ../../node_modules/zod-to-json-schema/dist/esm/parseDef.js
1180
- function parseDef(def, refs, forceResolution = false) {
1181
- const seenItem = refs.seen.get(def);
1182
- if (refs.override) {
1183
- const overrideResult = refs.override?.(def, refs, seenItem, forceResolution);
1184
- if (overrideResult !== ignoreOverride) {
1185
- return overrideResult;
1186
- }
1187
- }
1188
- if (seenItem && !forceResolution) {
1189
- const seenSchema = get$ref(seenItem, refs);
1190
- if (seenSchema !== void 0) {
1191
- return seenSchema;
1192
- }
1193
- }
1194
- const newItem = { def, path: refs.currentPath, jsonSchema: void 0 };
1195
- refs.seen.set(def, newItem);
1196
- const jsonSchemaOrGetter = selectParser(def, def.typeName, refs);
1197
- const jsonSchema = typeof jsonSchemaOrGetter === "function" ? parseDef(jsonSchemaOrGetter(), refs) : jsonSchemaOrGetter;
1198
- if (jsonSchema) {
1199
- addMeta(def, refs, jsonSchema);
1200
- }
1201
- if (refs.postProcess) {
1202
- const postProcessResult = refs.postProcess(jsonSchema, def, refs);
1203
- newItem.jsonSchema = jsonSchema;
1204
- return postProcessResult;
1205
- }
1206
- newItem.jsonSchema = jsonSchema;
1207
- return jsonSchema;
1208
- }
1209
- var get$ref = (item, refs) => {
1210
- switch (refs.$refStrategy) {
1211
- case "root":
1212
- return { $ref: item.path.join("/") };
1213
- case "relative":
1214
- return { $ref: getRelativePath(refs.currentPath, item.path) };
1215
- case "none":
1216
- case "seen": {
1217
- if (item.path.length < refs.currentPath.length && item.path.every((value, index) => refs.currentPath[index] === value)) {
1218
- console.warn(`Recursive reference detected at ${refs.currentPath.join("/")}! Defaulting to any`);
1219
- return {};
1220
- }
1221
- return refs.$refStrategy === "seen" ? {} : void 0;
1222
- }
1223
- }
1224
- };
1225
- var getRelativePath = (pathA, pathB) => {
1226
- let i = 0;
1227
- for (; i < pathA.length && i < pathB.length; i++) {
1228
- if (pathA[i] !== pathB[i])
1229
- break;
1230
- }
1231
- return [(pathA.length - i).toString(), ...pathB.slice(i)].join("/");
47
+ },
48
+ required: ["fixString"]
1232
49
  };
1233
- var addMeta = (def, refs, jsonSchema) => {
1234
- if (def.description) {
1235
- jsonSchema.description = def.description;
1236
- if (refs.markdownDescription) {
1237
- jsonSchema.markdownDescription = def.description;
50
+ var orderSchema = {
51
+ type: "object",
52
+ properties: {
53
+ clOrdID: {
54
+ type: "string",
55
+ description: "Client Order ID"
56
+ },
57
+ handlInst: {
58
+ type: "string",
59
+ enum: ["1", "2", "3"],
60
+ description: "Handling instruction (1=Manual, 2=Automated, 3=AutomatedNoIntervention)"
61
+ },
62
+ quantity: {
63
+ type: "number",
64
+ description: "Order quantity"
65
+ },
66
+ price: {
67
+ type: "number",
68
+ description: "Order price"
69
+ },
70
+ ordType: {
71
+ type: "string",
72
+ enum: [
73
+ "1",
74
+ "2",
75
+ "3",
76
+ "4",
77
+ "5",
78
+ "6",
79
+ "7",
80
+ "8",
81
+ "9",
82
+ "A",
83
+ "B",
84
+ "C",
85
+ "D",
86
+ "E",
87
+ "F",
88
+ "G",
89
+ "H",
90
+ "I",
91
+ "J",
92
+ "K",
93
+ "L",
94
+ "M",
95
+ "P",
96
+ "Q",
97
+ "R",
98
+ "S"
99
+ ],
100
+ description: "Order type (1=Market, 2=Limit, 3=Stop)"
101
+ },
102
+ side: {
103
+ type: "string",
104
+ enum: ["1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F", "G", "H"],
105
+ description: "Order side (1=Buy, 2=Sell, 3=BuyMinus, 4=SellPlus, 5=SellShort, 6=SellShortExempt, 7=Undisclosed, 8=Cross, 9=CrossShort, A=CrossShortExempt, B=AsDefined, C=Opposite, D=Subscribe, E=Redeem, F=Lend, G=Borrow, H=SellUndisclosed)"
106
+ },
107
+ symbol: {
108
+ type: "string",
109
+ description: "Trading symbol"
110
+ },
111
+ timeInForce: {
112
+ type: "string",
113
+ enum: ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C"],
114
+ description: "Time in force (0=Day, 1=Good Till Cancel, 2=At Opening, 3=Immediate or Cancel, 4=Fill or Kill, 5=Good Till Crossing, 6=Good Till Date)"
1238
115
  }
1239
- }
1240
- return jsonSchema;
116
+ },
117
+ required: ["clOrdID", "handlInst", "quantity", "price", "ordType", "side", "symbol", "timeInForce"]
1241
118
  };
1242
-
1243
- // ../../node_modules/zod-to-json-schema/dist/esm/zodToJsonSchema.js
1244
- var zodToJsonSchema = (schema, options) => {
1245
- const refs = getRefs(options);
1246
- const definitions = typeof options === "object" && options.definitions ? Object.entries(options.definitions).reduce((acc, [name2, schema2]) => ({
1247
- ...acc,
1248
- [name2]: parseDef(schema2._def, {
1249
- ...refs,
1250
- currentPath: [...refs.basePath, refs.definitionPath, name2]
1251
- }, true) ?? {}
1252
- }), {}) : void 0;
1253
- const name = typeof options === "string" ? options : options?.nameStrategy === "title" ? void 0 : options?.name;
1254
- const main = parseDef(schema._def, name === void 0 ? refs : {
1255
- ...refs,
1256
- currentPath: [...refs.basePath, refs.definitionPath, name]
1257
- }, false) ?? {};
1258
- const title = typeof options === "object" && options.name !== void 0 && options.nameStrategy === "title" ? options.name : void 0;
1259
- if (title !== void 0) {
1260
- main.title = title;
1261
- }
1262
- const combined = name === void 0 ? definitions ? {
1263
- ...main,
1264
- [refs.definitionPath]: definitions
1265
- } : main : {
1266
- $ref: [
1267
- ...refs.$refStrategy === "relative" ? [] : refs.basePath,
1268
- refs.definitionPath,
1269
- name
1270
- ].join("/"),
1271
- [refs.definitionPath]: {
1272
- ...definitions,
1273
- [name]: main
119
+ var marketDataRequestInputSchema = {
120
+ type: "object",
121
+ properties: {
122
+ mdUpdateType: {
123
+ type: "string",
124
+ enum: ["0", "1"],
125
+ description: 'Market data update type (IMPORTANT: Use the numeric/alphabetic value, not the descriptive name. For example, use "0" for FullRefresh, "1" for IncrementalRefresh)'
126
+ },
127
+ symbol: {
128
+ type: "string",
129
+ description: "Trading symbol"
130
+ },
131
+ mdReqID: {
132
+ type: "string",
133
+ description: "Market data request ID"
134
+ },
135
+ subscriptionRequestType: {
136
+ type: "string",
137
+ enum: ["0", "1", "2"],
138
+ description: 'Subscription request type (IMPORTANT: Use the numeric/alphabetic value, not the descriptive name. For example, use "0" for Snapshot + Updates, "1" for Snapshot, "2" for Unsubscribe)'
139
+ },
140
+ mdEntryType: {
141
+ type: "string",
142
+ enum: [
143
+ "0",
144
+ "1",
145
+ "2",
146
+ "3",
147
+ "4",
148
+ "5",
149
+ "6",
150
+ "7",
151
+ "8",
152
+ "9",
153
+ "A",
154
+ "B",
155
+ "C",
156
+ "D",
157
+ "E",
158
+ "F",
159
+ "G",
160
+ "H",
161
+ "J",
162
+ "K",
163
+ "L",
164
+ "M",
165
+ "N",
166
+ "O",
167
+ "P",
168
+ "Q",
169
+ "S",
170
+ "R",
171
+ "T",
172
+ "U",
173
+ "V",
174
+ "W",
175
+ "X",
176
+ "Y",
177
+ "Z",
178
+ "a",
179
+ "b",
180
+ "c",
181
+ "d",
182
+ "e",
183
+ "g",
184
+ "h",
185
+ "i",
186
+ "t"
187
+ ],
188
+ description: 'Market data entry type (IMPORTANT: Use the numeric/alphabetic value, not the descriptive name. For example, use "0" for Bid, "1" for Offer, "2" for Trade, "3" for Index Value, "4" for Opening Price)'
1274
189
  }
1275
- };
1276
- if (refs.target === "jsonSchema7") {
1277
- combined.$schema = "http://json-schema.org/draft-07/schema#";
1278
- } else if (refs.target === "jsonSchema2019-09" || refs.target === "openAi") {
1279
- combined.$schema = "https://json-schema.org/draft/2019-09/schema#";
1280
- }
1281
- if (refs.target === "openAi" && ("anyOf" in combined || "oneOf" in combined || "allOf" in combined || "type" in combined && Array.isArray(combined.type))) {
1282
- console.warn("Warning: OpenAI may not support schemas with unions as roots! Try wrapping it in an object property.");
1283
- }
1284
- return combined;
190
+ },
191
+ required: ["symbol", "mdReqID"]
1285
192
  };
1286
-
1287
- // src/MCPLocal.ts
1288
- var import_fixparser = require("fixparser");
1289
193
  var MCPLocal = class {
1290
- logger;
194
+ // private logger: Logger | undefined;
1291
195
  parser;
1292
196
  server = new import_server.Server(
1293
197
  {
@@ -1305,33 +209,35 @@ var MCPLocal = class {
1305
209
  transport = new import_stdio.StdioServerTransport();
1306
210
  onReady = void 0;
1307
211
  pendingRequests = /* @__PURE__ */ new Map();
212
+ verifiedOrders = /* @__PURE__ */ new Map();
1308
213
  constructor({ logger, onReady }) {
1309
- if (logger) this.logger = logger;
1310
214
  if (onReady) this.onReady = onReady;
1311
215
  }
1312
216
  async register(parser) {
1313
217
  this.parser = parser;
1314
218
  this.parser.addOnMessageCallback((message) => {
1315
- this.logger?.log({
1316
- level: "info",
1317
- message: `FIXParser (MCP): (${parser.protocol?.toUpperCase()}): << received ${message.description}`
1318
- });
1319
219
  const msgType = message.messageType;
1320
- if (msgType === import_fixparser.Messages.MarketDataSnapshotFullRefresh || msgType === import_fixparser.Messages.ExecutionReport) {
1321
- const idField = msgType === import_fixparser.Messages.MarketDataSnapshotFullRefresh ? message.getField(import_fixparser.Fields.MDReqID) : message.getField(import_fixparser.Fields.ClOrdID);
1322
- if (idField) {
1323
- const id = idField.value;
1324
- if (typeof id === "string" || typeof id === "number") {
1325
- const callback = this.pendingRequests.get(String(id));
1326
- if (callback) {
1327
- callback(message);
1328
- this.pendingRequests.delete(String(id));
1329
- }
220
+ if (msgType === import_fixparser.Messages.MarketDataSnapshotFullRefresh || msgType === import_fixparser.Messages.ExecutionReport || msgType === import_fixparser.Messages.Reject) {
221
+ let id;
222
+ if (msgType === import_fixparser.Messages.MarketDataSnapshotFullRefresh) {
223
+ const mdReqID = message.getField(import_fixparser.Fields.MDReqID);
224
+ if (mdReqID) id = String(mdReqID.value);
225
+ } else if (msgType === import_fixparser.Messages.ExecutionReport) {
226
+ const clOrdID = message.getField(import_fixparser.Fields.ClOrdID);
227
+ if (clOrdID) id = String(clOrdID.value);
228
+ } else if (msgType === import_fixparser.Messages.Reject) {
229
+ const refSeqNum = message.getField(import_fixparser.Fields.RefSeqNum);
230
+ if (refSeqNum) id = String(refSeqNum.value);
231
+ }
232
+ if (id) {
233
+ const callback = this.pendingRequests.get(id);
234
+ if (callback) {
235
+ callback(message);
236
+ this.pendingRequests.delete(id);
1330
237
  }
1331
238
  }
1332
239
  }
1333
240
  });
1334
- this.logger = parser.logger;
1335
241
  this.addWorkflows();
1336
242
  await this.server.connect(this.transport);
1337
243
  if (this.onReady) {
@@ -1340,19 +246,27 @@ var MCPLocal = class {
1340
246
  }
1341
247
  addWorkflows() {
1342
248
  if (!this.parser) {
1343
- this.logger?.log({
1344
- level: "error",
1345
- message: "FIXParser (MCP): -- FIXParser instance not initialized. Ignoring setup of workflows..."
1346
- });
1347
249
  return;
1348
250
  }
1349
251
  if (!this.server) {
1350
- this.logger?.log({
1351
- level: "error",
1352
- message: "FIXParser (MCP): -- MCP Server not initialized. Ignoring setup of workflows..."
1353
- });
1354
252
  return;
1355
253
  }
254
+ const validateArgs = (args, schema) => {
255
+ const result = {};
256
+ for (const [key, propSchema] of Object.entries(schema.properties || {})) {
257
+ const prop = propSchema;
258
+ const value = args?.[key];
259
+ if (prop.required && (value === void 0 || value === null)) {
260
+ throw new Error(`Required property '${key}' is missing`);
261
+ }
262
+ if (value !== void 0) {
263
+ result[key] = value;
264
+ } else if (prop.default !== void 0) {
265
+ result[key] = prop.default;
266
+ }
267
+ }
268
+ return result;
269
+ };
1356
270
  this.server.setRequestHandler(import_types.ListResourcesRequestSchema, async () => {
1357
271
  return {
1358
272
  resources: []
@@ -1364,143 +278,27 @@ var MCPLocal = class {
1364
278
  {
1365
279
  name: "parse",
1366
280
  description: "Parses a FIX message and describes it in plain language",
1367
- inputSchema: zodToJsonSchema(
1368
- import_zod5.z.object({
1369
- fixString: import_zod5.z.string().describe("FIX message string to parse")
1370
- }),
1371
- { name: "ParseInput" }
1372
- )
281
+ inputSchema: parseInputSchema
1373
282
  },
1374
283
  {
1375
284
  name: "parseToJSON",
1376
285
  description: "Parses a FIX message into JSON",
1377
- inputSchema: zodToJsonSchema(
1378
- import_zod5.z.object({
1379
- fixString: import_zod5.z.string().describe("FIX message string to parse")
1380
- }),
1381
- { name: "ParseToJSONInput" }
1382
- )
286
+ inputSchema: parseToJSONInputSchema
287
+ },
288
+ {
289
+ name: "verifyOrder",
290
+ description: "Verifies all parameters for a New Order Single. This is the first step - verification only, no order is sent.",
291
+ inputSchema: orderSchema
1383
292
  },
1384
293
  {
1385
- name: "newOrderSingle",
1386
- description: "Creates and sends a New Order Single",
1387
- inputSchema: zodToJsonSchema(
1388
- import_zod5.z.object({
1389
- clOrdID: import_zod5.z.string().describe("Client Order ID"),
1390
- handlInst: import_zod5.z.enum(["1", "2", "3"]).default(import_fixparser.HandlInst.AutomatedExecutionNoIntervention).optional().describe("Handling instruction"),
1391
- quantity: import_zod5.z.number().describe("Order quantity"),
1392
- price: import_zod5.z.number().describe("Order price"),
1393
- ordType: import_zod5.z.enum([
1394
- "1",
1395
- "2",
1396
- "3",
1397
- "4",
1398
- "5",
1399
- "6",
1400
- "7",
1401
- "8",
1402
- "9",
1403
- "A",
1404
- "B",
1405
- "C",
1406
- "D",
1407
- "E",
1408
- "F",
1409
- "G",
1410
- "H",
1411
- "I",
1412
- "J",
1413
- "K",
1414
- "L",
1415
- "M",
1416
- "P",
1417
- "Q",
1418
- "R",
1419
- "S"
1420
- ]).default("1").optional().describe("Order type"),
1421
- side: import_zod5.z.enum([
1422
- "1",
1423
- "2",
1424
- "3",
1425
- "4",
1426
- "5",
1427
- "6",
1428
- "7",
1429
- "8",
1430
- "9",
1431
- "A",
1432
- "B",
1433
- "C",
1434
- "D",
1435
- "E",
1436
- "F",
1437
- "G",
1438
- "H"
1439
- ]).describe("Order side (1=Buy, 2=Sell)"),
1440
- symbol: import_zod5.z.string().describe("Trading symbol"),
1441
- timeInForce: import_zod5.z.enum(["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C"]).default(import_fixparser.TimeInForce.Day).optional().describe("Time in force")
1442
- }),
1443
- { name: "NewOrderSingleInput" }
1444
- )
294
+ name: "executeOrder",
295
+ description: "Executes a New Order Single after verification. This is the second step - only call after successful verification.",
296
+ inputSchema: orderSchema
1445
297
  },
1446
298
  {
1447
299
  name: "marketDataRequest",
1448
- description: "Sends a request for Market Data with the given symbol",
1449
- inputSchema: zodToJsonSchema(
1450
- import_zod5.z.object({
1451
- mdUpdateType: import_zod5.z.enum(["0", "1"]).default("0").optional().describe("Market data update type"),
1452
- symbol: import_zod5.z.string().describe("Trading symbol"),
1453
- mdReqID: import_zod5.z.string().describe("Market data request ID"),
1454
- subscriptionRequestType: import_zod5.z.enum(["0", "1", "2"]).default(import_fixparser.SubscriptionRequestType.SnapshotAndUpdates).optional().describe("Subscription request type"),
1455
- mdEntryType: import_zod5.z.enum([
1456
- "0",
1457
- "1",
1458
- "2",
1459
- "3",
1460
- "4",
1461
- "5",
1462
- "6",
1463
- "7",
1464
- "8",
1465
- "9",
1466
- "A",
1467
- "B",
1468
- "C",
1469
- "D",
1470
- "E",
1471
- "F",
1472
- "G",
1473
- "H",
1474
- "J",
1475
- "K",
1476
- "L",
1477
- "M",
1478
- "N",
1479
- "O",
1480
- "P",
1481
- "Q",
1482
- "S",
1483
- "R",
1484
- "T",
1485
- "U",
1486
- "V",
1487
- "W",
1488
- "X",
1489
- "Y",
1490
- "Z",
1491
- "a",
1492
- "b",
1493
- "c",
1494
- "d",
1495
- "e",
1496
- "g",
1497
- "h",
1498
- "i",
1499
- "t"
1500
- ]).default(import_fixparser.MDEntryType.Bid).optional().describe("Market data entry type")
1501
- }),
1502
- { name: "MarketDataRequestInput" }
1503
- )
300
+ description: "Sends a request for Market Data with the given symbol. IMPORTANT: All parameters must be explicitly provided by the user - no assumptions will be made.",
301
+ inputSchema: marketDataRequestInputSchema
1504
302
  }
1505
303
  ]
1506
304
  };
@@ -1509,10 +307,8 @@ var MCPLocal = class {
1509
307
  const { name, arguments: args } = request.params;
1510
308
  switch (name) {
1511
309
  case "parse": {
1512
- const { fixString } = import_zod5.z.object({
1513
- fixString: import_zod5.z.string().describe("FIX message string to parse")
1514
- }).parse(args || {});
1515
310
  try {
311
+ const { fixString } = validateArgs(args, parseInputSchema);
1516
312
  const parsedMessage = this.parser?.parse(fixString);
1517
313
  if (!parsedMessage || parsedMessage.length === 0) {
1518
314
  return {
@@ -1524,7 +320,8 @@ var MCPLocal = class {
1524
320
  content: [
1525
321
  {
1526
322
  type: "text",
1527
- text: `Parsed FIX message: ${fixString} (placeholder implementation)`
323
+ text: `${parsedMessage[0].description}
324
+ ${parsedMessage[0].messageTypeDescription}`
1528
325
  }
1529
326
  ]
1530
327
  };
@@ -1534,17 +331,15 @@ var MCPLocal = class {
1534
331
  content: [
1535
332
  {
1536
333
  type: "text",
1537
- text: "Error: Failed to parse FIX string"
334
+ text: `Error: ${error instanceof Error ? error.message : "Failed to parse FIX string"}`
1538
335
  }
1539
336
  ]
1540
337
  };
1541
338
  }
1542
339
  }
1543
340
  case "parseToJSON": {
1544
- const { fixString } = import_zod5.z.object({
1545
- fixString: import_zod5.z.string().describe("FIX message string to parse")
1546
- }).parse(args || {});
1547
341
  try {
342
+ const { fixString } = validateArgs(args, parseToJSONInputSchema);
1548
343
  const parsedMessage = this.parser?.parse(fixString);
1549
344
  if (!parsedMessage || parsedMessage.length === 0) {
1550
345
  return {
@@ -1556,7 +351,7 @@ var MCPLocal = class {
1556
351
  content: [
1557
352
  {
1558
353
  type: "text",
1559
- text: JSON.stringify({ fixString, parsed: "placeholder" })
354
+ text: `${parsedMessage[0].toFIXJSON()}`
1560
355
  }
1561
356
  ]
1562
357
  };
@@ -1566,217 +361,192 @@ var MCPLocal = class {
1566
361
  content: [
1567
362
  {
1568
363
  type: "text",
1569
- text: "Error: Failed to parse FIX string"
364
+ text: `Error: ${error instanceof Error ? error.message : "Failed to parse FIX string"}`
1570
365
  }
1571
366
  ]
1572
367
  };
1573
368
  }
1574
369
  }
1575
- case "newOrderSingle": {
1576
- const { clOrdID, handlInst, quantity, price, ordType, side, symbol, timeInForce } = import_zod5.z.object({
1577
- clOrdID: import_zod5.z.string().describe("Client Order ID"),
1578
- handlInst: import_zod5.z.enum(["1", "2", "3"]).default(import_fixparser.HandlInst.AutomatedExecutionNoIntervention).optional().describe("Handling instruction"),
1579
- quantity: import_zod5.z.number().describe("Order quantity"),
1580
- price: import_zod5.z.number().describe("Order price"),
1581
- ordType: import_zod5.z.enum([
1582
- "1",
1583
- "2",
1584
- "3",
1585
- "4",
1586
- "5",
1587
- "6",
1588
- "7",
1589
- "8",
1590
- "9",
1591
- "A",
1592
- "B",
1593
- "C",
1594
- "D",
1595
- "E",
1596
- "F",
1597
- "G",
1598
- "H",
1599
- "I",
1600
- "J",
1601
- "K",
1602
- "L",
1603
- "M",
1604
- "P",
1605
- "Q",
1606
- "R",
1607
- "S"
1608
- ]).default(import_fixparser.OrdType.Market).optional().describe("Order type"),
1609
- side: import_zod5.z.enum([
1610
- "1",
1611
- "2",
1612
- "3",
1613
- "4",
1614
- "5",
1615
- "6",
1616
- "7",
1617
- "8",
1618
- "9",
1619
- "A",
1620
- "B",
1621
- "C",
1622
- "D",
1623
- "E",
1624
- "F",
1625
- "G",
1626
- "H"
1627
- ]).describe("Order side (1=Buy, 2=Sell)"),
1628
- symbol: import_zod5.z.string().describe("Trading symbol"),
1629
- timeInForce: import_zod5.z.enum(["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C"]).default(import_fixparser.TimeInForce.Day).optional().describe("Time in force")
1630
- }).parse(args || {});
1631
- const response = new Promise((resolve) => {
1632
- this.pendingRequests.set(clOrdID, resolve);
1633
- });
1634
- const order = this.parser?.createMessage(
1635
- new import_fixparser.Field(import_fixparser.Fields.MsgType, import_fixparser.Messages.NewOrderSingle),
1636
- new import_fixparser.Field(import_fixparser.Fields.MsgSeqNum, this.parser?.getNextTargetMsgSeqNum()),
1637
- new import_fixparser.Field(import_fixparser.Fields.SenderCompID, this.parser?.sender),
1638
- new import_fixparser.Field(import_fixparser.Fields.TargetCompID, this.parser?.target),
1639
- new import_fixparser.Field(import_fixparser.Fields.SendingTime, this.parser?.getTimestamp()),
1640
- new import_fixparser.Field(import_fixparser.Fields.ClOrdID, clOrdID),
1641
- new import_fixparser.Field(import_fixparser.Fields.Side, side),
1642
- new import_fixparser.Field(import_fixparser.Fields.Symbol, symbol),
1643
- new import_fixparser.Field(import_fixparser.Fields.OrderQty, quantity),
1644
- new import_fixparser.Field(import_fixparser.Fields.Price, price),
1645
- new import_fixparser.Field(import_fixparser.Fields.OrdType, ordType),
1646
- new import_fixparser.Field(import_fixparser.Fields.HandlInst, handlInst),
1647
- new import_fixparser.Field(import_fixparser.Fields.TimeInForce, timeInForce),
1648
- new import_fixparser.Field(import_fixparser.Fields.TransactTime, this.parser?.getTimestamp())
1649
- );
1650
- if (!this.parser?.connected) {
1651
- this.logger?.log({
1652
- level: "error",
1653
- message: "FIXParser (MCP): -- Not connected. Ignoring message."
370
+ case "verifyOrder": {
371
+ try {
372
+ const { clOrdID, handlInst, quantity, price, ordType, side, symbol, timeInForce } = validateArgs(args, orderSchema);
373
+ this.verifiedOrders.set(clOrdID, {
374
+ clOrdID,
375
+ handlInst,
376
+ quantity,
377
+ price,
378
+ ordType,
379
+ side,
380
+ symbol,
381
+ timeInForce
1654
382
  });
383
+ return {
384
+ content: [
385
+ {
386
+ type: "text",
387
+ text: `VERIFICATION: All parameters valid. Ready to proceed with order execution.
388
+
389
+ Parameters verified:
390
+ - ClOrdID: ${clOrdID}
391
+ - HandlInst: ${handlInst}
392
+ - Quantity: ${quantity}
393
+ - Price: ${price}
394
+ - OrdType: ${ordType}
395
+ - Side: ${side}
396
+ - Symbol: ${symbol}
397
+ - TimeInForce: ${timeInForce}
398
+
399
+ To execute this order, call the executeOrder tool with these exact same parameters.`
400
+ }
401
+ ]
402
+ };
403
+ } catch (error) {
1655
404
  return {
1656
405
  isError: true,
1657
406
  content: [
1658
407
  {
1659
408
  type: "text",
1660
- text: "Error: Not connected. Ignoring message."
409
+ text: `Error: ${error instanceof Error ? error.message : "Failed to verify order parameters"}`
410
+ }
411
+ ]
412
+ };
413
+ }
414
+ }
415
+ case "executeOrder": {
416
+ try {
417
+ const { clOrdID, handlInst, quantity, price, ordType, side, symbol, timeInForce } = validateArgs(args, orderSchema);
418
+ const verifiedOrder = this.verifiedOrders.get(clOrdID);
419
+ if (!verifiedOrder) {
420
+ return {
421
+ isError: true,
422
+ content: [
423
+ {
424
+ type: "text",
425
+ text: `Error: Order ${clOrdID} has not been verified. Please call verifyOrder first.`
426
+ }
427
+ ]
428
+ };
429
+ }
430
+ if (verifiedOrder.handlInst !== handlInst || verifiedOrder.quantity !== quantity || verifiedOrder.price !== price || verifiedOrder.ordType !== ordType || verifiedOrder.side !== side || verifiedOrder.symbol !== symbol || verifiedOrder.timeInForce !== timeInForce) {
431
+ return {
432
+ isError: true,
433
+ content: [
434
+ {
435
+ type: "text",
436
+ text: "Error: Order parameters do not match the verified order. Please use the exact same parameters that were verified."
437
+ }
438
+ ]
439
+ };
440
+ }
441
+ const response = new Promise((resolve) => {
442
+ this.pendingRequests.set(clOrdID, resolve);
443
+ });
444
+ const order = this.parser?.createMessage(
445
+ new import_fixparser.Field(import_fixparser.Fields.MsgType, import_fixparser.Messages.NewOrderSingle),
446
+ new import_fixparser.Field(import_fixparser.Fields.MsgSeqNum, this.parser?.getNextTargetMsgSeqNum()),
447
+ new import_fixparser.Field(import_fixparser.Fields.SenderCompID, this.parser?.sender),
448
+ new import_fixparser.Field(import_fixparser.Fields.TargetCompID, this.parser?.target),
449
+ new import_fixparser.Field(import_fixparser.Fields.SendingTime, this.parser?.getTimestamp()),
450
+ new import_fixparser.Field(import_fixparser.Fields.ClOrdID, clOrdID),
451
+ new import_fixparser.Field(import_fixparser.Fields.Side, side),
452
+ new import_fixparser.Field(import_fixparser.Fields.Symbol, symbol),
453
+ new import_fixparser.Field(import_fixparser.Fields.OrderQty, quantity),
454
+ new import_fixparser.Field(import_fixparser.Fields.Price, price),
455
+ new import_fixparser.Field(import_fixparser.Fields.OrdType, ordType),
456
+ new import_fixparser.Field(import_fixparser.Fields.HandlInst, handlInst),
457
+ new import_fixparser.Field(import_fixparser.Fields.TimeInForce, timeInForce),
458
+ new import_fixparser.Field(import_fixparser.Fields.TransactTime, this.parser?.getTimestamp())
459
+ );
460
+ if (!this.parser?.connected) {
461
+ return {
462
+ isError: true,
463
+ content: [
464
+ {
465
+ type: "text",
466
+ text: "Error: Not connected. Ignoring message."
467
+ }
468
+ ]
469
+ };
470
+ }
471
+ this.parser?.send(order);
472
+ const fixData = await response;
473
+ this.verifiedOrders.delete(clOrdID);
474
+ return {
475
+ content: [
476
+ {
477
+ type: "text",
478
+ text: fixData.messageType === import_fixparser.Messages.Reject ? `Reject message for order ${clOrdID}: ${JSON.stringify(fixData.toFIXJSON())}` : `Execution Report for order ${clOrdID}: ${JSON.stringify(fixData.toFIXJSON())}`
479
+ }
480
+ ]
481
+ };
482
+ } catch (error) {
483
+ return {
484
+ isError: true,
485
+ content: [
486
+ {
487
+ type: "text",
488
+ text: `Error: ${error instanceof Error ? error.message : "Failed to execute order"}`
1661
489
  }
1662
490
  ]
1663
491
  };
1664
492
  }
1665
- this.parser?.send(order);
1666
- this.logger?.log({
1667
- level: "info",
1668
- message: `FIXParser (MCP): (${this.parser?.protocol?.toUpperCase()}): >> sent ${order?.description}`
1669
- });
1670
- const fixData = await response;
1671
- return {
1672
- content: [
1673
- {
1674
- type: "text",
1675
- text: `Execution Report for order ${clOrdID}: ${JSON.stringify(fixData.toFIXJSON())}`
1676
- }
1677
- ]
1678
- };
1679
493
  }
1680
494
  case "marketDataRequest": {
1681
- const { mdUpdateType, symbol, mdReqID, subscriptionRequestType, mdEntryType } = import_zod5.z.object({
1682
- mdUpdateType: import_zod5.z.enum(["0", "1"]).default("0").optional().describe("Market data update type"),
1683
- symbol: import_zod5.z.string().describe("Trading symbol"),
1684
- mdReqID: import_zod5.z.string().describe("Market data request ID"),
1685
- subscriptionRequestType: import_zod5.z.enum(["0", "1", "2"]).default(import_fixparser.SubscriptionRequestType.SnapshotAndUpdates).optional().describe("Subscription request type"),
1686
- mdEntryType: import_zod5.z.enum([
1687
- "0",
1688
- "1",
1689
- "2",
1690
- "3",
1691
- "4",
1692
- "5",
1693
- "6",
1694
- "7",
1695
- "8",
1696
- "9",
1697
- "A",
1698
- "B",
1699
- "C",
1700
- "D",
1701
- "E",
1702
- "F",
1703
- "G",
1704
- "H",
1705
- "J",
1706
- "K",
1707
- "L",
1708
- "M",
1709
- "N",
1710
- "O",
1711
- "P",
1712
- "Q",
1713
- "S",
1714
- "R",
1715
- "T",
1716
- "U",
1717
- "V",
1718
- "W",
1719
- "X",
1720
- "Y",
1721
- "Z",
1722
- "a",
1723
- "b",
1724
- "c",
1725
- "d",
1726
- "e",
1727
- "g",
1728
- "h",
1729
- "i",
1730
- "t"
1731
- ]).default(import_fixparser.MDEntryType.Bid).optional().describe("Market data entry type")
1732
- }).parse(args || {});
1733
- const response = new Promise((resolve) => {
1734
- this.pendingRequests.set(mdReqID, resolve);
1735
- });
1736
- const marketDataRequest = this.parser?.createMessage(
1737
- new import_fixparser.Field(import_fixparser.Fields.MsgType, import_fixparser.Messages.MarketDataRequest),
1738
- new import_fixparser.Field(import_fixparser.Fields.SenderCompID, this.parser?.sender),
1739
- new import_fixparser.Field(import_fixparser.Fields.MsgSeqNum, this.parser?.getNextTargetMsgSeqNum()),
1740
- new import_fixparser.Field(import_fixparser.Fields.TargetCompID, this.parser?.target),
1741
- new import_fixparser.Field(import_fixparser.Fields.SendingTime, this.parser?.getTimestamp()),
1742
- new import_fixparser.Field(import_fixparser.Fields.MarketDepth, 0),
1743
- new import_fixparser.Field(import_fixparser.Fields.MDUpdateType, mdUpdateType),
1744
- new import_fixparser.Field(import_fixparser.Fields.NoRelatedSym, 1),
1745
- new import_fixparser.Field(import_fixparser.Fields.Symbol, symbol),
1746
- new import_fixparser.Field(import_fixparser.Fields.MDReqID, mdReqID),
1747
- new import_fixparser.Field(import_fixparser.Fields.SubscriptionRequestType, subscriptionRequestType),
1748
- new import_fixparser.Field(import_fixparser.Fields.NoMDEntryTypes, 1),
1749
- new import_fixparser.Field(import_fixparser.Fields.MDEntryType, mdEntryType)
1750
- );
1751
- if (!this.parser?.connected) {
1752
- this.logger?.log({
1753
- level: "error",
1754
- message: "FIXParser (MCP): -- Not connected. Ignoring message."
495
+ try {
496
+ const { mdUpdateType, symbol, mdReqID, subscriptionRequestType, mdEntryType } = validateArgs(
497
+ args,
498
+ marketDataRequestInputSchema
499
+ );
500
+ const response = new Promise((resolve) => {
501
+ this.pendingRequests.set(mdReqID, resolve);
1755
502
  });
503
+ const marketDataRequest = this.parser?.createMessage(
504
+ new import_fixparser.Field(import_fixparser.Fields.MsgType, import_fixparser.Messages.MarketDataRequest),
505
+ new import_fixparser.Field(import_fixparser.Fields.SenderCompID, this.parser?.sender),
506
+ new import_fixparser.Field(import_fixparser.Fields.MsgSeqNum, this.parser?.getNextTargetMsgSeqNum()),
507
+ new import_fixparser.Field(import_fixparser.Fields.TargetCompID, this.parser?.target),
508
+ new import_fixparser.Field(import_fixparser.Fields.SendingTime, this.parser?.getTimestamp()),
509
+ new import_fixparser.Field(import_fixparser.Fields.MarketDepth, 0),
510
+ new import_fixparser.Field(import_fixparser.Fields.MDUpdateType, mdUpdateType),
511
+ new import_fixparser.Field(import_fixparser.Fields.NoRelatedSym, 1),
512
+ new import_fixparser.Field(import_fixparser.Fields.Symbol, symbol),
513
+ new import_fixparser.Field(import_fixparser.Fields.MDReqID, mdReqID),
514
+ new import_fixparser.Field(import_fixparser.Fields.SubscriptionRequestType, subscriptionRequestType),
515
+ new import_fixparser.Field(import_fixparser.Fields.NoMDEntryTypes, 1),
516
+ new import_fixparser.Field(import_fixparser.Fields.MDEntryType, mdEntryType)
517
+ );
518
+ if (!this.parser?.connected) {
519
+ return {
520
+ isError: true,
521
+ content: [
522
+ {
523
+ type: "text",
524
+ text: "Error: Not connected. Ignoring message."
525
+ }
526
+ ]
527
+ };
528
+ }
529
+ this.parser?.send(marketDataRequest);
530
+ const fixData = await response;
531
+ return {
532
+ content: [
533
+ {
534
+ type: "text",
535
+ text: `Market data for ${symbol}: ${JSON.stringify(fixData.toFIXJSON())}`
536
+ }
537
+ ]
538
+ };
539
+ } catch (error) {
1756
540
  return {
1757
541
  isError: true,
1758
542
  content: [
1759
543
  {
1760
544
  type: "text",
1761
- text: "Error: Not connected. Ignoring message."
545
+ text: `Error: ${error instanceof Error ? error.message : "Failed to request market data"}`
1762
546
  }
1763
547
  ]
1764
548
  };
1765
549
  }
1766
- this.parser?.send(marketDataRequest);
1767
- this.logger?.log({
1768
- level: "info",
1769
- message: `FIXParser (MCP): (${this.parser?.protocol?.toUpperCase()}): >> sent ${marketDataRequest?.description}`
1770
- });
1771
- const fixData = await response;
1772
- return {
1773
- content: [
1774
- {
1775
- type: "text",
1776
- text: `Market data for ${symbol}: ${JSON.stringify(fixData.toFIXJSON())}`
1777
- }
1778
- ]
1779
- };
1780
550
  }
1781
551
  default:
1782
552
  throw new Error(`Unknown tool: ${name}`);
@@ -1808,8 +578,54 @@ var MCPLocal = class {
1808
578
  ]
1809
579
  },
1810
580
  {
1811
- name: "newOrderSingle",
1812
- description: "Creates and sends a New Order Single",
581
+ name: "verifyOrder",
582
+ description: "Verifies all parameters for a New Order Single. This is the first step - verification only, no order is sent.",
583
+ arguments: [
584
+ {
585
+ name: "clOrdID",
586
+ description: "Client Order ID",
587
+ required: true
588
+ },
589
+ {
590
+ name: "handlInst",
591
+ description: "Handling instruction (1=Manual, 2=Automated, 3=AutomatedNoIntervention)",
592
+ required: true
593
+ },
594
+ {
595
+ name: "quantity",
596
+ description: "Order quantity",
597
+ required: true
598
+ },
599
+ {
600
+ name: "price",
601
+ description: "Order price",
602
+ required: true
603
+ },
604
+ {
605
+ name: "ordType",
606
+ description: "Order type (1=Market, 2=Limit, 3=Stop)",
607
+ required: true
608
+ },
609
+ {
610
+ name: "side",
611
+ description: "Order side (1=Buy, 2=Sell, 3=BuyMinus, 4=SellPlus, 5=SellShort, 6=SellShortExempt, 7=Undisclosed, 8=Cross, 9=CrossShort, A=CrossShortExempt, B=AsDefined, C=Opposite, D=Subscribe, E=Redeem, F=Lend, G=Borrow, H=SellUndisclosed)",
612
+ required: true
613
+ },
614
+ {
615
+ name: "symbol",
616
+ description: "Trading symbol",
617
+ required: true
618
+ },
619
+ {
620
+ name: "timeInForce",
621
+ description: "Time in force (0=Day, 1=Good Till Cancel, 2=At Opening, 3=Immediate or Cancel, 4=Fill or Kill, 5=Good Till Crossing, 6=Good Till Date)",
622
+ required: true
623
+ }
624
+ ]
625
+ },
626
+ {
627
+ name: "executeOrder",
628
+ description: "Executes a New Order Single after verification. This is the second step - only call after successful verification.",
1813
629
  arguments: [
1814
630
  {
1815
631
  name: "clOrdID",
@@ -1818,8 +634,8 @@ var MCPLocal = class {
1818
634
  },
1819
635
  {
1820
636
  name: "handlInst",
1821
- description: "Handling instruction",
1822
- required: false
637
+ description: "Handling instruction (1=Manual, 2=Automated, 3=AutomatedNoIntervention)",
638
+ required: true
1823
639
  },
1824
640
  {
1825
641
  name: "quantity",
@@ -1833,12 +649,12 @@ var MCPLocal = class {
1833
649
  },
1834
650
  {
1835
651
  name: "ordType",
1836
- description: "Order type",
1837
- required: false
652
+ description: "Order type (1=Market, 2=Limit, 3=Stop)",
653
+ required: true
1838
654
  },
1839
655
  {
1840
656
  name: "side",
1841
- description: "Order side (1=Buy, 2=Sell)",
657
+ description: "Order side (1=Buy, 2=Sell, 3=BuyMinus, 4=SellPlus, 5=SellShort, 6=SellShortExempt, 7=Undisclosed, 8=Cross, 9=CrossShort, A=CrossShortExempt, B=AsDefined, C=Opposite, D=Subscribe, E=Redeem, F=Lend, G=Borrow, H=SellUndisclosed)",
1842
658
  required: true
1843
659
  },
1844
660
  {
@@ -1848,19 +664,19 @@ var MCPLocal = class {
1848
664
  },
1849
665
  {
1850
666
  name: "timeInForce",
1851
- description: "Time in force",
1852
- required: false
667
+ description: "Time in force (0=Day, 1=Good Till Cancel, 2=At Opening, 3=Immediate or Cancel, 4=Fill or Kill, 5=Good Till Crossing, 6=Good Till Date)",
668
+ required: true
1853
669
  }
1854
670
  ]
1855
671
  },
1856
672
  {
1857
673
  name: "marketDataRequest",
1858
- description: "Sends a request for Market Data with the given symbol",
674
+ description: "Sends a request for Market Data with the given symbol. IMPORTANT: All parameters must be explicitly provided by the user - no assumptions will be made.",
1859
675
  arguments: [
1860
676
  {
1861
677
  name: "mdUpdateType",
1862
- description: "Market data update type",
1863
- required: false
678
+ description: "Market data update type (0=FullRefresh, 1=IncrementalRefresh)",
679
+ required: true
1864
680
  },
1865
681
  {
1866
682
  name: "symbol",
@@ -1874,13 +690,13 @@ var MCPLocal = class {
1874
690
  },
1875
691
  {
1876
692
  name: "subscriptionRequestType",
1877
- description: "Subscription request type",
1878
- required: false
693
+ description: "Subscription request type (0=Snapshot + Updates, 1=Snapshot, 2=Unsubscribe)",
694
+ required: true
1879
695
  },
1880
696
  {
1881
697
  name: "mdEntryType",
1882
- description: "Market data entry type",
1883
- required: false
698
+ description: "Market data entry type (0=Bid, 1=Offer, 2=Trade, 3=Index Value, 4=Opening Price)",
699
+ required: true
1884
700
  }
1885
701
  ]
1886
702
  }
@@ -1918,7 +734,7 @@ var MCPLocal = class {
1918
734
  ]
1919
735
  };
1920
736
  }
1921
- case "newOrderSingle": {
737
+ case "verifyOrder": {
1922
738
  const { clOrdID, handlInst, quantity, price, ordType, side, symbol, timeInForce } = args || {};
1923
739
  return {
1924
740
  messages: [
@@ -1927,17 +743,68 @@ var MCPLocal = class {
1927
743
  content: {
1928
744
  type: "text",
1929
745
  text: [
1930
- "Create a New Order Single FIX message with the following parameters:",
746
+ "You are an AI assistant that helps users verify FIX New Order Single parameters.",
747
+ "This is STEP 1 of 2 - VERIFICATION ONLY. No order will be sent at this stage.",
748
+ "",
749
+ "You must verify that all required fields are provided and valid:",
750
+ "- ClOrdID (Client Order ID)",
751
+ "- HandlInst (1=Manual, 2=Automated, 3=AutomatedNoIntervention)",
752
+ "- Quantity (Order quantity)",
753
+ "- Price (Order price)",
754
+ "- OrdType (1=Market, 2=Limit, 3=Stop)",
755
+ "- Side (1=Buy, 2=Sell, 3=BuyMinus, 4=SellPlus, 5=SellShort, 6=SellShortExempt, 7=Undisclosed, 8=Cross, 9=CrossShort, A=CrossShortExempt, B=AsDefined, C=Opposite, D=Subscribe, E=Redeem, F=Lend, G=Borrow, H=SellUndisclosed)",
756
+ "- Symbol (Trading symbol)",
757
+ "- TimeInForce (0=Day, 1=Good Till Cancel, 2=At Opening, 3=Immediate or Cancel, 4=Fill or Kill, 5=Good Till Crossing, 6=Good Till Date)",
758
+ "",
759
+ "Current parameters to verify:",
1931
760
  `- ClOrdID: ${clOrdID}`,
1932
- `- HandlInst: ${handlInst ?? "default"}`,
761
+ `- HandlInst: ${handlInst}`,
1933
762
  `- Quantity: ${quantity}`,
1934
763
  `- Price: ${price}`,
1935
- `- OrdType: ${ordType ?? "default (Market)"}`,
764
+ `- OrdType: ${ordType}`,
1936
765
  `- Side: ${side}`,
1937
766
  `- Symbol: ${symbol}`,
1938
- `- TimeInForce: ${timeInForce ?? "default (Day)"}`,
767
+ `- TimeInForce: ${timeInForce}`,
1939
768
  "",
1940
- "Format the response as a JSON object with FIX tag numbers as keys and their corresponding values."
769
+ "If all parameters are valid, respond with:",
770
+ "`VERIFICATION: All parameters valid. Ready to proceed.`",
771
+ "",
772
+ "Otherwise, list the missing or invalid ones.",
773
+ "",
774
+ "IMPORTANT: This is only verification. To actually send the order, the user must call the executeOrder tool with the same parameters."
775
+ ].join("\n")
776
+ }
777
+ }
778
+ ]
779
+ };
780
+ }
781
+ case "executeOrder": {
782
+ const { clOrdID, handlInst, quantity, price, ordType, side, symbol, timeInForce } = args || {};
783
+ return {
784
+ messages: [
785
+ {
786
+ role: "user",
787
+ content: {
788
+ type: "text",
789
+ text: [
790
+ "You are an AI assistant that helps users execute FIX New Order Single messages.",
791
+ "This is STEP 2 of 2 - EXECUTION. This will send the order to the market.",
792
+ "",
793
+ "IMPORTANT: This tool should only be called after successful verification of all parameters.",
794
+ "",
795
+ "Parameters to execute:",
796
+ `- ClOrdID: ${clOrdID}`,
797
+ `- HandlInst: ${handlInst}`,
798
+ `- Quantity: ${quantity}`,
799
+ `- Price: ${price}`,
800
+ `- OrdType: ${ordType}`,
801
+ `- Side: ${side}`,
802
+ `- Symbol: ${symbol}`,
803
+ `- TimeInForce: ${timeInForce}`,
804
+ "",
805
+ "IMPORTANT: The response will be either:",
806
+ "1. An Execution Report (MsgType=8) if the order was successfully placed",
807
+ "2. A Reject message (MsgType=3) if the order failed to execute (e.g., due to missing or invalid parameters)"
1941
808
  ].join("\n")
1942
809
  }
1943
810
  }
@@ -1953,14 +820,27 @@ var MCPLocal = class {
1953
820
  content: {
1954
821
  type: "text",
1955
822
  text: [
1956
- "Create a Market Data Request FIX message with the following parameters:",
1957
- `- MDUpdateType: ${mdUpdateType ?? "default (0 = FullRefresh)"}`,
823
+ "You are an AI assistant that helps users create FIX Market Data Request messages.",
824
+ "You must **first verify** that all required fields are provided:",
825
+ "- MDUpdateType (0=FullRefresh, 1=IncrementalRefresh)",
826
+ "- Symbol (Trading symbol)",
827
+ "- MDReqID (Market data request ID)",
828
+ "- SubscriptionRequestType (0=Snapshot + Updates, 1=Snapshot, 2=Unsubscribe)",
829
+ "- MDEntryType (0=Bid, 1=Offer, 2=Trade, 3=Index Value, 4=Opening Price)",
830
+ "",
831
+ "Only when all fields are present and valid, respond with:",
832
+ "`VERIFICATION: All parameters valid. Ready to proceed.`",
833
+ "",
834
+ "Otherwise, list the missing or invalid ones.",
835
+ "",
836
+ "Do not create the FIX message until verification is complete.",
837
+ "",
838
+ "Current parameters:",
839
+ `- MDUpdateType: ${mdUpdateType}`,
1958
840
  `- Symbol: ${symbol}`,
1959
841
  `- MDReqID: ${mdReqID}`,
1960
- `- SubscriptionRequestType: ${subscriptionRequestType ?? "default (0 = Snapshot + Updates)"}`,
1961
- `- MDEntryType: ${mdEntryType ?? "default (0 = Bid)"}`,
1962
- "",
1963
- "Format the response as a JSON object with FIX tag numbers as keys and their corresponding values."
842
+ `- SubscriptionRequestType: ${subscriptionRequestType}`,
843
+ `- MDEntryType: ${mdEntryType}`
1964
844
  ].join("\n")
1965
845
  }
1966
846
  }