fixparser-plugin-mcp 9.1.7-f34f63d7 → 9.1.7-fa7eb92e
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/cjs/MCPLocal.js +486 -1585
- package/build/cjs/MCPLocal.js.map +4 -4
- package/build/esm/MCPLocal.mjs +488 -1594
- package/build/esm/MCPLocal.mjs.map +4 -4
- package/build-examples/cjs/example_mcp_local.js +4 -5
- package/build-examples/cjs/example_mcp_local.js.map +4 -4
- package/build-examples/esm/example_mcp_local.mjs +4 -5
- package/build-examples/esm/example_mcp_local.mjs.map +4 -4
- package/package.json +8 -7
- package/types/MCPLocal.d.ts +0 -1
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{EncryptMethod as je,FIXParser as $e,Field as P,Fields as S,LicenseManager as qe,Messages as Le,ResetSeqNumFlag as ze}from"fixparser";import{Server as B}from"@modelcontextprotocol/sdk/server/index.js";import{StdioServerTransport as J}from"@modelcontextprotocol/sdk/server/stdio.js";import{CallToolRequestSchema as H,ListResourcesRequestSchema as K,ListToolsRequestSchema as G}from"@modelcontextprotocol/sdk/types.js";import{z as u}from"zod";import{ZodFirstPartyTypeKind as c}from"zod";import{ZodFirstPartyTypeKind as ee}from"zod";import{ZodFirstPartyTypeKind as k}from"zod";import{ZodOptional as Se}from"zod";import{Field as g,Fields as d,HandlInst as N,MDEntryType as Z,Messages as T,OrdType as Ce,SubscriptionRequestType as E,TimeInForce as R}from"fixparser";var V=Symbol("Let zodToJsonSchema decide on which parser to use"),F={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"},W=e=>typeof e=="string"?{...F,name:e}:{...F,...e},Q=e=>{let t=W(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 C(e,t,n,r){r?.errorMessages&&n&&(e.errorMessage={...e.errorMessage,[t]:n})}function m(e,t,n,r,a){e[t]=n,C(e,t,r,a)}function Y(){return{}}function te(e,t){let n={type:"array"};return e.type?._def&&e.type?._def?.typeName!==ee.ZodAny&&(n.items=l(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 re(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 ne(){return{type:"boolean"}}function j(e,t){return l(e.type._def,t)}var ae=(e,t)=>l(e.innerType._def,t);function $(e,t,n){let r=n??t.dateStrategy;if(Array.isArray(r))return{anyOf:r.map((a,i)=>$(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 ie(e,t)}}var ie=(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 se(e,t){return{...l(e.innerType._def,t),default:e.defaultValue()}}function oe(e,t){return t.effectStrategy==="input"?l(e.schema._def,t):{}}function ue(e){return{type:"string",enum:Array.from(e.values)}}var ce=e=>"type"in e&&e.type==="string"?!1:"allOf"in e;function pe(e,t){let n=[l(e.left._def,{...t,currentPath:[...t.currentPath,"allOf","0"]}),l(e.right._def,{...t,currentPath:[...t.currentPath,"allOf","1"]})].filter(i=>!!i),r=t.target==="jsonSchema2019-09"?{unevaluatedProperties:!1}:void 0,a=[];return n.forEach(i=>{if(ce(i))a.push(...i.allOf),i.unevaluatedProperties===void 0&&(r=void 0);else{let o=i;if("additionalProperties"in i&&i.additionalProperties===!1){let{additionalProperties:p,...s}=i;o=s}else r=void 0;a.push(o)}}),a.length?{allOf:a,...r}:void 0}function le(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 w=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:()=>(w===void 0&&(w=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),w),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 q(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(`^${O(r.value,t)}`),r.message,t);break;case"endsWith":y(n,RegExp(`${O(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(O(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 O(e,t){return t.patternStrategy==="escape"?me(e):e}var de=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function me(e){let t="";for(let n=0;n<e.length;n++)de.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:x(t,r),...n&&r.errorMessages&&{errorMessage:{pattern:n}}})):m(e,"pattern",x(t,r),n,r)}function x(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="",i=!1,o=!1,p=!1;for(let s=0;s<r.length;s++){if(i){a+=r[s],i=!1;continue}if(n.i){if(o){if(r[s].match(/[a-z]/)){p?(a+=r[s],a+=`${r[s-2]}-${r[s]}`.toUpperCase(),p=!1):r[s+1]==="-"&&r[s+2]?.match(/[a-z]/)?(a+=r[s],p=!0):a+=`${r[s]}${r[s].toUpperCase()}`;continue}}else if(r[s].match(/[a-z]/)){a+=`[${r[s]}${r[s].toUpperCase()}]`;continue}}if(n.m){if(r[s]==="^"){a+=`(^|(?<=[\r
|
|
3
|
-
]))
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
]`;continue}a+=r[s],r[s]==="\\"?i=!0:o&&r[s]==="]"?o=!1:!o&&r[s]==="["&&(o=!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 L(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===k.ZodEnum)return{type:"object",required:e.keyType._def.values,properties:e.keyType._def.values.reduce((r,a)=>({...r,[a]:l(e.valueType._def,{...t,currentPath:[...t.currentPath,"properties",a]})??{}}),{}),additionalProperties:t.rejectedAdditionalProperties};let n={type:"object",additionalProperties:l(e.valueType._def,{...t,currentPath:[...t.currentPath,"additionalProperties"]})??t.allowedAdditionalProperties};if(t.target==="openApi3")return n;if(e.keyType?._def.typeName===k.ZodString&&e.keyType._def.checks?.length){let{type:r,...a}=q(e.keyType._def,t);return{...n,propertyNames:a}}else{if(e.keyType?._def.typeName===k.ZodEnum)return{...n,propertyNames:{enum:e.keyType._def.values}};if(e.keyType?._def.typeName===k.ZodBranded&&e.keyType._def.type._def.typeName===k.ZodString&&e.keyType._def.type._def.checks?.length){let{type:r,...a}=j(e.keyType._def,t);return{...n,propertyNames:a}}}return n}function ge(e,t){if(t.mapStrategy==="record")return L(e,t);let n=l(e.keyType._def,{...t,currentPath:[...t.currentPath,"items","items","0"]})||{},r=l(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 ye(e){let t=e.values,r=Object.keys(e.values).filter(i=>typeof t[t[i]]!="number").map(i=>t[i]),a=Array.from(new Set(r.map(i=>typeof i)));return{type:a.length===1?a[0]==="string"?"string":"number":["string","number"],enum:r}}function fe(){return{not:{}}}function he(e){return e.target==="openApi3"?{enum:["null"],nullable:!0}:{type:"null"}}var A={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};function be(e,t){if(t.target==="openApi3")return _(e,t);let n=e.options instanceof Map?Array.from(e.options.values()):e.options;if(n.every(r=>r._def.typeName in A&&(!r._def.checks||!r._def.checks.length))){let r=n.reduce((a,i)=>{let o=A[i._def.typeName];return o&&!a.includes(o)?[...a,o]: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,i)=>{let o=typeof i._def.value;switch(o){case"string":case"number":case"boolean":return[...a,o];case"bigint":return[...a,"integer"];case"object":if(i._def.value===null)return[...a,"null"];case"symbol":case"undefined":case"function":default:return a}},[]);if(r.length===n.length){let a=r.filter((i,o,p)=>p.indexOf(i)===o);return{type:a.length>1?a:a[0],enum:n.reduce((i,o)=>i.includes(o._def.value)?i:[...i,o._def.value],[])}}}else if(n.every(r=>r._def.typeName==="ZodEnum"))return{type:"string",enum:n.reduce((r,a)=>[...r,...a._def.values.filter(i=>!r.includes(i))],[])};return _(e,t)}var _=(e,t)=>{let n=(e.options instanceof Map?Array.from(e.options.values()):e.options).map((r,a)=>l(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 ve(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:A[e.innerType._def.typeName],nullable:!0}:{type:[A[e.innerType._def.typeName],"null"]};if(t.target==="openApi3"){let r=l(e.innerType._def,{...t,currentPath:[...t.currentPath]});return r&&"$ref"in r?{allOf:[r],nullable:!0}:r&&{...r,nullable:!0}}let n=l(e.innerType._def,{...t,currentPath:[...t.currentPath,"anyOf","0"]});return n&&{anyOf:[n,{type:"null"}]}}function Pe(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",C(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 ke(e,t){let n=t.target==="openAi",r={type:"object",properties:{}},a=[],i=e.shape();for(let p in i){let s=i[p];if(s===void 0||s._def===void 0)continue;let f=Me(s);f&&n&&(s instanceof Se&&(s=s._def.innerType),s.isNullable()||(s=s.nullable()),f=!1);let v=l(s._def,{...t,currentPath:[...t.currentPath,"properties",p],propertyPath:[...t.currentPath,"properties",p]});v!==void 0&&(r.properties[p]=v,f||a.push(p))}a.length&&(r.required=a);let o=Te(e,t);return o!==void 0&&(r.additionalProperties=o),r}function Te(e,t){if(e.catchall._def.typeName!=="ZodNever")return l(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 Me(e){try{return e.isOptional()}catch{return!0}}var Ae=(e,t)=>{if(t.currentPath.toString()===t.propertyPath?.toString())return l(e.innerType._def,t);let n=l(e.innerType._def,{...t,currentPath:[...t.currentPath,"anyOf","1"]});return n?{anyOf:[{not:{}},n]}:{}},Ie=(e,t)=>{if(t.pipeStrategy==="input")return l(e.in._def,t);if(t.pipeStrategy==="output")return l(e.out._def,t);let n=l(e.in._def,{...t,currentPath:[...t.currentPath,"allOf","0"]}),r=l(e.out._def,{...t,currentPath:[...t.currentPath,"allOf",n?"1":"0"]});return{allOf:[n,r].filter(a=>a!==void 0)}};function we(e,t){return l(e.type._def,t)}function Oe(e,t){let r={type:"array",uniqueItems:!0,items:l(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 De(e,t){return e.rest?{type:"array",minItems:e.items.length,items:e.items.map((n,r)=>l(n._def,{...t,currentPath:[...t.currentPath,"items",`${r}`]})).reduce((n,r)=>r===void 0?n:[...n,r],[]),additionalItems:l(e.rest._def,{...t,currentPath:[...t.currentPath,"additionalItems"]})}:{type:"array",minItems:e.items.length,maxItems:e.items.length,items:e.items.map((n,r)=>l(n._def,{...t,currentPath:[...t.currentPath,"items",`${r}`]})).reduce((n,r)=>r===void 0?n:[...n,r],[])}}function Fe(){return{not:{}}}function xe(){return{}}var _e=(e,t)=>l(e.innerType._def,t),Ne=(e,t,n)=>{switch(t){case c.ZodString:return q(e,n);case c.ZodNumber:return Pe(e,n);case c.ZodObject:return ke(e,n);case c.ZodBigInt:return re(e,n);case c.ZodBoolean:return ne();case c.ZodDate:return $(e,n);case c.ZodUndefined:return Fe();case c.ZodNull:return he(n);case c.ZodArray:return te(e,n);case c.ZodUnion:case c.ZodDiscriminatedUnion:return be(e,n);case c.ZodIntersection:return pe(e,n);case c.ZodTuple:return De(e,n);case c.ZodRecord:return L(e,n);case c.ZodLiteral:return le(e,n);case c.ZodEnum:return ue(e);case c.ZodNativeEnum:return ye(e);case c.ZodNullable:return ve(e,n);case c.ZodOptional:return Ae(e,n);case c.ZodMap:return ge(e,n);case c.ZodSet:return Oe(e,n);case c.ZodLazy:return()=>e.getter()._def;case c.ZodPromise:return we(e,n);case c.ZodNaN:case c.ZodNever:return fe();case c.ZodEffects:return oe(e,n);case c.ZodAny:return Y();case c.ZodUnknown:return xe();case c.ZodDefault:return se(e,n);case c.ZodBranded:return j(e,n);case c.ZodReadonly:return _e(e,n);case c.ZodCatch:return ae(e,n);case c.ZodPipeline:return Ie(e,n);case c.ZodFunction:case c.ZodVoid:case c.ZodSymbol:return;default:return(r=>{})(t)}};function l(e,t,n=!1){let r=t.seen.get(e);if(t.override){let p=t.override?.(e,t,r,n);if(p!==V)return p}if(r&&!n){let p=Ze(r,t);if(p!==void 0)return p}let a={def:e,path:t.currentPath,jsonSchema:void 0};t.seen.set(e,a);let i=Ne(e,e.typeName,t),o=typeof i=="function"?l(i(),t):i;if(o&&Re(e,t,o),t.postProcess){let p=t.postProcess(o,e,t);return a.jsonSchema=o,p}return a.jsonSchema=o,o}var Ze=(e,t)=>{switch(t.$refStrategy){case"root":return{$ref:e.path.join("/")};case"relative":return{$ref:Ee(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}},Ee=(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("/")},Re=(e,t,n)=>(e.description&&(n.description=e.description,t.markdownDescription&&(n.markdownDescription=e.description)),n),M=(e,t)=>{let n=Q(t),r=typeof t=="object"&&t.definitions?Object.entries(t.definitions).reduce((s,[f,v])=>({...s,[f]:l(v._def,{...n,currentPath:[...n.basePath,n.definitionPath,f]},!0)??{}}),{}):void 0,a=typeof t=="string"?t:t?.nameStrategy==="title"?void 0:t?.name,i=l(e._def,a===void 0?n:{...n,currentPath:[...n.basePath,n.definitionPath,a]},!1)??{},o=typeof t=="object"&&t.name!==void 0&&t.nameStrategy==="title"?t.name:void 0;o!==void 0&&(i.title=o);let p=a===void 0?r?{...i,[n.definitionPath]:r}:i:{$ref:[...n.$refStrategy==="relative"?[]:n.basePath,n.definitionPath,a].join("/"),[n.definitionPath]:{...r,[a]:i}};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},z=class{logger;parser;server=new B({name:"fixparser",version:"1.0.0"},{capabilities:{tools:{}}});transport=new J;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===T.MarketDataSnapshotFullRefresh||n===T.ExecutionReport){let r=n===T.MarketDataSnapshotFullRefresh?t.getField(d.MDReqID):t.getField(d.ClOrdID);if(r){let a=r.value;if(typeof a=="string"||typeof a=="number"){let i=this.pendingRequests.get(String(a));i&&(i(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(K,async()=>({resources:[]})),this.server.setRequestHandler(G,async()=>({tools:[{name:"parse",description:"Parses a FIX message and describes it in plain language",inputSchema:M(u.object({fixString:u.string().describe("FIX message string to parse")}),{name:"ParseInput"})},{name:"parseToJSON",description:"Parses a FIX message into JSON",inputSchema:M(u.object({fixString:u.string().describe("FIX message string to parse")}),{name:"ParseToJSONInput"})},{name:"newOrderSingle",description:"Creates and sends a New Order Single",inputSchema:M(u.object({clOrdID:u.string().describe("Client Order ID"),handlInst:u.enum(["1","2","3"]).default(N.AutomatedExecutionNoIntervention).optional().describe("Handling instruction"),quantity:u.number().describe("Order quantity"),price:u.number().describe("Order price"),ordType:u.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.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.string().describe("Trading symbol"),timeInForce:u.enum(["0","1","2","3","4","5","6","7","8","9","A","B","C"]).default(R.Day).optional().describe("Time in force")}),{name:"NewOrderSingleInput"})},{name:"marketDataRequest",description:"Sends a request for Market Data with the given symbol",inputSchema:M(u.object({mdUpdateType:u.enum(["0","1"]).default("0").optional().describe("Market data update type"),symbol:u.string().describe("Trading symbol"),mdReqID:u.string().describe("Market data request ID"),subscriptionRequestType:u.enum(["0","1","2"]).default(E.SnapshotAndUpdates).optional().describe("Subscription request type"),mdEntryType:u.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(Z.Bid).optional().describe("Market data entry type")}),{name:"MarketDataRequestInput"})}]})),this.server.setRequestHandler(H,async e=>{let{name:t,arguments:n}=e.params;switch(t){case"parse":{let{fixString:r}=u.object({fixString:u.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.object({fixString:u.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:i,price:o,ordType:p,side:s,symbol:f,timeInForce:v}=u.object({clOrdID:u.string().describe("Client Order ID"),handlInst:u.enum(["1","2","3"]).default(N.AutomatedExecutionNoIntervention).optional().describe("Handling instruction"),quantity:u.number().describe("Order quantity"),price:u.number().describe("Order price"),ordType:u.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(Ce.Market).optional().describe("Order type"),side:u.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.string().describe("Trading symbol"),timeInForce:u.enum(["0","1","2","3","4","5","6","7","8","9","A","B","C"]).default(R.Day).optional().describe("Time in force")}).parse(n||{}),I=new Promise(U=>{this.pendingRequests.set(r,U)}),D=this.parser?.createMessage(new g(d.MsgType,T.NewOrderSingle),new g(d.MsgSeqNum,this.parser?.getNextTargetMsgSeqNum()),new g(d.SenderCompID,this.parser?.sender),new g(d.TargetCompID,this.parser?.target),new g(d.SendingTime,this.parser?.getTimestamp()),new g(d.ClOrdID,r),new g(d.Side,s),new g(d.Symbol,f),new g(d.OrderQty,i),new g(d.Price,o),new g(d.OrdType,p),new g(d.HandlInst,a),new g(d.TimeInForce,v),new g(d.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(D),this.logger?.log({level:"info",message:`FIXParser (MCP): (${this.parser?.protocol?.toUpperCase()}): >> sent ${D?.description}`});let X=await I;return{content:[{type:"text",text:`Execution Report for order ${r}: ${JSON.stringify(X.toFIXJSON())}`}]}}case"marketDataRequest":{let{mdUpdateType:r,symbol:a,mdReqID:i,subscriptionRequestType:o,mdEntryType:p}=u.object({mdUpdateType:u.enum(["0","1"]).default("0").optional().describe("Market data update type"),symbol:u.string().describe("Trading symbol"),mdReqID:u.string().describe("Market data request ID"),subscriptionRequestType:u.enum(["0","1","2"]).default(E.SnapshotAndUpdates).optional().describe("Subscription request type"),mdEntryType:u.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(Z.Bid).optional().describe("Market data entry type")}).parse(n||{}),s=new Promise(I=>{this.pendingRequests.set(i,I)}),f=this.parser?.createMessage(new g(d.MsgType,T.MarketDataRequest),new g(d.SenderCompID,this.parser?.sender),new g(d.MsgSeqNum,this.parser?.getNextTargetMsgSeqNum()),new g(d.TargetCompID,this.parser?.target),new g(d.SendingTime,this.parser?.getTimestamp()),new g(d.MarketDepth,0),new g(d.MDUpdateType,r),new g(d.NoRelatedSym,1),new g(d.Symbol,a),new g(d.MDReqID,i),new g(d.SubscriptionRequestType,o),new g(d.NoMDEntryTypes,1),new g(d.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 s;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 Xe=async()=>{await qe.setLicenseKey(process.env.FIXPARSER_LICENSE_KEY);let e=new $e({plugins:[new z({port:3099,onReady:()=>{}})]}),t=()=>{let i=e.createMessage(new P(S.MsgType,Le.Logon),new P(S.MsgSeqNum,e.getNextTargetMsgSeqNum()),new P(S.SenderCompID,n),new P(S.SendingTime,e.getTimestamp()),new P(S.TargetCompID,r),new P(S.ResetSeqNumFlag,ze.Yes),new P(S.EncryptMethod,je.None),new P(S.HeartBtInt,10));e.send(i)},n="CLIENT2",r="EXECUTOR",a={host:"localhost",port:5001,protocol:"tcp",sender:n,target:r,fixVersion:"FIX.4.4",logging:!1,onOpen:()=>{t()},onMessage:i=>{},onClose:()=>{}};e.connect(a)};Xe().catch(e=>console.error("Error initializing server:",e));
|
|
2
|
+
import{EncryptMethod as C,FIXParser as X,Field as l,Fields as u,LicenseManager as U,Messages as k,ResetSeqNumFlag as $}from"fixparser";import{Server as v}from"@modelcontextprotocol/sdk/server/index.js";import{StdioServerTransport as b}from"@modelcontextprotocol/sdk/server/stdio.js";import{CallToolRequestSchema as N,GetPromptRequestSchema as E,ListPromptsRequestSchema as D,ListResourcesRequestSchema as P,ListToolsRequestSchema as A}from"@modelcontextprotocol/sdk/types.js";import{Field as t,Fields as r,Messages as d}from"fixparser";var T={type:"object",properties:{fixString:{type:"string",description:"FIX message string to parse"}},required:["fixString"]},I={type:"object",properties:{fixString:{type:"string",description:"FIX message string to parse"}},required:["fixString"]},R={type:"object",properties:{clOrdID:{type:"string",description:"Client Order ID"},handlInst:{type:"string",enum:["1","2","3"],description:'Handling instruction (IMPORTANT: Use the numeric/alphabetic value, not the descriptive name. For example, use "1" for Manual, "2" for Automated, "3" for AutomatedNoIntervention)'},quantity:{type:"number",description:"Order quantity"},price:{type:"number",description:"Order price"},ordType:{type:"string",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"],description:'Order type (IMPORTANT: Use the numeric/alphabetic value, not the descriptive name. For example, use "1" for Market, "2" for Limit, "3" for Stop)'},side:{type:"string",enum:["1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H"],description:'Order side (IMPORTANT: Use the numeric/alphabetic value, not the descriptive name. For example, use "1" for Buy, "2" for Sell, "3" for BuyMinus, "4" for SellPlus, "5" for SellShort, "6" for SellShortExempt, "7" for Undisclosed, "8" for Cross, "9" for CrossShort, "A" for CrossShortExempt, "B" for AsDefined, "C" for Opposite, "D" for Subscribe, "E" for Redeem, "F" for Lend, "G" for Borrow, "H" for SellUndisclosed)'},symbol:{type:"string",description:"Trading symbol"},timeInForce:{type:"string",enum:["0","1","2","3","4","5","6","7","8","9","A","B","C"],description:'Time in force (IMPORTANT: Use the numeric/alphabetic value, not the descriptive name. For example, use "0" for Day, "1" for Good Till Cancel, "2" for At Opening, "3" for Immediate or Cancel, "4" for Fill or Kill, "5" for Good Till Crossing, "6" for Good Till Date)'}},required:["clOrdID","quantity","price","side","symbol"]},F={type:"object",properties:{mdUpdateType:{type:"string",enum:["0","1"],description:'Market data update type (IMPORTANT: Use the numeric/alphabetic value, not the descriptive name. For example, use "0" for FullRefresh, "1" for IncrementalRefresh)'},symbol:{type:"string",description:"Trading symbol"},mdReqID:{type:"string",description:"Market data request ID"},subscriptionRequestType:{type:"string",enum:["0","1","2"],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)'},mdEntryType:{type:"string",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"],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)'}},required:["symbol","mdReqID"]},w=class{parser;server=new v({name:"fixparser",version:"1.0.0"},{capabilities:{tools:{},prompts:{},resources:{}}});transport=new b;onReady=void 0;pendingRequests=new Map;constructor({logger:a,onReady:i}){i&&(this.onReady=i)}async register(a){this.parser=a,this.parser.addOnMessageCallback(i=>{let o=i.messageType;if(o===d.MarketDataSnapshotFullRefresh||o===d.ExecutionReport||o===d.Reject){let n=o===d.MarketDataSnapshotFullRefresh?i.getField(r.MDReqID):o===d.Reject?i.getField(r.RefSeqNum):i.getField(r.ClOrdID);if(n){let e=n.value;if(typeof e=="string"||typeof e=="number")if(o===d.Reject){let s=i.getField(r.RefMsgType);if(s&&s.value===d.NewOrderSingle){let p=this.pendingRequests.get(String(e));p&&(p(i),this.pendingRequests.delete(String(e)))}}else{let s=this.pendingRequests.get(String(e));s&&(s(i),this.pendingRequests.delete(String(e)))}}}}),this.addWorkflows(),await this.server.connect(this.transport),this.onReady&&this.onReady()}addWorkflows(){if(!this.parser||!this.server)return;let a=(i,o)=>{let n={};for(let[e,s]of Object.entries(o.properties||{})){let p=s,c=i?.[e];if(p.required&&c==null)throw new Error(`Required property '${e}' is missing`);c!==void 0?n[e]=c:p.default!==void 0&&(n[e]=p.default)}return n};this.server.setRequestHandler(P,async()=>({resources:[]})),this.server.setRequestHandler(A,async()=>({tools:[{name:"parse",description:"Parses a FIX message and describes it in plain language",inputSchema:T},{name:"parseToJSON",description:"Parses a FIX message into JSON",inputSchema:I},{name:"newOrderSingle",description:"Creates and sends a New Order Single",inputSchema:R},{name:"marketDataRequest",description:"Sends a request for Market Data with the given symbol",inputSchema:F}]})),this.server.setRequestHandler(N,async i=>{let{name:o,arguments:n}=i.params;switch(o){case"parse":try{let{fixString:e}=a(n,T),s=this.parser?.parse(e);return!s||s.length===0?{isError:!0,content:[{type:"text",text:"Error: Failed to parse FIX string"}]}:{content:[{type:"text",text:`${s[0].description}
|
|
3
|
+
${s[0].messageTypeDescription}`}]}}catch(e){return{isError:!0,content:[{type:"text",text:`Error: ${e instanceof Error?e.message:"Failed to parse FIX string"}`}]}}case"parseToJSON":try{let{fixString:e}=a(n,I),s=this.parser?.parse(e);return!s||s.length===0?{isError:!0,content:[{type:"text",text:"Error: Failed to parse FIX string"}]}:{content:[{type:"text",text:`${s[0].toFIXJSON()}`}]}}catch(e){return{isError:!0,content:[{type:"text",text:`Error: ${e instanceof Error?e.message:"Failed to parse FIX string"}`}]}}case"newOrderSingle":try{let{clOrdID:e,handlInst:s,quantity:p,price:c,ordType:m,side:g,symbol:h,timeInForce:f}=a(n,R),y=new Promise(M=>{this.pendingRequests.set(e,M)}),x=this.parser?.createMessage(new t(r.MsgType,d.NewOrderSingle),new t(r.MsgSeqNum,this.parser?.getNextTargetMsgSeqNum()),new t(r.SenderCompID,this.parser?.sender),new t(r.TargetCompID,this.parser?.target),new t(r.SendingTime,this.parser?.getTimestamp()),new t(r.ClOrdID,e),new t(r.Side,g),new t(r.Symbol,h),new t(r.OrderQty,p),new t(r.Price,c),new t(r.OrdType,m),new t(r.HandlInst,s),new t(r.TimeInForce,f),new t(r.TransactTime,this.parser?.getTimestamp()));if(!this.parser?.connected)return{isError:!0,content:[{type:"text",text:"Error: Not connected. Ignoring message."}]};this.parser?.send(x);let S=await y;return{content:[{type:"text",text:S.messageType===d.Reject?`Reject message for order ${e}: ${JSON.stringify(S.toFIXJSON())}`:`Execution Report for order ${e}: ${JSON.stringify(S.toFIXJSON())}`}]}}catch(e){return{isError:!0,content:[{type:"text",text:`Error: ${e instanceof Error?e.message:"Failed to create order"}`}]}}case"marketDataRequest":try{let{mdUpdateType:e,symbol:s,mdReqID:p,subscriptionRequestType:c,mdEntryType:m}=a(n,F),g=new Promise(y=>{this.pendingRequests.set(p,y)}),h=this.parser?.createMessage(new t(r.MsgType,d.MarketDataRequest),new t(r.SenderCompID,this.parser?.sender),new t(r.MsgSeqNum,this.parser?.getNextTargetMsgSeqNum()),new t(r.TargetCompID,this.parser?.target),new t(r.SendingTime,this.parser?.getTimestamp()),new t(r.MarketDepth,0),new t(r.MDUpdateType,e),new t(r.NoRelatedSym,1),new t(r.Symbol,s),new t(r.MDReqID,p),new t(r.SubscriptionRequestType,c),new t(r.NoMDEntryTypes,1),new t(r.MDEntryType,m));if(!this.parser?.connected)return{isError:!0,content:[{type:"text",text:"Error: Not connected. Ignoring message."}]};this.parser?.send(h);let f=await g;return{content:[{type:"text",text:`Market data for ${s}: ${JSON.stringify(f.toFIXJSON())}`}]}}catch(e){return{isError:!0,content:[{type:"text",text:`Error: ${e instanceof Error?e.message:"Failed to request market data"}`}]}}default:throw new Error(`Unknown tool: ${o}`)}}),this.server.setRequestHandler(D,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:!0},{name:"quantity",description:"Order quantity",required:!0},{name:"price",description:"Order price",required:!0},{name:"ordType",description:"Order type",required:!0},{name:"side",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)",required:!0},{name:"symbol",description:"Trading symbol",required:!0},{name:"timeInForce",description:"Time in force",required:!0}]},{name:"marketDataRequest",description:"Sends a request for Market Data with the given symbol",arguments:[{name:"mdUpdateType",description:"Market data update type",required:!0},{name:"symbol",description:"Trading symbol",required:!0},{name:"mdReqID",description:"Market data request ID",required:!0},{name:"subscriptionRequestType",description:"Subscription request type",required:!0},{name:"mdEntryType",description:"Market data entry type",required:!0}]}]})),this.server.setRequestHandler(E,async i=>{let{name:o,arguments:n}=i.params;switch(o){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:e,handlInst:s,quantity:p,price:c,ordType:m,side:g,symbol:h,timeInForce:f}=n||{};return{messages:[{role:"user",content:{type:"text",text:["Create a New Order Single FIX message with the following parameters:",`- ClOrdID: ${e}`,`- HandlInst: ${s??"3"} (IMPORTANT: Use the numeric/alphabetic value, not the descriptive name. For example, use '1' for Manual, '2' for Automated, '3' for AutomatedNoIntervention)`,`- Quantity: ${p}`,`- Price: ${c}`,`- OrdType: ${m??"1"} (IMPORTANT: Use the numeric/alphabetic value, not the descriptive name. For example, use '1' for Market, '2' for Limit, '3' for Stop)`,`- Side: ${g} (IMPORTANT: Use the numeric/alphabetic value, not the descriptive name. For example, use '1' for Buy, '2' for Sell)`,`- Symbol: ${h}`,`- TimeInForce: ${f??"0"} (IMPORTANT: Use the numeric/alphabetic value, not the descriptive name. For example, use '0' for Day, '1' for Good Till Cancel, '2' for At Opening, '3' for Immediate or Cancel, '4' for Fill or Kill, '5' for Good Till Crossing, '6' for Good Till Date)`,"",'Note: For the OrdType parameter, always use the numeric/alphabetic value (e.g., "1" for Market, "2" for Limit, "3" for Stop) as defined in the FIX protocol, not the descriptive name.','Note: For the TimeInForce parameter, always use the numeric/alphabetic value (e.g., "0" for Day, "1" for Good Till Cancel, "2" for At Opening) as defined in the FIX protocol, not the descriptive name.',"","IMPORTANT: The response will be either:","1. An Execution Report (MsgType=8) if the order was successfully placed","2. A Reject message (MsgType=3) if the order failed to execute (e.g., due to missing or invalid parameters)"].join(`
|
|
4
|
+
`)}}]}}case"marketDataRequest":{let{mdUpdateType:e,symbol:s,mdReqID:p,subscriptionRequestType:c,mdEntryType:m}=n||{};return{messages:[{role:"user",content:{type:"text",text:["Create a Market Data Request FIX message with the following parameters:",`- MDUpdateType: ${e??"0"} (IMPORTANT: Use the numeric/alphabetic value, not the descriptive name. For example, use '0' for FullRefresh, '1' for IncrementalRefresh)`,`- Symbol: ${s}`,`- MDReqID: ${p}`,`- SubscriptionRequestType: ${c??"0"} (IMPORTANT: Use the numeric/alphabetic value, not the descriptive name. For example, use '0' for Snapshot + Updates, '1' for Snapshot, '2' for Unsubscribe)`,`- MDEntryType: ${m??"0"} (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)`,"","Format the response as a JSON object with FIX tag numbers as keys and their corresponding values.","",'Note: For the MDUpdateType parameter, always use the numeric/alphabetic value (e.g., "0" for FullRefresh, "1" for IncrementalRefresh) as defined in the FIX protocol, not the descriptive name.','Note: For the SubscriptionRequestType parameter, always use the numeric/alphabetic value (e.g., "0" for Snapshot + Updates, "1" for Snapshot, "2" for Unsubscribe) as defined in the FIX protocol, not the descriptive name.','Note: For the MDEntryType parameter, always use the numeric/alphabetic value (e.g., "0" for Bid, "1" for Offer, "2" for Trade, "3" for Index Value, "4" for Opening Price) as defined in the FIX protocol, not the descriptive name.'].join(`
|
|
5
|
+
`)}}]}}default:throw new Error(`Unknown prompt: ${o}`)}}),process.on("SIGINT",async()=>{await this.server.close(),process.exit(0)})}};var O="CLIENT2",q="EXECUTOR",J=async()=>{await U.setLicenseKey(process.env.FIXPARSER_LICENSE_KEY);let a=new X({logging:!1,plugins:[new w({port:3099,onReady:()=>{}})]}),i=()=>{let n=a.createMessage(new l(u.MsgType,k.Logon),new l(u.MsgSeqNum,a.getNextTargetMsgSeqNum()),new l(u.SenderCompID,O),new l(u.SendingTime,a.getTimestamp()),new l(u.TargetCompID,q),new l(u.ResetSeqNumFlag,$.Yes),new l(u.EncryptMethod,C.None),new l(u.HeartBtInt,10));a.send(n)},o={host:process.env.FIXPARSER_HOST||"10.0.1.42",port:process.env.FIXPARSER_PORT?Number.parseInt(process.env.FIXPARSER_PORT,10):5001,protocol:"tcp",sender:process.env.FIXPARSER_SENDER||O,target:process.env.FIXPARSER_TARGET||q,fixVersion:process.env.FIXPARSER_TARGET||"FIX.4.4",onOpen:()=>{i()},onMessage:n=>{},onClose:()=>{setTimeout(()=>{a.connect(o)},1e3)}};a.connect(o)};J().catch(a=>console.error("Error initializing server:",a));
|
|
7
6
|
//# sourceMappingURL=example_mcp_local.mjs.map
|