fixparser-plugin-mcp 9.2.3-df68ad37 → 9.3.0-bb19a1db
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/RemoteServer.js +1 -1
- package/build/cjs/RemoteServer.js.map +3 -3
- package/build/cjs/StdioServer.js.map +1 -1
- package/build/esm/RemoteServer.mjs +1 -1
- package/build/esm/RemoteServer.mjs.map +3 -3
- package/build/esm/StdioServer.mjs +0 -0
- package/build/esm/StdioServer.mjs.map +1 -1
- package/package.json +3 -3
- package/types/mcp/MCPRemote.d.ts +1 -2
|
@@ -14,5 +14,5 @@ Parameters verified:
|
|
|
14
14
|
- TimeInForce: ${e.timeInForce} (${at[e.timeInForce]})
|
|
15
15
|
|
|
16
16
|
To execute this order, call the executeOrder tool with these exact same parameters. Important: The user has to explicitly confirm before executeOrder is called!`,uri:"verifyOrder"}]}}catch(n){return{content:[{type:"text",text:`Error: ${n instanceof Error?n.message:"Failed to verify order parameters"}`,uri:"verifyOrder"}],isError:!0}}},ve=(h,t,e)=>async n=>{try{let o=t.get(n.clOrdID);if(!o)return{content:[{type:"text",text:`Error: Order ${n.clOrdID} has not been verified. Please call verifyOrder first.`,uri:"executeOrder"}],isError:!0};if(o.handlInst!==n.handlInst||o.quantity!==Number.parseFloat(String(n.quantity))||o.price!==Number.parseFloat(String(n.price))||o.ordType!==n.ordType||o.side!==n.side||o.symbol!==n.symbol||o.timeInForce!==n.timeInForce)return{content:[{type:"text",text:"Error: Order parameters do not match the verified order. Please use the exact same parameters that were verified.",uri:"executeOrder"}],isError:!0};let i=new Promise(c=>{e.set(n.clOrdID,c)}),l=h.createMessage(new k(V.MsgType,Me.NewOrderSingle),new k(V.MsgSeqNum,h.getNextTargetMsgSeqNum()),new k(V.SenderCompID,h.sender),new k(V.TargetCompID,h.target),new k(V.SendingTime,h.getTimestamp()),new k(V.ClOrdID,n.clOrdID),new k(V.Side,n.side),new k(V.Symbol,n.symbol),new k(V.OrderQty,Number.parseFloat(String(n.quantity))),new k(V.Price,Number.parseFloat(String(n.price))),new k(V.OrdType,n.ordType),new k(V.HandlInst,n.handlInst),new k(V.TimeInForce,n.timeInForce),new k(V.TransactTime,h.getTimestamp()));if(!h.connected)return{content:[{type:"text",text:"Error: Not connected. Ignoring message.",uri:"executeOrder"}],isError:!0};h.send(l);let r=await i;return t.delete(n.clOrdID),{content:[{type:"text",text:r.messageType===Me.Reject?`Reject message for order ${n.clOrdID}: ${JSON.stringify(r.toFIXJSON())}`:`Execution Report for order ${n.clOrdID}: ${JSON.stringify(r.toFIXJSON())}`,uri:"executeOrder"}]}}catch(o){return{content:[{type:"text",text:`Error: ${o instanceof Error?o.message:"Failed to execute order"}`,uri:"executeOrder"}],isError:!0}}};var Ie=h=>async t=>{try{let e=h.parse(t.fixString);return!e||e.length===0?{content:[{type:"text",text:"Error: Failed to parse FIX string",uri:"parse"}],isError:!0}:{content:[{type:"text",text:`${e[0].description}
|
|
17
|
-
${e[0].messageTypeDescription}`,uri:"parse"}]}}catch(e){return{content:[{type:"text",text:`Error: ${e instanceof Error?e.message:"Failed to parse FIX string"}`,uri:"parse"}],isError:!0}}};var Re=h=>async t=>{try{let e=h.parse(t.fixString);return!e||e.length===0?{content:[{type:"text",text:"Error: Failed to parse FIX string",uri:"parseToJSON"}],isError:!0}:{content:[{type:"text",text:`${e[0].toFIXJSON()}`,uri:"parseToJSON"}]}}catch(e){return{content:[{type:"text",text:`Error: ${e instanceof Error?e.message:"Failed to parse FIX string"}`,uri:"parseToJSON"}],isError:!0}}};var we=(h,t,e,n)=>({parse:Ie(h),parseToJSON:Re(h),verifyOrder:Se(h,t),executeOrder:ve(h,t,e),marketDataRequest:fe(h,e),getStockGraph:ye(n),getStockPriceHistory:Pe(n),technicalAnalysis:pe(n)});import{Fields as ae,MDEntryType as R,Messages as ie}from"fixparser";function lt(h,t){return h[t]||t}function xe(h,t,e,n,o,i){let l=h.messageType;if(l===ie.MarketDataSnapshotFullRefresh||l===ie.MarketDataIncrementalRefresh){let r=h.getField(ae.Symbol)?.value,a=h.toFIXJSON().Body?.NoMDEntries||[],s={timestamp:Date.now(),bid:0,offer:0,spread:0,volume:0,trade:0,indexValue:0,openingPrice:0,closingPrice:0,settlementPrice:0,tradingSessionHighPrice:0,tradingSessionLowPrice:0,vwap:0,imbalance:0,openInterest:0,compositeUnderlyingPrice:0,simulatedSellPrice:0,simulatedBuyPrice:0,marginRate:0,midPrice:0,emptyBook:0,settleHighPrice:0,settleLowPrice:0,priorSettlePrice:0,sessionHighBid:0,sessionLowOffer:0,earlyPrices:0,auctionClearingPrice:0,swapValueFactor:0,dailyValueAdjustmentForLongPositions:0,cumulativeValueAdjustmentForLongPositions:0,dailyValueAdjustmentForShortPositions:0,cumulativeValueAdjustmentForShortPositions:0,fixingPrice:0,cashRate:0,recoveryRate:0,recoveryRateForLong:0,recoveryRateForShort:0,marketBid:0,marketOffer:0,shortSaleMinPrice:0,previousClosingPrice:0,thresholdLimitPriceBanding:0,dailyFinancingValue:0,accruedFinancingValue:0,twap:0};for(let d of a){let f=d.MDEntryType,g=d.MDEntryPx?Number.parseFloat(d.MDEntryPx):0,b=d.MDEntrySize?Number.parseFloat(d.MDEntrySize):0;switch(lt(R,f)){case R.Bid:s.bid=g;break;case R.Offer:s.offer=g;break;case R.Trade:s.trade=g;break;case R.IndexValue:s.indexValue=g;break;case R.OpeningPrice:s.openingPrice=g;break;case R.ClosingPrice:s.closingPrice=g;break;case R.SettlementPrice:s.settlementPrice=g;break;case R.TradingSessionHighPrice:s.tradingSessionHighPrice=g;break;case R.TradingSessionLowPrice:s.tradingSessionLowPrice=g;break;case R.VWAP:s.vwap=g;break;case R.Imbalance:s.imbalance=b;break;case R.TradeVolume:s.volume=b;break;case R.OpenInterest:s.openInterest=b;break;case R.CompositeUnderlyingPrice:s.compositeUnderlyingPrice=g;break;case R.SimulatedSellPrice:s.simulatedSellPrice=g;break;case R.SimulatedBuyPrice:s.simulatedBuyPrice=g;break;case R.MarginRate:s.marginRate=g;break;case R.MidPrice:s.midPrice=g;break;case R.EmptyBook:s.emptyBook=1;break;case R.SettleHighPrice:s.settleHighPrice=g;break;case R.SettleLowPrice:s.settleLowPrice=g;break;case R.PriorSettlePrice:s.priorSettlePrice=g;break;case R.SessionHighBid:s.sessionHighBid=g;break;case R.SessionLowOffer:s.sessionLowOffer=g;break;case R.EarlyPrices:s.earlyPrices=g;break;case R.AuctionClearingPrice:s.auctionClearingPrice=g;break;case R.SwapValueFactor:s.swapValueFactor=g;break;case R.DailyValueAdjustmentForLongPositions:s.dailyValueAdjustmentForLongPositions=g;break;case R.CumulativeValueAdjustmentForLongPositions:s.cumulativeValueAdjustmentForLongPositions=g;break;case R.DailyValueAdjustmentForShortPositions:s.dailyValueAdjustmentForShortPositions=g;break;case R.CumulativeValueAdjustmentForShortPositions:s.cumulativeValueAdjustmentForShortPositions=g;break;case R.FixingPrice:s.fixingPrice=g;break;case R.CashRate:s.cashRate=g;break;case R.RecoveryRate:s.recoveryRate=g;break;case R.RecoveryRateForLong:s.recoveryRateForLong=g;break;case R.RecoveryRateForShort:s.recoveryRateForShort=g;break;case R.MarketBid:s.marketBid=g;break;case R.MarketOffer:s.marketOffer=g;break;case R.ShortSaleMinPrice:s.shortSaleMinPrice=g;break;case R.PreviousClosingPrice:s.previousClosingPrice=g;break;case R.ThresholdLimitPriceBanding:s.thresholdLimitPriceBanding=g;break;case R.DailyFinancingValue:s.dailyFinancingValue=g;break;case R.AccruedFinancingValue:s.accruedFinancingValue=g;break;case R.TWAP:s.twap=g;break}}s.spread=s.offer-s.bid,n.has(r)||n.set(r,[]);let u=n.get(r);u.push(s),u.length>o&&u.splice(0,u.length-o),i?.(r,s);let m=h.getField(ae.MDReqID)?.value;if(m){let d=e.get(m);d&&(d(h),e.delete(m))}}else if(l===ie.ExecutionReport){let r=h.getField(ae.ClOrdID)?.value,c=e.get(r);c&&(c(h),e.delete(r))}}var Z={};function gt(h){if(h.type==="object"){let t={};for(let[e,n]of Object.entries(h.properties||{})){let o=n;o.type==="string"?o.enum?t[e]=H.enum(o.enum):t[e]=H.string():o.type==="number"?t[e]=H.number():o.type==="boolean"?t[e]=H.boolean():o.type==="array"?o.items.type==="string"?t[e]=H.array(H.string()):o.items.type==="number"?t[e]=H.array(H.number()):o.items.type==="boolean"?t[e]=H.array(H.boolean()):t[e]=H.array(H.any()):t[e]=H.any()}return t}return{}}var te=class extends ee{port;httpServer;mcpServer;serverName;serverVersion;verifiedOrders=new Map;pendingRequests=new Map;marketDataPrices=new Map;MAX_PRICE_HISTORY=1e5;constructor({port:t,logger:e,onReady:n}){super({logger:e,onReady:n}),this.port=t}async register(t){this.parser=t,this.logger=t.logger,this.logger?.log({level:"info",message:`FIXParser (MCP): -- Plugin registered. Creating MCP server on port ${this.port}...`}),this.parser.addOnMessageCallback(e=>{this.parser&&xe(e,this.parser,this.pendingRequests,this.marketDataPrices,this.MAX_PRICE_HISTORY)}),this.httpServer=ut(async(e,n)=>{if(!e.url||!e.method){n.writeHead(400),n.end("Bad Request");return}if(e.url==="/mcp"){let o=e.headers["mcp-session-id"];if(e.method==="POST"){let i=[];e.on("data",l=>{i.push(l)}),e.on("end",async()=>{let l,r=Buffer.concat(i).toString();try{l=JSON.parse(r)}catch(a){n.writeHead(400),n.end(JSON.stringify({error:"Invalid JSON"}));return}let c;if(o&&Z[o])c=Z[o];else if(!o&&e.method==="POST"&&dt(l))c=new ht({sessionIdGenerator:()=>ct(),onsessioninitialized:a=>{Z[a]=c}}),c.onclose=()=>{c.sessionId&&delete Z[c.sessionId]},this.mcpServer=new mt({name:this.serverName||"FIXParser",version:this.serverVersion||"1.0.0"}),this.setupTools(),await this.mcpServer.connect(c);else{n.writeHead(400,{"Content-Type":"application/json"}),n.end(JSON.stringify({jsonrpc:"2.0",error:{code:-32e3,message:"Bad Request: No valid session ID provided"},id:null}));return}try{await c.handleRequest(e,n,l)}catch(a){throw this.logger?.log({level:"error",message:`Error handling request: ${a}`}),a}})}else if(e.method==="GET"||e.method==="DELETE"){if(!o||!Z[o]){n.writeHead(400),n.end("Invalid or missing session ID");return}let i=Z[o];try{await i.handleRequest(e,n)}catch(l){throw this.logger?.log({level:"error",message:`Error handling ${e.method} request: ${l}`}),l}}else this.logger?.log({level:"error",message:`Method not allowed: ${e.method}`}),n.writeHead(405),n.end("Method Not Allowed")}else n.writeHead(404),n.end("Not Found")}),this.httpServer.listen(this.port,()=>{this.logger?.log({level:"info",message:`FIXParser (MCP): -- Server listening on http://localhost:${this.port}...`})}),this.onReady&&this.onReady()}setupTools(){if(!this.parser){this.logger?.log({level:"error",message:"FIXParser (MCP): -- FIXParser instance not initialized. Ignoring setup of tools..."});return}if(!this.mcpServer){this.logger?.log({level:"error",message:"FIXParser (MCP): -- MCP Server not initialized. Ignoring setup of tools..."});return}let t=we(this.parser,this.verifiedOrders,this.pendingRequests,this.marketDataPrices);Object.entries(ge).forEach(([e,{description:n,schema:o}])=>{this.mcpServer?.registerTool(e,{description:n,inputSchema:gt(o)},async i=>{let l=t[e];if(!l)return{content:[{type:"text",text:`Tool not found: ${e}`}],isError:!0};let r=await l(i);return{content:r.content,isError:r.isError}})})}};var Mt=async()=>{let h={FIXPARSER_LICENSE_KEY:process.env.FIXPARSER_LICENSE_KEY,FIXPARSER_HOST:process.env.FIXPARSER_HOST,FIXPARSER_PORT:process.env.FIXPARSER_PORT,FIXPARSER_SENDER:process.env.FIXPARSER_SENDER,FIXPARSER_TARGET:process.env.FIXPARSER_TARGET},t=Object.entries(h).filter(([r,c])=>!c).map(([r])=>r);if(t.length>0)throw new Error(`Missing required environment variables: ${t.join(", ")}`);await bt.setLicenseKey(h.FIXPARSER_LICENSE_KEY);let e=h.FIXPARSER_SENDER,n=h.FIXPARSER_TARGET,o=new ft({logging:!0,logOptions:{name:e,level:"info",format:"jsonrpc",transport:new de({format:"jsonrpc",useStderr:!0})},plugins:[new te({port:3099,onReady:()=>
|
|
17
|
+
${e[0].messageTypeDescription}`,uri:"parse"}]}}catch(e){return{content:[{type:"text",text:`Error: ${e instanceof Error?e.message:"Failed to parse FIX string"}`,uri:"parse"}],isError:!0}}};var Re=h=>async t=>{try{let e=h.parse(t.fixString);return!e||e.length===0?{content:[{type:"text",text:"Error: Failed to parse FIX string",uri:"parseToJSON"}],isError:!0}:{content:[{type:"text",text:`${e[0].toFIXJSON()}`,uri:"parseToJSON"}]}}catch(e){return{content:[{type:"text",text:`Error: ${e instanceof Error?e.message:"Failed to parse FIX string"}`,uri:"parseToJSON"}],isError:!0}}};var we=(h,t,e,n)=>({parse:Ie(h),parseToJSON:Re(h),verifyOrder:Se(h,t),executeOrder:ve(h,t,e),marketDataRequest:fe(h,e),getStockGraph:ye(n),getStockPriceHistory:Pe(n),technicalAnalysis:pe(n)});import{Fields as ae,MDEntryType as R,Messages as ie}from"fixparser";function lt(h,t){return h[t]||t}function xe(h,t,e,n,o,i){let l=h.messageType;if(l===ie.MarketDataSnapshotFullRefresh||l===ie.MarketDataIncrementalRefresh){let r=h.getField(ae.Symbol)?.value,a=h.toFIXJSON().Body?.NoMDEntries||[],s={timestamp:Date.now(),bid:0,offer:0,spread:0,volume:0,trade:0,indexValue:0,openingPrice:0,closingPrice:0,settlementPrice:0,tradingSessionHighPrice:0,tradingSessionLowPrice:0,vwap:0,imbalance:0,openInterest:0,compositeUnderlyingPrice:0,simulatedSellPrice:0,simulatedBuyPrice:0,marginRate:0,midPrice:0,emptyBook:0,settleHighPrice:0,settleLowPrice:0,priorSettlePrice:0,sessionHighBid:0,sessionLowOffer:0,earlyPrices:0,auctionClearingPrice:0,swapValueFactor:0,dailyValueAdjustmentForLongPositions:0,cumulativeValueAdjustmentForLongPositions:0,dailyValueAdjustmentForShortPositions:0,cumulativeValueAdjustmentForShortPositions:0,fixingPrice:0,cashRate:0,recoveryRate:0,recoveryRateForLong:0,recoveryRateForShort:0,marketBid:0,marketOffer:0,shortSaleMinPrice:0,previousClosingPrice:0,thresholdLimitPriceBanding:0,dailyFinancingValue:0,accruedFinancingValue:0,twap:0};for(let d of a){let f=d.MDEntryType,g=d.MDEntryPx?Number.parseFloat(d.MDEntryPx):0,b=d.MDEntrySize?Number.parseFloat(d.MDEntrySize):0;switch(lt(R,f)){case R.Bid:s.bid=g;break;case R.Offer:s.offer=g;break;case R.Trade:s.trade=g;break;case R.IndexValue:s.indexValue=g;break;case R.OpeningPrice:s.openingPrice=g;break;case R.ClosingPrice:s.closingPrice=g;break;case R.SettlementPrice:s.settlementPrice=g;break;case R.TradingSessionHighPrice:s.tradingSessionHighPrice=g;break;case R.TradingSessionLowPrice:s.tradingSessionLowPrice=g;break;case R.VWAP:s.vwap=g;break;case R.Imbalance:s.imbalance=b;break;case R.TradeVolume:s.volume=b;break;case R.OpenInterest:s.openInterest=b;break;case R.CompositeUnderlyingPrice:s.compositeUnderlyingPrice=g;break;case R.SimulatedSellPrice:s.simulatedSellPrice=g;break;case R.SimulatedBuyPrice:s.simulatedBuyPrice=g;break;case R.MarginRate:s.marginRate=g;break;case R.MidPrice:s.midPrice=g;break;case R.EmptyBook:s.emptyBook=1;break;case R.SettleHighPrice:s.settleHighPrice=g;break;case R.SettleLowPrice:s.settleLowPrice=g;break;case R.PriorSettlePrice:s.priorSettlePrice=g;break;case R.SessionHighBid:s.sessionHighBid=g;break;case R.SessionLowOffer:s.sessionLowOffer=g;break;case R.EarlyPrices:s.earlyPrices=g;break;case R.AuctionClearingPrice:s.auctionClearingPrice=g;break;case R.SwapValueFactor:s.swapValueFactor=g;break;case R.DailyValueAdjustmentForLongPositions:s.dailyValueAdjustmentForLongPositions=g;break;case R.CumulativeValueAdjustmentForLongPositions:s.cumulativeValueAdjustmentForLongPositions=g;break;case R.DailyValueAdjustmentForShortPositions:s.dailyValueAdjustmentForShortPositions=g;break;case R.CumulativeValueAdjustmentForShortPositions:s.cumulativeValueAdjustmentForShortPositions=g;break;case R.FixingPrice:s.fixingPrice=g;break;case R.CashRate:s.cashRate=g;break;case R.RecoveryRate:s.recoveryRate=g;break;case R.RecoveryRateForLong:s.recoveryRateForLong=g;break;case R.RecoveryRateForShort:s.recoveryRateForShort=g;break;case R.MarketBid:s.marketBid=g;break;case R.MarketOffer:s.marketOffer=g;break;case R.ShortSaleMinPrice:s.shortSaleMinPrice=g;break;case R.PreviousClosingPrice:s.previousClosingPrice=g;break;case R.ThresholdLimitPriceBanding:s.thresholdLimitPriceBanding=g;break;case R.DailyFinancingValue:s.dailyFinancingValue=g;break;case R.AccruedFinancingValue:s.accruedFinancingValue=g;break;case R.TWAP:s.twap=g;break}}s.spread=s.offer-s.bid,n.has(r)||n.set(r,[]);let u=n.get(r);u.push(s),u.length>o&&u.splice(0,u.length-o),i?.(r,s);let m=h.getField(ae.MDReqID)?.value;if(m){let d=e.get(m);d&&(d(h),e.delete(m))}}else if(l===ie.ExecutionReport){let r=h.getField(ae.ClOrdID)?.value,c=e.get(r);c&&(c(h),e.delete(r))}}var Z={};function gt(h){if(h.type==="object"){let t={};for(let[e,n]of Object.entries(h.properties||{})){let o=n;o.type==="string"?o.enum?t[e]=H.enum(o.enum):t[e]=H.string():o.type==="number"?t[e]=H.number():o.type==="boolean"?t[e]=H.boolean():o.type==="array"?o.items.type==="string"?t[e]=H.array(H.string()):o.items.type==="number"?t[e]=H.array(H.number()):o.items.type==="boolean"?t[e]=H.array(H.boolean()):t[e]=H.array(H.any()):t[e]=H.any()}return t}return{}}var te=class extends ee{port;httpServer;mcpServer;serverName;serverVersion;verifiedOrders=new Map;pendingRequests=new Map;marketDataPrices=new Map;MAX_PRICE_HISTORY=1e5;constructor({port:t,logger:e,onReady:n}){super({logger:e,onReady:n}),this.port=t}async register(t){this.parser=t,this.logger=t.logger,this.logger?.log({level:"info",message:`FIXParser (MCP): -- Plugin registered. Creating MCP server on port ${this.port}...`}),this.parser.addOnMessageCallback(e=>{this.parser&&xe(e,this.parser,this.pendingRequests,this.marketDataPrices,this.MAX_PRICE_HISTORY)}),this.httpServer=ut(async(e,n)=>{if(!e.url||!e.method){n.writeHead(400),n.end("Bad Request");return}if(e.url==="/mcp"){let o=e.headers["mcp-session-id"];if(e.method==="POST"){let i=[];e.on("data",l=>{i.push(l)}),e.on("end",async()=>{let l,r=Buffer.concat(i).toString();try{l=JSON.parse(r)}catch(a){n.writeHead(400),n.end(JSON.stringify({error:"Invalid JSON"}));return}let c;if(o&&Z[o])c=Z[o],this.logger?.log({level:"info",message:`FIXParser (MCP): -- Using session ID: ${o}`});else if(!o&&e.method==="POST"&&dt(l))c=new ht({sessionIdGenerator:()=>ct(),onsessioninitialized:a=>{this.logger?.log({level:"info",message:`FIXParser (MCP): -- New session ID: ${a}`}),Z[a]=c}}),c.onclose=()=>{c.sessionId&&delete Z[c.sessionId]},this.mcpServer=new mt({name:this.serverName||"FIXParser",version:this.serverVersion||"1.0.0"}),this.setupTools(),await this.mcpServer.connect(c);else{n.writeHead(400,{"Content-Type":"application/json"}),n.end(JSON.stringify({jsonrpc:"2.0",error:{code:-32e3,message:"Bad Request: No valid session ID provided"},id:null}));return}try{await c.handleRequest(e,n,l)}catch(a){throw this.logger?.log({level:"error",message:`Error handling request: ${a}`}),a}})}else if(e.method==="GET"||e.method==="DELETE"){if(!o||!Z[o]){n.writeHead(400),n.end("Invalid or missing session ID");return}let i=Z[o];try{await i.handleRequest(e,n)}catch(l){throw this.logger?.log({level:"error",message:`Error handling ${e.method} request: ${l}`}),l}}else this.logger?.log({level:"error",message:`Method not allowed: ${e.method}`}),n.writeHead(405),n.end("Method Not Allowed")}else n.writeHead(404),n.end("Not Found")}),this.httpServer.listen(this.port,()=>{this.logger?.log({level:"info",message:`FIXParser (MCP): -- Server listening on http://localhost:${this.port}...`})}),this.onReady&&this.onReady()}setupTools(){if(!this.parser){this.logger?.log({level:"error",message:"FIXParser (MCP): -- FIXParser instance not initialized. Ignoring setup of tools..."});return}if(!this.mcpServer){this.logger?.log({level:"error",message:"FIXParser (MCP): -- MCP Server not initialized. Ignoring setup of tools..."});return}let t=we(this.parser,this.verifiedOrders,this.pendingRequests,this.marketDataPrices);Object.entries(ge).forEach(([e,{description:n,schema:o}])=>{this.mcpServer?.registerTool(e,{description:n,inputSchema:gt(o)},async i=>{let l=t[e];if(!l)return{content:[{type:"text",text:`Tool not found: ${e}`}],isError:!0};let r=await l(i);return{content:r.content,isError:r.isError}})})}};var Mt=async()=>{let h={FIXPARSER_LICENSE_KEY:process.env.FIXPARSER_LICENSE_KEY,FIXPARSER_HOST:process.env.FIXPARSER_HOST,FIXPARSER_PORT:process.env.FIXPARSER_PORT,FIXPARSER_SENDER:process.env.FIXPARSER_SENDER,FIXPARSER_TARGET:process.env.FIXPARSER_TARGET},t=Object.entries(h).filter(([r,c])=>!c).map(([r])=>r);if(t.length>0)throw new Error(`Missing required environment variables: ${t.join(", ")}`);await bt.setLicenseKey(h.FIXPARSER_LICENSE_KEY);let e=h.FIXPARSER_SENDER,n=h.FIXPARSER_TARGET,o=new ft({logging:!0,logOptions:{name:e,level:"info",format:"jsonrpc",transport:new de({format:"jsonrpc",useStderr:!0})},plugins:[new te({port:3099,onReady:()=>console.log("MCP Server started.")})]}),i=()=>{let r=o.createMessage(new K(Q.MsgType,yt.Logon),new K(Q.MsgSeqNum,o.getNextTargetMsgSeqNum()),new K(Q.SenderCompID,e),new K(Q.SendingTime,o.getTimestamp()),new K(Q.TargetCompID,n),new K(Q.ResetSeqNumFlag,Pt.Yes),new K(Q.EncryptMethod,pt.None),new K(Q.HeartBtInt,10)),c=o.parse(r.encode());console.log("sending message",c[0].description,c[0].messageString),o.send(r)},l={host:h.FIXPARSER_HOST,port:Number.parseInt(h.FIXPARSER_PORT,10),protocol:"tcp",sender:e,target:n,fixVersion:"FIX.4.4",onOpen:()=>{o.logger?.log({level:"info",message:"FIXParser (RemoteServer): -- Connection established"}),i()},onClose:()=>{o.logger?.log({level:"info",message:"FIXParser (RemoteServer): -- disconnected. Reconnecting in 1 second..."}),setTimeout(()=>{o.connect(l)},1e3)}};o.connect(l)};Mt().catch(h=>console.error("Error initializing server:",h));
|
|
18
18
|
//# sourceMappingURL=RemoteServer.mjs.map
|