fixparser-plugin-mcp 9.1.7-9a1ab782 → 9.1.7-a24bdbec
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 +40 -33
- package/build/cjs/MCPLocal.js.map +2 -2
- package/build/esm/MCPLocal.mjs +41 -43
- 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 +4 -4
package/build/esm/MCPLocal.mjs
CHANGED
|
@@ -8,16 +8,7 @@ import {
|
|
|
8
8
|
ListResourcesRequestSchema,
|
|
9
9
|
ListToolsRequestSchema
|
|
10
10
|
} from "@modelcontextprotocol/sdk/types.js";
|
|
11
|
-
import {
|
|
12
|
-
Field,
|
|
13
|
-
Fields,
|
|
14
|
-
HandlInst,
|
|
15
|
-
MDEntryType,
|
|
16
|
-
Messages,
|
|
17
|
-
OrdType,
|
|
18
|
-
SubscriptionRequestType,
|
|
19
|
-
TimeInForce
|
|
20
|
-
} from "fixparser";
|
|
11
|
+
import { Field, Fields, Messages } from "fixparser";
|
|
21
12
|
var parseInputSchema = {
|
|
22
13
|
type: "object",
|
|
23
14
|
properties: {
|
|
@@ -48,7 +39,6 @@ var newOrderSingleInputSchema = {
|
|
|
48
39
|
handlInst: {
|
|
49
40
|
type: "string",
|
|
50
41
|
enum: ["1", "2", "3"],
|
|
51
|
-
default: HandlInst.AutomatedExecutionNoIntervention,
|
|
52
42
|
description: 'Handling instruction (IMPORTANT: Use the numeric/alphabetic value, not the descriptive name. For example, use "1" for Manual, "2" for Automated, "3" for AutomatedNoIntervention)'
|
|
53
43
|
},
|
|
54
44
|
quantity: {
|
|
@@ -89,7 +79,6 @@ var newOrderSingleInputSchema = {
|
|
|
89
79
|
"R",
|
|
90
80
|
"S"
|
|
91
81
|
],
|
|
92
|
-
default: OrdType.Market,
|
|
93
82
|
description: 'Order type (IMPORTANT: Use the numeric/alphabetic value, not the descriptive name. For example, use "1" for Market, "2" for Limit, "3" for Stop)'
|
|
94
83
|
},
|
|
95
84
|
side: {
|
|
@@ -104,11 +93,10 @@ var newOrderSingleInputSchema = {
|
|
|
104
93
|
timeInForce: {
|
|
105
94
|
type: "string",
|
|
106
95
|
enum: ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C"],
|
|
107
|
-
default: TimeInForce.Day,
|
|
108
96
|
description: 'Time in force (IMPORTANT: Use the numeric/alphabetic value, not the descriptive name. For example, use "0" for Day, "1" for Good Till Cancel, "2" for At Opening, "3" for Immediate or Cancel, "4" for Fill or Kill, "5" for Good Till Crossing, "6" for Good Till Date)'
|
|
109
97
|
}
|
|
110
98
|
},
|
|
111
|
-
required: ["clOrdID", "quantity", "price", "side", "symbol"]
|
|
99
|
+
required: ["clOrdID", "quantity", "price", "side", "symbol", "handlInst", "ordType", "timeInForce"]
|
|
112
100
|
};
|
|
113
101
|
var marketDataRequestInputSchema = {
|
|
114
102
|
type: "object",
|
|
@@ -116,7 +104,6 @@ var marketDataRequestInputSchema = {
|
|
|
116
104
|
mdUpdateType: {
|
|
117
105
|
type: "string",
|
|
118
106
|
enum: ["0", "1"],
|
|
119
|
-
default: "0",
|
|
120
107
|
description: 'Market data update type (IMPORTANT: Use the numeric/alphabetic value, not the descriptive name. For example, use "0" for FullRefresh, "1" for IncrementalRefresh)'
|
|
121
108
|
},
|
|
122
109
|
symbol: {
|
|
@@ -130,7 +117,6 @@ var marketDataRequestInputSchema = {
|
|
|
130
117
|
subscriptionRequestType: {
|
|
131
118
|
type: "string",
|
|
132
119
|
enum: ["0", "1", "2"],
|
|
133
|
-
default: SubscriptionRequestType.SnapshotAndUpdates,
|
|
134
120
|
description: 'Subscription request type (IMPORTANT: Use the numeric/alphabetic value, not the descriptive name. For example, use "0" for Snapshot + Updates, "1" for Snapshot, "2" for Unsubscribe)'
|
|
135
121
|
},
|
|
136
122
|
mdEntryType: {
|
|
@@ -181,7 +167,6 @@ var marketDataRequestInputSchema = {
|
|
|
181
167
|
"i",
|
|
182
168
|
"t"
|
|
183
169
|
],
|
|
184
|
-
default: MDEntryType.Bid,
|
|
185
170
|
description: 'Market data entry type (IMPORTANT: Use the numeric/alphabetic value, not the descriptive name. For example, use "0" for Bid, "1" for Offer, "2" for Trade, "3" for Index Value, "4" for Opening Price)'
|
|
186
171
|
}
|
|
187
172
|
},
|
|
@@ -213,15 +198,26 @@ var MCPLocal = class {
|
|
|
213
198
|
this.parser = parser;
|
|
214
199
|
this.parser.addOnMessageCallback((message) => {
|
|
215
200
|
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);
|
|
201
|
+
if (msgType === Messages.MarketDataSnapshotFullRefresh || msgType === Messages.ExecutionReport || msgType === Messages.Reject) {
|
|
202
|
+
const idField = msgType === Messages.MarketDataSnapshotFullRefresh ? message.getField(Fields.MDReqID) : msgType === Messages.Reject ? message.getField(Fields.RefSeqNum) : message.getField(Fields.ClOrdID);
|
|
218
203
|
if (idField) {
|
|
219
204
|
const id = idField.value;
|
|
220
205
|
if (typeof id === "string" || typeof id === "number") {
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
206
|
+
if (msgType === Messages.Reject) {
|
|
207
|
+
const refMsgType = message.getField(Fields.RefMsgType);
|
|
208
|
+
if (refMsgType && refMsgType.value === Messages.NewOrderSingle) {
|
|
209
|
+
const callback = this.pendingRequests.get(String(id));
|
|
210
|
+
if (callback) {
|
|
211
|
+
callback(message);
|
|
212
|
+
this.pendingRequests.delete(String(id));
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
} else {
|
|
216
|
+
const callback = this.pendingRequests.get(String(id));
|
|
217
|
+
if (callback) {
|
|
218
|
+
callback(message);
|
|
219
|
+
this.pendingRequests.delete(String(id));
|
|
220
|
+
}
|
|
225
221
|
}
|
|
226
222
|
}
|
|
227
223
|
}
|
|
@@ -390,7 +386,7 @@ ${parsedMessage[0].messageTypeDescription}`
|
|
|
390
386
|
content: [
|
|
391
387
|
{
|
|
392
388
|
type: "text",
|
|
393
|
-
text: `Execution Report for order ${clOrdID}: ${JSON.stringify(fixData.toFIXJSON())}`
|
|
389
|
+
text: fixData.messageType === Messages.Reject ? `Reject message for order ${clOrdID}: ${JSON.stringify(fixData.toFIXJSON())}` : `Execution Report for order ${clOrdID}: ${JSON.stringify(fixData.toFIXJSON())}`
|
|
394
390
|
}
|
|
395
391
|
]
|
|
396
392
|
};
|
|
@@ -494,7 +490,7 @@ ${parsedMessage[0].messageTypeDescription}`
|
|
|
494
490
|
},
|
|
495
491
|
{
|
|
496
492
|
name: "newOrderSingle",
|
|
497
|
-
description: "Creates and sends a New Order Single",
|
|
493
|
+
description: "Creates and sends a New Order Single. IMPORTANT: All parameters must be explicitly provided by the user - no assumptions will be made.",
|
|
498
494
|
arguments: [
|
|
499
495
|
{
|
|
500
496
|
name: "clOrdID",
|
|
@@ -503,8 +499,8 @@ ${parsedMessage[0].messageTypeDescription}`
|
|
|
503
499
|
},
|
|
504
500
|
{
|
|
505
501
|
name: "handlInst",
|
|
506
|
-
description: "Handling instruction",
|
|
507
|
-
required:
|
|
502
|
+
description: "Handling instruction (1=Manual, 2=Automated, 3=AutomatedNoIntervention)",
|
|
503
|
+
required: true
|
|
508
504
|
},
|
|
509
505
|
{
|
|
510
506
|
name: "quantity",
|
|
@@ -518,8 +514,8 @@ ${parsedMessage[0].messageTypeDescription}`
|
|
|
518
514
|
},
|
|
519
515
|
{
|
|
520
516
|
name: "ordType",
|
|
521
|
-
description: "Order type",
|
|
522
|
-
required:
|
|
517
|
+
description: "Order type (1=Market, 2=Limit, 3=Stop)",
|
|
518
|
+
required: true
|
|
523
519
|
},
|
|
524
520
|
{
|
|
525
521
|
name: "side",
|
|
@@ -533,19 +529,19 @@ ${parsedMessage[0].messageTypeDescription}`
|
|
|
533
529
|
},
|
|
534
530
|
{
|
|
535
531
|
name: "timeInForce",
|
|
536
|
-
description: "Time in force",
|
|
537
|
-
required:
|
|
532
|
+
description: "Time in force (0=Day, 1=Good Till Cancel, 2=At Opening, 3=Immediate or Cancel, 4=Fill or Kill, 5=Good Till Crossing, 6=Good Till Date)",
|
|
533
|
+
required: true
|
|
538
534
|
}
|
|
539
535
|
]
|
|
540
536
|
},
|
|
541
537
|
{
|
|
542
538
|
name: "marketDataRequest",
|
|
543
|
-
description: "Sends a request for Market Data with the given symbol",
|
|
539
|
+
description: "Sends a request for Market Data with the given symbol. IMPORTANT: All parameters must be explicitly provided by the user - no assumptions will be made.",
|
|
544
540
|
arguments: [
|
|
545
541
|
{
|
|
546
542
|
name: "mdUpdateType",
|
|
547
|
-
description: "Market data update type",
|
|
548
|
-
required:
|
|
543
|
+
description: "Market data update type (0=FullRefresh, 1=IncrementalRefresh)",
|
|
544
|
+
required: true
|
|
549
545
|
},
|
|
550
546
|
{
|
|
551
547
|
name: "symbol",
|
|
@@ -559,13 +555,13 @@ ${parsedMessage[0].messageTypeDescription}`
|
|
|
559
555
|
},
|
|
560
556
|
{
|
|
561
557
|
name: "subscriptionRequestType",
|
|
562
|
-
description: "Subscription request type",
|
|
563
|
-
required:
|
|
558
|
+
description: "Subscription request type (0=Snapshot + Updates, 1=Snapshot, 2=Unsubscribe)",
|
|
559
|
+
required: true
|
|
564
560
|
},
|
|
565
561
|
{
|
|
566
562
|
name: "mdEntryType",
|
|
567
|
-
description: "Market data entry type",
|
|
568
|
-
required:
|
|
563
|
+
description: "Market data entry type (0=Bid, 1=Offer, 2=Trade, 3=Index Value, 4=Opening Price)",
|
|
564
|
+
required: true
|
|
569
565
|
}
|
|
570
566
|
]
|
|
571
567
|
}
|
|
@@ -622,12 +618,14 @@ ${parsedMessage[0].messageTypeDescription}`
|
|
|
622
618
|
`- Symbol: ${symbol}`,
|
|
623
619
|
`- TimeInForce: ${timeInForce ?? "0"} (IMPORTANT: Use the numeric/alphabetic value, not the descriptive name. For example, use '0' for Day, '1' for Good Till Cancel, '2' for At Opening, '3' for Immediate or Cancel, '4' for Fill or Kill, '5' for Good Till Crossing, '6' for Good Till Date)`,
|
|
624
620
|
"",
|
|
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
621
|
'Note: For the OrdType parameter, always use the numeric/alphabetic value (e.g., "1" for Market, "2" for Limit, "3" for Stop) as defined in the FIX protocol, not the descriptive name.',
|
|
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.'
|
|
622
|
+
'Note: For the TimeInForce parameter, always use the numeric/alphabetic value (e.g., "0" for Day, "1" for Good Till Cancel, "2" for At Opening) as defined in the FIX protocol, not the descriptive name.',
|
|
623
|
+
"",
|
|
624
|
+
"IMPORTANT: All parameters must be set before sending the order. Missing or invalid parameters will result in a Reject message.",
|
|
625
|
+
"",
|
|
626
|
+
"IMPORTANT: The response will be either:",
|
|
627
|
+
"1. An Execution Report (MsgType=8) if the order was successfully placed",
|
|
628
|
+
"2. A Reject message (MsgType=3) if the order failed to execute (e.g., due to missing or invalid parameters)"
|
|
631
629
|
].join("\n")
|
|
632
630
|
}
|
|
633
631
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/MCPLocal.ts"],
|
|
4
|
-
"sourcesContent": ["import { Server } from '@modelcontextprotocol/sdk/server/index.js';\nimport { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';\nimport {\n CallToolRequestSchema,\n GetPromptRequestSchema,\n ListPromptsRequestSchema,\n ListResourcesRequestSchema,\n ListToolsRequestSchema,\n} from '@modelcontextprotocol/sdk/types.js';\n\nimport {\n Field,\n Fields,\n HandlInst,\n type IFIXParser,\n 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,CAA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BAA2B,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 { Field, Fields, type IFIXParser, type Message, Messages } from 'fixparser';\nimport type { IPlugin } from 'fixparser-common';\nimport type { PluginOptions } from './PluginOptions';\n\n// Define JSON Schemas\nconst parseInputSchema = {\n type: 'object',\n properties: {\n fixString: {\n type: 'string',\n description: 'FIX message string to parse',\n },\n },\n required: ['fixString'],\n};\n\nconst parseToJSONInputSchema = {\n type: 'object',\n properties: {\n fixString: {\n type: 'string',\n description: 'FIX message string to parse',\n },\n },\n required: ['fixString'],\n};\n\nconst newOrderSingleInputSchema = {\n type: 'object',\n properties: {\n clOrdID: {\n type: 'string',\n description: 'Client Order ID',\n },\n handlInst: {\n type: 'string',\n enum: ['1', '2', '3'],\n description:\n 'Handling instruction (IMPORTANT: Use the numeric/alphabetic value, not the descriptive name. For example, use \"1\" for Manual, \"2\" for Automated, \"3\" for AutomatedNoIntervention)',\n },\n quantity: {\n type: 'number',\n description: 'Order quantity',\n },\n price: {\n type: 'number',\n description: 'Order price',\n },\n ordType: {\n type: 'string',\n enum: [\n '1',\n '2',\n '3',\n '4',\n '5',\n '6',\n '7',\n '8',\n '9',\n 'A',\n 'B',\n 'C',\n 'D',\n 'E',\n 'F',\n 'G',\n 'H',\n 'I',\n 'J',\n 'K',\n 'L',\n 'M',\n 'P',\n 'Q',\n 'R',\n 'S',\n ],\n description:\n 'Order type (IMPORTANT: Use the numeric/alphabetic value, not the descriptive name. For example, use \"1\" for Market, \"2\" for Limit, \"3\" for Stop)',\n },\n side: {\n type: 'string',\n enum: ['1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H'],\n description:\n 'Order side (IMPORTANT: Use the numeric/alphabetic value, not the descriptive name. For example, use \"1\" for Buy, \"2\" for Sell, \"3\" for BuyMinus, \"4\" for SellPlus, \"5\" for SellShort, \"6\" for SellShortExempt, \"7\" for Undisclosed, \"8\" for Cross, \"9\" for CrossShort, \"A\" for CrossShortExempt, \"B\" for AsDefined, \"C\" for Opposite, \"D\" for Subscribe, \"E\" for Redeem, \"F\" for Lend, \"G\" for Borrow, \"H\" for SellUndisclosed)',\n },\n symbol: {\n type: 'string',\n description: 'Trading symbol',\n },\n timeInForce: {\n type: 'string',\n enum: ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C'],\n description:\n 'Time in force (IMPORTANT: Use the numeric/alphabetic value, not the descriptive name. For example, use \"0\" for Day, \"1\" for Good Till Cancel, \"2\" for At Opening, \"3\" for Immediate or Cancel, \"4\" for Fill or Kill, \"5\" for Good Till Crossing, \"6\" for Good Till Date)',\n },\n },\n required: ['clOrdID', 'quantity', 'price', 'side', 'symbol', 'handlInst', 'ordType', 'timeInForce'],\n};\n\nconst marketDataRequestInputSchema = {\n type: 'object',\n properties: {\n mdUpdateType: {\n type: 'string',\n enum: ['0', '1'],\n description:\n 'Market data update type (IMPORTANT: Use the numeric/alphabetic value, not the descriptive name. For example, use \"0\" for FullRefresh, \"1\" for IncrementalRefresh)',\n },\n symbol: {\n type: 'string',\n description: 'Trading symbol',\n },\n mdReqID: {\n type: 'string',\n description: 'Market data request ID',\n },\n subscriptionRequestType: {\n type: 'string',\n enum: ['0', '1', '2'],\n description:\n 'Subscription request type (IMPORTANT: Use the numeric/alphabetic value, not the descriptive name. For example, use \"0\" for Snapshot + Updates, \"1\" for Snapshot, \"2\" for Unsubscribe)',\n },\n mdEntryType: {\n type: 'string',\n enum: [\n '0',\n '1',\n '2',\n '3',\n '4',\n '5',\n '6',\n '7',\n '8',\n '9',\n 'A',\n 'B',\n 'C',\n 'D',\n 'E',\n 'F',\n 'G',\n 'H',\n 'J',\n 'K',\n 'L',\n 'M',\n 'N',\n 'O',\n 'P',\n 'Q',\n 'S',\n 'R',\n 'T',\n 'U',\n 'V',\n 'W',\n 'X',\n 'Y',\n 'Z',\n 'a',\n 'b',\n 'c',\n 'd',\n 'e',\n 'g',\n 'h',\n 'i',\n 't',\n ],\n description:\n 'Market data entry type (IMPORTANT: Use the numeric/alphabetic value, not the descriptive name. For example, use \"0\" for Bid, \"1\" for Offer, \"2\" for Trade, \"3\" for Index Value, \"4\" for Opening Price)',\n },\n },\n required: ['symbol', 'mdReqID'],\n};\n\nexport class MCPLocal implements IPlugin<IFIXParser> {\n // private logger: Logger | undefined;\n private parser: IFIXParser | undefined;\n private server: Server = new Server(\n {\n name: 'fixparser',\n version: '1.0.0',\n },\n {\n capabilities: {\n tools: {},\n prompts: {},\n resources: {},\n },\n },\n );\n private transport: StdioServerTransport = new StdioServerTransport();\n private onReady: (() => void) | undefined = undefined;\n\n private pendingRequests: Map<string, (data: Message) => void> = new Map();\n\n constructor({ logger, onReady }: PluginOptions) {\n if (onReady) this.onReady = onReady;\n }\n\n public async register(parser: IFIXParser): Promise<void> {\n this.parser = parser;\n this.parser.addOnMessageCallback((message: Message) => {\n // this.logger?.log({\n // level: 'info',\n // message: `FIXParser (MCP): (${parser.protocol?.toUpperCase()}): << received ${message.description}`,\n // });\n const msgType = message.messageType;\n if (\n msgType === Messages.MarketDataSnapshotFullRefresh ||\n msgType === Messages.ExecutionReport ||\n msgType === Messages.Reject\n ) {\n const idField =\n msgType === Messages.MarketDataSnapshotFullRefresh\n ? message.getField(Fields.MDReqID)\n : msgType === Messages.Reject\n ? message.getField(Fields.RefSeqNum)\n : message.getField(Fields.ClOrdID);\n if (idField) {\n const id = idField.value;\n if (typeof id === 'string' || typeof id === 'number') {\n // For Reject messages, check if it's related to a New Order Single\n if (msgType === Messages.Reject) {\n const refMsgType = message.getField(Fields.RefMsgType);\n if (refMsgType && refMsgType.value === Messages.NewOrderSingle) {\n const callback = this.pendingRequests.get(String(id));\n if (callback) {\n callback(message);\n this.pendingRequests.delete(String(id));\n }\n }\n } else {\n const callback = this.pendingRequests.get(String(id));\n if (callback) {\n callback(message);\n this.pendingRequests.delete(String(id));\n }\n }\n }\n }\n }\n });\n\n this.addWorkflows();\n\n await this.server.connect(this.transport);\n\n if (this.onReady) {\n this.onReady();\n }\n }\n\n private addWorkflows() {\n if (!this.parser) {\n // this.logger?.log({\n // level: 'error',\n // message: 'FIXParser (MCP): -- FIXParser instance not initialized. Ignoring setup of workflows...',\n // });\n return;\n }\n\n if (!this.server) {\n // this.logger?.log({\n // level: 'error',\n // message: 'FIXParser (MCP): -- MCP Server not initialized. Ignoring setup of workflows...',\n // });\n return;\n }\n\n // Helper function to validate and parse arguments\n const validateArgs = (args: any, schema: any): any => {\n // Basic validation - in a real implementation, you might want to use a proper JSON Schema validator\n const result: any = {};\n\n for (const [key, propSchema] of Object.entries(schema.properties || {})) {\n const prop = propSchema as any;\n const value = args?.[key];\n\n if (prop.required && (value === undefined || value === null)) {\n throw new Error(`Required property '${key}' is missing`);\n }\n\n if (value !== undefined) {\n // Apply defaults\n result[key] = value;\n } else if (prop.default !== undefined) {\n result[key] = prop.default;\n }\n }\n\n return result;\n };\n\n // Empty handler for resources\n this.server.setRequestHandler(ListResourcesRequestSchema, async () => {\n return {\n resources: [],\n };\n });\n\n // Handler for listing available tools\n this.server.setRequestHandler(ListToolsRequestSchema, async () => {\n return {\n tools: [\n {\n name: 'parse',\n description: 'Parses a FIX message and describes it in plain language',\n inputSchema: parseInputSchema,\n },\n {\n name: 'parseToJSON',\n description: 'Parses a FIX message into JSON',\n inputSchema: parseToJSONInputSchema,\n },\n {\n name: 'newOrderSingle',\n description: 'Creates and sends a New Order Single',\n inputSchema: newOrderSingleInputSchema,\n },\n {\n name: 'marketDataRequest',\n description: 'Sends a request for Market Data with the given symbol',\n inputSchema: marketDataRequestInputSchema,\n },\n ],\n };\n });\n\n // Handler for tool calls\n this.server.setRequestHandler(CallToolRequestSchema, async (request) => {\n const { name, arguments: args } = request.params;\n\n switch (name) {\n case 'parse': {\n try {\n const { fixString } = validateArgs(args, parseInputSchema);\n const parsedMessage: Message[] | undefined = this.parser?.parse(fixString);\n if (!parsedMessage || parsedMessage.length === 0) {\n return {\n isError: true,\n content: [{ type: 'text', text: 'Error: Failed to parse FIX string' }],\n };\n }\n\n return {\n content: [\n {\n type: 'text',\n text: `${parsedMessage[0].description}\n${parsedMessage[0].messageTypeDescription}`,\n },\n ],\n };\n } catch (error) {\n return {\n isError: true,\n content: [\n {\n type: 'text',\n text: `Error: ${error instanceof Error ? error.message : 'Failed to parse FIX string'}`,\n },\n ],\n };\n }\n }\n\n case 'parseToJSON': {\n try {\n const { fixString } = validateArgs(args, parseToJSONInputSchema);\n const parsedMessage = this.parser?.parse(fixString);\n if (!parsedMessage || parsedMessage.length === 0) {\n return {\n isError: true,\n content: [{ type: 'text', text: 'Error: Failed to parse FIX string' }],\n };\n }\n\n return {\n content: [\n {\n type: 'text',\n text: `${parsedMessage[0].toFIXJSON()}`,\n },\n ],\n };\n } catch (error) {\n return {\n isError: true,\n content: [\n {\n type: 'text',\n text: `Error: ${error instanceof Error ? error.message : 'Failed to parse FIX string'}`,\n },\n ],\n };\n }\n }\n\n case 'newOrderSingle': {\n try {\n const { clOrdID, handlInst, quantity, price, ordType, side, symbol, timeInForce } =\n validateArgs(args, newOrderSingleInputSchema);\n\n const response = new Promise((resolve) => {\n this.pendingRequests.set(clOrdID, resolve);\n });\n\n const order: Message | undefined = this.parser?.createMessage(\n new Field(Fields.MsgType, Messages.NewOrderSingle),\n new Field(Fields.MsgSeqNum, this.parser?.getNextTargetMsgSeqNum()),\n new Field(Fields.SenderCompID, this.parser?.sender),\n new Field(Fields.TargetCompID, this.parser?.target),\n new Field(Fields.SendingTime, this.parser?.getTimestamp()),\n new Field(Fields.ClOrdID, clOrdID),\n new Field(Fields.Side, side),\n new Field(Fields.Symbol, symbol),\n new Field(Fields.OrderQty, quantity),\n new Field(Fields.Price, price),\n new Field(Fields.OrdType, ordType),\n new Field(Fields.HandlInst, handlInst),\n new Field(Fields.TimeInForce, timeInForce),\n new Field(Fields.TransactTime, this.parser?.getTimestamp()),\n );\n\n if (!this.parser?.connected) {\n // this.logger?.log({\n // level: 'error',\n // message: 'FIXParser (MCP): -- Not connected. Ignoring message.',\n // });\n return {\n isError: true,\n content: [\n {\n type: 'text',\n text: 'Error: Not connected. Ignoring message.',\n },\n ],\n };\n }\n\n this.parser?.send(order!);\n // this.logger?.log({\n // level: 'info',\n // message: `FIXParser (MCP): (${this.parser?.protocol?.toUpperCase()}): >> sent ${order?.description}`,\n // });\n\n const fixData = await response;\n\n return {\n content: [\n {\n type: 'text',\n text:\n (fixData as Message).messageType === Messages.Reject\n ? `Reject message for order ${clOrdID}: ${JSON.stringify((fixData as Message).toFIXJSON())}`\n : `Execution Report for order ${clOrdID}: ${JSON.stringify((fixData as Message).toFIXJSON())}`,\n },\n ],\n };\n } catch (error) {\n return {\n isError: true,\n content: [\n {\n type: 'text',\n text: `Error: ${error instanceof Error ? error.message : 'Failed to create order'}`,\n },\n ],\n };\n }\n }\n\n case 'marketDataRequest': {\n try {\n const { mdUpdateType, symbol, mdReqID, subscriptionRequestType, mdEntryType } = validateArgs(\n args,\n marketDataRequestInputSchema,\n );\n\n const response = new Promise((resolve) => {\n this.pendingRequests.set(mdReqID, resolve);\n });\n\n const marketDataRequest = this.parser?.createMessage(\n new Field(Fields.MsgType, Messages.MarketDataRequest),\n new Field(Fields.SenderCompID, this.parser?.sender),\n new Field(Fields.MsgSeqNum, this.parser?.getNextTargetMsgSeqNum()),\n new Field(Fields.TargetCompID, this.parser?.target),\n new Field(Fields.SendingTime, this.parser?.getTimestamp()),\n new Field(Fields.MarketDepth, 0),\n new Field(Fields.MDUpdateType, mdUpdateType),\n new Field(Fields.NoRelatedSym, 1),\n new Field(Fields.Symbol, symbol),\n new Field(Fields.MDReqID, mdReqID),\n new Field(Fields.SubscriptionRequestType, subscriptionRequestType),\n new Field(Fields.NoMDEntryTypes, 1),\n new Field(Fields.MDEntryType, mdEntryType),\n );\n\n if (!this.parser?.connected) {\n // this.logger?.log({\n // level: 'error',\n // message: 'FIXParser (MCP): -- Not connected. Ignoring message.',\n // });\n return {\n isError: true,\n content: [\n {\n type: 'text',\n text: 'Error: Not connected. Ignoring message.',\n },\n ],\n };\n }\n\n this.parser?.send(marketDataRequest!);\n // this.logger?.log({\n // level: 'info',\n // message: `FIXParser (MCP): (${this.parser?.protocol?.toUpperCase()}): >> sent ${marketDataRequest?.description}`,\n // });\n\n const fixData = await response;\n\n return {\n content: [\n {\n type: 'text',\n text: `Market data for ${symbol}: ${JSON.stringify((fixData as Message).toFIXJSON())}`,\n },\n ],\n };\n } catch (error) {\n return {\n isError: true,\n content: [\n {\n type: 'text',\n text: `Error: ${error instanceof Error ? error.message : 'Failed to request market data'}`,\n },\n ],\n };\n }\n }\n\n default:\n throw new Error(`Unknown tool: ${name}`);\n }\n });\n\n this.server.setRequestHandler(ListPromptsRequestSchema, async () => {\n return {\n prompts: [\n {\n name: 'parse',\n description: 'Parses a FIX message and describes it in plain language',\n arguments: [\n {\n name: 'fixString',\n description: 'FIX message string to parse',\n required: true,\n },\n ],\n },\n {\n name: 'parseToJSON',\n description: 'Parses a FIX message into JSON',\n arguments: [\n {\n name: 'fixString',\n description: 'FIX message string to parse',\n required: true,\n },\n ],\n },\n {\n name: 'newOrderSingle',\n description:\n 'Creates and sends a New Order Single. IMPORTANT: All parameters must be explicitly provided by the user - no assumptions will be made.',\n arguments: [\n {\n name: 'clOrdID',\n description: 'Client Order ID',\n required: true,\n },\n {\n name: 'handlInst',\n description: 'Handling instruction (1=Manual, 2=Automated, 3=AutomatedNoIntervention)',\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 (1=Market, 2=Limit, 3=Stop)',\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:\n 'Time in force (0=Day, 1=Good Till Cancel, 2=At Opening, 3=Immediate or Cancel, 4=Fill or Kill, 5=Good Till Crossing, 6=Good Till Date)',\n required: true,\n },\n ],\n },\n {\n name: 'marketDataRequest',\n description:\n 'Sends a request for Market Data with the given symbol. IMPORTANT: All parameters must be explicitly provided by the user - no assumptions will be made.',\n arguments: [\n {\n name: 'mdUpdateType',\n description: 'Market data update type (0=FullRefresh, 1=IncrementalRefresh)',\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:\n 'Subscription request type (0=Snapshot + Updates, 1=Snapshot, 2=Unsubscribe)',\n required: true,\n },\n {\n name: 'mdEntryType',\n description:\n 'Market data entry type (0=Bid, 1=Offer, 2=Trade, 3=Index Value, 4=Opening Price)',\n required: true,\n },\n ],\n },\n ],\n };\n });\n\n // Handler for getting specific prompts\n this.server.setRequestHandler(GetPromptRequestSchema, async (request) => {\n const { name, arguments: args } = request.params;\n\n switch (name) {\n case 'parse': {\n const fixString = args?.fixString || '';\n return {\n messages: [\n {\n role: 'user',\n content: {\n type: 'text',\n text: `Please parse and explain this FIX message: ${fixString}`,\n },\n },\n ],\n };\n }\n\n case 'parseToJSON': {\n const fixString = args?.fixString || '';\n return {\n messages: [\n {\n role: 'user',\n content: {\n type: 'text',\n text: `Please parse the FIX message to JSON: ${fixString}`,\n },\n },\n ],\n };\n }\n\n case 'newOrderSingle': {\n const { clOrdID, handlInst, quantity, price, ordType, side, symbol, timeInForce } = args || {};\n return {\n messages: [\n {\n role: 'user',\n content: {\n type: 'text',\n text: [\n 'Create a New Order Single FIX message with the following parameters:',\n `- ClOrdID: ${clOrdID}`,\n `- HandlInst: ${handlInst ?? '3'} (IMPORTANT: Use the numeric/alphabetic value, not the descriptive name. For example, use '1' for Manual, '2' for Automated, '3' for AutomatedNoIntervention)`,\n `- Quantity: ${quantity}`,\n `- Price: ${price}`,\n `- OrdType: ${ordType ?? '1'} (IMPORTANT: Use the numeric/alphabetic value, not the descriptive name. For example, use '1' for Market, '2' for Limit, '3' for Stop)`,\n `- Side: ${side} (IMPORTANT: Use the numeric/alphabetic value, not the descriptive name. For example, use '1' for Buy, '2' for Sell)`,\n `- Symbol: ${symbol}`,\n `- TimeInForce: ${timeInForce ?? '0'} (IMPORTANT: Use the numeric/alphabetic value, not the descriptive name. For example, use '0' for Day, '1' for Good Till Cancel, '2' for At Opening, '3' for Immediate or Cancel, '4' for Fill or Kill, '5' for Good Till Crossing, '6' for Good Till Date)`,\n '',\n 'Note: For the OrdType parameter, always use the numeric/alphabetic value (e.g., \"1\" for Market, \"2\" for Limit, \"3\" for Stop) as defined in the FIX protocol, not the descriptive name.',\n 'Note: For the TimeInForce parameter, always use the numeric/alphabetic value (e.g., \"0\" for Day, \"1\" for Good Till Cancel, \"2\" for At Opening) as defined in the FIX protocol, not the descriptive name.',\n '',\n 'IMPORTANT: All parameters must be set before sending the order. Missing or invalid parameters will result in a Reject message.',\n '',\n 'IMPORTANT: The response will be either:',\n '1. An Execution Report (MsgType=8) if the order was successfully placed',\n '2. A Reject message (MsgType=3) if the order failed to execute (e.g., due to missing or invalid parameters)',\n ].join('\\n'),\n },\n },\n ],\n };\n }\n\n case 'marketDataRequest': {\n const { mdUpdateType, symbol, mdReqID, subscriptionRequestType, mdEntryType } = args || {};\n return {\n messages: [\n {\n role: 'user',\n content: {\n type: 'text',\n text: [\n 'Create a Market Data Request FIX message with the following parameters:',\n `- MDUpdateType: ${mdUpdateType ?? '0'} (IMPORTANT: Use the numeric/alphabetic value, not the descriptive name. For example, use '0' for FullRefresh, '1' for IncrementalRefresh)`,\n `- Symbol: ${symbol}`,\n `- MDReqID: ${mdReqID}`,\n `- SubscriptionRequestType: ${subscriptionRequestType ?? '0'} (IMPORTANT: Use the numeric/alphabetic value, not the descriptive name. For example, use '0' for Snapshot + Updates, '1' for Snapshot, '2' for Unsubscribe)`,\n `- MDEntryType: ${mdEntryType ?? '0'} (IMPORTANT: Use the numeric/alphabetic value, not the descriptive name. For example, use '0' for Bid, '1' for Offer, '2' for Trade, '3' for Index Value, '4' for Opening Price)`,\n '',\n 'Format the response as a JSON object with FIX tag numbers as keys and their corresponding values.',\n '',\n 'Note: For the MDUpdateType parameter, always use the numeric/alphabetic value (e.g., \"0\" for FullRefresh, \"1\" for IncrementalRefresh) as defined in the FIX protocol, not the descriptive name.',\n 'Note: For the SubscriptionRequestType parameter, always use the numeric/alphabetic value (e.g., \"0\" for Snapshot + Updates, \"1\" for Snapshot, \"2\" for Unsubscribe) as defined in the FIX protocol, not the descriptive name.',\n 'Note: For the MDEntryType parameter, always use the numeric/alphabetic value (e.g., \"0\" for Bid, \"1\" for Offer, \"2\" for Trade, \"3\" for Index Value, \"4\" for Opening Price) as defined in the FIX protocol, not the descriptive name.',\n ].join('\\n'),\n },\n },\n ],\n };\n }\n\n default:\n throw new Error(`Unknown prompt: ${name}`);\n }\n });\n\n process.on('SIGINT', async () => {\n await this.server.close();\n process.exit(0);\n });\n }\n}\n"],
|
|
5
|
+
"mappings": ";AAAA,SAAS,cAAc;AACvB,SAAS,4BAA4B;AACrC;AAAA,EACI;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACG;AAEP,SAAS,OAAO,QAAuC,gBAAgB;AAKvE,IAAM,mBAAmB;AAAA,EACrB,MAAM;AAAA,EACN,YAAY;AAAA,IACR,WAAW;AAAA,MACP,MAAM;AAAA,MACN,aAAa;AAAA,IACjB;AAAA,EACJ;AAAA,EACA,UAAU,CAAC,WAAW;AAC1B;AAEA,IAAM,yBAAyB;AAAA,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,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,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AA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BACA;AAAA,oBACA;AAAA,oBACA;AAAA,oBACA;AAAA,oBACA;AAAA,kBACJ,EAAE,KAAK,IAAI;AAAA,gBACf;AAAA,cACJ;AAAA,YACJ;AAAA,UACJ;AAAA,QACJ;AAAA,QAEA;AACI,gBAAM,IAAI,MAAM,mBAAmB,IAAI,EAAE;AAAA,MACjD;AAAA,IACJ,CAAC;AAED,YAAQ,GAAG,UAAU,YAAY;AAC7B,YAAM,KAAK,OAAO,MAAM;AACxB,cAAQ,KAAK,CAAC;AAAA,IAClB,CAAC;AAAA,EACL;AACJ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
"use strict";var
|
|
3
|
-
${s[0].messageTypeDescription}`}]}}catch(
|
|
4
|
-
`)}}]}}case"marketDataRequest":{let{mdUpdateType:
|
|
5
|
-
`)}}]}}default:throw new Error(`Unknown prompt: ${
|
|
2
|
+
"use strict";var t=require("fixparser");var R=require("@modelcontextprotocol/sdk/server/index.js"),F=require("@modelcontextprotocol/sdk/server/stdio.js"),d=require("@modelcontextprotocol/sdk/types.js"),e=require("fixparser"),y={type:"object",properties:{fixString:{type:"string",description:"FIX message string to parse"}},required:["fixString"]},S={type:"object",properties:{fixString:{type:"string",description:"FIX message string to parse"}},required:["fixString"]},T={type:"object",properties:{clOrdID:{type:"string",description:"Client Order ID"},handlInst:{type:"string",enum:["1","2","3"],description:'Handling instruction (IMPORTANT: Use the numeric/alphabetic value, not the descriptive name. For example, use "1" for Manual, "2" for Automated, "3" for AutomatedNoIntervention)'},quantity:{type:"number",description:"Order quantity"},price:{type:"number",description:"Order price"},ordType:{type:"string",enum:["1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","P","Q","R","S"],description:'Order type (IMPORTANT: Use the numeric/alphabetic value, not the descriptive name. For example, use "1" for Market, "2" for Limit, "3" for Stop)'},side:{type:"string",enum:["1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H"],description:'Order side (IMPORTANT: Use the numeric/alphabetic value, not the descriptive name. For example, use "1" for Buy, "2" for Sell, "3" for BuyMinus, "4" for SellPlus, "5" for SellShort, "6" for SellShortExempt, "7" for Undisclosed, "8" for Cross, "9" for CrossShort, "A" for CrossShortExempt, "B" for AsDefined, "C" for Opposite, "D" for Subscribe, "E" for Redeem, "F" for Lend, "G" for Borrow, "H" for SellUndisclosed)'},symbol:{type:"string",description:"Trading symbol"},timeInForce:{type:"string",enum:["0","1","2","3","4","5","6","7","8","9","A","B","C"],description:'Time in force (IMPORTANT: Use the numeric/alphabetic value, not the descriptive name. For example, use "0" for Day, "1" for Good Till Cancel, "2" for At Opening, "3" for Immediate or Cancel, "4" for Fill or Kill, "5" for Good Till Crossing, "6" for Good Till Date)'}},required:["clOrdID","quantity","price","side","symbol","handlInst","ordType","timeInForce"]},I={type:"object",properties:{mdUpdateType:{type:"string",enum:["0","1"],description:'Market data update type (IMPORTANT: Use the numeric/alphabetic value, not the descriptive name. For example, use "0" for FullRefresh, "1" for IncrementalRefresh)'},symbol:{type:"string",description:"Trading symbol"},mdReqID:{type:"string",description:"Market data request ID"},subscriptionRequestType:{type:"string",enum:["0","1","2"],description:'Subscription request type (IMPORTANT: Use the numeric/alphabetic value, not the descriptive name. For example, use "0" for Snapshot + Updates, "1" for Snapshot, "2" for Unsubscribe)'},mdEntryType:{type:"string",enum:["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","J","K","L","M","N","O","P","Q","S","R","T","U","V","W","X","Y","Z","a","b","c","d","e","g","h","i","t"],description:'Market data entry type (IMPORTANT: Use the numeric/alphabetic value, not the descriptive name. For example, use "0" for Bid, "1" for Offer, "2" for Trade, "3" for Index Value, "4" for Opening Price)'}},required:["symbol","mdReqID"]},O=class{parser;server=new R.Server({name:"fixparser",version:"1.0.0"},{capabilities:{tools:{},prompts:{},resources:{}}});transport=new F.StdioServerTransport;onReady=void 0;pendingRequests=new Map;constructor({logger:a,onReady:i}){i&&(this.onReady=i)}async register(a){this.parser=a,this.parser.addOnMessageCallback(i=>{let o=i.messageType;if(o===e.Messages.MarketDataSnapshotFullRefresh||o===e.Messages.ExecutionReport||o===e.Messages.Reject){let n=o===e.Messages.MarketDataSnapshotFullRefresh?i.getField(e.Fields.MDReqID):o===e.Messages.Reject?i.getField(e.Fields.RefSeqNum):i.getField(e.Fields.ClOrdID);if(n){let r=n.value;if(typeof r=="string"||typeof r=="number")if(o===e.Messages.Reject){let s=i.getField(e.Fields.RefMsgType);if(s&&s.value===e.Messages.NewOrderSingle){let p=this.pendingRequests.get(String(r));p&&(p(i),this.pendingRequests.delete(String(r)))}}else{let s=this.pendingRequests.get(String(r));s&&(s(i),this.pendingRequests.delete(String(r)))}}}}),this.addWorkflows(),await this.server.connect(this.transport),this.onReady&&this.onReady()}addWorkflows(){if(!this.parser||!this.server)return;let a=(i,o)=>{let n={};for(let[r,s]of Object.entries(o.properties||{})){let p=s,c=i?.[r];if(p.required&&c==null)throw new Error(`Required property '${r}' is missing`);c!==void 0?n[r]=c:p.default!==void 0&&(n[r]=p.default)}return n};this.server.setRequestHandler(d.ListResourcesRequestSchema,async()=>({resources:[]})),this.server.setRequestHandler(d.ListToolsRequestSchema,async()=>({tools:[{name:"parse",description:"Parses a FIX message and describes it in plain language",inputSchema:y},{name:"parseToJSON",description:"Parses a FIX message into JSON",inputSchema:S},{name:"newOrderSingle",description:"Creates and sends a New Order Single",inputSchema:T},{name:"marketDataRequest",description:"Sends a request for Market Data with the given symbol",inputSchema:I}]})),this.server.setRequestHandler(d.CallToolRequestSchema,async i=>{let{name:o,arguments:n}=i.params;switch(o){case"parse":try{let{fixString:r}=a(n,y),s=this.parser?.parse(r);return!s||s.length===0?{isError:!0,content:[{type:"text",text:"Error: Failed to parse FIX string"}]}:{content:[{type:"text",text:`${s[0].description}
|
|
3
|
+
${s[0].messageTypeDescription}`}]}}catch(r){return{isError:!0,content:[{type:"text",text:`Error: ${r instanceof Error?r.message:"Failed to parse FIX string"}`}]}}case"parseToJSON":try{let{fixString:r}=a(n,S),s=this.parser?.parse(r);return!s||s.length===0?{isError:!0,content:[{type:"text",text:"Error: Failed to parse FIX string"}]}:{content:[{type:"text",text:`${s[0].toFIXJSON()}`}]}}catch(r){return{isError:!0,content:[{type:"text",text:`Error: ${r instanceof Error?r.message:"Failed to parse FIX string"}`}]}}case"newOrderSingle":try{let{clOrdID:r,handlInst:s,quantity:p,price:c,ordType:l,side:u,symbol:m,timeInForce:g}=a(n,T),h=new Promise(M=>{this.pendingRequests.set(r,M)}),x=this.parser?.createMessage(new e.Field(e.Fields.MsgType,e.Messages.NewOrderSingle),new e.Field(e.Fields.MsgSeqNum,this.parser?.getNextTargetMsgSeqNum()),new e.Field(e.Fields.SenderCompID,this.parser?.sender),new e.Field(e.Fields.TargetCompID,this.parser?.target),new e.Field(e.Fields.SendingTime,this.parser?.getTimestamp()),new e.Field(e.Fields.ClOrdID,r),new e.Field(e.Fields.Side,u),new e.Field(e.Fields.Symbol,m),new e.Field(e.Fields.OrderQty,p),new e.Field(e.Fields.Price,c),new e.Field(e.Fields.OrdType,l),new e.Field(e.Fields.HandlInst,s),new e.Field(e.Fields.TimeInForce,g),new e.Field(e.Fields.TransactTime,this.parser?.getTimestamp()));if(!this.parser?.connected)return{isError:!0,content:[{type:"text",text:"Error: Not connected. Ignoring message."}]};this.parser?.send(x);let f=await h;return{content:[{type:"text",text:f.messageType===e.Messages.Reject?`Reject message for order ${r}: ${JSON.stringify(f.toFIXJSON())}`:`Execution Report for order ${r}: ${JSON.stringify(f.toFIXJSON())}`}]}}catch(r){return{isError:!0,content:[{type:"text",text:`Error: ${r instanceof Error?r.message:"Failed to create order"}`}]}}case"marketDataRequest":try{let{mdUpdateType:r,symbol:s,mdReqID:p,subscriptionRequestType:c,mdEntryType:l}=a(n,I),u=new Promise(h=>{this.pendingRequests.set(p,h)}),m=this.parser?.createMessage(new e.Field(e.Fields.MsgType,e.Messages.MarketDataRequest),new e.Field(e.Fields.SenderCompID,this.parser?.sender),new e.Field(e.Fields.MsgSeqNum,this.parser?.getNextTargetMsgSeqNum()),new e.Field(e.Fields.TargetCompID,this.parser?.target),new e.Field(e.Fields.SendingTime,this.parser?.getTimestamp()),new e.Field(e.Fields.MarketDepth,0),new e.Field(e.Fields.MDUpdateType,r),new e.Field(e.Fields.NoRelatedSym,1),new e.Field(e.Fields.Symbol,s),new e.Field(e.Fields.MDReqID,p),new e.Field(e.Fields.SubscriptionRequestType,c),new e.Field(e.Fields.NoMDEntryTypes,1),new e.Field(e.Fields.MDEntryType,l));if(!this.parser?.connected)return{isError:!0,content:[{type:"text",text:"Error: Not connected. Ignoring message."}]};this.parser?.send(m);let g=await u;return{content:[{type:"text",text:`Market data for ${s}: ${JSON.stringify(g.toFIXJSON())}`}]}}catch(r){return{isError:!0,content:[{type:"text",text:`Error: ${r instanceof Error?r.message:"Failed to request market data"}`}]}}default:throw new Error(`Unknown tool: ${o}`)}}),this.server.setRequestHandler(d.ListPromptsRequestSchema,async()=>({prompts:[{name:"parse",description:"Parses a FIX message and describes it in plain language",arguments:[{name:"fixString",description:"FIX message string to parse",required:!0}]},{name:"parseToJSON",description:"Parses a FIX message into JSON",arguments:[{name:"fixString",description:"FIX message string to parse",required:!0}]},{name:"newOrderSingle",description:"Creates and sends a New Order Single. IMPORTANT: All parameters must be explicitly provided by the user - no assumptions will be made.",arguments:[{name:"clOrdID",description:"Client Order ID",required:!0},{name:"handlInst",description:"Handling instruction (1=Manual, 2=Automated, 3=AutomatedNoIntervention)",required:!0},{name:"quantity",description:"Order quantity",required:!0},{name:"price",description:"Order price",required:!0},{name:"ordType",description:"Order type (1=Market, 2=Limit, 3=Stop)",required:!0},{name:"side",description:"Order side (1=Buy, 2=Sell, 3=BuyMinus, 4=SellPlus, 5=SellShort, 6=SellShortExempt, 7=Undisclosed, 8=Cross, 9=CrossShort, A=CrossShortExempt, B=AsDefined, C=Opposite, D=Subscribe, E=Redeem, F=Lend, G=Borrow, H=SellUndisclosed)",required:!0},{name:"symbol",description:"Trading symbol",required:!0},{name:"timeInForce",description:"Time in force (0=Day, 1=Good Till Cancel, 2=At Opening, 3=Immediate or Cancel, 4=Fill or Kill, 5=Good Till Crossing, 6=Good Till Date)",required:!0}]},{name:"marketDataRequest",description:"Sends a request for Market Data with the given symbol. IMPORTANT: All parameters must be explicitly provided by the user - no assumptions will be made.",arguments:[{name:"mdUpdateType",description:"Market data update type (0=FullRefresh, 1=IncrementalRefresh)",required:!0},{name:"symbol",description:"Trading symbol",required:!0},{name:"mdReqID",description:"Market data request ID",required:!0},{name:"subscriptionRequestType",description:"Subscription request type (0=Snapshot + Updates, 1=Snapshot, 2=Unsubscribe)",required:!0},{name:"mdEntryType",description:"Market data entry type (0=Bid, 1=Offer, 2=Trade, 3=Index Value, 4=Opening Price)",required:!0}]}]})),this.server.setRequestHandler(d.GetPromptRequestSchema,async i=>{let{name:o,arguments:n}=i.params;switch(o){case"parse":return{messages:[{role:"user",content:{type:"text",text:`Please parse and explain this FIX message: ${n?.fixString||""}`}}]};case"parseToJSON":return{messages:[{role:"user",content:{type:"text",text:`Please parse the FIX message to JSON: ${n?.fixString||""}`}}]};case"newOrderSingle":{let{clOrdID:r,handlInst:s,quantity:p,price:c,ordType:l,side:u,symbol:m,timeInForce:g}=n||{};return{messages:[{role:"user",content:{type:"text",text:["Create a New Order Single FIX message with the following parameters:",`- ClOrdID: ${r}`,`- HandlInst: ${s??"3"} (IMPORTANT: Use the numeric/alphabetic value, not the descriptive name. For example, use '1' for Manual, '2' for Automated, '3' for AutomatedNoIntervention)`,`- Quantity: ${p}`,`- Price: ${c}`,`- OrdType: ${l??"1"} (IMPORTANT: Use the numeric/alphabetic value, not the descriptive name. For example, use '1' for Market, '2' for Limit, '3' for Stop)`,`- Side: ${u} (IMPORTANT: Use the numeric/alphabetic value, not the descriptive name. For example, use '1' for Buy, '2' for Sell)`,`- Symbol: ${m}`,`- TimeInForce: ${g??"0"} (IMPORTANT: Use the numeric/alphabetic value, not the descriptive name. For example, use '0' for Day, '1' for Good Till Cancel, '2' for At Opening, '3' for Immediate or Cancel, '4' for Fill or Kill, '5' for Good Till Crossing, '6' for Good Till Date)`,"",'Note: For the OrdType parameter, always use the numeric/alphabetic value (e.g., "1" for Market, "2" for Limit, "3" for Stop) as defined in the FIX protocol, not the descriptive name.','Note: For the TimeInForce parameter, always use the numeric/alphabetic value (e.g., "0" for Day, "1" for Good Till Cancel, "2" for At Opening) as defined in the FIX protocol, not the descriptive name.',"","IMPORTANT: All parameters must be set before sending the order. Missing or invalid parameters will result in a Reject message.","","IMPORTANT: The response will be either:","1. An Execution Report (MsgType=8) if the order was successfully placed","2. A Reject message (MsgType=3) if the order failed to execute (e.g., due to missing or invalid parameters)"].join(`
|
|
4
|
+
`)}}]}}case"marketDataRequest":{let{mdUpdateType:r,symbol:s,mdReqID:p,subscriptionRequestType:c,mdEntryType:l}=n||{};return{messages:[{role:"user",content:{type:"text",text:["Create a Market Data Request FIX message with the following parameters:",`- MDUpdateType: ${r??"0"} (IMPORTANT: Use the numeric/alphabetic value, not the descriptive name. For example, use '0' for FullRefresh, '1' for IncrementalRefresh)`,`- Symbol: ${s}`,`- MDReqID: ${p}`,`- SubscriptionRequestType: ${c??"0"} (IMPORTANT: Use the numeric/alphabetic value, not the descriptive name. For example, use '0' for Snapshot + Updates, '1' for Snapshot, '2' for Unsubscribe)`,`- MDEntryType: ${l??"0"} (IMPORTANT: Use the numeric/alphabetic value, not the descriptive name. For example, use '0' for Bid, '1' for Offer, '2' for Trade, '3' for Index Value, '4' for Opening Price)`,"","Format the response as a JSON object with FIX tag numbers as keys and their corresponding values.","",'Note: For the MDUpdateType parameter, always use the numeric/alphabetic value (e.g., "0" for FullRefresh, "1" for IncrementalRefresh) as defined in the FIX protocol, not the descriptive name.','Note: For the SubscriptionRequestType parameter, always use the numeric/alphabetic value (e.g., "0" for Snapshot + Updates, "1" for Snapshot, "2" for Unsubscribe) as defined in the FIX protocol, not the descriptive name.','Note: For the MDEntryType parameter, always use the numeric/alphabetic value (e.g., "0" for Bid, "1" for Offer, "2" for Trade, "3" for Index Value, "4" for Opening Price) as defined in the FIX protocol, not the descriptive name.'].join(`
|
|
5
|
+
`)}}]}}default:throw new Error(`Unknown prompt: ${o}`)}}),process.on("SIGINT",async()=>{await this.server.close(),process.exit(0)})}};var w="CLIENT2",b="EXECUTOR",q=async()=>{await t.LicenseManager.setLicenseKey(process.env.FIXPARSER_LICENSE_KEY);let a=new t.FIXParser({logging:!1,plugins:[new O({port:3099,onReady:()=>{}})]}),i=()=>{let n=a.createMessage(new t.Field(t.Fields.MsgType,t.Messages.Logon),new t.Field(t.Fields.MsgSeqNum,a.getNextTargetMsgSeqNum()),new t.Field(t.Fields.SenderCompID,w),new t.Field(t.Fields.SendingTime,a.getTimestamp()),new t.Field(t.Fields.TargetCompID,b),new t.Field(t.Fields.ResetSeqNumFlag,t.ResetSeqNumFlag.Yes),new t.Field(t.Fields.EncryptMethod,t.EncryptMethod.None),new t.Field(t.Fields.HeartBtInt,10));a.send(n)},o={host:process.env.FIXPARSER_HOST||"10.0.1.42",port:process.env.FIXPARSER_PORT?Number.parseInt(process.env.FIXPARSER_PORT,10):5001,protocol:"tcp",sender:process.env.FIXPARSER_SENDER||w,target:process.env.FIXPARSER_TARGET||b,fixVersion:process.env.FIXPARSER_TARGET||"FIX.4.4",onOpen:()=>{i()},onMessage:n=>{},onClose:()=>{setTimeout(()=>{a.connect(o)},1e3)}};a.connect(o)};q().catch(a=>console.error("Error initializing server:",a));
|
|
6
6
|
//# sourceMappingURL=example_mcp_local.js.map
|