fixparser-plugin-mcp 9.1.7-28bfe28b → 9.1.7-2c6248d2

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.
@@ -49,7 +49,7 @@ var newOrderSingleInputSchema = {
49
49
  type: "string",
50
50
  enum: ["1", "2", "3"],
51
51
  default: HandlInst.AutomatedExecutionNoIntervention,
52
- description: "Handling instruction"
52
+ 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
53
  },
54
54
  quantity: {
55
55
  type: "number",
@@ -90,12 +90,12 @@ var newOrderSingleInputSchema = {
90
90
  "S"
91
91
  ],
92
92
  default: OrdType.Market,
93
- description: "Order type"
93
+ 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
94
  },
95
95
  side: {
96
96
  type: "string",
97
97
  enum: ["1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F", "G", "H"],
98
- description: "Order side (1=Buy, 2=Sell)"
98
+ 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)'
99
99
  },
100
100
  symbol: {
101
101
  type: "string",
@@ -105,7 +105,7 @@ var newOrderSingleInputSchema = {
105
105
  type: "string",
106
106
  enum: ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C"],
107
107
  default: TimeInForce.Day,
108
- description: "Time in force"
108
+ 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
109
  }
110
110
  },
111
111
  required: ["clOrdID", "quantity", "price", "side", "symbol"]
@@ -117,7 +117,7 @@ var marketDataRequestInputSchema = {
117
117
  type: "string",
118
118
  enum: ["0", "1"],
119
119
  default: "0",
120
- description: "Market data update type"
120
+ 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
121
  },
122
122
  symbol: {
123
123
  type: "string",
@@ -131,7 +131,7 @@ var marketDataRequestInputSchema = {
131
131
  type: "string",
132
132
  enum: ["0", "1", "2"],
133
133
  default: SubscriptionRequestType.SnapshotAndUpdates,
134
- description: "Subscription request type"
134
+ 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
135
  },
136
136
  mdEntryType: {
137
137
  type: "string",
@@ -182,13 +182,13 @@ var marketDataRequestInputSchema = {
182
182
  "t"
183
183
  ],
184
184
  default: MDEntryType.Bid,
185
- description: "Market data entry type"
185
+ 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
186
  }
187
187
  },
188
188
  required: ["symbol", "mdReqID"]
189
189
  };
190
190
  var MCPLocal = class {
191
- logger;
191
+ // private logger: Logger | undefined;
192
192
  parser;
193
193
  server = new Server(
194
194
  {
@@ -207,16 +207,11 @@ var MCPLocal = class {
207
207
  onReady = void 0;
208
208
  pendingRequests = /* @__PURE__ */ new Map();
209
209
  constructor({ logger, onReady }) {
210
- if (logger) this.logger = logger;
211
210
  if (onReady) this.onReady = onReady;
212
211
  }
213
212
  async register(parser) {
214
213
  this.parser = parser;
215
214
  this.parser.addOnMessageCallback((message) => {
216
- this.logger?.log({
217
- level: "info",
218
- message: `FIXParser (MCP): (${parser.protocol?.toUpperCase()}): << received ${message.description}`
219
- });
220
215
  const msgType = message.messageType;
221
216
  if (msgType === Messages.MarketDataSnapshotFullRefresh || msgType === Messages.ExecutionReport) {
222
217
  const idField = msgType === Messages.MarketDataSnapshotFullRefresh ? message.getField(Fields.MDReqID) : message.getField(Fields.ClOrdID);
@@ -232,7 +227,6 @@ var MCPLocal = class {
232
227
  }
233
228
  }
234
229
  });
235
- this.logger = parser.logger;
236
230
  this.addWorkflows();
237
231
  await this.server.connect(this.transport);
238
232
  if (this.onReady) {
@@ -241,17 +235,9 @@ var MCPLocal = class {
241
235
  }
242
236
  addWorkflows() {
243
237
  if (!this.parser) {
244
- this.logger?.log({
245
- level: "error",
246
- message: "FIXParser (MCP): -- FIXParser instance not initialized. Ignoring setup of workflows..."
247
- });
248
238
  return;
249
239
  }
250
240
  if (!this.server) {
251
- this.logger?.log({
252
- level: "error",
253
- message: "FIXParser (MCP): -- MCP Server not initialized. Ignoring setup of workflows..."
254
- });
255
241
  return;
256
242
  }
257
243
  const validateArgs = (args, schema) => {
@@ -318,7 +304,8 @@ var MCPLocal = class {
318
304
  content: [
319
305
  {
320
306
  type: "text",
321
- text: `Parsed FIX message: ${fixString} (placeholder implementation)`
307
+ text: `${parsedMessage[0].description}
308
+ ${parsedMessage[0].messageTypeDescription}`
322
309
  }
323
310
  ]
324
311
  };
@@ -348,7 +335,7 @@ var MCPLocal = class {
348
335
  content: [
349
336
  {
350
337
  type: "text",
351
- text: JSON.stringify({ fixString, parsed: "placeholder" })
338
+ text: `${parsedMessage[0].toFIXJSON()}`
352
339
  }
353
340
  ]
354
341
  };
@@ -387,10 +374,6 @@ var MCPLocal = class {
387
374
  new Field(Fields.TransactTime, this.parser?.getTimestamp())
388
375
  );
389
376
  if (!this.parser?.connected) {
390
- this.logger?.log({
391
- level: "error",
392
- message: "FIXParser (MCP): -- Not connected. Ignoring message."
393
- });
394
377
  return {
395
378
  isError: true,
396
379
  content: [
@@ -402,10 +385,6 @@ var MCPLocal = class {
402
385
  };
403
386
  }
404
387
  this.parser?.send(order);
405
- this.logger?.log({
406
- level: "info",
407
- message: `FIXParser (MCP): (${this.parser?.protocol?.toUpperCase()}): >> sent ${order?.description}`
408
- });
409
388
  const fixData = await response;
410
389
  return {
411
390
  content: [
@@ -452,10 +431,6 @@ var MCPLocal = class {
452
431
  new Field(Fields.MDEntryType, mdEntryType)
453
432
  );
454
433
  if (!this.parser?.connected) {
455
- this.logger?.log({
456
- level: "error",
457
- message: "FIXParser (MCP): -- Not connected. Ignoring message."
458
- });
459
434
  return {
460
435
  isError: true,
461
436
  content: [
@@ -467,10 +442,6 @@ var MCPLocal = class {
467
442
  };
468
443
  }
469
444
  this.parser?.send(marketDataRequest);
470
- this.logger?.log({
471
- level: "info",
472
- message: `FIXParser (MCP): (${this.parser?.protocol?.toUpperCase()}): >> sent ${marketDataRequest?.description}`
473
- });
474
445
  const fixData = await response;
475
446
  return {
476
447
  content: [
@@ -552,7 +523,7 @@ var MCPLocal = class {
552
523
  },
553
524
  {
554
525
  name: "side",
555
- description: "Order side (1=Buy, 2=Sell)",
526
+ 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)",
556
527
  required: true
557
528
  },
558
529
  {
@@ -643,15 +614,20 @@ var MCPLocal = class {
643
614
  text: [
644
615
  "Create a New Order Single FIX message with the following parameters:",
645
616
  `- ClOrdID: ${clOrdID}`,
646
- `- HandlInst: ${handlInst ?? "default"}`,
617
+ `- 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)`,
647
618
  `- Quantity: ${quantity}`,
648
619
  `- Price: ${price}`,
649
- `- OrdType: ${ordType ?? "default (Market)"}`,
650
- `- Side: ${side}`,
620
+ `- 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)`,
621
+ `- Side: ${side} (IMPORTANT: Use the numeric/alphabetic value, not the descriptive name. For example, use '1' for Buy, '2' for Sell)`,
651
622
  `- Symbol: ${symbol}`,
652
- `- TimeInForce: ${timeInForce ?? "default (Day)"}`,
623
+ `- 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)`,
653
624
  "",
654
- "Format the response as a JSON object with FIX tag numbers as keys and their corresponding values."
625
+ "Format the response as a JSON object with FIX tag numbers as keys and their corresponding values.",
626
+ "",
627
+ '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.',
628
+ '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.',
629
+ '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.',
630
+ '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.'
655
631
  ].join("\n")
656
632
  }
657
633
  }
@@ -668,13 +644,17 @@ var MCPLocal = class {
668
644
  type: "text",
669
645
  text: [
670
646
  "Create a Market Data Request FIX message with the following parameters:",
671
- `- MDUpdateType: ${mdUpdateType ?? "default (0 = FullRefresh)"}`,
647
+ `- MDUpdateType: ${mdUpdateType ?? "0"} (IMPORTANT: Use the numeric/alphabetic value, not the descriptive name. For example, use '0' for FullRefresh, '1' for IncrementalRefresh)`,
672
648
  `- Symbol: ${symbol}`,
673
649
  `- MDReqID: ${mdReqID}`,
674
- `- SubscriptionRequestType: ${subscriptionRequestType ?? "default (0 = Snapshot + Updates)"}`,
675
- `- MDEntryType: ${mdEntryType ?? "default (0 = Bid)"}`,
650
+ `- 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)`,
651
+ `- 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)`,
652
+ "",
653
+ "Format the response as a JSON object with FIX tag numbers as keys and their corresponding values.",
676
654
  "",
677
- "Format the response as a JSON object with FIX tag numbers as keys and their corresponding values."
655
+ '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.',
656
+ '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.',
657
+ '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.'
678
658
  ].join("\n")
679
659
  }
680
660
  }
@@ -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: 'Handling instruction',\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: 'Order type',\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: 'Order side (1=Buy, 2=Sell)',\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: 'Time in force',\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: 'Market data update type',\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: 'Subscription request type',\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: 'Market data entry type',\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) this.logger = logger;\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 (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.logger = parser.logger;\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 = 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: `Parsed FIX message: ${fixString} (placeholder implementation)`,\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: JSON.stringify({ fixString, parsed: 'placeholder' }),\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: 'Order side (1=Buy, 2=Sell)',\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 ?? 'default'}`,\n `- Quantity: ${quantity}`,\n `- Price: ${price}`,\n `- OrdType: ${ordType ?? 'default (Market)'}`,\n `- Side: ${side}`,\n `- Symbol: ${symbol}`,\n `- TimeInForce: ${timeInForce ?? 'default (Day)'}`,\n '',\n 'Format the response as a JSON object with FIX tag numbers as keys and their corresponding values.',\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 ?? 'default (0 = FullRefresh)'}`,\n `- Symbol: ${symbol}`,\n `- MDReqID: ${mdReqID}`,\n `- SubscriptionRequestType: ${subscriptionRequestType ?? 'default (0 = Snapshot + Updates)'}`,\n `- MDEntryType: ${mdEntryType ?? 'default (0 = Bid)'}`,\n '',\n 'Format the response as a JSON object with FIX tag numbers as keys and their corresponding values.',\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,IACjB;AAAA,EACJ;AAAA,EACA,UAAU,CAAC,WAAW;AAC1B;AAEA,IAAM,yBAAyB;AAAA,EAC3B,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,4BAA4B;AAAA,EAC9B,MAAM;AAAA,EACN,YAAY;AAAA,IACR,SAAS;AAAA,MACL,MAAM;AAAA,MACN,aAAa;AAAA,IACjB;AAAA,IACA,WAAW;AAAA,MACP,MAAM;AAAA,MACN,MAAM,CAAC,KAAK,KAAK,GAAG;AAAA,MACpB,SAAS,UAAU;AAAA,MACnB,aAAa;AAAA,IACjB;AAAA,IACA,UAAU;AAAA,MACN,MAAM;AAAA,MACN,aAAa;AAAA,IACjB;AAAA,IACA,OAAO;AAAA,MACH,MAAM;AAAA,MACN,aAAa;AAAA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AAAA,oBACnB,kBAAkB,eAAe,eAAe;AAAA,oBAChD;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,2BAA2B;AAAA,oBAC9D,aAAa,MAAM;AAAA,oBACnB,cAAc,OAAO;AAAA,oBACrB,8BAA8B,2BAA2B,kCAAkC;AAAA,oBAC3F,kBAAkB,eAAe,mBAAmB;AAAA,oBACpD;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 {\n Field,\n Fields,\n HandlInst,\n type IFIXParser,\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 (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 (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,EAEA;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,IACjB;AAAA,EACJ;AAAA,EACA,UAAU,CAAC,WAAW;AAC1B;AAEA,IAAM,yBAAyB;AAAA,EAC3B,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,4BAA4B;AAAA,EAC9B,MAAM;AAAA,EACN,YAAY;AAAA,IACR,SAAS;AAAA,MACL,MAAM;AAAA,MACN,aAAa;AAAA,IACjB;AAAA,IACA,WAAW;AAAA,MACP,MAAM;AAAA,MACN,MAAM,CAAC,KAAK,KAAK,GAAG;AAAA,MACpB,SAAS,UAAU;AAAA,MACnB,aACI;AAAA,IACR;AAAA,IACA,UAAU;AAAA,MACN,MAAM;AAAA,MACN,aAAa;AAAA,IACjB;AAAA,IACA,OAAO;AAAA,MACH,MAAM;AAAA,MACN,aAAa;AAAA,IACjB;AAAA,IACA,SAAS;AAAA,MACL,MAAM;AAAA,MACN,MAAM;AAAA,QACF;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QAC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A,EACL;AACJ;",
6
6
  "names": []
7
7
  }
@@ -1,5 +1,6 @@
1
1
  #!/usr/bin/env node
2
- "use strict";var r=require("fixparser");var w=require("@modelcontextprotocol/sdk/server/index.js"),T=require("@modelcontextprotocol/sdk/server/stdio.js"),c=require("@modelcontextprotocol/sdk/types.js"),e=require("fixparser"),S={type:"object",properties:{fixString:{type:"string",description:"FIX message string to parse"}},required:["fixString"]},f={type:"object",properties:{fixString:{type:"string",description:"FIX message string to parse"}},required:["fixString"]},I={type:"object",properties:{clOrdID:{type:"string",description:"Client Order ID"},handlInst:{type:"string",enum:["1","2","3"],default:e.HandlInst.AutomatedExecutionNoIntervention,description:"Handling instruction"},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"},side:{type:"string",enum:["1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H"],description:"Order side (1=Buy, 2=Sell)"},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"}},required:["clOrdID","quantity","price","side","symbol"]},q={type:"object",properties:{mdUpdateType:{type:"string",enum:["0","1"],default:"0",description:"Market data update type"},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"},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"}},required:["symbol","mdReqID"]},F=class{logger;parser;server=new w.Server({name:"fixparser",version:"1.0.0"},{capabilities:{tools:{},prompts:{},resources:{}}});transport=new T.StdioServerTransport;onReady=void 0;pendingRequests=new Map;constructor({logger:n,onReady:a}){n&&(this.logger=n),a&&(this.onReady=a)}async register(n){this.parser=n,this.parser.addOnMessageCallback(a=>{this.logger?.log({level:"info",message:`FIXParser (MCP): (${n.protocol?.toUpperCase()}): << received ${a.description}`});let o=a.messageType;if(o===e.Messages.MarketDataSnapshotFullRefresh||o===e.Messages.ExecutionReport){let i=o===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 s=this.pendingRequests.get(String(t));s&&(s(a),this.pendingRequests.delete(String(t)))}}}}),this.logger=n.logger,this.addWorkflows(),await this.server.connect(this.transport),this.onReady&&this.onReady()}addWorkflows(){if(!this.parser){this.logger?.log({level:"error",message:"FIXParser (MCP): -- FIXParser instance not initialized. Ignoring setup of workflows..."});return}if(!this.server){this.logger?.log({level:"error",message:"FIXParser (MCP): -- MCP Server not initialized. Ignoring setup of workflows..."});return}let n=(a,o)=>{let i={};for(let[t,s]of Object.entries(o.properties||{})){let p=s,d=a?.[t];if(p.required&&d==null)throw new Error(`Required property '${t}' is missing`);d!==void 0?i[t]=d:p.default!==void 0&&(i[t]=p.default)}return i};this.server.setRequestHandler(c.ListResourcesRequestSchema,async()=>({resources:[]})),this.server.setRequestHandler(c.ListToolsRequestSchema,async()=>({tools:[{name:"parse",description:"Parses a FIX message and describes it in plain language",inputSchema:S},{name:"parseToJSON",description:"Parses a FIX message into JSON",inputSchema:f},{name:"newOrderSingle",description:"Creates and sends a New Order Single",inputSchema:I},{name:"marketDataRequest",description:"Sends a request for Market Data with the given symbol",inputSchema:q}]})),this.server.setRequestHandler(c.CallToolRequestSchema,async a=>{let{name:o,arguments:i}=a.params;switch(o){case"parse":try{let{fixString:t}=n(i,S),s=this.parser?.parse(t);return!s||s.length===0?{isError:!0,content:[{type:"text",text:"Error: Failed to parse FIX string"}]}:{content:[{type:"text",text:`Parsed FIX message: ${t} (placeholder implementation)`}]}}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}=n(i,f),s=this.parser?.parse(t);return!s||s.length===0?{isError:!0,content:[{type:"text",text:"Error: Failed to parse FIX string"}]}:{content:[{type:"text",text:JSON.stringify({fixString:t,parsed:"placeholder"})}]}}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:s,quantity:p,price:d,ordType:g,side:u,symbol:l,timeInForce:m}=n(i,I),y=new Promise(x=>{this.pendingRequests.set(t,x)}),h=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,l),new e.Field(e.Fields.OrderQty,p),new e.Field(e.Fields.Price,d),new e.Field(e.Fields.OrdType,g),new e.Field(e.Fields.HandlInst,s),new e.Field(e.Fields.TimeInForce,m),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(h),this.logger?.log({level:"info",message:`FIXParser (MCP): (${this.parser?.protocol?.toUpperCase()}): >> sent ${h?.description}`});let M=await y;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:s,mdReqID:p,subscriptionRequestType:d,mdEntryType:g}=n(i,q),u=new Promise(y=>{this.pendingRequests.set(p,y)}),l=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,s),new e.Field(e.Fields.MDReqID,p),new e.Field(e.Fields.SubscriptionRequestType,d),new e.Field(e.Fields.NoMDEntryTypes,1),new e.Field(e.Fields.MDEntryType,g));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(l),this.logger?.log({level:"info",message:`FIXParser (MCP): (${this.parser?.protocol?.toUpperCase()}): >> sent ${l?.description}`});let m=await u;return{content:[{type:"text",text:`Market data for ${s}: ${JSON.stringify(m.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: ${o}`)}}),this.server.setRequestHandler(c.ListPromptsRequestSchema,async()=>({prompts:[{name:"parse",description:"Parses a FIX message and describes it in plain language",arguments:[{name:"fixString",description:"FIX message string to parse",required:!0}]},{name:"parseToJSON",description:"Parses a FIX message into JSON",arguments:[{name:"fixString",description:"FIX message string to parse",required:!0}]},{name:"newOrderSingle",description:"Creates and sends a New Order Single",arguments:[{name:"clOrdID",description:"Client Order ID",required:!0},{name:"handlInst",description:"Handling instruction",required:!1},{name:"quantity",description:"Order quantity",required:!0},{name:"price",description:"Order price",required:!0},{name:"ordType",description:"Order type",required:!1},{name:"side",description:"Order side (1=Buy, 2=Sell)",required:!0},{name:"symbol",description:"Trading symbol",required:!0},{name:"timeInForce",description:"Time in force",required:!1}]},{name:"marketDataRequest",description:"Sends a request for Market Data with the given symbol",arguments:[{name:"mdUpdateType",description:"Market data update type",required:!1},{name:"symbol",description:"Trading symbol",required:!0},{name:"mdReqID",description:"Market data request ID",required:!0},{name:"subscriptionRequestType",description:"Subscription request type",required:!1},{name:"mdEntryType",description:"Market data entry type",required:!1}]}]})),this.server.setRequestHandler(c.GetPromptRequestSchema,async a=>{let{name:o,arguments:i}=a.params;switch(o){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:s,quantity:p,price:d,ordType:g,side:u,symbol:l,timeInForce:m}=i||{};return{messages:[{role:"user",content:{type:"text",text:["Create a New Order Single FIX message with the following parameters:",`- ClOrdID: ${t}`,`- HandlInst: ${s??"default"}`,`- Quantity: ${p}`,`- Price: ${d}`,`- OrdType: ${g??"default (Market)"}`,`- Side: ${u}`,`- Symbol: ${l}`,`- TimeInForce: ${m??"default (Day)"}`,"","Format the response as a JSON object with FIX tag numbers as keys and their corresponding values."].join(`
3
- `)}}]}}case"marketDataRequest":{let{mdUpdateType:t,symbol:s,mdReqID:p,subscriptionRequestType:d,mdEntryType:g}=i||{};return{messages:[{role:"user",content:{type:"text",text:["Create a Market Data Request FIX message with the following parameters:",`- MDUpdateType: ${t??"default (0 = FullRefresh)"}`,`- Symbol: ${s}`,`- MDReqID: ${p}`,`- SubscriptionRequestType: ${d??"default (0 = Snapshot + Updates)"}`,`- MDEntryType: ${g??"default (0 = Bid)"}`,"","Format the response as a JSON object with FIX tag numbers as keys and their corresponding values."].join(`
4
- `)}}]}}default:throw new Error(`Unknown prompt: ${o}`)}}),process.on("SIGINT",async()=>{await this.server.close(),process.exit(0)})}};var R=async()=>{await r.LicenseManager.setLicenseKey(process.env.FIXPARSER_LICENSE_KEY);let n=new r.FIXParser({plugins:[new F({port:3099,onReady:()=>{}})]}),a=()=>{let s=n.createMessage(new r.Field(r.Fields.MsgType,r.Messages.Logon),new r.Field(r.Fields.MsgSeqNum,n.getNextTargetMsgSeqNum()),new r.Field(r.Fields.SenderCompID,o),new r.Field(r.Fields.SendingTime,n.getTimestamp()),new r.Field(r.Fields.TargetCompID,i),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));n.send(s)},o="CLIENT2",i="EXECUTOR",t={host:"10.0.1.42",port:5001,protocol:"tcp",sender:o,target:i,fixVersion:"FIX.4.4",logging:!1,onOpen:()=>{a()},onMessage:s=>{},onClose:()=>{}};n.connect(t)};R().catch(n=>console.error("Error initializing server:",n));
2
+ "use strict";var r=require("fixparser");var I=require("@modelcontextprotocol/sdk/server/index.js"),F=require("@modelcontextprotocol/sdk/server/stdio.js"),c=require("@modelcontextprotocol/sdk/types.js"),e=require("fixparser"),g={type:"object",properties:{fixString:{type:"string",description:"FIX message string to parse"}},required:["fixString"]},y={type:"object",properties:{fixString:{type:"string",description:"FIX message string to parse"}},required:["fixString"]},S={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"]},T={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"]},w=class{parser;server=new I.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){let n=o===e.Messages.MarketDataSnapshotFullRefresh?i.getField(e.Fields.MDReqID):i.getField(e.Fields.ClOrdID);if(n){let t=n.value;if(typeof t=="string"||typeof t=="number"){let s=this.pendingRequests.get(String(t));s&&(s(i),this.pendingRequests.delete(String(t)))}}}}),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[t,s]of Object.entries(o.properties||{})){let p=s,d=i?.[t];if(p.required&&d==null)throw new Error(`Required property '${t}' is missing`);d!==void 0?n[t]=d:p.default!==void 0&&(n[t]=p.default)}return n};this.server.setRequestHandler(c.ListResourcesRequestSchema,async()=>({resources:[]})),this.server.setRequestHandler(c.ListToolsRequestSchema,async()=>({tools:[{name:"parse",description:"Parses a FIX message and describes it in plain language",inputSchema:g},{name:"parseToJSON",description:"Parses a FIX message into JSON",inputSchema:y},{name:"newOrderSingle",description:"Creates and sends a New Order Single",inputSchema:S},{name:"marketDataRequest",description:"Sends a request for Market Data with the given symbol",inputSchema:T}]})),this.server.setRequestHandler(c.CallToolRequestSchema,async i=>{let{name:o,arguments:n}=i.params;switch(o){case"parse":try{let{fixString:t}=a(n,g),s=this.parser?.parse(t);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(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}=a(n,y),s=this.parser?.parse(t);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(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:s,quantity:p,price:d,ordType:l,side:u,symbol:m,timeInForce:h}=a(n,S),f=new Promise(b=>{this.pendingRequests.set(t,b)}),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,t),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,d),new e.Field(e.Fields.OrdType,l),new e.Field(e.Fields.HandlInst,s),new e.Field(e.Fields.TimeInForce,h),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 O=await f;return{content:[{type:"text",text:`Execution Report for order ${t}: ${JSON.stringify(O.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:s,mdReqID:p,subscriptionRequestType:d,mdEntryType:l}=a(n,T),u=new Promise(f=>{this.pendingRequests.set(p,f)}),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,s),new e.Field(e.Fields.MDReqID,p),new e.Field(e.Fields.SubscriptionRequestType,d),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 h=await u;return{content:[{type:"text",text:`Market data for ${s}: ${JSON.stringify(h.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: ${o}`)}}),this.server.setRequestHandler(c.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(c.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:t,handlInst:s,quantity:p,price:d,ordType:l,side:u,symbol:m,timeInForce:h}=n||{};return{messages:[{role:"user",content:{type:"text",text:["Create a New Order Single FIX message with the following parameters:",`- ClOrdID: ${t}`,`- 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: ${d}`,`- 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: ${h??"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:s,mdReqID:p,subscriptionRequestType:d,mdEntryType:l}=n||{};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: ${s}`,`- MDReqID: ${p}`,`- SubscriptionRequestType: ${d??"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 q="CLIENT2",R="EXECUTOR",v=async()=>{await r.LicenseManager.setLicenseKey(process.env.FIXPARSER_LICENSE_KEY);let a=new r.FIXParser({logging:!1,plugins:[new w({port:3099,onReady:()=>{}})]}),i=()=>{let n=a.createMessage(new r.Field(r.Fields.MsgType,r.Messages.Logon),new r.Field(r.Fields.MsgSeqNum,a.getNextTargetMsgSeqNum()),new r.Field(r.Fields.SenderCompID,q),new r.Field(r.Fields.SendingTime,a.getTimestamp()),new r.Field(r.Fields.TargetCompID,R),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));a.send(n)},o={host:"10.0.1.42",port:5001,protocol:"tcp",sender:q,target:R,fixVersion:"FIX.4.4",onOpen:()=>{i()},onMessage:n=>{},onClose:()=>{setTimeout(()=>{a.connect(o)},1e3)}};a.connect(o)};v().catch(a=>console.error("Error initializing server:",a));
5
6
  //# sourceMappingURL=example_mcp_local.js.map