fixparser-plugin-mcp 9.1.7-9a1ab782 → 9.1.7-b2bba224
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/cjs/MCPLocal.js +29 -18
- package/build/cjs/MCPLocal.js.map +2 -2
- package/build/esm/MCPLocal.mjs +29 -18
- package/build/esm/MCPLocal.mjs.map +2 -2
- package/build-examples/cjs/example_mcp_local.js +4 -4
- package/build-examples/cjs/example_mcp_local.js.map +3 -3
- package/build-examples/esm/example_mcp_local.mjs +4 -4
- package/build-examples/esm/example_mcp_local.mjs.map +3 -3
- package/package.json +2 -2
package/build/cjs/MCPLocal.js
CHANGED
|
@@ -222,15 +222,26 @@ var MCPLocal = class {
|
|
|
222
222
|
this.parser = parser;
|
|
223
223
|
this.parser.addOnMessageCallback((message) => {
|
|
224
224
|
const msgType = message.messageType;
|
|
225
|
-
if (msgType === import_fixparser.Messages.MarketDataSnapshotFullRefresh || msgType === import_fixparser.Messages.ExecutionReport) {
|
|
226
|
-
const idField = msgType === import_fixparser.Messages.MarketDataSnapshotFullRefresh ? message.getField(import_fixparser.Fields.MDReqID) : message.getField(import_fixparser.Fields.ClOrdID);
|
|
225
|
+
if (msgType === import_fixparser.Messages.MarketDataSnapshotFullRefresh || msgType === import_fixparser.Messages.ExecutionReport || msgType === import_fixparser.Messages.Reject) {
|
|
226
|
+
const idField = msgType === import_fixparser.Messages.MarketDataSnapshotFullRefresh ? message.getField(import_fixparser.Fields.MDReqID) : msgType === import_fixparser.Messages.Reject ? message.getField(import_fixparser.Fields.RefSeqNum) : message.getField(import_fixparser.Fields.ClOrdID);
|
|
227
227
|
if (idField) {
|
|
228
228
|
const id = idField.value;
|
|
229
229
|
if (typeof id === "string" || typeof id === "number") {
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
230
|
+
if (msgType === import_fixparser.Messages.Reject) {
|
|
231
|
+
const refMsgType = message.getField(import_fixparser.Fields.RefMsgType);
|
|
232
|
+
if (refMsgType && refMsgType.value === import_fixparser.Messages.NewOrderSingle) {
|
|
233
|
+
const callback = this.pendingRequests.get(String(id));
|
|
234
|
+
if (callback) {
|
|
235
|
+
callback(message);
|
|
236
|
+
this.pendingRequests.delete(String(id));
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
} else {
|
|
240
|
+
const callback = this.pendingRequests.get(String(id));
|
|
241
|
+
if (callback) {
|
|
242
|
+
callback(message);
|
|
243
|
+
this.pendingRequests.delete(String(id));
|
|
244
|
+
}
|
|
234
245
|
}
|
|
235
246
|
}
|
|
236
247
|
}
|
|
@@ -399,7 +410,7 @@ ${parsedMessage[0].messageTypeDescription}`
|
|
|
399
410
|
content: [
|
|
400
411
|
{
|
|
401
412
|
type: "text",
|
|
402
|
-
text: `Execution Report for order ${clOrdID}: ${JSON.stringify(fixData.toFIXJSON())}`
|
|
413
|
+
text: fixData.messageType === import_fixparser.Messages.Reject ? `Reject message for order ${clOrdID}: ${JSON.stringify(fixData.toFIXJSON())}` : `Execution Report for order ${clOrdID}: ${JSON.stringify(fixData.toFIXJSON())}`
|
|
403
414
|
}
|
|
404
415
|
]
|
|
405
416
|
};
|
|
@@ -513,7 +524,7 @@ ${parsedMessage[0].messageTypeDescription}`
|
|
|
513
524
|
{
|
|
514
525
|
name: "handlInst",
|
|
515
526
|
description: "Handling instruction",
|
|
516
|
-
required:
|
|
527
|
+
required: true
|
|
517
528
|
},
|
|
518
529
|
{
|
|
519
530
|
name: "quantity",
|
|
@@ -528,7 +539,7 @@ ${parsedMessage[0].messageTypeDescription}`
|
|
|
528
539
|
{
|
|
529
540
|
name: "ordType",
|
|
530
541
|
description: "Order type",
|
|
531
|
-
required:
|
|
542
|
+
required: true
|
|
532
543
|
},
|
|
533
544
|
{
|
|
534
545
|
name: "side",
|
|
@@ -543,7 +554,7 @@ ${parsedMessage[0].messageTypeDescription}`
|
|
|
543
554
|
{
|
|
544
555
|
name: "timeInForce",
|
|
545
556
|
description: "Time in force",
|
|
546
|
-
required:
|
|
557
|
+
required: true
|
|
547
558
|
}
|
|
548
559
|
]
|
|
549
560
|
},
|
|
@@ -554,7 +565,7 @@ ${parsedMessage[0].messageTypeDescription}`
|
|
|
554
565
|
{
|
|
555
566
|
name: "mdUpdateType",
|
|
556
567
|
description: "Market data update type",
|
|
557
|
-
required:
|
|
568
|
+
required: true
|
|
558
569
|
},
|
|
559
570
|
{
|
|
560
571
|
name: "symbol",
|
|
@@ -569,12 +580,12 @@ ${parsedMessage[0].messageTypeDescription}`
|
|
|
569
580
|
{
|
|
570
581
|
name: "subscriptionRequestType",
|
|
571
582
|
description: "Subscription request type",
|
|
572
|
-
required:
|
|
583
|
+
required: true
|
|
573
584
|
},
|
|
574
585
|
{
|
|
575
586
|
name: "mdEntryType",
|
|
576
587
|
description: "Market data entry type",
|
|
577
|
-
required:
|
|
588
|
+
required: true
|
|
578
589
|
}
|
|
579
590
|
]
|
|
580
591
|
}
|
|
@@ -631,12 +642,12 @@ ${parsedMessage[0].messageTypeDescription}`
|
|
|
631
642
|
`- Symbol: ${symbol}`,
|
|
632
643
|
`- 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)`,
|
|
633
644
|
"",
|
|
634
|
-
"Format the response as a JSON object with FIX tag numbers as keys and their corresponding values.",
|
|
635
|
-
"",
|
|
636
|
-
'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.',
|
|
637
|
-
'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.',
|
|
638
645
|
'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.',
|
|
639
|
-
'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.'
|
|
646
|
+
'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.',
|
|
647
|
+
"",
|
|
648
|
+
"IMPORTANT: The response will be either:",
|
|
649
|
+
"1. An Execution Report (MsgType=8) if the order was successfully placed",
|
|
650
|
+
"2. A Reject message (MsgType=3) if the order failed to execute (e.g., due to missing or invalid parameters)"
|
|
640
651
|
].join("\n")
|
|
641
652
|
}
|
|
642
653
|
}
|
|
@@ -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 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;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAuB;AACvB,mBAAqC;AACrC,mBAMO;AAEP,uBAWO;AAKP,IAAM,mBAAmB;AAAA,EACrB,MAAM;AAAA,EACN,YAAY;AAAA,IACR,WAAW;AAAA,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AA,oBACpC;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;",
|
|
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 (\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: (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: 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;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAuB;AACvB,mBAAqC;AACrC,mBAMO;AAEP,uBAWO;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,2BAAU;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;AAA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;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
|
}
|
package/build/esm/MCPLocal.mjs
CHANGED
|
@@ -213,15 +213,26 @@ var MCPLocal = class {
|
|
|
213
213
|
this.parser = parser;
|
|
214
214
|
this.parser.addOnMessageCallback((message) => {
|
|
215
215
|
const msgType = message.messageType;
|
|
216
|
-
if (msgType === Messages.MarketDataSnapshotFullRefresh || msgType === Messages.ExecutionReport) {
|
|
217
|
-
const idField = msgType === Messages.MarketDataSnapshotFullRefresh ? message.getField(Fields.MDReqID) : message.getField(Fields.ClOrdID);
|
|
216
|
+
if (msgType === Messages.MarketDataSnapshotFullRefresh || msgType === Messages.ExecutionReport || msgType === Messages.Reject) {
|
|
217
|
+
const idField = msgType === Messages.MarketDataSnapshotFullRefresh ? message.getField(Fields.MDReqID) : msgType === Messages.Reject ? message.getField(Fields.RefSeqNum) : message.getField(Fields.ClOrdID);
|
|
218
218
|
if (idField) {
|
|
219
219
|
const id = idField.value;
|
|
220
220
|
if (typeof id === "string" || typeof id === "number") {
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
221
|
+
if (msgType === Messages.Reject) {
|
|
222
|
+
const refMsgType = message.getField(Fields.RefMsgType);
|
|
223
|
+
if (refMsgType && refMsgType.value === Messages.NewOrderSingle) {
|
|
224
|
+
const callback = this.pendingRequests.get(String(id));
|
|
225
|
+
if (callback) {
|
|
226
|
+
callback(message);
|
|
227
|
+
this.pendingRequests.delete(String(id));
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
} else {
|
|
231
|
+
const callback = this.pendingRequests.get(String(id));
|
|
232
|
+
if (callback) {
|
|
233
|
+
callback(message);
|
|
234
|
+
this.pendingRequests.delete(String(id));
|
|
235
|
+
}
|
|
225
236
|
}
|
|
226
237
|
}
|
|
227
238
|
}
|
|
@@ -390,7 +401,7 @@ ${parsedMessage[0].messageTypeDescription}`
|
|
|
390
401
|
content: [
|
|
391
402
|
{
|
|
392
403
|
type: "text",
|
|
393
|
-
text: `Execution Report for order ${clOrdID}: ${JSON.stringify(fixData.toFIXJSON())}`
|
|
404
|
+
text: fixData.messageType === Messages.Reject ? `Reject message for order ${clOrdID}: ${JSON.stringify(fixData.toFIXJSON())}` : `Execution Report for order ${clOrdID}: ${JSON.stringify(fixData.toFIXJSON())}`
|
|
394
405
|
}
|
|
395
406
|
]
|
|
396
407
|
};
|
|
@@ -504,7 +515,7 @@ ${parsedMessage[0].messageTypeDescription}`
|
|
|
504
515
|
{
|
|
505
516
|
name: "handlInst",
|
|
506
517
|
description: "Handling instruction",
|
|
507
|
-
required:
|
|
518
|
+
required: true
|
|
508
519
|
},
|
|
509
520
|
{
|
|
510
521
|
name: "quantity",
|
|
@@ -519,7 +530,7 @@ ${parsedMessage[0].messageTypeDescription}`
|
|
|
519
530
|
{
|
|
520
531
|
name: "ordType",
|
|
521
532
|
description: "Order type",
|
|
522
|
-
required:
|
|
533
|
+
required: true
|
|
523
534
|
},
|
|
524
535
|
{
|
|
525
536
|
name: "side",
|
|
@@ -534,7 +545,7 @@ ${parsedMessage[0].messageTypeDescription}`
|
|
|
534
545
|
{
|
|
535
546
|
name: "timeInForce",
|
|
536
547
|
description: "Time in force",
|
|
537
|
-
required:
|
|
548
|
+
required: true
|
|
538
549
|
}
|
|
539
550
|
]
|
|
540
551
|
},
|
|
@@ -545,7 +556,7 @@ ${parsedMessage[0].messageTypeDescription}`
|
|
|
545
556
|
{
|
|
546
557
|
name: "mdUpdateType",
|
|
547
558
|
description: "Market data update type",
|
|
548
|
-
required:
|
|
559
|
+
required: true
|
|
549
560
|
},
|
|
550
561
|
{
|
|
551
562
|
name: "symbol",
|
|
@@ -560,12 +571,12 @@ ${parsedMessage[0].messageTypeDescription}`
|
|
|
560
571
|
{
|
|
561
572
|
name: "subscriptionRequestType",
|
|
562
573
|
description: "Subscription request type",
|
|
563
|
-
required:
|
|
574
|
+
required: true
|
|
564
575
|
},
|
|
565
576
|
{
|
|
566
577
|
name: "mdEntryType",
|
|
567
578
|
description: "Market data entry type",
|
|
568
|
-
required:
|
|
579
|
+
required: true
|
|
569
580
|
}
|
|
570
581
|
]
|
|
571
582
|
}
|
|
@@ -622,12 +633,12 @@ ${parsedMessage[0].messageTypeDescription}`
|
|
|
622
633
|
`- Symbol: ${symbol}`,
|
|
623
634
|
`- 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)`,
|
|
624
635
|
"",
|
|
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
636
|
'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.'
|
|
637
|
+
'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.',
|
|
638
|
+
"",
|
|
639
|
+
"IMPORTANT: The response will be either:",
|
|
640
|
+
"1. An Execution Report (MsgType=8) if the order was successfully placed",
|
|
641
|
+
"2. A Reject message (MsgType=3) if the order failed to execute (e.g., due to missing or invalid parameters)"
|
|
631
642
|
].join("\n")
|
|
632
643
|
}
|
|
633
644
|
}
|