fixparser-plugin-mcp 9.1.7-af630b11 → 9.1.7-f34f63d7

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.
@@ -1,9 +1,7 @@
1
1
  #!/usr/bin/env node
2
- "use strict";var g=require("fixparser");var F=require("@modelcontextprotocol/sdk/server/index.js"),N=require("@modelcontextprotocol/sdk/server/stdio.js"),S=require("@modelcontextprotocol/sdk/types.js"),c=require("zod"),l=require("zod"),q=require("zod"),P=require("zod"),C=require("zod"),i=require("fixparser"),z=Symbol("Let zodToJsonSchema decide on which parser to use"),D={name:void 0,$refStrategy:"root",basePath:["#"],effectStrategy:"input",pipeStrategy:"all",dateStrategy:"format:date-time",mapStrategy:"entries",removeAdditionalStrategy:"passthrough",allowedAdditionalProperties:!0,rejectedAdditionalProperties:!1,definitionPath:"definitions",target:"jsonSchema7",strictUnions:!1,definitions:{},errorMessages:!1,markdownDescription:!1,patternStrategy:"escape",applyRegexFlags:!1,emailStrategy:"format:email",base64Strategy:"contentEncoding:base64",nameStrategy:"ref"},U=t=>typeof t=="string"?{...D,name:t}:{...D,...t},B=t=>{let e=U(t),n=e.name!==void 0?[...e.basePath,e.definitionPath,e.name]:e.basePath;return{...e,currentPath:n,propertyPath:void 0,seen:new Map(Object.entries(e.definitions).map(([r,a])=>[a._def,{def:a._def,path:[...e.basePath,e.definitionPath,r],jsonSchema:void 0}]))}};function _(t,e,n,r){r?.errorMessages&&n&&(t.errorMessage={...t.errorMessage,[e]:n})}function m(t,e,n,r,a){t[e]=n,_(t,e,r,a)}function J(){return{}}function H(t,e){let n={type:"array"};return t.type?._def&&t.type?._def?.typeName!==q.ZodFirstPartyTypeKind.ZodAny&&(n.items=d(t.type._def,{...e,currentPath:[...e.currentPath,"items"]})),t.minLength&&m(n,"minItems",t.minLength.value,t.minLength.message,e),t.maxLength&&m(n,"maxItems",t.maxLength.value,t.maxLength.message,e),t.exactLength&&(m(n,"minItems",t.exactLength.value,t.exactLength.message,e),m(n,"maxItems",t.exactLength.value,t.exactLength.message,e)),n}function K(t,e){let n={type:"integer",format:"int64"};if(!t.checks)return n;for(let r of t.checks)switch(r.kind){case"min":e.target==="jsonSchema7"?r.inclusive?m(n,"minimum",r.value,r.message,e):m(n,"exclusiveMinimum",r.value,r.message,e):(r.inclusive||(n.exclusiveMinimum=!0),m(n,"minimum",r.value,r.message,e));break;case"max":e.target==="jsonSchema7"?r.inclusive?m(n,"maximum",r.value,r.message,e):m(n,"exclusiveMaximum",r.value,r.message,e):(r.inclusive||(n.exclusiveMaximum=!0),m(n,"maximum",r.value,r.message,e));break;case"multipleOf":m(n,"multipleOf",r.value,r.message,e);break}return n}function G(){return{type:"boolean"}}function R(t,e){return d(t.type._def,e)}var V=(t,e)=>d(t.innerType._def,e);function Z(t,e,n){let r=n??e.dateStrategy;if(Array.isArray(r))return{anyOf:r.map((a,s)=>Z(t,e,a))};switch(r){case"string":case"format:date-time":return{type:"string",format:"date-time"};case"format:date":return{type:"string",format:"date"};case"integer":return W(t,e)}}var W=(t,e)=>{let n={type:"integer",format:"unix-time"};if(e.target==="openApi3")return n;for(let r of t.checks)switch(r.kind){case"min":m(n,"minimum",r.value,r.message,e);break;case"max":m(n,"maximum",r.value,r.message,e);break}return n};function Q(t,e){return{...d(t.innerType._def,e),default:t.defaultValue()}}function Y(t,e){return e.effectStrategy==="input"?d(t.schema._def,e):{}}function ee(t){return{type:"string",enum:Array.from(t.values)}}var te=t=>"type"in t&&t.type==="string"?!1:"allOf"in t;function re(t,e){let n=[d(t.left._def,{...e,currentPath:[...e.currentPath,"allOf","0"]}),d(t.right._def,{...e,currentPath:[...e.currentPath,"allOf","1"]})].filter(s=>!!s),r=e.target==="jsonSchema2019-09"?{unevaluatedProperties:!1}:void 0,a=[];return n.forEach(s=>{if(te(s))a.push(...s.allOf),s.unevaluatedProperties===void 0&&(r=void 0);else{let u=s;if("additionalProperties"in s&&s.additionalProperties===!1){let{additionalProperties:p,...o}=s;u=o}else r=void 0;a.push(u)}}),a.length?{allOf:a,...r}:void 0}function ne(t,e){let n=typeof t.value;return n!=="bigint"&&n!=="number"&&n!=="boolean"&&n!=="string"?{type:Array.isArray(t.value)?"array":"object"}:e.target==="openApi3"?{type:n==="bigint"?"integer":n,enum:[t.value]}:{type:n==="bigint"?"integer":n,const:t.value}}var O=void 0,h={cuid:/^[cC][^\s-]{8,}$/,cuid2:/^[0-9a-z]+$/,ulid:/^[0-9A-HJKMNP-TV-Z]{26}$/,email:/^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-\.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9\-]*\.)+[a-zA-Z]{2,}$/,emoji:()=>(O===void 0&&(O=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),O),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}$/,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])$/,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])$/,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})))$/,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])$/,base64:/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,base64url:/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,nanoid:/^[a-zA-Z0-9_-]{21}$/,jwt:/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/};function E(t,e){let n={type:"string"};if(t.checks)for(let r of t.checks)switch(r.kind){case"min":m(n,"minLength",typeof n.minLength=="number"?Math.max(n.minLength,r.value):r.value,r.message,e);break;case"max":m(n,"maxLength",typeof n.maxLength=="number"?Math.min(n.maxLength,r.value):r.value,r.message,e);break;case"email":switch(e.emailStrategy){case"format:email":b(n,"email",r.message,e);break;case"format:idn-email":b(n,"idn-email",r.message,e);break;case"pattern:zod":y(n,h.email,r.message,e);break}break;case"url":b(n,"uri",r.message,e);break;case"uuid":b(n,"uuid",r.message,e);break;case"regex":y(n,r.regex,r.message,e);break;case"cuid":y(n,h.cuid,r.message,e);break;case"cuid2":y(n,h.cuid2,r.message,e);break;case"startsWith":y(n,RegExp(`^${w(r.value,e)}`),r.message,e);break;case"endsWith":y(n,RegExp(`${w(r.value,e)}$`),r.message,e);break;case"datetime":b(n,"date-time",r.message,e);break;case"date":b(n,"date",r.message,e);break;case"time":b(n,"time",r.message,e);break;case"duration":b(n,"duration",r.message,e);break;case"length":m(n,"minLength",typeof n.minLength=="number"?Math.max(n.minLength,r.value):r.value,r.message,e),m(n,"maxLength",typeof n.maxLength=="number"?Math.min(n.maxLength,r.value):r.value,r.message,e);break;case"includes":{y(n,RegExp(w(r.value,e)),r.message,e);break}case"ip":{r.version!=="v6"&&b(n,"ipv4",r.message,e),r.version!=="v4"&&b(n,"ipv6",r.message,e);break}case"base64url":y(n,h.base64url,r.message,e);break;case"jwt":y(n,h.jwt,r.message,e);break;case"cidr":{r.version!=="v6"&&y(n,h.ipv4Cidr,r.message,e),r.version!=="v4"&&y(n,h.ipv6Cidr,r.message,e);break}case"emoji":y(n,h.emoji(),r.message,e);break;case"ulid":{y(n,h.ulid,r.message,e);break}case"base64":{switch(e.base64Strategy){case"format:binary":{b(n,"binary",r.message,e);break}case"contentEncoding:base64":{m(n,"contentEncoding","base64",r.message,e);break}case"pattern:zod":{y(n,h.base64,r.message,e);break}}break}case"nanoid":y(n,h.nanoid,r.message,e);case"toLowerCase":case"toUpperCase":case"trim":break;default:}return n}function w(t,e){return e.patternStrategy==="escape"?ie(t):t}var ae=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function ie(t){let e="";for(let n=0;n<t.length;n++)ae.has(t[n])||(e+="\\"),e+=t[n];return e}function b(t,e,n,r){t.format||t.anyOf?.some(a=>a.format)?(t.anyOf||(t.anyOf=[]),t.format&&(t.anyOf.push({format:t.format,...t.errorMessage&&r.errorMessages&&{errorMessage:{format:t.errorMessage.format}}}),delete t.format,t.errorMessage&&(delete t.errorMessage.format,Object.keys(t.errorMessage).length===0&&delete t.errorMessage)),t.anyOf.push({format:e,...n&&r.errorMessages&&{errorMessage:{format:n}}})):m(t,"format",e,n,r)}function y(t,e,n,r){t.pattern||t.allOf?.some(a=>a.pattern)?(t.allOf||(t.allOf=[]),t.pattern&&(t.allOf.push({pattern:t.pattern,...t.errorMessage&&r.errorMessages&&{errorMessage:{pattern:t.errorMessage.pattern}}}),delete t.pattern,t.errorMessage&&(delete t.errorMessage.pattern,Object.keys(t.errorMessage).length===0&&delete t.errorMessage)),t.allOf.push({pattern:x(e,r),...n&&r.errorMessages&&{errorMessage:{pattern:n}}})):m(t,"pattern",x(e,r),n,r)}function x(t,e){if(!e.applyRegexFlags||!t.flags)return t.source;let n={i:t.flags.includes("i"),m:t.flags.includes("m"),s:t.flags.includes("s")},r=n.i?t.source.toLowerCase():t.source,a="",s=!1,u=!1,p=!1;for(let o=0;o<r.length;o++){if(s){a+=r[o],s=!1;continue}if(n.i){if(u){if(r[o].match(/[a-z]/)){p?(a+=r[o],a+=`${r[o-2]}-${r[o]}`.toUpperCase(),p=!1):r[o+1]==="-"&&r[o+2]?.match(/[a-z]/)?(a+=r[o],p=!0):a+=`${r[o]}${r[o].toUpperCase()}`;continue}}else if(r[o].match(/[a-z]/)){a+=`[${r[o]}${r[o].toUpperCase()}]`;continue}}if(n.m){if(r[o]==="^"){a+=`(^|(?<=[\r
2
+ "use strict";var g=require("fixparser");var x=require("@modelcontextprotocol/sdk/server/index.js"),_=require("@modelcontextprotocol/sdk/server/stdio.js"),S=require("@modelcontextprotocol/sdk/types.js"),u=require("zod"),p=require("zod"),Z=require("zod"),P=require("zod"),$=require("zod"),i=require("fixparser"),X=Symbol("Let zodToJsonSchema decide on which parser to use"),O={name:void 0,$refStrategy:"root",basePath:["#"],effectStrategy:"input",pipeStrategy:"all",dateStrategy:"format:date-time",mapStrategy:"entries",removeAdditionalStrategy:"passthrough",allowedAdditionalProperties:!0,rejectedAdditionalProperties:!1,definitionPath:"definitions",target:"jsonSchema7",strictUnions:!1,definitions:{},errorMessages:!1,markdownDescription:!1,patternStrategy:"escape",applyRegexFlags:!1,emailStrategy:"format:email",base64Strategy:"contentEncoding:base64",nameStrategy:"ref"},U=e=>typeof e=="string"?{...O,name:e}:{...O,...e},B=e=>{let t=U(e),n=t.name!==void 0?[...t.basePath,t.definitionPath,t.name]:t.basePath;return{...t,currentPath:n,propertyPath:void 0,seen:new Map(Object.entries(t.definitions).map(([r,a])=>[a._def,{def:a._def,path:[...t.basePath,t.definitionPath,r],jsonSchema:void 0}]))}};function N(e,t,n,r){r?.errorMessages&&n&&(e.errorMessage={...e.errorMessage,[t]:n})}function m(e,t,n,r,a){e[t]=n,N(e,t,r,a)}function J(){return{}}function H(e,t){let n={type:"array"};return e.type?._def&&e.type?._def?.typeName!==Z.ZodFirstPartyTypeKind.ZodAny&&(n.items=d(e.type._def,{...t,currentPath:[...t.currentPath,"items"]})),e.minLength&&m(n,"minItems",e.minLength.value,e.minLength.message,t),e.maxLength&&m(n,"maxItems",e.maxLength.value,e.maxLength.message,t),e.exactLength&&(m(n,"minItems",e.exactLength.value,e.exactLength.message,t),m(n,"maxItems",e.exactLength.value,e.exactLength.message,t)),n}function K(e,t){let n={type:"integer",format:"int64"};if(!e.checks)return n;for(let r of e.checks)switch(r.kind){case"min":t.target==="jsonSchema7"?r.inclusive?m(n,"minimum",r.value,r.message,t):m(n,"exclusiveMinimum",r.value,r.message,t):(r.inclusive||(n.exclusiveMinimum=!0),m(n,"minimum",r.value,r.message,t));break;case"max":t.target==="jsonSchema7"?r.inclusive?m(n,"maximum",r.value,r.message,t):m(n,"exclusiveMaximum",r.value,r.message,t):(r.inclusive||(n.exclusiveMaximum=!0),m(n,"maximum",r.value,r.message,t));break;case"multipleOf":m(n,"multipleOf",r.value,r.message,t);break}return n}function G(){return{type:"boolean"}}function E(e,t){return d(e.type._def,t)}var V=(e,t)=>d(e.innerType._def,t);function R(e,t,n){let r=n??t.dateStrategy;if(Array.isArray(r))return{anyOf:r.map((a,s)=>R(e,t,a))};switch(r){case"string":case"format:date-time":return{type:"string",format:"date-time"};case"format:date":return{type:"string",format:"date"};case"integer":return W(e,t)}}var W=(e,t)=>{let n={type:"integer",format:"unix-time"};if(t.target==="openApi3")return n;for(let r of e.checks)switch(r.kind){case"min":m(n,"minimum",r.value,r.message,t);break;case"max":m(n,"maximum",r.value,r.message,t);break}return n};function Q(e,t){return{...d(e.innerType._def,t),default:e.defaultValue()}}function Y(e,t){return t.effectStrategy==="input"?d(e.schema._def,t):{}}function ee(e){return{type:"string",enum:Array.from(e.values)}}var te=e=>"type"in e&&e.type==="string"?!1:"allOf"in e;function re(e,t){let n=[d(e.left._def,{...t,currentPath:[...t.currentPath,"allOf","0"]}),d(e.right._def,{...t,currentPath:[...t.currentPath,"allOf","1"]})].filter(s=>!!s),r=t.target==="jsonSchema2019-09"?{unevaluatedProperties:!1}:void 0,a=[];return n.forEach(s=>{if(te(s))a.push(...s.allOf),s.unevaluatedProperties===void 0&&(r=void 0);else{let c=s;if("additionalProperties"in s&&s.additionalProperties===!1){let{additionalProperties:l,...o}=s;c=o}else r=void 0;a.push(c)}}),a.length?{allOf:a,...r}:void 0}function ne(e,t){let n=typeof e.value;return n!=="bigint"&&n!=="number"&&n!=="boolean"&&n!=="string"?{type:Array.isArray(e.value)?"array":"object"}:t.target==="openApi3"?{type:n==="bigint"?"integer":n,enum:[e.value]}:{type:n==="bigint"?"integer":n,const:e.value}}var A=void 0,h={cuid:/^[cC][^\s-]{8,}$/,cuid2:/^[0-9a-z]+$/,ulid:/^[0-9A-HJKMNP-TV-Z]{26}$/,email:/^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-\.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9\-]*\.)+[a-zA-Z]{2,}$/,emoji:()=>(A===void 0&&(A=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),A),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}$/,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])$/,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])$/,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})))$/,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])$/,base64:/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,base64url:/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,nanoid:/^[a-zA-Z0-9_-]{21}$/,jwt:/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/};function C(e,t){let n={type:"string"};if(e.checks)for(let r of e.checks)switch(r.kind){case"min":m(n,"minLength",typeof n.minLength=="number"?Math.max(n.minLength,r.value):r.value,r.message,t);break;case"max":m(n,"maxLength",typeof n.maxLength=="number"?Math.min(n.maxLength,r.value):r.value,r.message,t);break;case"email":switch(t.emailStrategy){case"format:email":b(n,"email",r.message,t);break;case"format:idn-email":b(n,"idn-email",r.message,t);break;case"pattern:zod":y(n,h.email,r.message,t);break}break;case"url":b(n,"uri",r.message,t);break;case"uuid":b(n,"uuid",r.message,t);break;case"regex":y(n,r.regex,r.message,t);break;case"cuid":y(n,h.cuid,r.message,t);break;case"cuid2":y(n,h.cuid2,r.message,t);break;case"startsWith":y(n,RegExp(`^${I(r.value,t)}`),r.message,t);break;case"endsWith":y(n,RegExp(`${I(r.value,t)}$`),r.message,t);break;case"datetime":b(n,"date-time",r.message,t);break;case"date":b(n,"date",r.message,t);break;case"time":b(n,"time",r.message,t);break;case"duration":b(n,"duration",r.message,t);break;case"length":m(n,"minLength",typeof n.minLength=="number"?Math.max(n.minLength,r.value):r.value,r.message,t),m(n,"maxLength",typeof n.maxLength=="number"?Math.min(n.maxLength,r.value):r.value,r.message,t);break;case"includes":{y(n,RegExp(I(r.value,t)),r.message,t);break}case"ip":{r.version!=="v6"&&b(n,"ipv4",r.message,t),r.version!=="v4"&&b(n,"ipv6",r.message,t);break}case"base64url":y(n,h.base64url,r.message,t);break;case"jwt":y(n,h.jwt,r.message,t);break;case"cidr":{r.version!=="v6"&&y(n,h.ipv4Cidr,r.message,t),r.version!=="v4"&&y(n,h.ipv6Cidr,r.message,t);break}case"emoji":y(n,h.emoji(),r.message,t);break;case"ulid":{y(n,h.ulid,r.message,t);break}case"base64":{switch(t.base64Strategy){case"format:binary":{b(n,"binary",r.message,t);break}case"contentEncoding:base64":{m(n,"contentEncoding","base64",r.message,t);break}case"pattern:zod":{y(n,h.base64,r.message,t);break}}break}case"nanoid":y(n,h.nanoid,r.message,t);case"toLowerCase":case"toUpperCase":case"trim":break;default:}return n}function I(e,t){return t.patternStrategy==="escape"?ie(e):e}var ae=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function ie(e){let t="";for(let n=0;n<e.length;n++)ae.has(e[n])||(t+="\\"),t+=e[n];return t}function b(e,t,n,r){e.format||e.anyOf?.some(a=>a.format)?(e.anyOf||(e.anyOf=[]),e.format&&(e.anyOf.push({format:e.format,...e.errorMessage&&r.errorMessages&&{errorMessage:{format:e.errorMessage.format}}}),delete e.format,e.errorMessage&&(delete e.errorMessage.format,Object.keys(e.errorMessage).length===0&&delete e.errorMessage)),e.anyOf.push({format:t,...n&&r.errorMessages&&{errorMessage:{format:n}}})):m(e,"format",t,n,r)}function y(e,t,n,r){e.pattern||e.allOf?.some(a=>a.pattern)?(e.allOf||(e.allOf=[]),e.pattern&&(e.allOf.push({pattern:e.pattern,...e.errorMessage&&r.errorMessages&&{errorMessage:{pattern:e.errorMessage.pattern}}}),delete e.pattern,e.errorMessage&&(delete e.errorMessage.pattern,Object.keys(e.errorMessage).length===0&&delete e.errorMessage)),e.allOf.push({pattern:D(t,r),...n&&r.errorMessages&&{errorMessage:{pattern:n}}})):m(e,"pattern",D(t,r),n,r)}function D(e,t){if(!t.applyRegexFlags||!e.flags)return e.source;let n={i:e.flags.includes("i"),m:e.flags.includes("m"),s:e.flags.includes("s")},r=n.i?e.source.toLowerCase():e.source,a="",s=!1,c=!1,l=!1;for(let o=0;o<r.length;o++){if(s){a+=r[o],s=!1;continue}if(n.i){if(c){if(r[o].match(/[a-z]/)){l?(a+=r[o],a+=`${r[o-2]}-${r[o]}`.toUpperCase(),l=!1):r[o+1]==="-"&&r[o+2]?.match(/[a-z]/)?(a+=r[o],l=!0):a+=`${r[o]}${r[o].toUpperCase()}`;continue}}else if(r[o].match(/[a-z]/)){a+=`[${r[o]}${r[o].toUpperCase()}]`;continue}}if(n.m){if(r[o]==="^"){a+=`(^|(?<=[\r
3
3
  ]))`;continue}else if(r[o]==="$"){a+=`($|(?=[\r
4
- ]))`;continue}}if(n.s&&r[o]==="."){a+=u?`${r[o]}\r
4
+ ]))`;continue}}if(n.s&&r[o]==="."){a+=c?`${r[o]}\r
5
5
  `:`[${r[o]}\r
6
- ]`;continue}a+=r[o],r[o]==="\\"?s=!0:u&&r[o]==="]"?u=!1:!u&&r[o]==="["&&(u=!0)}try{new RegExp(a)}catch{return console.warn(`Could not convert regex pattern at ${e.currentPath.join("/")} to a flag-independent form! Falling back to the flag-ignorant source`),t.source}return a}function $(t,e){if(e.target==="openAi"&&console.warn("Warning: OpenAI may not support records in schemas! Try an array of key-value pairs instead."),e.target==="openApi3"&&t.keyType?._def.typeName===P.ZodFirstPartyTypeKind.ZodEnum)return{type:"object",required:t.keyType._def.values,properties:t.keyType._def.values.reduce((r,a)=>({...r,[a]:d(t.valueType._def,{...e,currentPath:[...e.currentPath,"properties",a]})??{}}),{}),additionalProperties:e.rejectedAdditionalProperties};let n={type:"object",additionalProperties:d(t.valueType._def,{...e,currentPath:[...e.currentPath,"additionalProperties"]})??e.allowedAdditionalProperties};if(e.target==="openApi3")return n;if(t.keyType?._def.typeName===P.ZodFirstPartyTypeKind.ZodString&&t.keyType._def.checks?.length){let{type:r,...a}=E(t.keyType._def,e);return{...n,propertyNames:a}}else{if(t.keyType?._def.typeName===P.ZodFirstPartyTypeKind.ZodEnum)return{...n,propertyNames:{enum:t.keyType._def.values}};if(t.keyType?._def.typeName===P.ZodFirstPartyTypeKind.ZodBranded&&t.keyType._def.type._def.typeName===P.ZodFirstPartyTypeKind.ZodString&&t.keyType._def.type._def.checks?.length){let{type:r,...a}=R(t.keyType._def,e);return{...n,propertyNames:a}}}return n}function se(t,e){if(e.mapStrategy==="record")return $(t,e);let n=d(t.keyType._def,{...e,currentPath:[...e.currentPath,"items","items","0"]})||{},r=d(t.valueType._def,{...e,currentPath:[...e.currentPath,"items","items","1"]})||{};return{type:"array",maxItems:125,items:{type:"array",items:[n,r],minItems:2,maxItems:2}}}function oe(t){let e=t.values,r=Object.keys(t.values).filter(s=>typeof e[e[s]]!="number").map(s=>e[s]),a=Array.from(new Set(r.map(s=>typeof s)));return{type:a.length===1?a[0]==="string"?"string":"number":["string","number"],enum:r}}function ue(){return{not:{}}}function ce(t){return t.target==="openApi3"?{enum:["null"],nullable:!0}:{type:"null"}}var I={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};function pe(t,e){if(e.target==="openApi3")return A(t,e);let n=t.options instanceof Map?Array.from(t.options.values()):t.options;if(n.every(r=>r._def.typeName in I&&(!r._def.checks||!r._def.checks.length))){let r=n.reduce((a,s)=>{let u=I[s._def.typeName];return u&&!a.includes(u)?[...a,u]:a},[]);return{type:r.length>1?r:r[0]}}else if(n.every(r=>r._def.typeName==="ZodLiteral"&&!r.description)){let r=n.reduce((a,s)=>{let u=typeof s._def.value;switch(u){case"string":case"number":case"boolean":return[...a,u];case"bigint":return[...a,"integer"];case"object":if(s._def.value===null)return[...a,"null"];case"symbol":case"undefined":case"function":default:return a}},[]);if(r.length===n.length){let a=r.filter((s,u,p)=>p.indexOf(s)===u);return{type:a.length>1?a:a[0],enum:n.reduce((s,u)=>s.includes(u._def.value)?s:[...s,u._def.value],[])}}}else if(n.every(r=>r._def.typeName==="ZodEnum"))return{type:"string",enum:n.reduce((r,a)=>[...r,...a._def.values.filter(s=>!r.includes(s))],[])};return A(t,e)}var A=(t,e)=>{let n=(t.options instanceof Map?Array.from(t.options.values()):t.options).map((r,a)=>d(r._def,{...e,currentPath:[...e.currentPath,"anyOf",`${a}`]})).filter(r=>!!r&&(!e.strictUnions||typeof r=="object"&&Object.keys(r).length>0));return n.length?{anyOf:n}:void 0};function le(t,e){if(["ZodString","ZodNumber","ZodBigInt","ZodBoolean","ZodNull"].includes(t.innerType._def.typeName)&&(!t.innerType._def.checks||!t.innerType._def.checks.length))return e.target==="openApi3"?{type:I[t.innerType._def.typeName],nullable:!0}:{type:[I[t.innerType._def.typeName],"null"]};if(e.target==="openApi3"){let r=d(t.innerType._def,{...e,currentPath:[...e.currentPath]});return r&&"$ref"in r?{allOf:[r],nullable:!0}:r&&{...r,nullable:!0}}let n=d(t.innerType._def,{...e,currentPath:[...e.currentPath,"anyOf","0"]});return n&&{anyOf:[n,{type:"null"}]}}function de(t,e){let n={type:"number"};if(!t.checks)return n;for(let r of t.checks)switch(r.kind){case"int":n.type="integer",_(n,"type",r.message,e);break;case"min":e.target==="jsonSchema7"?r.inclusive?m(n,"minimum",r.value,r.message,e):m(n,"exclusiveMinimum",r.value,r.message,e):(r.inclusive||(n.exclusiveMinimum=!0),m(n,"minimum",r.value,r.message,e));break;case"max":e.target==="jsonSchema7"?r.inclusive?m(n,"maximum",r.value,r.message,e):m(n,"exclusiveMaximum",r.value,r.message,e):(r.inclusive||(n.exclusiveMaximum=!0),m(n,"maximum",r.value,r.message,e));break;case"multipleOf":m(n,"multipleOf",r.value,r.message,e);break}return n}function me(t,e){let n=e.target==="openAi",r={type:"object",properties:{}},a=[],s=t.shape();for(let p in s){let o=s[p];if(o===void 0||o._def===void 0)continue;let f=ye(o);f&&n&&(o instanceof C.ZodOptional&&(o=o._def.innerType),o.isNullable()||(o=o.nullable()),f=!1);let v=d(o._def,{...e,currentPath:[...e.currentPath,"properties",p],propertyPath:[...e.currentPath,"properties",p]});v!==void 0&&(r.properties[p]=v,f||a.push(p))}a.length&&(r.required=a);let u=ge(t,e);return u!==void 0&&(r.additionalProperties=u),r}function ge(t,e){if(t.catchall._def.typeName!=="ZodNever")return d(t.catchall._def,{...e,currentPath:[...e.currentPath,"additionalProperties"]});switch(t.unknownKeys){case"passthrough":return e.allowedAdditionalProperties;case"strict":return e.rejectedAdditionalProperties;case"strip":return e.removeAdditionalStrategy==="strict"?e.allowedAdditionalProperties:e.rejectedAdditionalProperties}}function ye(t){try{return t.isOptional()}catch{return!0}}var fe=(t,e)=>{if(e.currentPath.toString()===e.propertyPath?.toString())return d(t.innerType._def,e);let n=d(t.innerType._def,{...e,currentPath:[...e.currentPath,"anyOf","1"]});return n?{anyOf:[{not:{}},n]}:{}},he=(t,e)=>{if(e.pipeStrategy==="input")return d(t.in._def,e);if(e.pipeStrategy==="output")return d(t.out._def,e);let n=d(t.in._def,{...e,currentPath:[...e.currentPath,"allOf","0"]}),r=d(t.out._def,{...e,currentPath:[...e.currentPath,"allOf",n?"1":"0"]});return{allOf:[n,r].filter(a=>a!==void 0)}};function be(t,e){return d(t.type._def,e)}function ve(t,e){let r={type:"array",uniqueItems:!0,items:d(t.valueType._def,{...e,currentPath:[...e.currentPath,"items"]})};return t.minSize&&m(r,"minItems",t.minSize.value,t.minSize.message,e),t.maxSize&&m(r,"maxItems",t.maxSize.value,t.maxSize.message,e),r}function Se(t,e){return t.rest?{type:"array",minItems:t.items.length,items:t.items.map((n,r)=>d(n._def,{...e,currentPath:[...e.currentPath,"items",`${r}`]})).reduce((n,r)=>r===void 0?n:[...n,r],[]),additionalItems:d(t.rest._def,{...e,currentPath:[...e.currentPath,"additionalItems"]})}:{type:"array",minItems:t.items.length,maxItems:t.items.length,items:t.items.map((n,r)=>d(n._def,{...e,currentPath:[...e.currentPath,"items",`${r}`]})).reduce((n,r)=>r===void 0?n:[...n,r],[])}}function Pe(){return{not:{}}}function Te(){return{}}var Ie=(t,e)=>d(t.innerType._def,e),ke=(t,e,n)=>{switch(e){case l.ZodFirstPartyTypeKind.ZodString:return E(t,n);case l.ZodFirstPartyTypeKind.ZodNumber:return de(t,n);case l.ZodFirstPartyTypeKind.ZodObject:return me(t,n);case l.ZodFirstPartyTypeKind.ZodBigInt:return K(t,n);case l.ZodFirstPartyTypeKind.ZodBoolean:return G();case l.ZodFirstPartyTypeKind.ZodDate:return Z(t,n);case l.ZodFirstPartyTypeKind.ZodUndefined:return Pe();case l.ZodFirstPartyTypeKind.ZodNull:return ce(n);case l.ZodFirstPartyTypeKind.ZodArray:return H(t,n);case l.ZodFirstPartyTypeKind.ZodUnion:case l.ZodFirstPartyTypeKind.ZodDiscriminatedUnion:return pe(t,n);case l.ZodFirstPartyTypeKind.ZodIntersection:return re(t,n);case l.ZodFirstPartyTypeKind.ZodTuple:return Se(t,n);case l.ZodFirstPartyTypeKind.ZodRecord:return $(t,n);case l.ZodFirstPartyTypeKind.ZodLiteral:return ne(t,n);case l.ZodFirstPartyTypeKind.ZodEnum:return ee(t);case l.ZodFirstPartyTypeKind.ZodNativeEnum:return oe(t);case l.ZodFirstPartyTypeKind.ZodNullable:return le(t,n);case l.ZodFirstPartyTypeKind.ZodOptional:return fe(t,n);case l.ZodFirstPartyTypeKind.ZodMap:return se(t,n);case l.ZodFirstPartyTypeKind.ZodSet:return ve(t,n);case l.ZodFirstPartyTypeKind.ZodLazy:return()=>t.getter()._def;case l.ZodFirstPartyTypeKind.ZodPromise:return be(t,n);case l.ZodFirstPartyTypeKind.ZodNaN:case l.ZodFirstPartyTypeKind.ZodNever:return ue();case l.ZodFirstPartyTypeKind.ZodEffects:return Y(t,n);case l.ZodFirstPartyTypeKind.ZodAny:return J();case l.ZodFirstPartyTypeKind.ZodUnknown:return Te();case l.ZodFirstPartyTypeKind.ZodDefault:return Q(t,n);case l.ZodFirstPartyTypeKind.ZodBranded:return R(t,n);case l.ZodFirstPartyTypeKind.ZodReadonly:return Ie(t,n);case l.ZodFirstPartyTypeKind.ZodCatch:return V(t,n);case l.ZodFirstPartyTypeKind.ZodPipeline:return he(t,n);case l.ZodFirstPartyTypeKind.ZodFunction:case l.ZodFirstPartyTypeKind.ZodVoid:case l.ZodFirstPartyTypeKind.ZodSymbol:return;default:return(r=>{})(e)}};function d(t,e,n=!1){let r=e.seen.get(t);if(e.override){let p=e.override?.(t,e,r,n);if(p!==z)return p}if(r&&!n){let p=Oe(r,e);if(p!==void 0)return p}let a={def:t,path:e.currentPath,jsonSchema:void 0};e.seen.set(t,a);let s=ke(t,t.typeName,e),u=typeof s=="function"?d(s(),e):s;if(u&&Me(t,e,u),e.postProcess){let p=e.postProcess(u,t,e);return a.jsonSchema=u,p}return a.jsonSchema=u,u}var Oe=(t,e)=>{switch(e.$refStrategy){case"root":return{$ref:t.path.join("/")};case"relative":return{$ref:we(e.currentPath,t.path)};case"none":case"seen":return t.path.length<e.currentPath.length&&t.path.every((n,r)=>e.currentPath[r]===n)?(console.warn(`Recursive reference detected at ${e.currentPath.join("/")}! Defaulting to any`),{}):e.$refStrategy==="seen"?{}:void 0}},we=(t,e)=>{let n=0;for(;n<t.length&&n<e.length&&t[n]===e[n];n++);return[(t.length-n).toString(),...e.slice(n)].join("/")},Me=(t,e,n)=>(t.description&&(n.description=t.description,e.markdownDescription&&(n.markdownDescription=t.description)),n),T=(t,e)=>{let n=B(e),r=typeof e=="object"&&e.definitions?Object.entries(e.definitions).reduce((o,[f,v])=>({...o,[f]:d(v._def,{...n,currentPath:[...n.basePath,n.definitionPath,f]},!0)??{}}),{}):void 0,a=typeof e=="string"?e:e?.nameStrategy==="title"?void 0:e?.name,s=d(t._def,a===void 0?n:{...n,currentPath:[...n.basePath,n.definitionPath,a]},!1)??{},u=typeof e=="object"&&e.name!==void 0&&e.nameStrategy==="title"?e.name:void 0;u!==void 0&&(s.title=u);let p=a===void 0?r?{...s,[n.definitionPath]:r}:s:{$ref:[...n.$refStrategy==="relative"?[]:n.basePath,n.definitionPath,a].join("/"),[n.definitionPath]:{...r,[a]:s}};return n.target==="jsonSchema7"?p.$schema="http://json-schema.org/draft-07/schema#":(n.target==="jsonSchema2019-09"||n.target==="openAi")&&(p.$schema="https://json-schema.org/draft/2019-09/schema#"),n.target==="openAi"&&("anyOf"in p||"oneOf"in p||"allOf"in p||"type"in p&&Array.isArray(p.type))&&console.warn("Warning: OpenAI may not support schemas with unions as roots! Try wrapping it in an object property."),p},j=class{logger;parser;server=new F.Server({name:"fixparser",version:"1.0.0"},{capabilities:{tools:{listChanged:!0},prompts:{listChanged:!0},resources:{listChanged:!0}}});transport=new N.StdioServerTransport;onReady=void 0;pendingRequests=new Map;constructor({logger:t,onReady:e}){t&&(this.logger=t),e&&(this.onReady=e)}async register(t){this.parser=t,this.parser.addOnMessageCallback(e=>{this.logger?.log({level:"info",message:`FIXParser (MCP): (${t.protocol?.toUpperCase()}): << received ${e.description}`});let n=e.messageType;if(n===i.Messages.MarketDataSnapshotFullRefresh||n===i.Messages.ExecutionReport){let r=n===i.Messages.MarketDataSnapshotFullRefresh?e.getField(i.Fields.MDReqID):e.getField(i.Fields.ClOrdID);if(r){let a=r.value;if(typeof a=="string"||typeof a=="number"){let s=this.pendingRequests.get(String(a));s&&(s(e),this.pendingRequests.delete(String(a)))}}}}),this.logger=t.logger,this.addWorkflows(),await this.server.connect(this.transport),this.onReady&&this.onReady()}addWorkflows(){if(!this.parser){this.logger?.log({level:"error",message:"FIXParser (MCP): -- FIXParser instance not initialized. Ignoring setup of workflows..."});return}if(!this.server){this.logger?.log({level:"error",message:"FIXParser (MCP): -- MCP Server not initialized. Ignoring setup of workflows..."});return}this.server.setRequestHandler(S.ListResourcesRequestSchema,async()=>({resources:[]})),this.server.setRequestHandler(S.ListToolsRequestSchema,async()=>({tools:[{name:"parse",description:"Parses a FIX message and describes it in plain language",inputSchema:T(c.z.object({fixString:c.z.string().describe("FIX message string to parse")}),{name:"ParseInput"})},{name:"parseToJSON",description:"Parses a FIX message into JSON",inputSchema:T(c.z.object({fixString:c.z.string().describe("FIX message string to parse")}),{name:"ParseToJSONInput"})},{name:"newOrderSingle",description:"Creates and sends a New Order Single",inputSchema:T(c.z.object({clOrdID:c.z.string().describe("Client Order ID"),handlInst:c.z.enum(["1","2","3"]).default(i.HandlInst.AutomatedExecutionNoIntervention).optional().describe("Handling instruction"),quantity:c.z.number().describe("Order quantity"),price:c.z.number().describe("Order price"),ordType:c.z.enum(["1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","P","Q","R","S"]).default("1").optional().describe("Order type"),side:c.z.enum(["1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H"]).describe("Order side (1=Buy, 2=Sell)"),symbol:c.z.string().describe("Trading symbol"),timeInForce:c.z.enum(["0","1","2","3","4","5","6","7","8","9","A","B","C"]).default(i.TimeInForce.Day).optional().describe("Time in force")}),{name:"NewOrderSingleInput"})},{name:"marketDataRequest",description:"Sends a request for Market Data with the given symbol",inputSchema:T(c.z.object({mdUpdateType:c.z.enum(["0","1"]).default("0").optional().describe("Market data update type"),symbol:c.z.string().describe("Trading symbol"),mdReqID:c.z.string().describe("Market data request ID"),subscriptionRequestType:c.z.enum(["0","1","2"]).default(i.SubscriptionRequestType.SnapshotAndUpdates).optional().describe("Subscription request type"),mdEntryType:c.z.enum(["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","J","K","L","M","N","O","P","Q","S","R","T","U","V","W","X","Y","Z","a","b","c","d","e","g","h","i","t"]).default(i.MDEntryType.Bid).optional().describe("Market data entry type")}),{name:"MarketDataRequestInput"})}]})),this.server.setRequestHandler(S.CallToolRequestSchema,async t=>{let{name:e,arguments:n}=t.params;switch(e){case"parse":{let{fixString:r}=c.z.object({fixString:c.z.string().describe("FIX message string to parse")}).parse(n||{});try{let a=this.parser?.parse(r);return!a||a.length===0?{isError:!0,content:[{type:"text",text:"Error: Failed to parse FIX string"}]}:{content:[{type:"text",text:`Parsed FIX message: ${r} (placeholder implementation)`}]}}catch{return{isError:!0,content:[{type:"text",text:"Error: Failed to parse FIX string"}]}}}case"parseToJSON":{let{fixString:r}=c.z.object({fixString:c.z.string().describe("FIX message string to parse")}).parse(n||{});try{let a=this.parser?.parse(r);return!a||a.length===0?{isError:!0,content:[{type:"text",text:"Error: Failed to parse FIX string"}]}:{content:[{type:"text",text:JSON.stringify({fixString:r,parsed:"placeholder"})}]}}catch{return{isError:!0,content:[{type:"text",text:"Error: Failed to parse FIX string"}]}}}case"newOrderSingle":{let{clOrdID:r,handlInst:a,quantity:s,price:u,ordType:p,side:o,symbol:f,timeInForce:v}=c.z.object({clOrdID:c.z.string().describe("Client Order ID"),handlInst:c.z.enum(["1","2","3"]).default(i.HandlInst.AutomatedExecutionNoIntervention).optional().describe("Handling instruction"),quantity:c.z.number().describe("Order quantity"),price:c.z.number().describe("Order price"),ordType:c.z.enum(["1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","P","Q","R","S"]).default(i.OrdType.Market).optional().describe("Order type"),side:c.z.enum(["1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H"]).describe("Order side (1=Buy, 2=Sell)"),symbol:c.z.string().describe("Trading symbol"),timeInForce:c.z.enum(["0","1","2","3","4","5","6","7","8","9","A","B","C"]).default(i.TimeInForce.Day).optional().describe("Time in force")}).parse(n||{}),k=new Promise(X=>{this.pendingRequests.set(r,X)}),M=this.parser?.createMessage(new i.Field(i.Fields.MsgType,i.Messages.NewOrderSingle),new i.Field(i.Fields.MsgSeqNum,this.parser?.getNextTargetMsgSeqNum()),new i.Field(i.Fields.SenderCompID,this.parser?.sender),new i.Field(i.Fields.TargetCompID,this.parser?.target),new i.Field(i.Fields.SendingTime,this.parser?.getTimestamp()),new i.Field(i.Fields.ClOrdID,r),new i.Field(i.Fields.Side,o),new i.Field(i.Fields.Symbol,f),new i.Field(i.Fields.OrderQty,s),new i.Field(i.Fields.Price,u),new i.Field(i.Fields.OrdType,p),new i.Field(i.Fields.HandlInst,a),new i.Field(i.Fields.TimeInForce,v),new i.Field(i.Fields.TransactTime,this.parser?.getTimestamp()));if(!this.parser?.connected)return this.logger?.log({level:"error",message:"FIXParser (MCP): -- Not connected. Ignoring message."}),{isError:!0,content:[{type:"text",text:"Error: Not connected. Ignoring message."}]};this.parser?.send(M),this.logger?.log({level:"info",message:`FIXParser (MCP): (${this.parser?.protocol?.toUpperCase()}): >> sent ${M?.description}`});let L=await k;return{content:[{type:"text",text:`Execution Report for order ${r}: ${JSON.stringify(L.toFIXJSON())}`}]}}case"marketDataRequest":{let{mdUpdateType:r,symbol:a,mdReqID:s,subscriptionRequestType:u,mdEntryType:p}=c.z.object({mdUpdateType:c.z.enum(["0","1"]).default("0").optional().describe("Market data update type"),symbol:c.z.string().describe("Trading symbol"),mdReqID:c.z.string().describe("Market data request ID"),subscriptionRequestType:c.z.enum(["0","1","2"]).default(i.SubscriptionRequestType.SnapshotAndUpdates).optional().describe("Subscription request type"),mdEntryType:c.z.enum(["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","J","K","L","M","N","O","P","Q","S","R","T","U","V","W","X","Y","Z","a","b","c","d","e","g","h","i","t"]).default(i.MDEntryType.Bid).optional().describe("Market data entry type")}).parse(n||{}),o=new Promise(k=>{this.pendingRequests.set(s,k)}),f=this.parser?.createMessage(new i.Field(i.Fields.MsgType,i.Messages.MarketDataRequest),new i.Field(i.Fields.SenderCompID,this.parser?.sender),new i.Field(i.Fields.MsgSeqNum,this.parser?.getNextTargetMsgSeqNum()),new i.Field(i.Fields.TargetCompID,this.parser?.target),new i.Field(i.Fields.SendingTime,this.parser?.getTimestamp()),new i.Field(i.Fields.MarketDepth,0),new i.Field(i.Fields.MDUpdateType,r),new i.Field(i.Fields.NoRelatedSym,1),new i.Field(i.Fields.Symbol,a),new i.Field(i.Fields.MDReqID,s),new i.Field(i.Fields.SubscriptionRequestType,u),new i.Field(i.Fields.NoMDEntryTypes,1),new i.Field(i.Fields.MDEntryType,p));if(!this.parser?.connected)return this.logger?.log({level:"error",message:"FIXParser (MCP): -- Not connected. Ignoring message."}),{isError:!0,content:[{type:"text",text:"Error: Not connected. Ignoring message."}]};this.parser?.send(f),this.logger?.log({level:"info",message:`FIXParser (MCP): (${this.parser?.protocol?.toUpperCase()}): >> sent ${f?.description}`});let v=await o;return{content:[{type:"text",text:`Market data for ${a}: ${JSON.stringify(v.toFIXJSON())}`}]}}default:throw new Error(`Unknown tool: ${e}`)}}),this.server.setRequestHandler(S.ListPromptsRequestSchema,async()=>({prompts:[{name:"parse",description:"Parses a FIX message and describes it in plain language",arguments:[{name:"fixString",description:"FIX message string to parse",required:!0}]},{name:"parseToJSON",description:"Parses a FIX message into JSON",arguments:[{name:"fixString",description:"FIX message string to parse",required:!0}]},{name:"newOrderSingle",description:"Creates and sends a New Order Single",arguments:[{name:"clOrdID",description:"Client Order ID",required:!0},{name:"handlInst",description:"Handling instruction",required:!1},{name:"quantity",description:"Order quantity",required:!0},{name:"price",description:"Order price",required:!0},{name:"ordType",description:"Order type",required:!1},{name:"side",description:"Order side (1=Buy, 2=Sell)",required:!0},{name:"symbol",description:"Trading symbol",required:!0},{name:"timeInForce",description:"Time in force",required:!1}]},{name:"marketDataRequest",description:"Sends a request for Market Data with the given symbol",arguments:[{name:"mdUpdateType",description:"Market data update type",required:!1},{name:"symbol",description:"Trading symbol",required:!0},{name:"mdReqID",description:"Market data request ID",required:!0},{name:"subscriptionRequestType",description:"Subscription request type",required:!1},{name:"mdEntryType",description:"Market data entry type",required:!1}]}]})),this.server.setRequestHandler(S.GetPromptRequestSchema,async t=>{let{name:e,arguments:n}=t.params;switch(e){case"parse":return{messages:[{role:"user",content:{type:"text",text:`Please parse and explain this FIX message: ${n?.fixString||""}`}}]};case"parseToJSON":return{messages:[{role:"user",content:{type:"text",text:`Please parse the FIX message to JSON: ${n?.fixString||""}`}}]};case"newOrderSingle":{let{clOrdID:r,handlInst:a,quantity:s,price:u,ordType:p,side:o,symbol:f,timeInForce:v}=n||{};return{messages:[{role:"user",content:{type:"text",text:["Create a New Order Single FIX message with the following parameters:",`- ClOrdID: ${r}`,`- HandlInst: ${a??"default"}`,`- Quantity: ${s}`,`- Price: ${u}`,`- OrdType: ${p??"default (Market)"}`,`- Side: ${o}`,`- Symbol: ${f}`,`- TimeInForce: ${v??"default (Day)"}`,"","Format the response as a JSON object with FIX tag numbers as keys and their corresponding values."].join(`
7
- `)}}]}}case"marketDataRequest":{let{mdUpdateType:r,symbol:a,mdReqID:s,subscriptionRequestType:u,mdEntryType:p}=n||{};return{messages:[{role:"user",content:{type:"text",text:["Create a Market Data Request FIX message with the following parameters:",`- MDUpdateType: ${r??"default (0 = FullRefresh)"}`,`- Symbol: ${a}`,`- MDReqID: ${s}`,`- SubscriptionRequestType: ${u??"default (0 = Snapshot + Updates)"}`,`- MDEntryType: ${p??"default (0 = Bid)"}`,"","Format the response as a JSON object with FIX tag numbers as keys and their corresponding values."].join(`
8
- `)}}]}}default:throw new Error(`Unknown prompt: ${e}`)}}),process.on("SIGINT",async()=>{await this.server.close(),process.exit(0)})}};var De=async()=>{await g.LicenseManager.setLicenseKey(process.env.FIXPARSER_LICENSE_KEY);let t=new g.FIXParser({plugins:[new j({port:3099,onReady:()=>{}})]}),e=()=>{let s=t.createMessage(new g.Field(g.Fields.MsgType,g.Messages.Logon),new g.Field(g.Fields.MsgSeqNum,t.getNextTargetMsgSeqNum()),new g.Field(g.Fields.SenderCompID,n),new g.Field(g.Fields.SendingTime,t.getTimestamp()),new g.Field(g.Fields.TargetCompID,r),new g.Field(g.Fields.ResetSeqNumFlag,g.ResetSeqNumFlag.Yes),new g.Field(g.Fields.EncryptMethod,g.EncryptMethod.None),new g.Field(g.Fields.HeartBtInt,10));t.send(s)},n="CLIENT2",r="EXECUTOR",a={host:"localhost",port:5001,protocol:"tcp",sender:n,target:r,fixVersion:"FIX.4.4",logging:!1,onOpen:()=>{e()},onMessage:s=>{},onClose:()=>{}};t.connect(a)};De().catch(t=>console.error("Error initializing server:",t));
6
+ ]`;continue}a+=r[o],r[o]==="\\"?s=!0:c&&r[o]==="]"?c=!1:!c&&r[o]==="["&&(c=!0)}try{new RegExp(a)}catch{return console.warn(`Could not convert regex pattern at ${t.currentPath.join("/")} to a flag-independent form! Falling back to the flag-ignorant source`),e.source}return a}function j(e,t){if(t.target==="openAi"&&console.warn("Warning: OpenAI may not support records in schemas! Try an array of key-value pairs instead."),t.target==="openApi3"&&e.keyType?._def.typeName===P.ZodFirstPartyTypeKind.ZodEnum)return{type:"object",required:e.keyType._def.values,properties:e.keyType._def.values.reduce((r,a)=>({...r,[a]:d(e.valueType._def,{...t,currentPath:[...t.currentPath,"properties",a]})??{}}),{}),additionalProperties:t.rejectedAdditionalProperties};let n={type:"object",additionalProperties:d(e.valueType._def,{...t,currentPath:[...t.currentPath,"additionalProperties"]})??t.allowedAdditionalProperties};if(t.target==="openApi3")return n;if(e.keyType?._def.typeName===P.ZodFirstPartyTypeKind.ZodString&&e.keyType._def.checks?.length){let{type:r,...a}=C(e.keyType._def,t);return{...n,propertyNames:a}}else{if(e.keyType?._def.typeName===P.ZodFirstPartyTypeKind.ZodEnum)return{...n,propertyNames:{enum:e.keyType._def.values}};if(e.keyType?._def.typeName===P.ZodFirstPartyTypeKind.ZodBranded&&e.keyType._def.type._def.typeName===P.ZodFirstPartyTypeKind.ZodString&&e.keyType._def.type._def.checks?.length){let{type:r,...a}=E(e.keyType._def,t);return{...n,propertyNames:a}}}return n}function se(e,t){if(t.mapStrategy==="record")return j(e,t);let n=d(e.keyType._def,{...t,currentPath:[...t.currentPath,"items","items","0"]})||{},r=d(e.valueType._def,{...t,currentPath:[...t.currentPath,"items","items","1"]})||{};return{type:"array",maxItems:125,items:{type:"array",items:[n,r],minItems:2,maxItems:2}}}function oe(e){let t=e.values,r=Object.keys(e.values).filter(s=>typeof t[t[s]]!="number").map(s=>t[s]),a=Array.from(new Set(r.map(s=>typeof s)));return{type:a.length===1?a[0]==="string"?"string":"number":["string","number"],enum:r}}function ue(){return{not:{}}}function ce(e){return e.target==="openApi3"?{enum:["null"],nullable:!0}:{type:"null"}}var T={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};function pe(e,t){if(t.target==="openApi3")return F(e,t);let n=e.options instanceof Map?Array.from(e.options.values()):e.options;if(n.every(r=>r._def.typeName in T&&(!r._def.checks||!r._def.checks.length))){let r=n.reduce((a,s)=>{let c=T[s._def.typeName];return c&&!a.includes(c)?[...a,c]:a},[]);return{type:r.length>1?r:r[0]}}else if(n.every(r=>r._def.typeName==="ZodLiteral"&&!r.description)){let r=n.reduce((a,s)=>{let c=typeof s._def.value;switch(c){case"string":case"number":case"boolean":return[...a,c];case"bigint":return[...a,"integer"];case"object":if(s._def.value===null)return[...a,"null"];case"symbol":case"undefined":case"function":default:return a}},[]);if(r.length===n.length){let a=r.filter((s,c,l)=>l.indexOf(s)===c);return{type:a.length>1?a:a[0],enum:n.reduce((s,c)=>s.includes(c._def.value)?s:[...s,c._def.value],[])}}}else if(n.every(r=>r._def.typeName==="ZodEnum"))return{type:"string",enum:n.reduce((r,a)=>[...r,...a._def.values.filter(s=>!r.includes(s))],[])};return F(e,t)}var F=(e,t)=>{let n=(e.options instanceof Map?Array.from(e.options.values()):e.options).map((r,a)=>d(r._def,{...t,currentPath:[...t.currentPath,"anyOf",`${a}`]})).filter(r=>!!r&&(!t.strictUnions||typeof r=="object"&&Object.keys(r).length>0));return n.length?{anyOf:n}:void 0};function le(e,t){if(["ZodString","ZodNumber","ZodBigInt","ZodBoolean","ZodNull"].includes(e.innerType._def.typeName)&&(!e.innerType._def.checks||!e.innerType._def.checks.length))return t.target==="openApi3"?{type:T[e.innerType._def.typeName],nullable:!0}:{type:[T[e.innerType._def.typeName],"null"]};if(t.target==="openApi3"){let r=d(e.innerType._def,{...t,currentPath:[...t.currentPath]});return r&&"$ref"in r?{allOf:[r],nullable:!0}:r&&{...r,nullable:!0}}let n=d(e.innerType._def,{...t,currentPath:[...t.currentPath,"anyOf","0"]});return n&&{anyOf:[n,{type:"null"}]}}function de(e,t){let n={type:"number"};if(!e.checks)return n;for(let r of e.checks)switch(r.kind){case"int":n.type="integer",N(n,"type",r.message,t);break;case"min":t.target==="jsonSchema7"?r.inclusive?m(n,"minimum",r.value,r.message,t):m(n,"exclusiveMinimum",r.value,r.message,t):(r.inclusive||(n.exclusiveMinimum=!0),m(n,"minimum",r.value,r.message,t));break;case"max":t.target==="jsonSchema7"?r.inclusive?m(n,"maximum",r.value,r.message,t):m(n,"exclusiveMaximum",r.value,r.message,t):(r.inclusive||(n.exclusiveMaximum=!0),m(n,"maximum",r.value,r.message,t));break;case"multipleOf":m(n,"multipleOf",r.value,r.message,t);break}return n}function me(e,t){let n=t.target==="openAi",r={type:"object",properties:{}},a=[],s=e.shape();for(let l in s){let o=s[l];if(o===void 0||o._def===void 0)continue;let f=ye(o);f&&n&&(o instanceof $.ZodOptional&&(o=o._def.innerType),o.isNullable()||(o=o.nullable()),f=!1);let v=d(o._def,{...t,currentPath:[...t.currentPath,"properties",l],propertyPath:[...t.currentPath,"properties",l]});v!==void 0&&(r.properties[l]=v,f||a.push(l))}a.length&&(r.required=a);let c=ge(e,t);return c!==void 0&&(r.additionalProperties=c),r}function ge(e,t){if(e.catchall._def.typeName!=="ZodNever")return d(e.catchall._def,{...t,currentPath:[...t.currentPath,"additionalProperties"]});switch(e.unknownKeys){case"passthrough":return t.allowedAdditionalProperties;case"strict":return t.rejectedAdditionalProperties;case"strip":return t.removeAdditionalStrategy==="strict"?t.allowedAdditionalProperties:t.rejectedAdditionalProperties}}function ye(e){try{return e.isOptional()}catch{return!0}}var fe=(e,t)=>{if(t.currentPath.toString()===t.propertyPath?.toString())return d(e.innerType._def,t);let n=d(e.innerType._def,{...t,currentPath:[...t.currentPath,"anyOf","1"]});return n?{anyOf:[{not:{}},n]}:{}},he=(e,t)=>{if(t.pipeStrategy==="input")return d(e.in._def,t);if(t.pipeStrategy==="output")return d(e.out._def,t);let n=d(e.in._def,{...t,currentPath:[...t.currentPath,"allOf","0"]}),r=d(e.out._def,{...t,currentPath:[...t.currentPath,"allOf",n?"1":"0"]});return{allOf:[n,r].filter(a=>a!==void 0)}};function be(e,t){return d(e.type._def,t)}function ve(e,t){let r={type:"array",uniqueItems:!0,items:d(e.valueType._def,{...t,currentPath:[...t.currentPath,"items"]})};return e.minSize&&m(r,"minItems",e.minSize.value,e.minSize.message,t),e.maxSize&&m(r,"maxItems",e.maxSize.value,e.maxSize.message,t),r}function Pe(e,t){return e.rest?{type:"array",minItems:e.items.length,items:e.items.map((n,r)=>d(n._def,{...t,currentPath:[...t.currentPath,"items",`${r}`]})).reduce((n,r)=>r===void 0?n:[...n,r],[]),additionalItems:d(e.rest._def,{...t,currentPath:[...t.currentPath,"additionalItems"]})}:{type:"array",minItems:e.items.length,maxItems:e.items.length,items:e.items.map((n,r)=>d(n._def,{...t,currentPath:[...t.currentPath,"items",`${r}`]})).reduce((n,r)=>r===void 0?n:[...n,r],[])}}function Se(){return{not:{}}}function ke(){return{}}var Te=(e,t)=>d(e.innerType._def,t),Me=(e,t,n)=>{switch(t){case p.ZodFirstPartyTypeKind.ZodString:return C(e,n);case p.ZodFirstPartyTypeKind.ZodNumber:return de(e,n);case p.ZodFirstPartyTypeKind.ZodObject:return me(e,n);case p.ZodFirstPartyTypeKind.ZodBigInt:return K(e,n);case p.ZodFirstPartyTypeKind.ZodBoolean:return G();case p.ZodFirstPartyTypeKind.ZodDate:return R(e,n);case p.ZodFirstPartyTypeKind.ZodUndefined:return Se();case p.ZodFirstPartyTypeKind.ZodNull:return ce(n);case p.ZodFirstPartyTypeKind.ZodArray:return H(e,n);case p.ZodFirstPartyTypeKind.ZodUnion:case p.ZodFirstPartyTypeKind.ZodDiscriminatedUnion:return pe(e,n);case p.ZodFirstPartyTypeKind.ZodIntersection:return re(e,n);case p.ZodFirstPartyTypeKind.ZodTuple:return Pe(e,n);case p.ZodFirstPartyTypeKind.ZodRecord:return j(e,n);case p.ZodFirstPartyTypeKind.ZodLiteral:return ne(e,n);case p.ZodFirstPartyTypeKind.ZodEnum:return ee(e);case p.ZodFirstPartyTypeKind.ZodNativeEnum:return oe(e);case p.ZodFirstPartyTypeKind.ZodNullable:return le(e,n);case p.ZodFirstPartyTypeKind.ZodOptional:return fe(e,n);case p.ZodFirstPartyTypeKind.ZodMap:return se(e,n);case p.ZodFirstPartyTypeKind.ZodSet:return ve(e,n);case p.ZodFirstPartyTypeKind.ZodLazy:return()=>e.getter()._def;case p.ZodFirstPartyTypeKind.ZodPromise:return be(e,n);case p.ZodFirstPartyTypeKind.ZodNaN:case p.ZodFirstPartyTypeKind.ZodNever:return ue();case p.ZodFirstPartyTypeKind.ZodEffects:return Y(e,n);case p.ZodFirstPartyTypeKind.ZodAny:return J();case p.ZodFirstPartyTypeKind.ZodUnknown:return ke();case p.ZodFirstPartyTypeKind.ZodDefault:return Q(e,n);case p.ZodFirstPartyTypeKind.ZodBranded:return E(e,n);case p.ZodFirstPartyTypeKind.ZodReadonly:return Te(e,n);case p.ZodFirstPartyTypeKind.ZodCatch:return V(e,n);case p.ZodFirstPartyTypeKind.ZodPipeline:return he(e,n);case p.ZodFirstPartyTypeKind.ZodFunction:case p.ZodFirstPartyTypeKind.ZodVoid:case p.ZodFirstPartyTypeKind.ZodSymbol:return;default:return(r=>{})(t)}};function d(e,t,n=!1){let r=t.seen.get(e);if(t.override){let l=t.override?.(e,t,r,n);if(l!==X)return l}if(r&&!n){let l=Ae(r,t);if(l!==void 0)return l}let a={def:e,path:t.currentPath,jsonSchema:void 0};t.seen.set(e,a);let s=Me(e,e.typeName,t),c=typeof s=="function"?d(s(),t):s;if(c&&we(e,t,c),t.postProcess){let l=t.postProcess(c,e,t);return a.jsonSchema=c,l}return a.jsonSchema=c,c}var Ae=(e,t)=>{switch(t.$refStrategy){case"root":return{$ref:e.path.join("/")};case"relative":return{$ref:Ie(t.currentPath,e.path)};case"none":case"seen":return e.path.length<t.currentPath.length&&e.path.every((n,r)=>t.currentPath[r]===n)?(console.warn(`Recursive reference detected at ${t.currentPath.join("/")}! Defaulting to any`),{}):t.$refStrategy==="seen"?{}:void 0}},Ie=(e,t)=>{let n=0;for(;n<e.length&&n<t.length&&e[n]===t[n];n++);return[(e.length-n).toString(),...t.slice(n)].join("/")},we=(e,t,n)=>(e.description&&(n.description=e.description,t.markdownDescription&&(n.markdownDescription=e.description)),n),k=(e,t)=>{let n=B(t),r=typeof t=="object"&&t.definitions?Object.entries(t.definitions).reduce((o,[f,v])=>({...o,[f]:d(v._def,{...n,currentPath:[...n.basePath,n.definitionPath,f]},!0)??{}}),{}):void 0,a=typeof t=="string"?t:t?.nameStrategy==="title"?void 0:t?.name,s=d(e._def,a===void 0?n:{...n,currentPath:[...n.basePath,n.definitionPath,a]},!1)??{},c=typeof t=="object"&&t.name!==void 0&&t.nameStrategy==="title"?t.name:void 0;c!==void 0&&(s.title=c);let l=a===void 0?r?{...s,[n.definitionPath]:r}:s:{$ref:[...n.$refStrategy==="relative"?[]:n.basePath,n.definitionPath,a].join("/"),[n.definitionPath]:{...r,[a]:s}};return n.target==="jsonSchema7"?l.$schema="http://json-schema.org/draft-07/schema#":(n.target==="jsonSchema2019-09"||n.target==="openAi")&&(l.$schema="https://json-schema.org/draft/2019-09/schema#"),n.target==="openAi"&&("anyOf"in l||"oneOf"in l||"allOf"in l||"type"in l&&Array.isArray(l.type))&&console.warn("Warning: OpenAI may not support schemas with unions as roots! Try wrapping it in an object property."),l},q=class{logger;parser;server=new x.Server({name:"fixparser",version:"1.0.0"},{capabilities:{tools:{}}});transport=new _.StdioServerTransport;onReady=void 0;pendingRequests=new Map;constructor({logger:e,onReady:t}){e&&(this.logger=e),t&&(this.onReady=t)}async register(e){this.parser=e,this.parser.addOnMessageCallback(t=>{this.logger?.log({level:"info",message:`FIXParser (MCP): (${e.protocol?.toUpperCase()}): << received ${t.description}`});let n=t.messageType;if(n===i.Messages.MarketDataSnapshotFullRefresh||n===i.Messages.ExecutionReport){let r=n===i.Messages.MarketDataSnapshotFullRefresh?t.getField(i.Fields.MDReqID):t.getField(i.Fields.ClOrdID);if(r){let a=r.value;if(typeof a=="string"||typeof a=="number"){let s=this.pendingRequests.get(String(a));s&&(s(t),this.pendingRequests.delete(String(a)))}}}}),this.logger=e.logger,this.addWorkflows(),await this.server.connect(this.transport),this.onReady&&this.onReady()}addWorkflows(){if(!this.parser){this.logger?.log({level:"error",message:"FIXParser (MCP): -- FIXParser instance not initialized. Ignoring setup of workflows..."});return}if(!this.server){this.logger?.log({level:"error",message:"FIXParser (MCP): -- MCP Server not initialized. Ignoring setup of workflows..."});return}this.server.setRequestHandler(S.ListResourcesRequestSchema,async()=>({resources:[]})),this.server.setRequestHandler(S.ListToolsRequestSchema,async()=>({tools:[{name:"parse",description:"Parses a FIX message and describes it in plain language",inputSchema:k(u.z.object({fixString:u.z.string().describe("FIX message string to parse")}),{name:"ParseInput"})},{name:"parseToJSON",description:"Parses a FIX message into JSON",inputSchema:k(u.z.object({fixString:u.z.string().describe("FIX message string to parse")}),{name:"ParseToJSONInput"})},{name:"newOrderSingle",description:"Creates and sends a New Order Single",inputSchema:k(u.z.object({clOrdID:u.z.string().describe("Client Order ID"),handlInst:u.z.enum(["1","2","3"]).default(i.HandlInst.AutomatedExecutionNoIntervention).optional().describe("Handling instruction"),quantity:u.z.number().describe("Order quantity"),price:u.z.number().describe("Order price"),ordType:u.z.enum(["1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","P","Q","R","S"]).default("1").optional().describe("Order type"),side:u.z.enum(["1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H"]).describe("Order side (1=Buy, 2=Sell)"),symbol:u.z.string().describe("Trading symbol"),timeInForce:u.z.enum(["0","1","2","3","4","5","6","7","8","9","A","B","C"]).default(i.TimeInForce.Day).optional().describe("Time in force")}),{name:"NewOrderSingleInput"})},{name:"marketDataRequest",description:"Sends a request for Market Data with the given symbol",inputSchema:k(u.z.object({mdUpdateType:u.z.enum(["0","1"]).default("0").optional().describe("Market data update type"),symbol:u.z.string().describe("Trading symbol"),mdReqID:u.z.string().describe("Market data request ID"),subscriptionRequestType:u.z.enum(["0","1","2"]).default(i.SubscriptionRequestType.SnapshotAndUpdates).optional().describe("Subscription request type"),mdEntryType:u.z.enum(["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","J","K","L","M","N","O","P","Q","S","R","T","U","V","W","X","Y","Z","a","b","c","d","e","g","h","i","t"]).default(i.MDEntryType.Bid).optional().describe("Market data entry type")}),{name:"MarketDataRequestInput"})}]})),this.server.setRequestHandler(S.CallToolRequestSchema,async e=>{let{name:t,arguments:n}=e.params;switch(t){case"parse":{let{fixString:r}=u.z.object({fixString:u.z.string().describe("FIX message string to parse")}).parse(n||{});try{let a=this.parser?.parse(r);return!a||a.length===0?{isError:!0,content:[{type:"text",text:"Error: Failed to parse FIX string"}]}:{content:[{type:"text",text:`Parsed FIX message: ${r} (placeholder implementation)`}]}}catch{return{isError:!0,content:[{type:"text",text:"Error: Failed to parse FIX string"}]}}}case"parseToJSON":{let{fixString:r}=u.z.object({fixString:u.z.string().describe("FIX message string to parse")}).parse(n||{});try{let a=this.parser?.parse(r);return!a||a.length===0?{isError:!0,content:[{type:"text",text:"Error: Failed to parse FIX string"}]}:{content:[{type:"text",text:JSON.stringify({fixString:r,parsed:"placeholder"})}]}}catch{return{isError:!0,content:[{type:"text",text:"Error: Failed to parse FIX string"}]}}}case"newOrderSingle":{let{clOrdID:r,handlInst:a,quantity:s,price:c,ordType:l,side:o,symbol:f,timeInForce:v}=u.z.object({clOrdID:u.z.string().describe("Client Order ID"),handlInst:u.z.enum(["1","2","3"]).default(i.HandlInst.AutomatedExecutionNoIntervention).optional().describe("Handling instruction"),quantity:u.z.number().describe("Order quantity"),price:u.z.number().describe("Order price"),ordType:u.z.enum(["1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","P","Q","R","S"]).default(i.OrdType.Market).optional().describe("Order type"),side:u.z.enum(["1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H"]).describe("Order side (1=Buy, 2=Sell)"),symbol:u.z.string().describe("Trading symbol"),timeInForce:u.z.enum(["0","1","2","3","4","5","6","7","8","9","A","B","C"]).default(i.TimeInForce.Day).optional().describe("Time in force")}).parse(n||{}),M=new Promise(z=>{this.pendingRequests.set(r,z)}),w=this.parser?.createMessage(new i.Field(i.Fields.MsgType,i.Messages.NewOrderSingle),new i.Field(i.Fields.MsgSeqNum,this.parser?.getNextTargetMsgSeqNum()),new i.Field(i.Fields.SenderCompID,this.parser?.sender),new i.Field(i.Fields.TargetCompID,this.parser?.target),new i.Field(i.Fields.SendingTime,this.parser?.getTimestamp()),new i.Field(i.Fields.ClOrdID,r),new i.Field(i.Fields.Side,o),new i.Field(i.Fields.Symbol,f),new i.Field(i.Fields.OrderQty,s),new i.Field(i.Fields.Price,c),new i.Field(i.Fields.OrdType,l),new i.Field(i.Fields.HandlInst,a),new i.Field(i.Fields.TimeInForce,v),new i.Field(i.Fields.TransactTime,this.parser?.getTimestamp()));if(!this.parser?.connected)return this.logger?.log({level:"error",message:"FIXParser (MCP): -- Not connected. Ignoring message."}),{isError:!0,content:[{type:"text",text:"Error: Not connected. Ignoring message."}]};this.parser?.send(w),this.logger?.log({level:"info",message:`FIXParser (MCP): (${this.parser?.protocol?.toUpperCase()}): >> sent ${w?.description}`});let L=await M;return{content:[{type:"text",text:`Execution Report for order ${r}: ${JSON.stringify(L.toFIXJSON())}`}]}}case"marketDataRequest":{let{mdUpdateType:r,symbol:a,mdReqID:s,subscriptionRequestType:c,mdEntryType:l}=u.z.object({mdUpdateType:u.z.enum(["0","1"]).default("0").optional().describe("Market data update type"),symbol:u.z.string().describe("Trading symbol"),mdReqID:u.z.string().describe("Market data request ID"),subscriptionRequestType:u.z.enum(["0","1","2"]).default(i.SubscriptionRequestType.SnapshotAndUpdates).optional().describe("Subscription request type"),mdEntryType:u.z.enum(["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","J","K","L","M","N","O","P","Q","S","R","T","U","V","W","X","Y","Z","a","b","c","d","e","g","h","i","t"]).default(i.MDEntryType.Bid).optional().describe("Market data entry type")}).parse(n||{}),o=new Promise(M=>{this.pendingRequests.set(s,M)}),f=this.parser?.createMessage(new i.Field(i.Fields.MsgType,i.Messages.MarketDataRequest),new i.Field(i.Fields.SenderCompID,this.parser?.sender),new i.Field(i.Fields.MsgSeqNum,this.parser?.getNextTargetMsgSeqNum()),new i.Field(i.Fields.TargetCompID,this.parser?.target),new i.Field(i.Fields.SendingTime,this.parser?.getTimestamp()),new i.Field(i.Fields.MarketDepth,0),new i.Field(i.Fields.MDUpdateType,r),new i.Field(i.Fields.NoRelatedSym,1),new i.Field(i.Fields.Symbol,a),new i.Field(i.Fields.MDReqID,s),new i.Field(i.Fields.SubscriptionRequestType,c),new i.Field(i.Fields.NoMDEntryTypes,1),new i.Field(i.Fields.MDEntryType,l));if(!this.parser?.connected)return this.logger?.log({level:"error",message:"FIXParser (MCP): -- Not connected. Ignoring message."}),{isError:!0,content:[{type:"text",text:"Error: Not connected. Ignoring message."}]};this.parser?.send(f),this.logger?.log({level:"info",message:`FIXParser (MCP): (${this.parser?.protocol?.toUpperCase()}): >> sent ${f?.description}`});let v=await o;return{content:[{type:"text",text:`Market data for ${a}: ${JSON.stringify(v.toFIXJSON())}`}]}}default:throw new Error(`Unknown tool: ${t}`)}}),process.on("SIGINT",async()=>{await this.server.close(),process.exit(0)})}};var Oe=async()=>{await g.LicenseManager.setLicenseKey(process.env.FIXPARSER_LICENSE_KEY);let e=new g.FIXParser({plugins:[new q({port:3099,onReady:()=>{}})]}),t=()=>{let s=e.createMessage(new g.Field(g.Fields.MsgType,g.Messages.Logon),new g.Field(g.Fields.MsgSeqNum,e.getNextTargetMsgSeqNum()),new g.Field(g.Fields.SenderCompID,n),new g.Field(g.Fields.SendingTime,e.getTimestamp()),new g.Field(g.Fields.TargetCompID,r),new g.Field(g.Fields.ResetSeqNumFlag,g.ResetSeqNumFlag.Yes),new g.Field(g.Fields.EncryptMethod,g.EncryptMethod.None),new g.Field(g.Fields.HeartBtInt,10));e.send(s)},n="CLIENT2",r="EXECUTOR",a={host:"localhost",port:5001,protocol:"tcp",sender:n,target:r,fixVersion:"FIX.4.4",logging:!1,onOpen:()=>{t()},onMessage:s=>{},onClose:()=>{}};e.connect(a)};Oe().catch(e=>console.error("Error initializing server:",e));
9
7
  //# sourceMappingURL=example_mcp_local.js.map