fixparser-plugin-mcp 9.1.7-f3ba3218 → 9.1.7-fe71108a

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.
@@ -8,16 +8,7 @@ import {
8
8
  ListResourcesRequestSchema,
9
9
  ListToolsRequestSchema
10
10
  } from "@modelcontextprotocol/sdk/types.js";
11
- import {
12
- Field,
13
- Fields,
14
- HandlInst,
15
- MDEntryType,
16
- Messages,
17
- OrdType,
18
- SubscriptionRequestType,
19
- TimeInForce
20
- } from "fixparser";
11
+ import { Field, Fields, Messages } from "fixparser";
21
12
  var parseInputSchema = {
22
13
  type: "object",
23
14
  properties: {
@@ -48,7 +39,6 @@ var newOrderSingleInputSchema = {
48
39
  handlInst: {
49
40
  type: "string",
50
41
  enum: ["1", "2", "3"],
51
- default: HandlInst.AutomatedExecutionNoIntervention,
52
42
  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)'
53
43
  },
54
44
  quantity: {
@@ -89,7 +79,6 @@ var newOrderSingleInputSchema = {
89
79
  "R",
90
80
  "S"
91
81
  ],
92
- default: OrdType.Market,
93
82
  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)'
94
83
  },
95
84
  side: {
@@ -104,11 +93,10 @@ var newOrderSingleInputSchema = {
104
93
  timeInForce: {
105
94
  type: "string",
106
95
  enum: ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C"],
107
- default: TimeInForce.Day,
108
96
  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)'
109
97
  }
110
98
  },
111
- required: ["clOrdID", "quantity", "price", "side", "symbol"]
99
+ required: ["clOrdID", "quantity", "price", "side", "symbol", "handlInst", "ordType", "timeInForce"]
112
100
  };
113
101
  var marketDataRequestInputSchema = {
114
102
  type: "object",
@@ -116,7 +104,6 @@ var marketDataRequestInputSchema = {
116
104
  mdUpdateType: {
117
105
  type: "string",
118
106
  enum: ["0", "1"],
119
- default: "0",
120
107
  description: 'Market data update type (IMPORTANT: Use the numeric/alphabetic value, not the descriptive name. For example, use "0" for FullRefresh, "1" for IncrementalRefresh)'
121
108
  },
122
109
  symbol: {
@@ -130,7 +117,6 @@ var marketDataRequestInputSchema = {
130
117
  subscriptionRequestType: {
131
118
  type: "string",
132
119
  enum: ["0", "1", "2"],
133
- default: SubscriptionRequestType.SnapshotAndUpdates,
134
120
  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)'
135
121
  },
136
122
  mdEntryType: {
@@ -181,14 +167,13 @@ var marketDataRequestInputSchema = {
181
167
  "i",
182
168
  "t"
183
169
  ],
184
- default: MDEntryType.Bid,
185
170
  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)'
186
171
  }
187
172
  },
188
173
  required: ["symbol", "mdReqID"]
189
174
  };
190
175
  var MCPLocal = class {
191
- logger;
176
+ // private logger: Logger | undefined;
192
177
  parser;
193
178
  server = new Server(
194
179
  {
@@ -207,27 +192,32 @@ var MCPLocal = class {
207
192
  onReady = void 0;
208
193
  pendingRequests = /* @__PURE__ */ new Map();
209
194
  constructor({ logger, onReady }) {
210
- if (logger && !logger.silent) {
211
- this.logger = logger;
212
- }
213
195
  if (onReady) this.onReady = onReady;
214
196
  }
215
197
  async register(parser) {
216
198
  this.parser = parser;
217
- if (parser.logger && !parser.logger.silent) {
218
- this.logger = parser.logger;
219
- }
220
199
  this.parser.addOnMessageCallback((message) => {
221
200
  const msgType = message.messageType;
222
- if (msgType === Messages.MarketDataSnapshotFullRefresh || msgType === Messages.ExecutionReport) {
223
- const idField = msgType === Messages.MarketDataSnapshotFullRefresh ? message.getField(Fields.MDReqID) : message.getField(Fields.ClOrdID);
201
+ if (msgType === Messages.MarketDataSnapshotFullRefresh || msgType === Messages.ExecutionReport || msgType === Messages.Reject) {
202
+ const idField = msgType === Messages.MarketDataSnapshotFullRefresh ? message.getField(Fields.MDReqID) : msgType === Messages.Reject ? message.getField(Fields.RefSeqNum) : message.getField(Fields.ClOrdID);
224
203
  if (idField) {
225
204
  const id = idField.value;
226
205
  if (typeof id === "string" || typeof id === "number") {
227
- const callback = this.pendingRequests.get(String(id));
228
- if (callback) {
229
- callback(message);
230
- this.pendingRequests.delete(String(id));
206
+ if (msgType === Messages.Reject) {
207
+ const refMsgType = message.getField(Fields.RefMsgType);
208
+ if (refMsgType && refMsgType.value === Messages.NewOrderSingle) {
209
+ const callback = this.pendingRequests.get(String(id));
210
+ if (callback) {
211
+ callback(message);
212
+ this.pendingRequests.delete(String(id));
213
+ }
214
+ }
215
+ } else {
216
+ const callback = this.pendingRequests.get(String(id));
217
+ if (callback) {
218
+ callback(message);
219
+ this.pendingRequests.delete(String(id));
220
+ }
231
221
  }
232
222
  }
233
223
  }
@@ -241,17 +231,9 @@ var MCPLocal = class {
241
231
  }
242
232
  addWorkflows() {
243
233
  if (!this.parser) {
244
- this.logger?.log({
245
- level: "error",
246
- message: "FIXParser (MCP): -- FIXParser instance not initialized. Ignoring setup of workflows..."
247
- });
248
234
  return;
249
235
  }
250
236
  if (!this.server) {
251
- this.logger?.log({
252
- level: "error",
253
- message: "FIXParser (MCP): -- MCP Server not initialized. Ignoring setup of workflows..."
254
- });
255
237
  return;
256
238
  }
257
239
  const validateArgs = (args, schema) => {
@@ -388,10 +370,6 @@ ${parsedMessage[0].messageTypeDescription}`
388
370
  new Field(Fields.TransactTime, this.parser?.getTimestamp())
389
371
  );
390
372
  if (!this.parser?.connected) {
391
- this.logger?.log({
392
- level: "error",
393
- message: "FIXParser (MCP): -- Not connected. Ignoring message."
394
- });
395
373
  return {
396
374
  isError: true,
397
375
  content: [
@@ -403,16 +381,12 @@ ${parsedMessage[0].messageTypeDescription}`
403
381
  };
404
382
  }
405
383
  this.parser?.send(order);
406
- this.logger?.log({
407
- level: "info",
408
- message: `FIXParser (MCP): (${this.parser?.protocol?.toUpperCase()}): >> sent ${order?.description}`
409
- });
410
384
  const fixData = await response;
411
385
  return {
412
386
  content: [
413
387
  {
414
388
  type: "text",
415
- text: `Execution Report for order ${clOrdID}: ${JSON.stringify(fixData.toFIXJSON())}`
389
+ text: fixData.messageType === Messages.Reject ? `Reject message for order ${clOrdID}: ${JSON.stringify(fixData.toFIXJSON())}` : `Execution Report for order ${clOrdID}: ${JSON.stringify(fixData.toFIXJSON())}`
416
390
  }
417
391
  ]
418
392
  };
@@ -453,10 +427,6 @@ ${parsedMessage[0].messageTypeDescription}`
453
427
  new Field(Fields.MDEntryType, mdEntryType)
454
428
  );
455
429
  if (!this.parser?.connected) {
456
- this.logger?.log({
457
- level: "error",
458
- message: "FIXParser (MCP): -- Not connected. Ignoring message."
459
- });
460
430
  return {
461
431
  isError: true,
462
432
  content: [
@@ -468,10 +438,6 @@ ${parsedMessage[0].messageTypeDescription}`
468
438
  };
469
439
  }
470
440
  this.parser?.send(marketDataRequest);
471
- this.logger?.log({
472
- level: "info",
473
- message: `FIXParser (MCP): (${this.parser?.protocol?.toUpperCase()}): >> sent ${marketDataRequest?.description}`
474
- });
475
441
  const fixData = await response;
476
442
  return {
477
443
  content: [
@@ -534,7 +500,7 @@ ${parsedMessage[0].messageTypeDescription}`
534
500
  {
535
501
  name: "handlInst",
536
502
  description: "Handling instruction",
537
- required: false
503
+ required: true
538
504
  },
539
505
  {
540
506
  name: "quantity",
@@ -549,7 +515,7 @@ ${parsedMessage[0].messageTypeDescription}`
549
515
  {
550
516
  name: "ordType",
551
517
  description: "Order type",
552
- required: false
518
+ required: true
553
519
  },
554
520
  {
555
521
  name: "side",
@@ -564,7 +530,7 @@ ${parsedMessage[0].messageTypeDescription}`
564
530
  {
565
531
  name: "timeInForce",
566
532
  description: "Time in force",
567
- required: false
533
+ required: true
568
534
  }
569
535
  ]
570
536
  },
@@ -575,7 +541,7 @@ ${parsedMessage[0].messageTypeDescription}`
575
541
  {
576
542
  name: "mdUpdateType",
577
543
  description: "Market data update type",
578
- required: false
544
+ required: true
579
545
  },
580
546
  {
581
547
  name: "symbol",
@@ -590,12 +556,12 @@ ${parsedMessage[0].messageTypeDescription}`
590
556
  {
591
557
  name: "subscriptionRequestType",
592
558
  description: "Subscription request type",
593
- required: false
559
+ required: true
594
560
  },
595
561
  {
596
562
  name: "mdEntryType",
597
563
  description: "Market data entry type",
598
- required: false
564
+ required: true
599
565
  }
600
566
  ]
601
567
  }
@@ -652,12 +618,14 @@ ${parsedMessage[0].messageTypeDescription}`
652
618
  `- Symbol: ${symbol}`,
653
619
  `- TimeInForce: ${timeInForce ?? "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)`,
654
620
  "",
655
- "Format the response as a JSON object with FIX tag numbers as keys and their corresponding values.",
656
- "",
657
- 'Note: For the Side parameter, always use the numeric/alphabetic value (e.g., "1" for Buy, "2" for Sell) as defined in the FIX protocol, not the descriptive name.',
658
- 'Note: For the HandlInst parameter, always use the numeric/alphabetic value (e.g., "1" for Manual, "2" for Automated, "3" for AutomatedNoIntervention) as defined in the FIX protocol, not the descriptive name.',
659
621
  '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.',
660
- '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.'
622
+ '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.',
623
+ "",
624
+ "IMPORTANT: All parameters must be set before sending the order. Missing or invalid parameters will result in a Reject message.",
625
+ "",
626
+ "IMPORTANT: The response will be either:",
627
+ "1. An Execution Report (MsgType=8) if the order was successfully placed",
628
+ "2. A Reject message (MsgType=3) if the order failed to execute (e.g., due to missing or invalid parameters)"
661
629
  ].join("\n")
662
630
  }
663
631
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/MCPLocal.ts"],
4
- "sourcesContent": ["import { Server } from '@modelcontextprotocol/sdk/server/index.js';\nimport { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';\nimport {\n CallToolRequestSchema,\n GetPromptRequestSchema,\n ListPromptsRequestSchema,\n ListResourcesRequestSchema,\n ListToolsRequestSchema,\n} from '@modelcontextprotocol/sdk/types.js';\n\nimport {\n Field,\n Fields,\n HandlInst,\n type IFIXParser,\n type Logger,\n MDEntryType,\n type Message,\n Messages,\n OrdType,\n SubscriptionRequestType,\n TimeInForce,\n} from 'fixparser';\nimport type { IPlugin } from 'fixparser-common';\nimport type { PluginOptions } from './PluginOptions';\n\n// Define JSON Schemas\nconst parseInputSchema = {\n type: 'object',\n properties: {\n fixString: {\n type: 'string',\n description: 'FIX message string to parse',\n },\n },\n required: ['fixString'],\n};\n\nconst parseToJSONInputSchema = {\n type: 'object',\n properties: {\n fixString: {\n type: 'string',\n description: 'FIX message string to parse',\n },\n },\n required: ['fixString'],\n};\n\nconst newOrderSingleInputSchema = {\n type: 'object',\n properties: {\n clOrdID: {\n type: 'string',\n description: 'Client Order ID',\n },\n handlInst: {\n type: 'string',\n enum: ['1', '2', '3'],\n default: HandlInst.AutomatedExecutionNoIntervention,\n description:\n 'Handling instruction (IMPORTANT: Use the numeric/alphabetic value, not the descriptive name. For example, use \"1\" for Manual, \"2\" for Automated, \"3\" for AutomatedNoIntervention)',\n },\n quantity: {\n type: 'number',\n description: 'Order quantity',\n },\n price: {\n type: 'number',\n description: 'Order price',\n },\n ordType: {\n type: 'string',\n enum: [\n '1',\n '2',\n '3',\n '4',\n '5',\n '6',\n '7',\n '8',\n '9',\n 'A',\n 'B',\n 'C',\n 'D',\n 'E',\n 'F',\n 'G',\n 'H',\n 'I',\n 'J',\n 'K',\n 'L',\n 'M',\n 'P',\n 'Q',\n 'R',\n 'S',\n ],\n default: OrdType.Market,\n description:\n 'Order type (IMPORTANT: Use the numeric/alphabetic value, not the descriptive name. For example, use \"1\" for Market, \"2\" for Limit, \"3\" for Stop)',\n },\n side: {\n type: 'string',\n enum: ['1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H'],\n description:\n '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)',\n },\n symbol: {\n type: 'string',\n description: 'Trading symbol',\n },\n timeInForce: {\n type: 'string',\n enum: ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C'],\n default: TimeInForce.Day,\n description:\n '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)',\n },\n },\n required: ['clOrdID', 'quantity', 'price', 'side', 'symbol'],\n};\n\nconst marketDataRequestInputSchema = {\n type: 'object',\n properties: {\n mdUpdateType: {\n type: 'string',\n enum: ['0', '1'],\n default: '0',\n description:\n 'Market data update type (IMPORTANT: Use the numeric/alphabetic value, not the descriptive name. For example, use \"0\" for FullRefresh, \"1\" for IncrementalRefresh)',\n },\n symbol: {\n type: 'string',\n description: 'Trading symbol',\n },\n mdReqID: {\n type: 'string',\n description: 'Market data request ID',\n },\n subscriptionRequestType: {\n type: 'string',\n enum: ['0', '1', '2'],\n default: SubscriptionRequestType.SnapshotAndUpdates,\n description:\n '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)',\n },\n mdEntryType: {\n type: 'string',\n enum: [\n '0',\n '1',\n '2',\n '3',\n '4',\n '5',\n '6',\n '7',\n '8',\n '9',\n 'A',\n 'B',\n 'C',\n 'D',\n 'E',\n 'F',\n 'G',\n 'H',\n 'J',\n 'K',\n 'L',\n 'M',\n 'N',\n 'O',\n 'P',\n 'Q',\n 'S',\n 'R',\n 'T',\n 'U',\n 'V',\n 'W',\n 'X',\n 'Y',\n 'Z',\n 'a',\n 'b',\n 'c',\n 'd',\n 'e',\n 'g',\n 'h',\n 'i',\n 't',\n ],\n default: MDEntryType.Bid,\n description:\n '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)',\n },\n },\n required: ['symbol', 'mdReqID'],\n};\n\nexport class MCPLocal implements IPlugin<IFIXParser> {\n private logger: Logger | undefined;\n private parser: IFIXParser | undefined;\n private server: Server = new Server(\n {\n name: 'fixparser',\n version: '1.0.0',\n },\n {\n capabilities: {\n tools: {},\n prompts: {},\n resources: {},\n },\n },\n );\n private transport: StdioServerTransport = new StdioServerTransport();\n private onReady: (() => void) | undefined = undefined;\n\n private pendingRequests: Map<string, (data: Message) => void> = new Map();\n\n constructor({ logger, onReady }: PluginOptions) {\n if (logger && !logger.silent) {\n this.logger = logger;\n }\n\n if (onReady) this.onReady = onReady;\n }\n\n public async register(parser: IFIXParser): Promise<void> {\n this.parser = parser;\n if (parser.logger && !parser.logger.silent) {\n this.logger = parser.logger;\n }\n this.parser.addOnMessageCallback((message: Message) => {\n // this.logger?.log({\n // level: 'info',\n // message: `FIXParser (MCP): (${parser.protocol?.toUpperCase()}): << received ${message.description}`,\n // });\n const msgType = message.messageType;\n if (msgType === Messages.MarketDataSnapshotFullRefresh || msgType === Messages.ExecutionReport) {\n const idField =\n msgType === Messages.MarketDataSnapshotFullRefresh\n ? message.getField(Fields.MDReqID)\n : message.getField(Fields.ClOrdID);\n if (idField) {\n const id = idField.value;\n if (typeof id === 'string' || typeof id === 'number') {\n const callback = this.pendingRequests.get(String(id));\n if (callback) {\n callback(message);\n this.pendingRequests.delete(String(id));\n }\n }\n }\n }\n });\n\n this.addWorkflows();\n\n await this.server.connect(this.transport);\n\n if (this.onReady) {\n this.onReady();\n }\n }\n\n private addWorkflows() {\n if (!this.parser) {\n this.logger?.log({\n level: 'error',\n message: 'FIXParser (MCP): -- FIXParser instance not initialized. Ignoring setup of workflows...',\n });\n return;\n }\n\n if (!this.server) {\n this.logger?.log({\n level: 'error',\n message: 'FIXParser (MCP): -- MCP Server not initialized. Ignoring setup of workflows...',\n });\n return;\n }\n\n // Helper function to validate and parse arguments\n const validateArgs = (args: any, schema: any): any => {\n // Basic validation - in a real implementation, you might want to use a proper JSON Schema validator\n const result: any = {};\n\n for (const [key, propSchema] of Object.entries(schema.properties || {})) {\n const prop = propSchema as any;\n const value = args?.[key];\n\n if (prop.required && (value === undefined || value === null)) {\n throw new Error(`Required property '${key}' is missing`);\n }\n\n if (value !== undefined) {\n // Apply defaults\n result[key] = value;\n } else if (prop.default !== undefined) {\n result[key] = prop.default;\n }\n }\n\n return result;\n };\n\n // Empty handler for resources\n this.server.setRequestHandler(ListResourcesRequestSchema, async () => {\n return {\n resources: [],\n };\n });\n\n // Handler for listing available tools\n this.server.setRequestHandler(ListToolsRequestSchema, async () => {\n return {\n tools: [\n {\n name: 'parse',\n description: 'Parses a FIX message and describes it in plain language',\n inputSchema: parseInputSchema,\n },\n {\n name: 'parseToJSON',\n description: 'Parses a FIX message into JSON',\n inputSchema: parseToJSONInputSchema,\n },\n {\n name: 'newOrderSingle',\n description: 'Creates and sends a New Order Single',\n inputSchema: newOrderSingleInputSchema,\n },\n {\n name: 'marketDataRequest',\n description: 'Sends a request for Market Data with the given symbol',\n inputSchema: marketDataRequestInputSchema,\n },\n ],\n };\n });\n\n // Handler for tool calls\n this.server.setRequestHandler(CallToolRequestSchema, async (request) => {\n const { name, arguments: args } = request.params;\n\n switch (name) {\n case 'parse': {\n try {\n const { fixString } = validateArgs(args, parseInputSchema);\n const parsedMessage: Message[] | undefined = this.parser?.parse(fixString);\n if (!parsedMessage || parsedMessage.length === 0) {\n return {\n isError: true,\n content: [{ type: 'text', text: 'Error: Failed to parse FIX string' }],\n };\n }\n\n return {\n content: [\n {\n type: 'text',\n text: `${parsedMessage[0].description}\n${parsedMessage[0].messageTypeDescription}`,\n },\n ],\n };\n } catch (error) {\n return {\n isError: true,\n content: [\n {\n type: 'text',\n text: `Error: ${error instanceof Error ? error.message : 'Failed to parse FIX string'}`,\n },\n ],\n };\n }\n }\n\n case 'parseToJSON': {\n try {\n const { fixString } = validateArgs(args, parseToJSONInputSchema);\n const parsedMessage = this.parser?.parse(fixString);\n if (!parsedMessage || parsedMessage.length === 0) {\n return {\n isError: true,\n content: [{ type: 'text', text: 'Error: Failed to parse FIX string' }],\n };\n }\n\n return {\n content: [\n {\n type: 'text',\n text: `${parsedMessage[0].toFIXJSON()}`,\n },\n ],\n };\n } catch (error) {\n return {\n isError: true,\n content: [\n {\n type: 'text',\n text: `Error: ${error instanceof Error ? error.message : 'Failed to parse FIX string'}`,\n },\n ],\n };\n }\n }\n\n case 'newOrderSingle': {\n try {\n const { clOrdID, handlInst, quantity, price, ordType, side, symbol, timeInForce } =\n validateArgs(args, newOrderSingleInputSchema);\n\n const response = new Promise((resolve) => {\n this.pendingRequests.set(clOrdID, resolve);\n });\n\n const order: Message | undefined = this.parser?.createMessage(\n new Field(Fields.MsgType, Messages.NewOrderSingle),\n new Field(Fields.MsgSeqNum, this.parser?.getNextTargetMsgSeqNum()),\n new Field(Fields.SenderCompID, this.parser?.sender),\n new Field(Fields.TargetCompID, this.parser?.target),\n new Field(Fields.SendingTime, this.parser?.getTimestamp()),\n new Field(Fields.ClOrdID, clOrdID),\n new Field(Fields.Side, side),\n new Field(Fields.Symbol, symbol),\n new Field(Fields.OrderQty, quantity),\n new Field(Fields.Price, price),\n new Field(Fields.OrdType, ordType),\n new Field(Fields.HandlInst, handlInst),\n new Field(Fields.TimeInForce, timeInForce),\n new Field(Fields.TransactTime, this.parser?.getTimestamp()),\n );\n\n if (!this.parser?.connected) {\n this.logger?.log({\n level: 'error',\n message: 'FIXParser (MCP): -- Not connected. Ignoring message.',\n });\n return {\n isError: true,\n content: [\n {\n type: 'text',\n text: 'Error: Not connected. Ignoring message.',\n },\n ],\n };\n }\n\n this.parser?.send(order!);\n this.logger?.log({\n level: 'info',\n message: `FIXParser (MCP): (${this.parser?.protocol?.toUpperCase()}): >> sent ${order?.description}`,\n });\n\n const fixData = await response;\n return {\n content: [\n {\n type: 'text',\n text: `Execution Report for order ${clOrdID}: ${JSON.stringify((fixData as Message).toFIXJSON())}`,\n },\n ],\n };\n } catch (error) {\n return {\n isError: true,\n content: [\n {\n type: 'text',\n text: `Error: ${error instanceof Error ? error.message : 'Failed to create order'}`,\n },\n ],\n };\n }\n }\n\n case 'marketDataRequest': {\n try {\n const { mdUpdateType, symbol, mdReqID, subscriptionRequestType, mdEntryType } = validateArgs(\n args,\n marketDataRequestInputSchema,\n );\n\n const response = new Promise((resolve) => {\n this.pendingRequests.set(mdReqID, resolve);\n });\n\n const marketDataRequest = this.parser?.createMessage(\n new Field(Fields.MsgType, Messages.MarketDataRequest),\n new Field(Fields.SenderCompID, this.parser?.sender),\n new Field(Fields.MsgSeqNum, this.parser?.getNextTargetMsgSeqNum()),\n new Field(Fields.TargetCompID, this.parser?.target),\n new Field(Fields.SendingTime, this.parser?.getTimestamp()),\n new Field(Fields.MarketDepth, 0),\n new Field(Fields.MDUpdateType, mdUpdateType),\n new Field(Fields.NoRelatedSym, 1),\n new Field(Fields.Symbol, symbol),\n new Field(Fields.MDReqID, mdReqID),\n new Field(Fields.SubscriptionRequestType, subscriptionRequestType),\n new Field(Fields.NoMDEntryTypes, 1),\n new Field(Fields.MDEntryType, mdEntryType),\n );\n\n if (!this.parser?.connected) {\n this.logger?.log({\n level: 'error',\n message: 'FIXParser (MCP): -- Not connected. Ignoring message.',\n });\n return {\n isError: true,\n content: [\n {\n type: 'text',\n text: 'Error: Not connected. Ignoring message.',\n },\n ],\n };\n }\n\n this.parser?.send(marketDataRequest!);\n this.logger?.log({\n level: 'info',\n message: `FIXParser (MCP): (${this.parser?.protocol?.toUpperCase()}): >> sent ${marketDataRequest?.description}`,\n });\n\n const fixData = await response;\n\n return {\n content: [\n {\n type: 'text',\n text: `Market data for ${symbol}: ${JSON.stringify((fixData as Message).toFIXJSON())}`,\n },\n ],\n };\n } catch (error) {\n return {\n isError: true,\n content: [\n {\n type: 'text',\n text: `Error: ${error instanceof Error ? error.message : 'Failed to request market data'}`,\n },\n ],\n };\n }\n }\n\n default:\n throw new Error(`Unknown tool: ${name}`);\n }\n });\n\n this.server.setRequestHandler(ListPromptsRequestSchema, async () => {\n return {\n prompts: [\n {\n name: 'parse',\n description: 'Parses a FIX message and describes it in plain language',\n arguments: [\n {\n name: 'fixString',\n description: 'FIX message string to parse',\n required: true,\n },\n ],\n },\n {\n name: 'parseToJSON',\n description: 'Parses a FIX message into JSON',\n arguments: [\n {\n name: 'fixString',\n description: 'FIX message string to parse',\n required: true,\n },\n ],\n },\n {\n name: 'newOrderSingle',\n description: 'Creates and sends a New Order Single',\n arguments: [\n {\n name: 'clOrdID',\n description: 'Client Order ID',\n required: true,\n },\n {\n name: 'handlInst',\n description: 'Handling instruction',\n required: false,\n },\n {\n name: 'quantity',\n description: 'Order quantity',\n required: true,\n },\n {\n name: 'price',\n description: 'Order price',\n required: true,\n },\n {\n name: 'ordType',\n description: 'Order type',\n required: false,\n },\n {\n name: 'side',\n description:\n '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)',\n required: true,\n },\n {\n name: 'symbol',\n description: 'Trading symbol',\n required: true,\n },\n {\n name: 'timeInForce',\n description: 'Time in force',\n required: false,\n },\n ],\n },\n {\n name: 'marketDataRequest',\n description: 'Sends a request for Market Data with the given symbol',\n arguments: [\n {\n name: 'mdUpdateType',\n description: 'Market data update type',\n required: false,\n },\n {\n name: 'symbol',\n description: 'Trading symbol',\n required: true,\n },\n {\n name: 'mdReqID',\n description: 'Market data request ID',\n required: true,\n },\n {\n name: 'subscriptionRequestType',\n description: 'Subscription request type',\n required: false,\n },\n {\n name: 'mdEntryType',\n description: 'Market data entry type',\n required: false,\n },\n ],\n },\n ],\n };\n });\n\n // Handler for getting specific prompts\n this.server.setRequestHandler(GetPromptRequestSchema, async (request) => {\n const { name, arguments: args } = request.params;\n\n switch (name) {\n case 'parse': {\n const fixString = args?.fixString || '';\n return {\n messages: [\n {\n role: 'user',\n content: {\n type: 'text',\n text: `Please parse and explain this FIX message: ${fixString}`,\n },\n },\n ],\n };\n }\n\n case 'parseToJSON': {\n const fixString = args?.fixString || '';\n return {\n messages: [\n {\n role: 'user',\n content: {\n type: 'text',\n text: `Please parse the FIX message to JSON: ${fixString}`,\n },\n },\n ],\n };\n }\n\n case 'newOrderSingle': {\n const { clOrdID, handlInst, quantity, price, ordType, side, symbol, timeInForce } = args || {};\n return {\n messages: [\n {\n role: 'user',\n content: {\n type: 'text',\n text: [\n 'Create a New Order Single FIX message with the following parameters:',\n `- ClOrdID: ${clOrdID}`,\n `- HandlInst: ${handlInst ?? '3'} (IMPORTANT: Use the numeric/alphabetic value, not the descriptive name. For example, use '1' for Manual, '2' for Automated, '3' for AutomatedNoIntervention)`,\n `- Quantity: ${quantity}`,\n `- Price: ${price}`,\n `- OrdType: ${ordType ?? '1'} (IMPORTANT: Use the numeric/alphabetic value, not the descriptive name. For example, use '1' for Market, '2' for Limit, '3' for Stop)`,\n `- Side: ${side} (IMPORTANT: Use the numeric/alphabetic value, not the descriptive name. For example, use '1' for Buy, '2' for Sell)`,\n `- Symbol: ${symbol}`,\n `- TimeInForce: ${timeInForce ?? '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)`,\n '',\n 'Format the response as a JSON object with FIX tag numbers as keys and their corresponding values.',\n '',\n 'Note: For the Side parameter, always use the numeric/alphabetic value (e.g., \"1\" for Buy, \"2\" for Sell) as defined in the FIX protocol, not the descriptive name.',\n 'Note: For the HandlInst parameter, always use the numeric/alphabetic value (e.g., \"1\" for Manual, \"2\" for Automated, \"3\" for AutomatedNoIntervention) as defined in the FIX protocol, not the descriptive name.',\n '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.',\n '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.',\n ].join('\\n'),\n },\n },\n ],\n };\n }\n\n case 'marketDataRequest': {\n const { mdUpdateType, symbol, mdReqID, subscriptionRequestType, mdEntryType } = args || {};\n return {\n messages: [\n {\n role: 'user',\n content: {\n type: 'text',\n text: [\n 'Create a Market Data Request FIX message with the following parameters:',\n `- MDUpdateType: ${mdUpdateType ?? '0'} (IMPORTANT: Use the numeric/alphabetic value, not the descriptive name. For example, use '0' for FullRefresh, '1' for IncrementalRefresh)`,\n `- Symbol: ${symbol}`,\n `- MDReqID: ${mdReqID}`,\n `- SubscriptionRequestType: ${subscriptionRequestType ?? '0'} (IMPORTANT: Use the numeric/alphabetic value, not the descriptive name. For example, use '0' for Snapshot + Updates, '1' for Snapshot, '2' for Unsubscribe)`,\n `- MDEntryType: ${mdEntryType ?? '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)`,\n '',\n 'Format the response as a JSON object with FIX tag numbers as keys and their corresponding values.',\n '',\n '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.',\n '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.',\n '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.',\n ].join('\\n'),\n },\n },\n ],\n };\n }\n\n default:\n throw new Error(`Unknown prompt: ${name}`);\n }\n });\n\n process.on('SIGINT', async () => {\n await this.server.close();\n process.exit(0);\n });\n }\n}\n"],
5
- "mappings": ";AAAA,SAAS,cAAc;AACvB,SAAS,4BAA4B;AACrC;AAAA,EACI;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACG;AAEP;AAAA,EACI;AAAA,EACA;AAAA,EACA;AAAA,EAGA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACG;AAKP,IAAM,mBAAmB;AAAA,EACrB,MAAM;AAAA,EACN,YAAY;AAAA,IACR,WAAW;AAAA,MACP,MAAM;AAAA,MACN,aAAa;AAAA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AAAA,oBACA;AAAA,kBACJ,EAAE,KAAK,IAAI;AAAA,gBACf;AAAA,cACJ;AAAA,YACJ;AAAA,UACJ;AAAA,QACJ;AAAA,QAEA;AACI,gBAAM,IAAI,MAAM,mBAAmB,IAAI,EAAE;AAAA,MACjD;AAAA,IACJ,CAAC;AAED,YAAQ,GAAG,UAAU,YAAY;AAC7B,YAAM,KAAK,OAAO,MAAM;AACxB,cAAQ,KAAK,CAAC;AAAA,IAClB,CAAC;AAAA,EACL;AACJ;",
4
+ "sourcesContent": ["import { Server } from '@modelcontextprotocol/sdk/server/index.js';\nimport { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';\nimport {\n CallToolRequestSchema,\n GetPromptRequestSchema,\n ListPromptsRequestSchema,\n ListResourcesRequestSchema,\n ListToolsRequestSchema,\n} from '@modelcontextprotocol/sdk/types.js';\n\nimport { Field, Fields, type IFIXParser, type Message, Messages } from 'fixparser';\nimport type { IPlugin } from 'fixparser-common';\nimport type { PluginOptions } from './PluginOptions';\n\n// Define JSON Schemas\nconst parseInputSchema = {\n type: 'object',\n properties: {\n fixString: {\n type: 'string',\n description: 'FIX message string to parse',\n },\n },\n required: ['fixString'],\n};\n\nconst parseToJSONInputSchema = {\n type: 'object',\n properties: {\n fixString: {\n type: 'string',\n description: 'FIX message string to parse',\n },\n },\n required: ['fixString'],\n};\n\nconst newOrderSingleInputSchema = {\n type: 'object',\n properties: {\n clOrdID: {\n type: 'string',\n description: 'Client Order ID',\n },\n handlInst: {\n type: 'string',\n enum: ['1', '2', '3'],\n description:\n 'Handling instruction (IMPORTANT: Use the numeric/alphabetic value, not the descriptive name. For example, use \"1\" for Manual, \"2\" for Automated, \"3\" for AutomatedNoIntervention)',\n },\n quantity: {\n type: 'number',\n description: 'Order quantity',\n },\n price: {\n type: 'number',\n description: 'Order price',\n },\n ordType: {\n type: 'string',\n enum: [\n '1',\n '2',\n '3',\n '4',\n '5',\n '6',\n '7',\n '8',\n '9',\n 'A',\n 'B',\n 'C',\n 'D',\n 'E',\n 'F',\n 'G',\n 'H',\n 'I',\n 'J',\n 'K',\n 'L',\n 'M',\n 'P',\n 'Q',\n 'R',\n 'S',\n ],\n description:\n 'Order type (IMPORTANT: Use the numeric/alphabetic value, not the descriptive name. For example, use \"1\" for Market, \"2\" for Limit, \"3\" for Stop)',\n },\n side: {\n type: 'string',\n enum: ['1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H'],\n description:\n '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)',\n },\n symbol: {\n type: 'string',\n description: 'Trading symbol',\n },\n timeInForce: {\n type: 'string',\n enum: ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C'],\n description:\n '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)',\n },\n },\n required: ['clOrdID', 'quantity', 'price', 'side', 'symbol', 'handlInst', 'ordType', 'timeInForce'],\n};\n\nconst marketDataRequestInputSchema = {\n type: 'object',\n properties: {\n mdUpdateType: {\n type: 'string',\n enum: ['0', '1'],\n description:\n 'Market data update type (IMPORTANT: Use the numeric/alphabetic value, not the descriptive name. For example, use \"0\" for FullRefresh, \"1\" for IncrementalRefresh)',\n },\n symbol: {\n type: 'string',\n description: 'Trading symbol',\n },\n mdReqID: {\n type: 'string',\n description: 'Market data request ID',\n },\n subscriptionRequestType: {\n type: 'string',\n enum: ['0', '1', '2'],\n description:\n '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)',\n },\n mdEntryType: {\n type: 'string',\n enum: [\n '0',\n '1',\n '2',\n '3',\n '4',\n '5',\n '6',\n '7',\n '8',\n '9',\n 'A',\n 'B',\n 'C',\n 'D',\n 'E',\n 'F',\n 'G',\n 'H',\n 'J',\n 'K',\n 'L',\n 'M',\n 'N',\n 'O',\n 'P',\n 'Q',\n 'S',\n 'R',\n 'T',\n 'U',\n 'V',\n 'W',\n 'X',\n 'Y',\n 'Z',\n 'a',\n 'b',\n 'c',\n 'd',\n 'e',\n 'g',\n 'h',\n 'i',\n 't',\n ],\n description:\n '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)',\n },\n },\n required: ['symbol', 'mdReqID'],\n};\n\nexport class MCPLocal implements IPlugin<IFIXParser> {\n // private logger: Logger | undefined;\n private parser: IFIXParser | undefined;\n private server: Server = new Server(\n {\n name: 'fixparser',\n version: '1.0.0',\n },\n {\n capabilities: {\n tools: {},\n prompts: {},\n resources: {},\n },\n },\n );\n private transport: StdioServerTransport = new StdioServerTransport();\n private onReady: (() => void) | undefined = undefined;\n\n private pendingRequests: Map<string, (data: Message) => void> = new Map();\n\n constructor({ logger, onReady }: PluginOptions) {\n if (onReady) this.onReady = onReady;\n }\n\n public async register(parser: IFIXParser): Promise<void> {\n this.parser = parser;\n this.parser.addOnMessageCallback((message: Message) => {\n // this.logger?.log({\n // level: 'info',\n // message: `FIXParser (MCP): (${parser.protocol?.toUpperCase()}): << received ${message.description}`,\n // });\n const msgType = message.messageType;\n if (\n msgType === Messages.MarketDataSnapshotFullRefresh ||\n msgType === Messages.ExecutionReport ||\n msgType === Messages.Reject\n ) {\n const idField =\n msgType === Messages.MarketDataSnapshotFullRefresh\n ? message.getField(Fields.MDReqID)\n : msgType === Messages.Reject\n ? message.getField(Fields.RefSeqNum)\n : message.getField(Fields.ClOrdID);\n if (idField) {\n const id = idField.value;\n if (typeof id === 'string' || typeof id === 'number') {\n // For Reject messages, check if it's related to a New Order Single\n if (msgType === Messages.Reject) {\n const refMsgType = message.getField(Fields.RefMsgType);\n if (refMsgType && refMsgType.value === Messages.NewOrderSingle) {\n const callback = this.pendingRequests.get(String(id));\n if (callback) {\n callback(message);\n this.pendingRequests.delete(String(id));\n }\n }\n } else {\n const callback = this.pendingRequests.get(String(id));\n if (callback) {\n callback(message);\n this.pendingRequests.delete(String(id));\n }\n }\n }\n }\n }\n });\n\n this.addWorkflows();\n\n await this.server.connect(this.transport);\n\n if (this.onReady) {\n this.onReady();\n }\n }\n\n private addWorkflows() {\n if (!this.parser) {\n // this.logger?.log({\n // level: 'error',\n // message: 'FIXParser (MCP): -- FIXParser instance not initialized. Ignoring setup of workflows...',\n // });\n return;\n }\n\n if (!this.server) {\n // this.logger?.log({\n // level: 'error',\n // message: 'FIXParser (MCP): -- MCP Server not initialized. Ignoring setup of workflows...',\n // });\n return;\n }\n\n // Helper function to validate and parse arguments\n const validateArgs = (args: any, schema: any): any => {\n // Basic validation - in a real implementation, you might want to use a proper JSON Schema validator\n const result: any = {};\n\n for (const [key, propSchema] of Object.entries(schema.properties || {})) {\n const prop = propSchema as any;\n const value = args?.[key];\n\n if (prop.required && (value === undefined || value === null)) {\n throw new Error(`Required property '${key}' is missing`);\n }\n\n if (value !== undefined) {\n // Apply defaults\n result[key] = value;\n } else if (prop.default !== undefined) {\n result[key] = prop.default;\n }\n }\n\n return result;\n };\n\n // Empty handler for resources\n this.server.setRequestHandler(ListResourcesRequestSchema, async () => {\n return {\n resources: [],\n };\n });\n\n // Handler for listing available tools\n this.server.setRequestHandler(ListToolsRequestSchema, async () => {\n return {\n tools: [\n {\n name: 'parse',\n description: 'Parses a FIX message and describes it in plain language',\n inputSchema: parseInputSchema,\n },\n {\n name: 'parseToJSON',\n description: 'Parses a FIX message into JSON',\n inputSchema: parseToJSONInputSchema,\n },\n {\n name: 'newOrderSingle',\n description: 'Creates and sends a New Order Single',\n inputSchema: newOrderSingleInputSchema,\n },\n {\n name: 'marketDataRequest',\n description: 'Sends a request for Market Data with the given symbol',\n inputSchema: marketDataRequestInputSchema,\n },\n ],\n };\n });\n\n // Handler for tool calls\n this.server.setRequestHandler(CallToolRequestSchema, async (request) => {\n const { name, arguments: args } = request.params;\n\n switch (name) {\n case 'parse': {\n try {\n const { fixString } = validateArgs(args, parseInputSchema);\n const parsedMessage: Message[] | undefined = this.parser?.parse(fixString);\n if (!parsedMessage || parsedMessage.length === 0) {\n return {\n isError: true,\n content: [{ type: 'text', text: 'Error: Failed to parse FIX string' }],\n };\n }\n\n return {\n content: [\n {\n type: 'text',\n text: `${parsedMessage[0].description}\n${parsedMessage[0].messageTypeDescription}`,\n },\n ],\n };\n } catch (error) {\n return {\n isError: true,\n content: [\n {\n type: 'text',\n text: `Error: ${error instanceof Error ? error.message : 'Failed to parse FIX string'}`,\n },\n ],\n };\n }\n }\n\n case 'parseToJSON': {\n try {\n const { fixString } = validateArgs(args, parseToJSONInputSchema);\n const parsedMessage = this.parser?.parse(fixString);\n if (!parsedMessage || parsedMessage.length === 0) {\n return {\n isError: true,\n content: [{ type: 'text', text: 'Error: Failed to parse FIX string' }],\n };\n }\n\n return {\n content: [\n {\n type: 'text',\n text: `${parsedMessage[0].toFIXJSON()}`,\n },\n ],\n };\n } catch (error) {\n return {\n isError: true,\n content: [\n {\n type: 'text',\n text: `Error: ${error instanceof Error ? error.message : 'Failed to parse FIX string'}`,\n },\n ],\n };\n }\n }\n\n case 'newOrderSingle': {\n try {\n const { clOrdID, handlInst, quantity, price, ordType, side, symbol, timeInForce } =\n validateArgs(args, newOrderSingleInputSchema);\n\n const response = new Promise((resolve) => {\n this.pendingRequests.set(clOrdID, resolve);\n });\n\n const order: Message | undefined = this.parser?.createMessage(\n new Field(Fields.MsgType, Messages.NewOrderSingle),\n new Field(Fields.MsgSeqNum, this.parser?.getNextTargetMsgSeqNum()),\n new Field(Fields.SenderCompID, this.parser?.sender),\n new Field(Fields.TargetCompID, this.parser?.target),\n new Field(Fields.SendingTime, this.parser?.getTimestamp()),\n new Field(Fields.ClOrdID, clOrdID),\n new Field(Fields.Side, side),\n new Field(Fields.Symbol, symbol),\n new Field(Fields.OrderQty, quantity),\n new Field(Fields.Price, price),\n new Field(Fields.OrdType, ordType),\n new Field(Fields.HandlInst, handlInst),\n new Field(Fields.TimeInForce, timeInForce),\n new Field(Fields.TransactTime, this.parser?.getTimestamp()),\n );\n\n if (!this.parser?.connected) {\n // this.logger?.log({\n // level: 'error',\n // message: 'FIXParser (MCP): -- Not connected. Ignoring message.',\n // });\n return {\n isError: true,\n content: [\n {\n type: 'text',\n text: 'Error: Not connected. Ignoring message.',\n },\n ],\n };\n }\n\n this.parser?.send(order!);\n // this.logger?.log({\n // level: 'info',\n // message: `FIXParser (MCP): (${this.parser?.protocol?.toUpperCase()}): >> sent ${order?.description}`,\n // });\n\n const fixData = await response;\n\n return {\n content: [\n {\n type: 'text',\n text:\n (fixData as Message).messageType === Messages.Reject\n ? `Reject message for order ${clOrdID}: ${JSON.stringify((fixData as Message).toFIXJSON())}`\n : `Execution Report for order ${clOrdID}: ${JSON.stringify((fixData as Message).toFIXJSON())}`,\n },\n ],\n };\n } catch (error) {\n return {\n isError: true,\n content: [\n {\n type: 'text',\n text: `Error: ${error instanceof Error ? error.message : 'Failed to create order'}`,\n },\n ],\n };\n }\n }\n\n case 'marketDataRequest': {\n try {\n const { mdUpdateType, symbol, mdReqID, subscriptionRequestType, mdEntryType } = validateArgs(\n args,\n marketDataRequestInputSchema,\n );\n\n const response = new Promise((resolve) => {\n this.pendingRequests.set(mdReqID, resolve);\n });\n\n const marketDataRequest = this.parser?.createMessage(\n new Field(Fields.MsgType, Messages.MarketDataRequest),\n new Field(Fields.SenderCompID, this.parser?.sender),\n new Field(Fields.MsgSeqNum, this.parser?.getNextTargetMsgSeqNum()),\n new Field(Fields.TargetCompID, this.parser?.target),\n new Field(Fields.SendingTime, this.parser?.getTimestamp()),\n new Field(Fields.MarketDepth, 0),\n new Field(Fields.MDUpdateType, mdUpdateType),\n new Field(Fields.NoRelatedSym, 1),\n new Field(Fields.Symbol, symbol),\n new Field(Fields.MDReqID, mdReqID),\n new Field(Fields.SubscriptionRequestType, subscriptionRequestType),\n new Field(Fields.NoMDEntryTypes, 1),\n new Field(Fields.MDEntryType, mdEntryType),\n );\n\n if (!this.parser?.connected) {\n // this.logger?.log({\n // level: 'error',\n // message: 'FIXParser (MCP): -- Not connected. Ignoring message.',\n // });\n return {\n isError: true,\n content: [\n {\n type: 'text',\n text: 'Error: Not connected. Ignoring message.',\n },\n ],\n };\n }\n\n this.parser?.send(marketDataRequest!);\n // this.logger?.log({\n // level: 'info',\n // message: `FIXParser (MCP): (${this.parser?.protocol?.toUpperCase()}): >> sent ${marketDataRequest?.description}`,\n // });\n\n const fixData = await response;\n\n return {\n content: [\n {\n type: 'text',\n text: `Market data for ${symbol}: ${JSON.stringify((fixData as Message).toFIXJSON())}`,\n },\n ],\n };\n } catch (error) {\n return {\n isError: true,\n content: [\n {\n type: 'text',\n text: `Error: ${error instanceof Error ? error.message : 'Failed to request market data'}`,\n },\n ],\n };\n }\n }\n\n default:\n throw new Error(`Unknown tool: ${name}`);\n }\n });\n\n this.server.setRequestHandler(ListPromptsRequestSchema, async () => {\n return {\n prompts: [\n {\n name: 'parse',\n description: 'Parses a FIX message and describes it in plain language',\n arguments: [\n {\n name: 'fixString',\n description: 'FIX message string to parse',\n required: true,\n },\n ],\n },\n {\n name: 'parseToJSON',\n description: 'Parses a FIX message into JSON',\n arguments: [\n {\n name: 'fixString',\n description: 'FIX message string to parse',\n required: true,\n },\n ],\n },\n {\n name: 'newOrderSingle',\n description: 'Creates and sends a New Order Single',\n arguments: [\n {\n name: 'clOrdID',\n description: 'Client Order ID',\n required: true,\n },\n {\n name: 'handlInst',\n description: 'Handling instruction',\n required: true,\n },\n {\n name: 'quantity',\n description: 'Order quantity',\n required: true,\n },\n {\n name: 'price',\n description: 'Order price',\n required: true,\n },\n {\n name: 'ordType',\n description: 'Order type',\n required: true,\n },\n {\n name: 'side',\n description:\n '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)',\n required: true,\n },\n {\n name: 'symbol',\n description: 'Trading symbol',\n required: true,\n },\n {\n name: 'timeInForce',\n description: 'Time in force',\n required: true,\n },\n ],\n },\n {\n name: 'marketDataRequest',\n description: 'Sends a request for Market Data with the given symbol',\n arguments: [\n {\n name: 'mdUpdateType',\n description: 'Market data update type',\n required: true,\n },\n {\n name: 'symbol',\n description: 'Trading symbol',\n required: true,\n },\n {\n name: 'mdReqID',\n description: 'Market data request ID',\n required: true,\n },\n {\n name: 'subscriptionRequestType',\n description: 'Subscription request type',\n required: true,\n },\n {\n name: 'mdEntryType',\n description: 'Market data entry type',\n required: true,\n },\n ],\n },\n ],\n };\n });\n\n // Handler for getting specific prompts\n this.server.setRequestHandler(GetPromptRequestSchema, async (request) => {\n const { name, arguments: args } = request.params;\n\n switch (name) {\n case 'parse': {\n const fixString = args?.fixString || '';\n return {\n messages: [\n {\n role: 'user',\n content: {\n type: 'text',\n text: `Please parse and explain this FIX message: ${fixString}`,\n },\n },\n ],\n };\n }\n\n case 'parseToJSON': {\n const fixString = args?.fixString || '';\n return {\n messages: [\n {\n role: 'user',\n content: {\n type: 'text',\n text: `Please parse the FIX message to JSON: ${fixString}`,\n },\n },\n ],\n };\n }\n\n case 'newOrderSingle': {\n const { clOrdID, handlInst, quantity, price, ordType, side, symbol, timeInForce } = args || {};\n return {\n messages: [\n {\n role: 'user',\n content: {\n type: 'text',\n text: [\n 'Create a New Order Single FIX message with the following parameters:',\n `- ClOrdID: ${clOrdID}`,\n `- HandlInst: ${handlInst ?? '3'} (IMPORTANT: Use the numeric/alphabetic value, not the descriptive name. For example, use '1' for Manual, '2' for Automated, '3' for AutomatedNoIntervention)`,\n `- Quantity: ${quantity}`,\n `- Price: ${price}`,\n `- OrdType: ${ordType ?? '1'} (IMPORTANT: Use the numeric/alphabetic value, not the descriptive name. For example, use '1' for Market, '2' for Limit, '3' for Stop)`,\n `- Side: ${side} (IMPORTANT: Use the numeric/alphabetic value, not the descriptive name. For example, use '1' for Buy, '2' for Sell)`,\n `- Symbol: ${symbol}`,\n `- TimeInForce: ${timeInForce ?? '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)`,\n '',\n '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.',\n '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.',\n '',\n 'IMPORTANT: All parameters must be set before sending the order. Missing or invalid parameters will result in a Reject message.',\n '',\n 'IMPORTANT: The response will be either:',\n '1. An Execution Report (MsgType=8) if the order was successfully placed',\n '2. A Reject message (MsgType=3) if the order failed to execute (e.g., due to missing or invalid parameters)',\n ].join('\\n'),\n },\n },\n ],\n };\n }\n\n case 'marketDataRequest': {\n const { mdUpdateType, symbol, mdReqID, subscriptionRequestType, mdEntryType } = args || {};\n return {\n messages: [\n {\n role: 'user',\n content: {\n type: 'text',\n text: [\n 'Create a Market Data Request FIX message with the following parameters:',\n `- MDUpdateType: ${mdUpdateType ?? '0'} (IMPORTANT: Use the numeric/alphabetic value, not the descriptive name. For example, use '0' for FullRefresh, '1' for IncrementalRefresh)`,\n `- Symbol: ${symbol}`,\n `- MDReqID: ${mdReqID}`,\n `- SubscriptionRequestType: ${subscriptionRequestType ?? '0'} (IMPORTANT: Use the numeric/alphabetic value, not the descriptive name. For example, use '0' for Snapshot + Updates, '1' for Snapshot, '2' for Unsubscribe)`,\n `- MDEntryType: ${mdEntryType ?? '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)`,\n '',\n 'Format the response as a JSON object with FIX tag numbers as keys and their corresponding values.',\n '',\n '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.',\n '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.',\n '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.',\n ].join('\\n'),\n },\n },\n ],\n };\n }\n\n default:\n throw new Error(`Unknown prompt: ${name}`);\n }\n });\n\n process.on('SIGINT', async () => {\n await this.server.close();\n process.exit(0);\n });\n }\n}\n"],
5
+ "mappings": ";AAAA,SAAS,cAAc;AACvB,SAAS,4BAA4B;AACrC;AAAA,EACI;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACG;AAEP,SAAS,OAAO,QAAuC,gBAAgB;AAKvE,IAAM,mBAAmB;AAAA,EACrB,MAAM;AAAA,EACN,YAAY;AAAA,IACR,WAAW;AAAA,MACP,MAAM;AAAA,MACN,aAAa;AAAA,IACjB;AAAA,EACJ;AAAA,EACA,UAAU,CAAC,WAAW;AAC1B;AAEA,IAAM,yBAAyB;AAAA,E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eAAe,QAAQ;AAAA,oBACvB,YAAY,KAAK;AAAA,oBACjB,cAAc,WAAW,GAAG;AAAA,oBAC5B,WAAW,IAAI;AAAA,oBACf,aAAa,MAAM;AAAA,oBACnB,kBAAkB,eAAe,GAAG;AAAA,oBACpC;AAAA,oBACA;AAAA,oBACA;AAAA,oBACA;AAAA,oBACA;AAAA,oBACA;AAAA,oBACA;AAAA,oBACA;AAAA,oBACA;AAAA,kBACJ,EAAE,KAAK,IAAI;AAAA,gBACf;AAAA,cACJ;AAAA,YACJ;AAAA,UACJ;AAAA,QACJ;AAAA,QAEA,KAAK,qBAAqB;AACtB,gBAAM,EAAE,cAAc,QAAQ,SAAS,yBAAyB,YAAY,IAAI,QAAQ,CAAC;AACzF,iBAAO;AAAA,YACH,UAAU;AAAA,cACN;AAAA,gBACI,MAAM;AAAA,gBACN,SAAS;AAAA,kBACL,MAAM;AAAA,kBACN,MAAM;AAAA,oBACF;AAAA,oBACA,mBAAmB,gBAAgB,GAAG;AAAA,oBACtC,aAAa,MAAM;AAAA,oBACnB,cAAc,OAAO;AAAA,oBACrB,8BAA8B,2BAA2B,GAAG;AAAA,oBAC5D,kBAAkB,eAAe,GAAG;AAAA,oBACpC;AAAA,oBACA;AAAA,oBACA;AAAA,oBACA;AAAA,oBACA;AAAA,oBACA;AAAA,kBACJ,EAAE,KAAK,IAAI;AAAA,gBACf;AAAA,cACJ;AAAA,YACJ;AAAA,UACJ;AAAA,QACJ;AAAA,QAEA;AACI,gBAAM,IAAI,MAAM,mBAAmB,IAAI,EAAE;AAAA,MACjD;AAAA,IACJ,CAAC;AAED,YAAQ,GAAG,UAAU,YAAY;AAC7B,YAAM,KAAK,OAAO,MAAM;AACxB,cAAQ,KAAK,CAAC;AAAA,IAClB,CAAC;AAAA,EACL;AACJ;",
6
6
  "names": []
7
7
  }
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
- "use strict";var r=require("fixparser");var F=require("@modelcontextprotocol/sdk/server/index.js"),w=require("@modelcontextprotocol/sdk/server/stdio.js"),d=require("@modelcontextprotocol/sdk/types.js"),e=require("fixparser"),y={type:"object",properties:{fixString:{type:"string",description:"FIX message string to parse"}},required:["fixString"]},S={type:"object",properties:{fixString:{type:"string",description:"FIX message string to parse"}},required:["fixString"]},T={type:"object",properties:{clOrdID:{type:"string",description:"Client Order ID"},handlInst:{type:"string",enum:["1","2","3"],default:e.HandlInst.AutomatedExecutionNoIntervention,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"],default:e.OrdType.Market,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"],default:e.TimeInForce.Day,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"]},I={type:"object",properties:{mdUpdateType:{type:"string",enum:["0","1"],default:"0",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"],default:e.SubscriptionRequestType.SnapshotAndUpdates,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"],default:e.MDEntryType.Bid,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"]},v=class{logger;parser;server=new F.Server({name:"fixparser",version:"1.0.0"},{capabilities:{tools:{},prompts:{},resources:{}}});transport=new w.StdioServerTransport;onReady=void 0;pendingRequests=new Map;constructor({logger:s,onReady:a}){s&&!s.silent&&(this.logger=s),a&&(this.onReady=a)}async register(s){this.parser=s,s.logger&&!s.logger.silent&&(this.logger=s.logger),this.parser.addOnMessageCallback(a=>{let c=a.messageType;if(c===e.Messages.MarketDataSnapshotFullRefresh||c===e.Messages.ExecutionReport){let i=c===e.Messages.MarketDataSnapshotFullRefresh?a.getField(e.Fields.MDReqID):a.getField(e.Fields.ClOrdID);if(i){let t=i.value;if(typeof t=="string"||typeof t=="number"){let n=this.pendingRequests.get(String(t));n&&(n(a),this.pendingRequests.delete(String(t)))}}}}),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}let s=(a,c)=>{let i={};for(let[t,n]of Object.entries(c.properties||{})){let o=n,p=a?.[t];if(o.required&&p==null)throw new Error(`Required property '${t}' is missing`);p!==void 0?i[t]=p:o.default!==void 0&&(i[t]=o.default)}return i};this.server.setRequestHandler(d.ListResourcesRequestSchema,async()=>({resources:[]})),this.server.setRequestHandler(d.ListToolsRequestSchema,async()=>({tools:[{name:"parse",description:"Parses a FIX message and describes it in plain language",inputSchema:y},{name:"parseToJSON",description:"Parses a FIX message into JSON",inputSchema:S},{name:"newOrderSingle",description:"Creates and sends a New Order Single",inputSchema:T},{name:"marketDataRequest",description:"Sends a request for Market Data with the given symbol",inputSchema:I}]})),this.server.setRequestHandler(d.CallToolRequestSchema,async a=>{let{name:c,arguments:i}=a.params;switch(c){case"parse":try{let{fixString:t}=s(i,y),n=this.parser?.parse(t);return!n||n.length===0?{isError:!0,content:[{type:"text",text:"Error: Failed to parse FIX string"}]}:{content:[{type:"text",text:`${n[0].description}
3
- ${n[0].messageTypeDescription}`}]}}catch(t){return{isError:!0,content:[{type:"text",text:`Error: ${t instanceof Error?t.message:"Failed to parse FIX string"}`}]}}case"parseToJSON":try{let{fixString:t}=s(i,S),n=this.parser?.parse(t);return!n||n.length===0?{isError:!0,content:[{type:"text",text:"Error: Failed to parse FIX string"}]}:{content:[{type:"text",text:`${n[0].toFIXJSON()}`}]}}catch(t){return{isError:!0,content:[{type:"text",text:`Error: ${t instanceof Error?t.message:"Failed to parse FIX string"}`}]}}case"newOrderSingle":try{let{clOrdID:t,handlInst:n,quantity:o,price:p,ordType:l,side:u,symbol:m,timeInForce:g}=s(i,T),h=new Promise(O=>{this.pendingRequests.set(t,O)}),f=this.parser?.createMessage(new e.Field(e.Fields.MsgType,e.Messages.NewOrderSingle),new e.Field(e.Fields.MsgSeqNum,this.parser?.getNextTargetMsgSeqNum()),new e.Field(e.Fields.SenderCompID,this.parser?.sender),new e.Field(e.Fields.TargetCompID,this.parser?.target),new e.Field(e.Fields.SendingTime,this.parser?.getTimestamp()),new e.Field(e.Fields.ClOrdID,t),new e.Field(e.Fields.Side,u),new e.Field(e.Fields.Symbol,m),new e.Field(e.Fields.OrderQty,o),new e.Field(e.Fields.Price,p),new e.Field(e.Fields.OrdType,l),new e.Field(e.Fields.HandlInst,n),new e.Field(e.Fields.TimeInForce,g),new e.Field(e.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(f),this.logger?.log({level:"info",message:`FIXParser (MCP): (${this.parser?.protocol?.toUpperCase()}): >> sent ${f?.description}`});let M=await h;return{content:[{type:"text",text:`Execution Report for order ${t}: ${JSON.stringify(M.toFIXJSON())}`}]}}catch(t){return{isError:!0,content:[{type:"text",text:`Error: ${t instanceof Error?t.message:"Failed to create order"}`}]}}case"marketDataRequest":try{let{mdUpdateType:t,symbol:n,mdReqID:o,subscriptionRequestType:p,mdEntryType:l}=s(i,I),u=new Promise(h=>{this.pendingRequests.set(o,h)}),m=this.parser?.createMessage(new e.Field(e.Fields.MsgType,e.Messages.MarketDataRequest),new e.Field(e.Fields.SenderCompID,this.parser?.sender),new e.Field(e.Fields.MsgSeqNum,this.parser?.getNextTargetMsgSeqNum()),new e.Field(e.Fields.TargetCompID,this.parser?.target),new e.Field(e.Fields.SendingTime,this.parser?.getTimestamp()),new e.Field(e.Fields.MarketDepth,0),new e.Field(e.Fields.MDUpdateType,t),new e.Field(e.Fields.NoRelatedSym,1),new e.Field(e.Fields.Symbol,n),new e.Field(e.Fields.MDReqID,o),new e.Field(e.Fields.SubscriptionRequestType,p),new e.Field(e.Fields.NoMDEntryTypes,1),new e.Field(e.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(m),this.logger?.log({level:"info",message:`FIXParser (MCP): (${this.parser?.protocol?.toUpperCase()}): >> sent ${m?.description}`});let g=await u;return{content:[{type:"text",text:`Market data for ${n}: ${JSON.stringify(g.toFIXJSON())}`}]}}catch(t){return{isError:!0,content:[{type:"text",text:`Error: ${t instanceof Error?t.message:"Failed to request market data"}`}]}}default:throw new Error(`Unknown tool: ${c}`)}}),this.server.setRequestHandler(d.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, 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:!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(d.GetPromptRequestSchema,async a=>{let{name:c,arguments:i}=a.params;switch(c){case"parse":return{messages:[{role:"user",content:{type:"text",text:`Please parse and explain this FIX message: ${i?.fixString||""}`}}]};case"parseToJSON":return{messages:[{role:"user",content:{type:"text",text:`Please parse the FIX message to JSON: ${i?.fixString||""}`}}]};case"newOrderSingle":{let{clOrdID:t,handlInst:n,quantity:o,price:p,ordType:l,side:u,symbol:m,timeInForce:g}=i||{};return{messages:[{role:"user",content:{type:"text",text:["Create a New Order Single FIX message with the following parameters:",`- ClOrdID: ${t}`,`- HandlInst: ${n??"3"} (IMPORTANT: Use the numeric/alphabetic value, not the descriptive name. For example, use '1' for Manual, '2' for Automated, '3' for AutomatedNoIntervention)`,`- Quantity: ${o}`,`- Price: ${p}`,`- OrdType: ${l??"1"} (IMPORTANT: Use the numeric/alphabetic value, not the descriptive name. For example, use '1' for Market, '2' for Limit, '3' for Stop)`,`- Side: ${u} (IMPORTANT: Use the numeric/alphabetic value, not the descriptive name. For example, use '1' for Buy, '2' for Sell)`,`- Symbol: ${m}`,`- TimeInForce: ${g??"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)`,"","Format the response as a JSON object with FIX tag numbers as keys and their corresponding values.","",'Note: For the Side parameter, always use the numeric/alphabetic value (e.g., "1" for Buy, "2" for Sell) as defined in the FIX protocol, not the descriptive name.','Note: For the HandlInst parameter, always use the numeric/alphabetic value (e.g., "1" for Manual, "2" for Automated, "3" for AutomatedNoIntervention) as defined in the FIX protocol, not the descriptive name.','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.'].join(`
4
- `)}}]}}case"marketDataRequest":{let{mdUpdateType:t,symbol:n,mdReqID:o,subscriptionRequestType:p,mdEntryType:l}=i||{};return{messages:[{role:"user",content:{type:"text",text:["Create a Market Data Request FIX message with the following parameters:",`- MDUpdateType: ${t??"0"} (IMPORTANT: Use the numeric/alphabetic value, not the descriptive name. For example, use '0' for FullRefresh, '1' for IncrementalRefresh)`,`- Symbol: ${n}`,`- MDReqID: ${o}`,`- SubscriptionRequestType: ${p??"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: ${l??"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: ${c}`)}}),process.on("SIGINT",async()=>{await this.server.close(),process.exit(0)})}};var R=async()=>{await r.LicenseManager.setLicenseKey(process.env.FIXPARSER_LICENSE_KEY);let s=new r.FIXParser({logging:!0,plugins:[new v({port:3099,onReady:()=>{}})]}),a=()=>{let o=s.createMessage(new r.Field(r.Fields.MsgType,r.Messages.Logon),new r.Field(r.Fields.MsgSeqNum,s.getNextTargetMsgSeqNum()),new r.Field(r.Fields.SenderCompID,i),new r.Field(r.Fields.SendingTime,s.getTimestamp()),new r.Field(r.Fields.TargetCompID,t),new r.Field(r.Fields.ResetSeqNumFlag,r.ResetSeqNumFlag.Yes),new r.Field(r.Fields.EncryptMethod,r.EncryptMethod.None),new r.Field(r.Fields.HeartBtInt,10));s.send(o)},c=()=>{let o=s.parse("8=FIX.4.4|9=138|35=D|34=3|49=CLIENT2|56=EXECUTOR|52=20250531-15:26:58.415|11=NFLXSELLS|54=2|55=NFLX|38=300|44=410|40=1|21=1|59=0|60=20250531-15:26:58.415|10=107|");if(o){let p=new r.Field(r.Fields.SendingTime,s.getTimestamp());o[0].setField(p);let l=new r.Field(r.Fields.TransactTime,s.getTimestamp());o[0].setField(l),s.send(o[0])}},i="CLIENT2",t="EXECUTOR",n={host:"10.0.1.42",port:5001,protocol:"tcp",sender:i,target:t,fixVersion:"FIX.4.4",onOpen:()=>{a(),setTimeout(()=>{c()},1e3)},onMessage:o=>{},onClose:()=>{console.log(JSON.stringify({event:"FIX Connection closed",action:"Attempting to reconnect in 1 second"},null,2)),setTimeout(()=>{console.log(JSON.stringify({event:"Reconnecting"},null,2)),s.connect(n)},1e3)}};s.connect(n)};R().catch(s=>console.error("Error initializing server:",s));
2
+ "use strict";var t=require("fixparser");var R=require("@modelcontextprotocol/sdk/server/index.js"),F=require("@modelcontextprotocol/sdk/server/stdio.js"),d=require("@modelcontextprotocol/sdk/types.js"),e=require("fixparser"),y={type:"object",properties:{fixString:{type:"string",description:"FIX message string to parse"}},required:["fixString"]},S={type:"object",properties:{fixString:{type:"string",description:"FIX message string to parse"}},required:["fixString"]},T={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","handlInst","ordType","timeInForce"]},I={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 R.Server({name:"fixparser",version:"1.0.0"},{capabilities:{tools:{},prompts:{},resources:{}}});transport=new F.StdioServerTransport;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===e.Messages.MarketDataSnapshotFullRefresh||o===e.Messages.ExecutionReport||o===e.Messages.Reject){let n=o===e.Messages.MarketDataSnapshotFullRefresh?i.getField(e.Fields.MDReqID):o===e.Messages.Reject?i.getField(e.Fields.RefSeqNum):i.getField(e.Fields.ClOrdID);if(n){let r=n.value;if(typeof r=="string"||typeof r=="number")if(o===e.Messages.Reject){let s=i.getField(e.Fields.RefMsgType);if(s&&s.value===e.Messages.NewOrderSingle){let p=this.pendingRequests.get(String(r));p&&(p(i),this.pendingRequests.delete(String(r)))}}else{let s=this.pendingRequests.get(String(r));s&&(s(i),this.pendingRequests.delete(String(r)))}}}}),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[r,s]of Object.entries(o.properties||{})){let p=s,c=i?.[r];if(p.required&&c==null)throw new Error(`Required property '${r}' is missing`);c!==void 0?n[r]=c:p.default!==void 0&&(n[r]=p.default)}return n};this.server.setRequestHandler(d.ListResourcesRequestSchema,async()=>({resources:[]})),this.server.setRequestHandler(d.ListToolsRequestSchema,async()=>({tools:[{name:"parse",description:"Parses a FIX message and describes it in plain language",inputSchema:y},{name:"parseToJSON",description:"Parses a FIX message into JSON",inputSchema:S},{name:"newOrderSingle",description:"Creates and sends a New Order Single",inputSchema:T},{name:"marketDataRequest",description:"Sends a request for Market Data with the given symbol",inputSchema:I}]})),this.server.setRequestHandler(d.CallToolRequestSchema,async i=>{let{name:o,arguments:n}=i.params;switch(o){case"parse":try{let{fixString:r}=a(n,y),s=this.parser?.parse(r);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(r){return{isError:!0,content:[{type:"text",text:`Error: ${r instanceof Error?r.message:"Failed to parse FIX string"}`}]}}case"parseToJSON":try{let{fixString:r}=a(n,S),s=this.parser?.parse(r);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(r){return{isError:!0,content:[{type:"text",text:`Error: ${r instanceof Error?r.message:"Failed to parse FIX string"}`}]}}case"newOrderSingle":try{let{clOrdID:r,handlInst:s,quantity:p,price:c,ordType:l,side:u,symbol:m,timeInForce:g}=a(n,T),h=new Promise(M=>{this.pendingRequests.set(r,M)}),x=this.parser?.createMessage(new e.Field(e.Fields.MsgType,e.Messages.NewOrderSingle),new e.Field(e.Fields.MsgSeqNum,this.parser?.getNextTargetMsgSeqNum()),new e.Field(e.Fields.SenderCompID,this.parser?.sender),new e.Field(e.Fields.TargetCompID,this.parser?.target),new e.Field(e.Fields.SendingTime,this.parser?.getTimestamp()),new e.Field(e.Fields.ClOrdID,r),new e.Field(e.Fields.Side,u),new e.Field(e.Fields.Symbol,m),new e.Field(e.Fields.OrderQty,p),new e.Field(e.Fields.Price,c),new e.Field(e.Fields.OrdType,l),new e.Field(e.Fields.HandlInst,s),new e.Field(e.Fields.TimeInForce,g),new e.Field(e.Fields.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 f=await h;return{content:[{type:"text",text:f.messageType===e.Messages.Reject?`Reject message for order ${r}: ${JSON.stringify(f.toFIXJSON())}`:`Execution Report for order ${r}: ${JSON.stringify(f.toFIXJSON())}`}]}}catch(r){return{isError:!0,content:[{type:"text",text:`Error: ${r instanceof Error?r.message:"Failed to create order"}`}]}}case"marketDataRequest":try{let{mdUpdateType:r,symbol:s,mdReqID:p,subscriptionRequestType:c,mdEntryType:l}=a(n,I),u=new Promise(h=>{this.pendingRequests.set(p,h)}),m=this.parser?.createMessage(new e.Field(e.Fields.MsgType,e.Messages.MarketDataRequest),new e.Field(e.Fields.SenderCompID,this.parser?.sender),new e.Field(e.Fields.MsgSeqNum,this.parser?.getNextTargetMsgSeqNum()),new e.Field(e.Fields.TargetCompID,this.parser?.target),new e.Field(e.Fields.SendingTime,this.parser?.getTimestamp()),new e.Field(e.Fields.MarketDepth,0),new e.Field(e.Fields.MDUpdateType,r),new e.Field(e.Fields.NoRelatedSym,1),new e.Field(e.Fields.Symbol,s),new e.Field(e.Fields.MDReqID,p),new e.Field(e.Fields.SubscriptionRequestType,c),new e.Field(e.Fields.NoMDEntryTypes,1),new e.Field(e.Fields.MDEntryType,l));if(!this.parser?.connected)return{isError:!0,content:[{type:"text",text:"Error: Not connected. Ignoring message."}]};this.parser?.send(m);let g=await u;return{content:[{type:"text",text:`Market data for ${s}: ${JSON.stringify(g.toFIXJSON())}`}]}}catch(r){return{isError:!0,content:[{type:"text",text:`Error: ${r instanceof Error?r.message:"Failed to request market data"}`}]}}default:throw new Error(`Unknown tool: ${o}`)}}),this.server.setRequestHandler(d.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:!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(d.GetPromptRequestSchema,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:r,handlInst:s,quantity:p,price:c,ordType:l,side:u,symbol:m,timeInForce:g}=n||{};return{messages:[{role:"user",content:{type:"text",text:["Create a New Order Single FIX message with the following parameters:",`- ClOrdID: ${r}`,`- 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: ${l??"1"} (IMPORTANT: Use the numeric/alphabetic value, not the descriptive name. For example, use '1' for Market, '2' for Limit, '3' for Stop)`,`- Side: ${u} (IMPORTANT: Use the numeric/alphabetic value, not the descriptive name. For example, use '1' for Buy, '2' for Sell)`,`- Symbol: ${m}`,`- TimeInForce: ${g??"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: All parameters must be set before sending the order. Missing or invalid parameters will result in a Reject message.","","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:r,symbol:s,mdReqID:p,subscriptionRequestType:c,mdEntryType:l}=n||{};return{messages:[{role:"user",content:{type:"text",text:["Create a Market Data Request FIX message with the following parameters:",`- MDUpdateType: ${r??"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: ${l??"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",b=async()=>{await t.LicenseManager.setLicenseKey(process.env.FIXPARSER_LICENSE_KEY);let a=new t.FIXParser({logging:!1,plugins:[new w({port:3099,onReady:()=>{}})]}),i=()=>{let n=a.createMessage(new t.Field(t.Fields.MsgType,t.Messages.Logon),new t.Field(t.Fields.MsgSeqNum,a.getNextTargetMsgSeqNum()),new t.Field(t.Fields.SenderCompID,O),new t.Field(t.Fields.SendingTime,a.getTimestamp()),new t.Field(t.Fields.TargetCompID,q),new t.Field(t.Fields.ResetSeqNumFlag,t.ResetSeqNumFlag.Yes),new t.Field(t.Fields.EncryptMethod,t.EncryptMethod.None),new t.Field(t.Fields.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)};b().catch(a=>console.error("Error initializing server:",a));
6
6
  //# sourceMappingURL=example_mcp_local.js.map