fixparser-plugin-mcp 9.1.7-8fdb1e41 → 9.1.7-98049daf

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.
@@ -1,845 +0,0 @@
1
- // src/MCPLocal.ts
2
- import { Server } from "@modelcontextprotocol/sdk/server/index.js";
3
- import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
4
- import {
5
- CallToolRequestSchema,
6
- GetPromptRequestSchema,
7
- ListPromptsRequestSchema,
8
- ListResourcesRequestSchema,
9
- ListToolsRequestSchema
10
- } from "@modelcontextprotocol/sdk/types.js";
11
- import { Field, Fields, Messages } from "fixparser";
12
- var parseInputSchema = {
13
- type: "object",
14
- properties: {
15
- fixString: {
16
- type: "string",
17
- description: "FIX message string to parse"
18
- }
19
- },
20
- required: ["fixString"]
21
- };
22
- var parseToJSONInputSchema = {
23
- type: "object",
24
- properties: {
25
- fixString: {
26
- type: "string",
27
- description: "FIX message string to parse"
28
- }
29
- },
30
- required: ["fixString"]
31
- };
32
- var orderSchema = {
33
- type: "object",
34
- properties: {
35
- clOrdID: {
36
- type: "string",
37
- description: "Client Order ID"
38
- },
39
- handlInst: {
40
- type: "string",
41
- enum: ["1", "2", "3"],
42
- description: "Handling instruction (1=Manual, 2=Automated, 3=AutomatedNoIntervention)"
43
- },
44
- quantity: {
45
- type: "number",
46
- description: "Order quantity"
47
- },
48
- price: {
49
- type: "number",
50
- description: "Order price"
51
- },
52
- ordType: {
53
- type: "string",
54
- enum: [
55
- "1",
56
- "2",
57
- "3",
58
- "4",
59
- "5",
60
- "6",
61
- "7",
62
- "8",
63
- "9",
64
- "A",
65
- "B",
66
- "C",
67
- "D",
68
- "E",
69
- "F",
70
- "G",
71
- "H",
72
- "I",
73
- "J",
74
- "K",
75
- "L",
76
- "M",
77
- "P",
78
- "Q",
79
- "R",
80
- "S"
81
- ],
82
- description: "Order type (1=Market, 2=Limit, 3=Stop)"
83
- },
84
- side: {
85
- type: "string",
86
- enum: ["1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F", "G", "H"],
87
- 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)"
88
- },
89
- symbol: {
90
- type: "string",
91
- description: "Trading symbol"
92
- },
93
- timeInForce: {
94
- type: "string",
95
- enum: ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C"],
96
- 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)"
97
- }
98
- },
99
- required: ["clOrdID", "handlInst", "quantity", "price", "ordType", "side", "symbol", "timeInForce"]
100
- };
101
- var marketDataRequestInputSchema = {
102
- type: "object",
103
- properties: {
104
- mdUpdateType: {
105
- type: "string",
106
- enum: ["0", "1"],
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)'
108
- },
109
- symbol: {
110
- type: "string",
111
- description: "Trading symbol"
112
- },
113
- mdReqID: {
114
- type: "string",
115
- description: "Market data request ID"
116
- },
117
- subscriptionRequestType: {
118
- type: "string",
119
- enum: ["0", "1", "2"],
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)'
121
- },
122
- mdEntryType: {
123
- type: "string",
124
- enum: [
125
- "0",
126
- "1",
127
- "2",
128
- "3",
129
- "4",
130
- "5",
131
- "6",
132
- "7",
133
- "8",
134
- "9",
135
- "A",
136
- "B",
137
- "C",
138
- "D",
139
- "E",
140
- "F",
141
- "G",
142
- "H",
143
- "J",
144
- "K",
145
- "L",
146
- "M",
147
- "N",
148
- "O",
149
- "P",
150
- "Q",
151
- "S",
152
- "R",
153
- "T",
154
- "U",
155
- "V",
156
- "W",
157
- "X",
158
- "Y",
159
- "Z",
160
- "a",
161
- "b",
162
- "c",
163
- "d",
164
- "e",
165
- "g",
166
- "h",
167
- "i",
168
- "t"
169
- ],
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)'
171
- }
172
- },
173
- required: ["symbol", "mdReqID"]
174
- };
175
- var MCPLocal = class {
176
- // private logger: Logger | undefined;
177
- parser;
178
- server = new Server(
179
- {
180
- name: "fixparser",
181
- version: "1.0.0"
182
- },
183
- {
184
- capabilities: {
185
- tools: {},
186
- prompts: {},
187
- resources: {}
188
- }
189
- }
190
- );
191
- transport = new StdioServerTransport();
192
- onReady = void 0;
193
- pendingRequests = /* @__PURE__ */ new Map();
194
- verifiedOrders = /* @__PURE__ */ new Map();
195
- constructor({ logger, onReady }) {
196
- if (onReady) this.onReady = onReady;
197
- }
198
- async register(parser) {
199
- this.parser = parser;
200
- this.parser.addOnMessageCallback((message) => {
201
- const msgType = message.messageType;
202
- if (msgType === Messages.MarketDataSnapshotFullRefresh || msgType === Messages.ExecutionReport || msgType === Messages.Reject) {
203
- let id;
204
- if (msgType === Messages.MarketDataSnapshotFullRefresh) {
205
- const mdReqID = message.getField(Fields.MDReqID);
206
- if (mdReqID) id = String(mdReqID.value);
207
- } else if (msgType === Messages.ExecutionReport) {
208
- const clOrdID = message.getField(Fields.ClOrdID);
209
- if (clOrdID) id = String(clOrdID.value);
210
- } else if (msgType === Messages.Reject) {
211
- const refSeqNum = message.getField(Fields.RefSeqNum);
212
- if (refSeqNum) id = String(refSeqNum.value);
213
- }
214
- if (id) {
215
- const callback = this.pendingRequests.get(id);
216
- if (callback) {
217
- callback(message);
218
- this.pendingRequests.delete(id);
219
- }
220
- }
221
- }
222
- });
223
- this.addWorkflows();
224
- await this.server.connect(this.transport);
225
- if (this.onReady) {
226
- this.onReady();
227
- }
228
- }
229
- addWorkflows() {
230
- if (!this.parser) {
231
- return;
232
- }
233
- if (!this.server) {
234
- return;
235
- }
236
- const validateArgs = (args, schema) => {
237
- const result = {};
238
- for (const [key, propSchema] of Object.entries(schema.properties || {})) {
239
- const prop = propSchema;
240
- const value = args?.[key];
241
- if (prop.required && (value === void 0 || value === null)) {
242
- throw new Error(`Required property '${key}' is missing`);
243
- }
244
- if (value !== void 0) {
245
- result[key] = value;
246
- } else if (prop.default !== void 0) {
247
- result[key] = prop.default;
248
- }
249
- }
250
- return result;
251
- };
252
- this.server.setRequestHandler(ListResourcesRequestSchema, async () => {
253
- return {
254
- resources: []
255
- };
256
- });
257
- this.server.setRequestHandler(ListToolsRequestSchema, async () => {
258
- return {
259
- tools: [
260
- {
261
- name: "parse",
262
- description: "Parses a FIX message and describes it in plain language",
263
- inputSchema: parseInputSchema
264
- },
265
- {
266
- name: "parseToJSON",
267
- description: "Parses a FIX message into JSON",
268
- inputSchema: parseToJSONInputSchema
269
- },
270
- {
271
- name: "verifyOrder",
272
- description: "Verifies all parameters for a New Order Single. This is the first step - verification only, no order is sent.",
273
- inputSchema: orderSchema
274
- },
275
- {
276
- name: "executeOrder",
277
- description: "Executes a New Order Single after verification. This is the second step - only call after successful verification.",
278
- inputSchema: orderSchema
279
- },
280
- {
281
- name: "marketDataRequest",
282
- 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.",
283
- inputSchema: marketDataRequestInputSchema
284
- }
285
- ]
286
- };
287
- });
288
- this.server.setRequestHandler(CallToolRequestSchema, async (request) => {
289
- const { name, arguments: args } = request.params;
290
- switch (name) {
291
- case "parse": {
292
- try {
293
- const { fixString } = validateArgs(args, parseInputSchema);
294
- const parsedMessage = this.parser?.parse(fixString);
295
- if (!parsedMessage || parsedMessage.length === 0) {
296
- return {
297
- isError: true,
298
- content: [{ type: "text", text: "Error: Failed to parse FIX string" }]
299
- };
300
- }
301
- return {
302
- content: [
303
- {
304
- type: "text",
305
- text: `${parsedMessage[0].description}
306
- ${parsedMessage[0].messageTypeDescription}`
307
- }
308
- ]
309
- };
310
- } catch (error) {
311
- return {
312
- isError: true,
313
- content: [
314
- {
315
- type: "text",
316
- text: `Error: ${error instanceof Error ? error.message : "Failed to parse FIX string"}`
317
- }
318
- ]
319
- };
320
- }
321
- }
322
- case "parseToJSON": {
323
- try {
324
- const { fixString } = validateArgs(args, parseToJSONInputSchema);
325
- const parsedMessage = this.parser?.parse(fixString);
326
- if (!parsedMessage || parsedMessage.length === 0) {
327
- return {
328
- isError: true,
329
- content: [{ type: "text", text: "Error: Failed to parse FIX string" }]
330
- };
331
- }
332
- return {
333
- content: [
334
- {
335
- type: "text",
336
- text: `${parsedMessage[0].toFIXJSON()}`
337
- }
338
- ]
339
- };
340
- } catch (error) {
341
- return {
342
- isError: true,
343
- content: [
344
- {
345
- type: "text",
346
- text: `Error: ${error instanceof Error ? error.message : "Failed to parse FIX string"}`
347
- }
348
- ]
349
- };
350
- }
351
- }
352
- case "verifyOrder": {
353
- try {
354
- const { clOrdID, handlInst, quantity, price, ordType, side, symbol, timeInForce } = validateArgs(args, orderSchema);
355
- this.verifiedOrders.set(clOrdID, {
356
- clOrdID,
357
- handlInst,
358
- quantity,
359
- price,
360
- ordType,
361
- side,
362
- symbol,
363
- timeInForce
364
- });
365
- return {
366
- content: [
367
- {
368
- type: "text",
369
- text: `VERIFICATION: All parameters valid. Ready to proceed with order execution.
370
-
371
- Parameters verified:
372
- - ClOrdID: ${clOrdID}
373
- - HandlInst: ${handlInst}
374
- - Quantity: ${quantity}
375
- - Price: ${price}
376
- - OrdType: ${ordType}
377
- - Side: ${side}
378
- - Symbol: ${symbol}
379
- - TimeInForce: ${timeInForce}
380
-
381
- To execute this order, call the executeOrder tool with these exact same parameters.`
382
- }
383
- ]
384
- };
385
- } catch (error) {
386
- return {
387
- isError: true,
388
- content: [
389
- {
390
- type: "text",
391
- text: `Error: ${error instanceof Error ? error.message : "Failed to verify order parameters"}`
392
- }
393
- ]
394
- };
395
- }
396
- }
397
- case "executeOrder": {
398
- try {
399
- const { clOrdID, handlInst, quantity, price, ordType, side, symbol, timeInForce } = validateArgs(args, orderSchema);
400
- const verifiedOrder = this.verifiedOrders.get(clOrdID);
401
- if (!verifiedOrder) {
402
- return {
403
- isError: true,
404
- content: [
405
- {
406
- type: "text",
407
- text: `Error: Order ${clOrdID} has not been verified. Please call verifyOrder first.`
408
- }
409
- ]
410
- };
411
- }
412
- if (verifiedOrder.handlInst !== handlInst || verifiedOrder.quantity !== quantity || verifiedOrder.price !== price || verifiedOrder.ordType !== ordType || verifiedOrder.side !== side || verifiedOrder.symbol !== symbol || verifiedOrder.timeInForce !== timeInForce) {
413
- return {
414
- isError: true,
415
- content: [
416
- {
417
- type: "text",
418
- text: "Error: Order parameters do not match the verified order. Please use the exact same parameters that were verified."
419
- }
420
- ]
421
- };
422
- }
423
- const response = new Promise((resolve) => {
424
- this.pendingRequests.set(clOrdID, resolve);
425
- });
426
- const order = this.parser?.createMessage(
427
- new Field(Fields.MsgType, Messages.NewOrderSingle),
428
- new Field(Fields.MsgSeqNum, this.parser?.getNextTargetMsgSeqNum()),
429
- new Field(Fields.SenderCompID, this.parser?.sender),
430
- new Field(Fields.TargetCompID, this.parser?.target),
431
- new Field(Fields.SendingTime, this.parser?.getTimestamp()),
432
- new Field(Fields.ClOrdID, clOrdID),
433
- new Field(Fields.Side, side),
434
- new Field(Fields.Symbol, symbol),
435
- new Field(Fields.OrderQty, quantity),
436
- new Field(Fields.Price, price),
437
- new Field(Fields.OrdType, ordType),
438
- new Field(Fields.HandlInst, handlInst),
439
- new Field(Fields.TimeInForce, timeInForce),
440
- new Field(Fields.TransactTime, this.parser?.getTimestamp())
441
- );
442
- if (!this.parser?.connected) {
443
- return {
444
- isError: true,
445
- content: [
446
- {
447
- type: "text",
448
- text: "Error: Not connected. Ignoring message."
449
- }
450
- ]
451
- };
452
- }
453
- this.parser?.send(order);
454
- const fixData = await response;
455
- this.verifiedOrders.delete(clOrdID);
456
- return {
457
- content: [
458
- {
459
- type: "text",
460
- text: fixData.messageType === Messages.Reject ? `Reject message for order ${clOrdID}: ${JSON.stringify(fixData.toFIXJSON())}` : `Execution Report for order ${clOrdID}: ${JSON.stringify(fixData.toFIXJSON())}`
461
- }
462
- ]
463
- };
464
- } catch (error) {
465
- return {
466
- isError: true,
467
- content: [
468
- {
469
- type: "text",
470
- text: `Error: ${error instanceof Error ? error.message : "Failed to execute order"}`
471
- }
472
- ]
473
- };
474
- }
475
- }
476
- case "marketDataRequest": {
477
- try {
478
- const { mdUpdateType, symbol, mdReqID, subscriptionRequestType, mdEntryType } = validateArgs(
479
- args,
480
- marketDataRequestInputSchema
481
- );
482
- const response = new Promise((resolve) => {
483
- this.pendingRequests.set(mdReqID, resolve);
484
- });
485
- const marketDataRequest = this.parser?.createMessage(
486
- new Field(Fields.MsgType, Messages.MarketDataRequest),
487
- new Field(Fields.SenderCompID, this.parser?.sender),
488
- new Field(Fields.MsgSeqNum, this.parser?.getNextTargetMsgSeqNum()),
489
- new Field(Fields.TargetCompID, this.parser?.target),
490
- new Field(Fields.SendingTime, this.parser?.getTimestamp()),
491
- new Field(Fields.MarketDepth, 0),
492
- new Field(Fields.MDUpdateType, mdUpdateType),
493
- new Field(Fields.NoRelatedSym, 1),
494
- new Field(Fields.Symbol, symbol),
495
- new Field(Fields.MDReqID, mdReqID),
496
- new Field(Fields.SubscriptionRequestType, subscriptionRequestType),
497
- new Field(Fields.NoMDEntryTypes, 1),
498
- new Field(Fields.MDEntryType, mdEntryType)
499
- );
500
- if (!this.parser?.connected) {
501
- return {
502
- isError: true,
503
- content: [
504
- {
505
- type: "text",
506
- text: "Error: Not connected. Ignoring message."
507
- }
508
- ]
509
- };
510
- }
511
- this.parser?.send(marketDataRequest);
512
- const fixData = await response;
513
- return {
514
- content: [
515
- {
516
- type: "text",
517
- text: `Market data for ${symbol}: ${JSON.stringify(fixData.toFIXJSON())}`
518
- }
519
- ]
520
- };
521
- } catch (error) {
522
- return {
523
- isError: true,
524
- content: [
525
- {
526
- type: "text",
527
- text: `Error: ${error instanceof Error ? error.message : "Failed to request market data"}`
528
- }
529
- ]
530
- };
531
- }
532
- }
533
- default:
534
- throw new Error(`Unknown tool: ${name}`);
535
- }
536
- });
537
- this.server.setRequestHandler(ListPromptsRequestSchema, async () => {
538
- return {
539
- prompts: [
540
- {
541
- name: "parse",
542
- description: "Parses a FIX message and describes it in plain language",
543
- arguments: [
544
- {
545
- name: "fixString",
546
- description: "FIX message string to parse",
547
- required: true
548
- }
549
- ]
550
- },
551
- {
552
- name: "parseToJSON",
553
- description: "Parses a FIX message into JSON",
554
- arguments: [
555
- {
556
- name: "fixString",
557
- description: "FIX message string to parse",
558
- required: true
559
- }
560
- ]
561
- },
562
- {
563
- name: "verifyOrder",
564
- description: "Verifies all parameters for a New Order Single. This is the first step - verification only, no order is sent.",
565
- arguments: [
566
- {
567
- name: "clOrdID",
568
- description: "Client Order ID",
569
- required: true
570
- },
571
- {
572
- name: "handlInst",
573
- description: "Handling instruction (1=Manual, 2=Automated, 3=AutomatedNoIntervention)",
574
- required: true
575
- },
576
- {
577
- name: "quantity",
578
- description: "Order quantity",
579
- required: true
580
- },
581
- {
582
- name: "price",
583
- description: "Order price",
584
- required: true
585
- },
586
- {
587
- name: "ordType",
588
- description: "Order type (1=Market, 2=Limit, 3=Stop)",
589
- required: true
590
- },
591
- {
592
- name: "side",
593
- 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)",
594
- required: true
595
- },
596
- {
597
- name: "symbol",
598
- description: "Trading symbol",
599
- required: true
600
- },
601
- {
602
- name: "timeInForce",
603
- 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)",
604
- required: true
605
- }
606
- ]
607
- },
608
- {
609
- name: "executeOrder",
610
- description: "Executes a New Order Single after verification. This is the second step - only call after successful verification.",
611
- arguments: [
612
- {
613
- name: "clOrdID",
614
- description: "Client Order ID",
615
- required: true
616
- },
617
- {
618
- name: "handlInst",
619
- description: "Handling instruction (1=Manual, 2=Automated, 3=AutomatedNoIntervention)",
620
- required: true
621
- },
622
- {
623
- name: "quantity",
624
- description: "Order quantity",
625
- required: true
626
- },
627
- {
628
- name: "price",
629
- description: "Order price",
630
- required: true
631
- },
632
- {
633
- name: "ordType",
634
- description: "Order type (1=Market, 2=Limit, 3=Stop)",
635
- required: true
636
- },
637
- {
638
- name: "side",
639
- 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)",
640
- required: true
641
- },
642
- {
643
- name: "symbol",
644
- description: "Trading symbol",
645
- required: true
646
- },
647
- {
648
- name: "timeInForce",
649
- 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)",
650
- required: true
651
- }
652
- ]
653
- },
654
- {
655
- name: "marketDataRequest",
656
- 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.",
657
- arguments: [
658
- {
659
- name: "mdUpdateType",
660
- description: "Market data update type (0=FullRefresh, 1=IncrementalRefresh)",
661
- required: true
662
- },
663
- {
664
- name: "symbol",
665
- description: "Trading symbol",
666
- required: true
667
- },
668
- {
669
- name: "mdReqID",
670
- description: "Market data request ID",
671
- required: true
672
- },
673
- {
674
- name: "subscriptionRequestType",
675
- description: "Subscription request type (0=Snapshot + Updates, 1=Snapshot, 2=Unsubscribe)",
676
- required: true
677
- },
678
- {
679
- name: "mdEntryType",
680
- description: "Market data entry type (0=Bid, 1=Offer, 2=Trade, 3=Index Value, 4=Opening Price)",
681
- required: true
682
- }
683
- ]
684
- }
685
- ]
686
- };
687
- });
688
- this.server.setRequestHandler(GetPromptRequestSchema, async (request) => {
689
- const { name, arguments: args } = request.params;
690
- switch (name) {
691
- case "parse": {
692
- const fixString = args?.fixString || "";
693
- return {
694
- messages: [
695
- {
696
- role: "user",
697
- content: {
698
- type: "text",
699
- text: `Please parse and explain this FIX message: ${fixString}`
700
- }
701
- }
702
- ]
703
- };
704
- }
705
- case "parseToJSON": {
706
- const fixString = args?.fixString || "";
707
- return {
708
- messages: [
709
- {
710
- role: "user",
711
- content: {
712
- type: "text",
713
- text: `Please parse the FIX message to JSON: ${fixString}`
714
- }
715
- }
716
- ]
717
- };
718
- }
719
- case "verifyOrder": {
720
- const { clOrdID, handlInst, quantity, price, ordType, side, symbol, timeInForce } = args || {};
721
- return {
722
- messages: [
723
- {
724
- role: "user",
725
- content: {
726
- type: "text",
727
- text: [
728
- "You are an AI assistant that helps users verify FIX New Order Single parameters.",
729
- "This is STEP 1 of 2 - VERIFICATION ONLY. No order will be sent at this stage.",
730
- "",
731
- "You must verify that all required fields are provided and valid:",
732
- "- ClOrdID (Client Order ID)",
733
- "- HandlInst (1=Manual, 2=Automated, 3=AutomatedNoIntervention)",
734
- "- Quantity (Order quantity)",
735
- "- Price (Order price)",
736
- "- OrdType (1=Market, 2=Limit, 3=Stop)",
737
- "- 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)",
738
- "- Symbol (Trading symbol)",
739
- "- TimeInForce (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)",
740
- "",
741
- "Current parameters to verify:",
742
- `- ClOrdID: ${clOrdID}`,
743
- `- HandlInst: ${handlInst}`,
744
- `- Quantity: ${quantity}`,
745
- `- Price: ${price}`,
746
- `- OrdType: ${ordType}`,
747
- `- Side: ${side}`,
748
- `- Symbol: ${symbol}`,
749
- `- TimeInForce: ${timeInForce}`,
750
- "",
751
- "If all parameters are valid, respond with:",
752
- "`VERIFICATION: All parameters valid. Ready to proceed.`",
753
- "",
754
- "Otherwise, list the missing or invalid ones.",
755
- "",
756
- "IMPORTANT: This is only verification. To actually send the order, the user must call the executeOrder tool with the same parameters."
757
- ].join("\n")
758
- }
759
- }
760
- ]
761
- };
762
- }
763
- case "executeOrder": {
764
- const { clOrdID, handlInst, quantity, price, ordType, side, symbol, timeInForce } = args || {};
765
- return {
766
- messages: [
767
- {
768
- role: "user",
769
- content: {
770
- type: "text",
771
- text: [
772
- "You are an AI assistant that helps users execute FIX New Order Single messages.",
773
- "This is STEP 2 of 2 - EXECUTION. This will send the order to the market.",
774
- "",
775
- "IMPORTANT: This tool should only be called after successful verification of all parameters.",
776
- "",
777
- "Parameters to execute:",
778
- `- ClOrdID: ${clOrdID}`,
779
- `- HandlInst: ${handlInst}`,
780
- `- Quantity: ${quantity}`,
781
- `- Price: ${price}`,
782
- `- OrdType: ${ordType}`,
783
- `- Side: ${side}`,
784
- `- Symbol: ${symbol}`,
785
- `- TimeInForce: ${timeInForce}`,
786
- "",
787
- "IMPORTANT: The response will be either:",
788
- "1. An Execution Report (MsgType=8) if the order was successfully placed",
789
- "2. A Reject message (MsgType=3) if the order failed to execute (e.g., due to missing or invalid parameters)"
790
- ].join("\n")
791
- }
792
- }
793
- ]
794
- };
795
- }
796
- case "marketDataRequest": {
797
- const { mdUpdateType, symbol, mdReqID, subscriptionRequestType, mdEntryType } = args || {};
798
- return {
799
- messages: [
800
- {
801
- role: "user",
802
- content: {
803
- type: "text",
804
- text: [
805
- "You are an AI assistant that helps users create FIX Market Data Request messages.",
806
- "You must **first verify** that all required fields are provided:",
807
- "- MDUpdateType (0=FullRefresh, 1=IncrementalRefresh)",
808
- "- Symbol (Trading symbol)",
809
- "- MDReqID (Market data request ID)",
810
- "- SubscriptionRequestType (0=Snapshot + Updates, 1=Snapshot, 2=Unsubscribe)",
811
- "- MDEntryType (0=Bid, 1=Offer, 2=Trade, 3=Index Value, 4=Opening Price)",
812
- "",
813
- "Only when all fields are present and valid, respond with:",
814
- "`VERIFICATION: All parameters valid. Ready to proceed.`",
815
- "",
816
- "Otherwise, list the missing or invalid ones.",
817
- "",
818
- "Do not create the FIX message until verification is complete.",
819
- "",
820
- "Current parameters:",
821
- `- MDUpdateType: ${mdUpdateType}`,
822
- `- Symbol: ${symbol}`,
823
- `- MDReqID: ${mdReqID}`,
824
- `- SubscriptionRequestType: ${subscriptionRequestType}`,
825
- `- MDEntryType: ${mdEntryType}`
826
- ].join("\n")
827
- }
828
- }
829
- ]
830
- };
831
- }
832
- default:
833
- throw new Error(`Unknown prompt: ${name}`);
834
- }
835
- });
836
- process.on("SIGINT", async () => {
837
- await this.server.close();
838
- process.exit(0);
839
- });
840
- }
841
- };
842
- export {
843
- MCPLocal
844
- };
845
- //# sourceMappingURL=MCPLocal.mjs.map