fixparser-plugin-mcp 9.1.7-9d6b5ca3 → 9.1.7-9eab5b4d
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 +110 -452
- package/build/cjs/MCPLocal.js.map +4 -4
- package/build/cjs/MCPRemote.js +435 -1294
- package/build/cjs/MCPRemote.js.map +4 -4
- package/build/esm/MCPLocal.mjs +110 -452
- package/build/esm/MCPLocal.mjs.map +4 -4
- package/build/esm/MCPRemote.mjs +444 -1284
- package/build/esm/MCPRemote.mjs.map +4 -4
- package/build-examples/cjs/example_mcp_local.js +7 -7
- package/build-examples/cjs/example_mcp_local.js.map +4 -4
- package/build-examples/esm/example_mcp_local.mjs +7 -7
- package/build-examples/esm/example_mcp_local.mjs.map +4 -4
- package/package.json +6 -6
- package/types/MCPLocal.d.ts +16 -0
- package/types/MCPRemote.d.ts +60 -0
- package/types/PluginOptions.d.ts +6 -0
- package/types/index.d.ts +3 -0
- package/types/schemas/index.d.ts +30 -0
- package/types/schemas/schemas.d.ts +168 -0
- package/types/tools/index.d.ts +17 -0
- package/types/tools/marketData.d.ts +40 -0
- package/types/tools/order.d.ts +11 -0
- package/types/tools/parse.d.ts +5 -0
- package/types/tools/parseToJSON.d.ts +5 -0
- package/build/cjs/index.js +0 -1593
- package/build/cjs/index.js.map +0 -7
- package/build/esm/index.mjs +0 -1555
- package/build/esm/index.mjs.map +0 -7
- package/build-examples/cjs/example_mcp_remote.js +0 -16
- package/build-examples/cjs/example_mcp_remote.js.map +0 -7
- package/build-examples/esm/example_mcp_remote.mjs +0 -16
- package/build-examples/esm/example_mcp_remote.mjs.map +0 -7
package/build/cjs/MCPLocal.js
CHANGED
|
@@ -35,51 +35,9 @@ __export(MCPLocal_exports, {
|
|
|
35
35
|
module.exports = __toCommonJS(MCPLocal_exports);
|
|
36
36
|
var import_server = require("@modelcontextprotocol/sdk/server/index.js");
|
|
37
37
|
var import_stdio = require("@modelcontextprotocol/sdk/server/stdio.js");
|
|
38
|
+
var import_fixparser3 = require("fixparser");
|
|
38
39
|
var import_zod = require("zod");
|
|
39
40
|
|
|
40
|
-
// src/MCPBase.ts
|
|
41
|
-
var MCPBase = class {
|
|
42
|
-
/**
|
|
43
|
-
* Optional logger instance for diagnostics and output.
|
|
44
|
-
* @protected
|
|
45
|
-
*/
|
|
46
|
-
logger;
|
|
47
|
-
/**
|
|
48
|
-
* FIXParser instance, set during plugin register().
|
|
49
|
-
* @protected
|
|
50
|
-
*/
|
|
51
|
-
parser;
|
|
52
|
-
/**
|
|
53
|
-
* Called when server is setup and listening.
|
|
54
|
-
* @protected
|
|
55
|
-
*/
|
|
56
|
-
onReady = void 0;
|
|
57
|
-
/**
|
|
58
|
-
* Map to store verified orders before execution
|
|
59
|
-
* @protected
|
|
60
|
-
*/
|
|
61
|
-
verifiedOrders = /* @__PURE__ */ new Map();
|
|
62
|
-
/**
|
|
63
|
-
* Map to store pending market data requests
|
|
64
|
-
* @protected
|
|
65
|
-
*/
|
|
66
|
-
pendingRequests = /* @__PURE__ */ new Map();
|
|
67
|
-
/**
|
|
68
|
-
* Map to store market data prices
|
|
69
|
-
* @protected
|
|
70
|
-
*/
|
|
71
|
-
marketDataPrices = /* @__PURE__ */ new Map();
|
|
72
|
-
/**
|
|
73
|
-
* Maximum number of price history entries to keep per symbol
|
|
74
|
-
* @protected
|
|
75
|
-
*/
|
|
76
|
-
MAX_PRICE_HISTORY = 1e5;
|
|
77
|
-
constructor({ logger, onReady }) {
|
|
78
|
-
this.logger = logger;
|
|
79
|
-
this.onReady = onReady;
|
|
80
|
-
}
|
|
81
|
-
};
|
|
82
|
-
|
|
83
41
|
// src/schemas/schemas.ts
|
|
84
42
|
var toolSchemas = {
|
|
85
43
|
parse: {
|
|
@@ -163,7 +121,7 @@ var toolSchemas = {
|
|
|
163
121
|
}
|
|
164
122
|
},
|
|
165
123
|
executeOrder: {
|
|
166
|
-
description: "Executes a verified order. verifyOrder must be called before executeOrder.",
|
|
124
|
+
description: "Executes a verified order. verifyOrder must be called before executeOrder. user has to explicitly allow executeOrder.",
|
|
167
125
|
schema: {
|
|
168
126
|
type: "object",
|
|
169
127
|
properties: {
|
|
@@ -316,63 +274,10 @@ var import_quickchart_js = __toESM(require("quickchart-js"), 1);
|
|
|
316
274
|
var createMarketDataRequestHandler = (parser, pendingRequests) => {
|
|
317
275
|
return async (args) => {
|
|
318
276
|
try {
|
|
319
|
-
parser.logger.log({
|
|
320
|
-
level: "info",
|
|
321
|
-
message: `Sending market data request for symbols: ${args.symbols.join(", ")}`
|
|
322
|
-
});
|
|
323
277
|
const response = new Promise((resolve) => {
|
|
324
278
|
pendingRequests.set(args.mdReqID, resolve);
|
|
325
|
-
parser.logger.log({
|
|
326
|
-
level: "info",
|
|
327
|
-
message: `Registered callback for market data request ID: ${args.mdReqID}`
|
|
328
|
-
});
|
|
329
279
|
});
|
|
330
|
-
const entryTypes = args.mdEntryTypes || [
|
|
331
|
-
import_fixparser.MDEntryType.Bid,
|
|
332
|
-
import_fixparser.MDEntryType.Offer,
|
|
333
|
-
import_fixparser.MDEntryType.Trade,
|
|
334
|
-
import_fixparser.MDEntryType.IndexValue,
|
|
335
|
-
import_fixparser.MDEntryType.OpeningPrice,
|
|
336
|
-
import_fixparser.MDEntryType.ClosingPrice,
|
|
337
|
-
import_fixparser.MDEntryType.SettlementPrice,
|
|
338
|
-
import_fixparser.MDEntryType.TradingSessionHighPrice,
|
|
339
|
-
import_fixparser.MDEntryType.TradingSessionLowPrice,
|
|
340
|
-
import_fixparser.MDEntryType.VWAP,
|
|
341
|
-
import_fixparser.MDEntryType.Imbalance,
|
|
342
|
-
import_fixparser.MDEntryType.TradeVolume,
|
|
343
|
-
import_fixparser.MDEntryType.OpenInterest,
|
|
344
|
-
import_fixparser.MDEntryType.CompositeUnderlyingPrice,
|
|
345
|
-
import_fixparser.MDEntryType.SimulatedSellPrice,
|
|
346
|
-
import_fixparser.MDEntryType.SimulatedBuyPrice,
|
|
347
|
-
import_fixparser.MDEntryType.MarginRate,
|
|
348
|
-
import_fixparser.MDEntryType.MidPrice,
|
|
349
|
-
import_fixparser.MDEntryType.EmptyBook,
|
|
350
|
-
import_fixparser.MDEntryType.SettleHighPrice,
|
|
351
|
-
import_fixparser.MDEntryType.SettleLowPrice,
|
|
352
|
-
import_fixparser.MDEntryType.PriorSettlePrice,
|
|
353
|
-
import_fixparser.MDEntryType.SessionHighBid,
|
|
354
|
-
import_fixparser.MDEntryType.SessionLowOffer,
|
|
355
|
-
import_fixparser.MDEntryType.EarlyPrices,
|
|
356
|
-
import_fixparser.MDEntryType.AuctionClearingPrice,
|
|
357
|
-
import_fixparser.MDEntryType.SwapValueFactor,
|
|
358
|
-
import_fixparser.MDEntryType.DailyValueAdjustmentForLongPositions,
|
|
359
|
-
import_fixparser.MDEntryType.CumulativeValueAdjustmentForLongPositions,
|
|
360
|
-
import_fixparser.MDEntryType.DailyValueAdjustmentForShortPositions,
|
|
361
|
-
import_fixparser.MDEntryType.CumulativeValueAdjustmentForShortPositions,
|
|
362
|
-
import_fixparser.MDEntryType.FixingPrice,
|
|
363
|
-
import_fixparser.MDEntryType.CashRate,
|
|
364
|
-
import_fixparser.MDEntryType.RecoveryRate,
|
|
365
|
-
import_fixparser.MDEntryType.RecoveryRateForLong,
|
|
366
|
-
import_fixparser.MDEntryType.RecoveryRateForShort,
|
|
367
|
-
import_fixparser.MDEntryType.MarketBid,
|
|
368
|
-
import_fixparser.MDEntryType.MarketOffer,
|
|
369
|
-
import_fixparser.MDEntryType.ShortSaleMinPrice,
|
|
370
|
-
import_fixparser.MDEntryType.PreviousClosingPrice,
|
|
371
|
-
import_fixparser.MDEntryType.ThresholdLimitPriceBanding,
|
|
372
|
-
import_fixparser.MDEntryType.DailyFinancingValue,
|
|
373
|
-
import_fixparser.MDEntryType.AccruedFinancingValue,
|
|
374
|
-
import_fixparser.MDEntryType.TWAP
|
|
375
|
-
];
|
|
280
|
+
const entryTypes = args.mdEntryTypes || [import_fixparser.MDEntryType.Bid, import_fixparser.MDEntryType.Offer, import_fixparser.MDEntryType.TradeVolume];
|
|
376
281
|
const messageFields = [
|
|
377
282
|
new import_fixparser.Field(import_fixparser.Fields.MsgType, import_fixparser.Messages.MarketDataRequest),
|
|
378
283
|
new import_fixparser.Field(import_fixparser.Fields.SenderCompID, parser.sender),
|
|
@@ -394,10 +299,6 @@ var createMarketDataRequestHandler = (parser, pendingRequests) => {
|
|
|
394
299
|
});
|
|
395
300
|
const mdr = parser.createMessage(...messageFields);
|
|
396
301
|
if (!parser.connected) {
|
|
397
|
-
parser.logger.log({
|
|
398
|
-
level: "error",
|
|
399
|
-
message: "Not connected. Cannot send market data request."
|
|
400
|
-
});
|
|
401
302
|
return {
|
|
402
303
|
content: [
|
|
403
304
|
{
|
|
@@ -409,16 +310,8 @@ var createMarketDataRequestHandler = (parser, pendingRequests) => {
|
|
|
409
310
|
isError: true
|
|
410
311
|
};
|
|
411
312
|
}
|
|
412
|
-
parser.logger.log({
|
|
413
|
-
level: "info",
|
|
414
|
-
message: `Sending market data request message: ${JSON.stringify(mdr?.toFIXJSON())}`
|
|
415
|
-
});
|
|
416
313
|
parser.send(mdr);
|
|
417
314
|
const fixData = await response;
|
|
418
|
-
parser.logger.log({
|
|
419
|
-
level: "info",
|
|
420
|
-
message: `Received market data response for request ID: ${args.mdReqID}`
|
|
421
|
-
});
|
|
422
315
|
return {
|
|
423
316
|
content: [
|
|
424
317
|
{
|
|
@@ -459,17 +352,13 @@ var createGetStockGraphHandler = (marketDataPrices) => {
|
|
|
459
352
|
};
|
|
460
353
|
}
|
|
461
354
|
const chart = new import_quickchart_js.default();
|
|
462
|
-
chart.setWidth(
|
|
463
|
-
chart.setHeight(
|
|
464
|
-
chart.setBackgroundColor("transparent");
|
|
355
|
+
chart.setWidth(600);
|
|
356
|
+
chart.setHeight(300);
|
|
465
357
|
const labels = priceHistory.map((point) => new Date(point.timestamp).toLocaleTimeString());
|
|
466
358
|
const bidData = priceHistory.map((point) => point.bid);
|
|
467
359
|
const offerData = priceHistory.map((point) => point.offer);
|
|
468
360
|
const spreadData = priceHistory.map((point) => point.spread);
|
|
469
361
|
const volumeData = priceHistory.map((point) => point.volume);
|
|
470
|
-
const tradeData = priceHistory.map((point) => point.trade);
|
|
471
|
-
const vwapData = priceHistory.map((point) => point.vwap);
|
|
472
|
-
const twapData = priceHistory.map((point) => point.twap);
|
|
473
362
|
const config = {
|
|
474
363
|
type: "line",
|
|
475
364
|
data: {
|
|
@@ -499,30 +388,6 @@ var createGetStockGraphHandler = (marketDataPrices) => {
|
|
|
499
388
|
fill: false,
|
|
500
389
|
tension: 0.4
|
|
501
390
|
},
|
|
502
|
-
{
|
|
503
|
-
label: "Trade",
|
|
504
|
-
data: tradeData,
|
|
505
|
-
borderColor: "#ffc107",
|
|
506
|
-
backgroundColor: "rgba(255, 193, 7, 0.1)",
|
|
507
|
-
fill: false,
|
|
508
|
-
tension: 0.4
|
|
509
|
-
},
|
|
510
|
-
{
|
|
511
|
-
label: "VWAP",
|
|
512
|
-
data: vwapData,
|
|
513
|
-
borderColor: "#17a2b8",
|
|
514
|
-
backgroundColor: "rgba(23, 162, 184, 0.1)",
|
|
515
|
-
fill: false,
|
|
516
|
-
tension: 0.4
|
|
517
|
-
},
|
|
518
|
-
{
|
|
519
|
-
label: "TWAP",
|
|
520
|
-
data: twapData,
|
|
521
|
-
borderColor: "#6610f2",
|
|
522
|
-
backgroundColor: "rgba(102, 16, 242, 0.1)",
|
|
523
|
-
fill: false,
|
|
524
|
-
tension: 0.4
|
|
525
|
-
},
|
|
526
391
|
{
|
|
527
392
|
label: "Volume",
|
|
528
393
|
data: volumeData,
|
|
@@ -550,16 +415,16 @@ var createGetStockGraphHandler = (marketDataPrices) => {
|
|
|
550
415
|
};
|
|
551
416
|
chart.setConfig(config);
|
|
552
417
|
const imageBuffer = await chart.toBinary();
|
|
553
|
-
const
|
|
418
|
+
const base64Image = imageBuffer.toString("base64");
|
|
554
419
|
return {
|
|
555
420
|
content: [
|
|
556
421
|
{
|
|
557
|
-
type: "
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
422
|
+
type: "image",
|
|
423
|
+
image: {
|
|
424
|
+
source: `data:image/png;base64,${base64Image}`
|
|
425
|
+
},
|
|
426
|
+
uri: "getStockGraph",
|
|
427
|
+
mimeType: "image/png"
|
|
563
428
|
}
|
|
564
429
|
]
|
|
565
430
|
};
|
|
@@ -568,7 +433,7 @@ var createGetStockGraphHandler = (marketDataPrices) => {
|
|
|
568
433
|
content: [
|
|
569
434
|
{
|
|
570
435
|
type: "text",
|
|
571
|
-
text: `Error: ${error instanceof Error ? error.message : "Failed to generate
|
|
436
|
+
text: `Error: ${error instanceof Error ? error.message : "Failed to generate chart"}`,
|
|
572
437
|
uri: "getStockGraph"
|
|
573
438
|
}
|
|
574
439
|
],
|
|
@@ -606,48 +471,7 @@ var createGetStockPriceHistoryHandler = (marketDataPrices) => {
|
|
|
606
471
|
bid: point.bid,
|
|
607
472
|
offer: point.offer,
|
|
608
473
|
spread: point.spread,
|
|
609
|
-
volume: point.volume
|
|
610
|
-
trade: point.trade,
|
|
611
|
-
indexValue: point.indexValue,
|
|
612
|
-
openingPrice: point.openingPrice,
|
|
613
|
-
closingPrice: point.closingPrice,
|
|
614
|
-
settlementPrice: point.settlementPrice,
|
|
615
|
-
tradingSessionHighPrice: point.tradingSessionHighPrice,
|
|
616
|
-
tradingSessionLowPrice: point.tradingSessionLowPrice,
|
|
617
|
-
vwap: point.vwap,
|
|
618
|
-
imbalance: point.imbalance,
|
|
619
|
-
openInterest: point.openInterest,
|
|
620
|
-
compositeUnderlyingPrice: point.compositeUnderlyingPrice,
|
|
621
|
-
simulatedSellPrice: point.simulatedSellPrice,
|
|
622
|
-
simulatedBuyPrice: point.simulatedBuyPrice,
|
|
623
|
-
marginRate: point.marginRate,
|
|
624
|
-
midPrice: point.midPrice,
|
|
625
|
-
emptyBook: point.emptyBook,
|
|
626
|
-
settleHighPrice: point.settleHighPrice,
|
|
627
|
-
settleLowPrice: point.settleLowPrice,
|
|
628
|
-
priorSettlePrice: point.priorSettlePrice,
|
|
629
|
-
sessionHighBid: point.sessionHighBid,
|
|
630
|
-
sessionLowOffer: point.sessionLowOffer,
|
|
631
|
-
earlyPrices: point.earlyPrices,
|
|
632
|
-
auctionClearingPrice: point.auctionClearingPrice,
|
|
633
|
-
swapValueFactor: point.swapValueFactor,
|
|
634
|
-
dailyValueAdjustmentForLongPositions: point.dailyValueAdjustmentForLongPositions,
|
|
635
|
-
cumulativeValueAdjustmentForLongPositions: point.cumulativeValueAdjustmentForLongPositions,
|
|
636
|
-
dailyValueAdjustmentForShortPositions: point.dailyValueAdjustmentForShortPositions,
|
|
637
|
-
cumulativeValueAdjustmentForShortPositions: point.cumulativeValueAdjustmentForShortPositions,
|
|
638
|
-
fixingPrice: point.fixingPrice,
|
|
639
|
-
cashRate: point.cashRate,
|
|
640
|
-
recoveryRate: point.recoveryRate,
|
|
641
|
-
recoveryRateForLong: point.recoveryRateForLong,
|
|
642
|
-
recoveryRateForShort: point.recoveryRateForShort,
|
|
643
|
-
marketBid: point.marketBid,
|
|
644
|
-
marketOffer: point.marketOffer,
|
|
645
|
-
shortSaleMinPrice: point.shortSaleMinPrice,
|
|
646
|
-
previousClosingPrice: point.previousClosingPrice,
|
|
647
|
-
thresholdLimitPriceBanding: point.thresholdLimitPriceBanding,
|
|
648
|
-
dailyFinancingValue: point.dailyFinancingValue,
|
|
649
|
-
accruedFinancingValue: point.accruedFinancingValue,
|
|
650
|
-
twap: point.twap
|
|
474
|
+
volume: point.volume
|
|
651
475
|
}))
|
|
652
476
|
},
|
|
653
477
|
null,
|
|
@@ -662,7 +486,7 @@ var createGetStockPriceHistoryHandler = (marketDataPrices) => {
|
|
|
662
486
|
content: [
|
|
663
487
|
{
|
|
664
488
|
type: "text",
|
|
665
|
-
text: `Error: ${error instanceof Error ? error.message : "Failed to get price history"}`,
|
|
489
|
+
text: `Error: ${error instanceof Error ? error.message : "Failed to get stock price history"}`,
|
|
666
490
|
uri: "getStockPriceHistory"
|
|
667
491
|
}
|
|
668
492
|
],
|
|
@@ -770,7 +594,7 @@ Parameters verified:
|
|
|
770
594
|
- Symbol: ${args.symbol}
|
|
771
595
|
- TimeInForce: ${args.timeInForce} (${timeInForceNames[args.timeInForce]})
|
|
772
596
|
|
|
773
|
-
To execute this order, call the executeOrder tool with these exact same parameters
|
|
597
|
+
To execute this order, call the executeOrder tool with these exact same parameters.`,
|
|
774
598
|
uri: "verifyOrder"
|
|
775
599
|
}
|
|
776
600
|
]
|
|
@@ -969,255 +793,9 @@ var createToolHandlers = (parser, verifiedOrders, pendingRequests, marketDataPri
|
|
|
969
793
|
getStockPriceHistory: createGetStockPriceHistoryHandler(marketDataPrices)
|
|
970
794
|
});
|
|
971
795
|
|
|
972
|
-
// src/utils/messageHandler.ts
|
|
973
|
-
var import_fixparser3 = require("fixparser");
|
|
974
|
-
function getEnumValue(enumObj, name) {
|
|
975
|
-
return enumObj[name] || name;
|
|
976
|
-
}
|
|
977
|
-
function handleMessage(message, parser, pendingRequests, marketDataPrices, maxPriceHistory, onPriceUpdate) {
|
|
978
|
-
const msgType = message.messageType;
|
|
979
|
-
if (msgType === import_fixparser3.Messages.MarketDataSnapshotFullRefresh || msgType === import_fixparser3.Messages.MarketDataIncrementalRefresh) {
|
|
980
|
-
const symbol = message.getField(import_fixparser3.Fields.Symbol)?.value;
|
|
981
|
-
const fixJson = message.toFIXJSON();
|
|
982
|
-
const entries = fixJson.Body?.NoMDEntries || [];
|
|
983
|
-
const data = {
|
|
984
|
-
timestamp: Date.now(),
|
|
985
|
-
bid: 0,
|
|
986
|
-
offer: 0,
|
|
987
|
-
spread: 0,
|
|
988
|
-
volume: 0,
|
|
989
|
-
trade: 0,
|
|
990
|
-
indexValue: 0,
|
|
991
|
-
openingPrice: 0,
|
|
992
|
-
closingPrice: 0,
|
|
993
|
-
settlementPrice: 0,
|
|
994
|
-
tradingSessionHighPrice: 0,
|
|
995
|
-
tradingSessionLowPrice: 0,
|
|
996
|
-
vwap: 0,
|
|
997
|
-
imbalance: 0,
|
|
998
|
-
openInterest: 0,
|
|
999
|
-
compositeUnderlyingPrice: 0,
|
|
1000
|
-
simulatedSellPrice: 0,
|
|
1001
|
-
simulatedBuyPrice: 0,
|
|
1002
|
-
marginRate: 0,
|
|
1003
|
-
midPrice: 0,
|
|
1004
|
-
emptyBook: 0,
|
|
1005
|
-
settleHighPrice: 0,
|
|
1006
|
-
settleLowPrice: 0,
|
|
1007
|
-
priorSettlePrice: 0,
|
|
1008
|
-
sessionHighBid: 0,
|
|
1009
|
-
sessionLowOffer: 0,
|
|
1010
|
-
earlyPrices: 0,
|
|
1011
|
-
auctionClearingPrice: 0,
|
|
1012
|
-
swapValueFactor: 0,
|
|
1013
|
-
dailyValueAdjustmentForLongPositions: 0,
|
|
1014
|
-
cumulativeValueAdjustmentForLongPositions: 0,
|
|
1015
|
-
dailyValueAdjustmentForShortPositions: 0,
|
|
1016
|
-
cumulativeValueAdjustmentForShortPositions: 0,
|
|
1017
|
-
fixingPrice: 0,
|
|
1018
|
-
cashRate: 0,
|
|
1019
|
-
recoveryRate: 0,
|
|
1020
|
-
recoveryRateForLong: 0,
|
|
1021
|
-
recoveryRateForShort: 0,
|
|
1022
|
-
marketBid: 0,
|
|
1023
|
-
marketOffer: 0,
|
|
1024
|
-
shortSaleMinPrice: 0,
|
|
1025
|
-
previousClosingPrice: 0,
|
|
1026
|
-
thresholdLimitPriceBanding: 0,
|
|
1027
|
-
dailyFinancingValue: 0,
|
|
1028
|
-
accruedFinancingValue: 0,
|
|
1029
|
-
twap: 0
|
|
1030
|
-
};
|
|
1031
|
-
for (const entry of entries) {
|
|
1032
|
-
const entryType = entry.MDEntryType;
|
|
1033
|
-
const price = entry.MDEntryPx ? Number.parseFloat(entry.MDEntryPx) : 0;
|
|
1034
|
-
const size = entry.MDEntrySize ? Number.parseFloat(entry.MDEntrySize) : 0;
|
|
1035
|
-
const enumValue = getEnumValue(import_fixparser3.MDEntryType, entryType);
|
|
1036
|
-
switch (enumValue) {
|
|
1037
|
-
case import_fixparser3.MDEntryType.Bid:
|
|
1038
|
-
data.bid = price;
|
|
1039
|
-
break;
|
|
1040
|
-
case import_fixparser3.MDEntryType.Offer:
|
|
1041
|
-
data.offer = price;
|
|
1042
|
-
break;
|
|
1043
|
-
case import_fixparser3.MDEntryType.Trade:
|
|
1044
|
-
data.trade = price;
|
|
1045
|
-
break;
|
|
1046
|
-
case import_fixparser3.MDEntryType.IndexValue:
|
|
1047
|
-
data.indexValue = price;
|
|
1048
|
-
break;
|
|
1049
|
-
case import_fixparser3.MDEntryType.OpeningPrice:
|
|
1050
|
-
data.openingPrice = price;
|
|
1051
|
-
break;
|
|
1052
|
-
case import_fixparser3.MDEntryType.ClosingPrice:
|
|
1053
|
-
data.closingPrice = price;
|
|
1054
|
-
break;
|
|
1055
|
-
case import_fixparser3.MDEntryType.SettlementPrice:
|
|
1056
|
-
data.settlementPrice = price;
|
|
1057
|
-
break;
|
|
1058
|
-
case import_fixparser3.MDEntryType.TradingSessionHighPrice:
|
|
1059
|
-
data.tradingSessionHighPrice = price;
|
|
1060
|
-
break;
|
|
1061
|
-
case import_fixparser3.MDEntryType.TradingSessionLowPrice:
|
|
1062
|
-
data.tradingSessionLowPrice = price;
|
|
1063
|
-
break;
|
|
1064
|
-
case import_fixparser3.MDEntryType.VWAP:
|
|
1065
|
-
data.vwap = price;
|
|
1066
|
-
break;
|
|
1067
|
-
case import_fixparser3.MDEntryType.Imbalance:
|
|
1068
|
-
data.imbalance = size;
|
|
1069
|
-
break;
|
|
1070
|
-
case import_fixparser3.MDEntryType.TradeVolume:
|
|
1071
|
-
data.volume = size;
|
|
1072
|
-
break;
|
|
1073
|
-
case import_fixparser3.MDEntryType.OpenInterest:
|
|
1074
|
-
data.openInterest = size;
|
|
1075
|
-
break;
|
|
1076
|
-
case import_fixparser3.MDEntryType.CompositeUnderlyingPrice:
|
|
1077
|
-
data.compositeUnderlyingPrice = price;
|
|
1078
|
-
break;
|
|
1079
|
-
case import_fixparser3.MDEntryType.SimulatedSellPrice:
|
|
1080
|
-
data.simulatedSellPrice = price;
|
|
1081
|
-
break;
|
|
1082
|
-
case import_fixparser3.MDEntryType.SimulatedBuyPrice:
|
|
1083
|
-
data.simulatedBuyPrice = price;
|
|
1084
|
-
break;
|
|
1085
|
-
case import_fixparser3.MDEntryType.MarginRate:
|
|
1086
|
-
data.marginRate = price;
|
|
1087
|
-
break;
|
|
1088
|
-
case import_fixparser3.MDEntryType.MidPrice:
|
|
1089
|
-
data.midPrice = price;
|
|
1090
|
-
break;
|
|
1091
|
-
case import_fixparser3.MDEntryType.EmptyBook:
|
|
1092
|
-
data.emptyBook = 1;
|
|
1093
|
-
break;
|
|
1094
|
-
case import_fixparser3.MDEntryType.SettleHighPrice:
|
|
1095
|
-
data.settleHighPrice = price;
|
|
1096
|
-
break;
|
|
1097
|
-
case import_fixparser3.MDEntryType.SettleLowPrice:
|
|
1098
|
-
data.settleLowPrice = price;
|
|
1099
|
-
break;
|
|
1100
|
-
case import_fixparser3.MDEntryType.PriorSettlePrice:
|
|
1101
|
-
data.priorSettlePrice = price;
|
|
1102
|
-
break;
|
|
1103
|
-
case import_fixparser3.MDEntryType.SessionHighBid:
|
|
1104
|
-
data.sessionHighBid = price;
|
|
1105
|
-
break;
|
|
1106
|
-
case import_fixparser3.MDEntryType.SessionLowOffer:
|
|
1107
|
-
data.sessionLowOffer = price;
|
|
1108
|
-
break;
|
|
1109
|
-
case import_fixparser3.MDEntryType.EarlyPrices:
|
|
1110
|
-
data.earlyPrices = price;
|
|
1111
|
-
break;
|
|
1112
|
-
case import_fixparser3.MDEntryType.AuctionClearingPrice:
|
|
1113
|
-
data.auctionClearingPrice = price;
|
|
1114
|
-
break;
|
|
1115
|
-
case import_fixparser3.MDEntryType.SwapValueFactor:
|
|
1116
|
-
data.swapValueFactor = price;
|
|
1117
|
-
break;
|
|
1118
|
-
case import_fixparser3.MDEntryType.DailyValueAdjustmentForLongPositions:
|
|
1119
|
-
data.dailyValueAdjustmentForLongPositions = price;
|
|
1120
|
-
break;
|
|
1121
|
-
case import_fixparser3.MDEntryType.CumulativeValueAdjustmentForLongPositions:
|
|
1122
|
-
data.cumulativeValueAdjustmentForLongPositions = price;
|
|
1123
|
-
break;
|
|
1124
|
-
case import_fixparser3.MDEntryType.DailyValueAdjustmentForShortPositions:
|
|
1125
|
-
data.dailyValueAdjustmentForShortPositions = price;
|
|
1126
|
-
break;
|
|
1127
|
-
case import_fixparser3.MDEntryType.CumulativeValueAdjustmentForShortPositions:
|
|
1128
|
-
data.cumulativeValueAdjustmentForShortPositions = price;
|
|
1129
|
-
break;
|
|
1130
|
-
case import_fixparser3.MDEntryType.FixingPrice:
|
|
1131
|
-
data.fixingPrice = price;
|
|
1132
|
-
break;
|
|
1133
|
-
case import_fixparser3.MDEntryType.CashRate:
|
|
1134
|
-
data.cashRate = price;
|
|
1135
|
-
break;
|
|
1136
|
-
case import_fixparser3.MDEntryType.RecoveryRate:
|
|
1137
|
-
data.recoveryRate = price;
|
|
1138
|
-
break;
|
|
1139
|
-
case import_fixparser3.MDEntryType.RecoveryRateForLong:
|
|
1140
|
-
data.recoveryRateForLong = price;
|
|
1141
|
-
break;
|
|
1142
|
-
case import_fixparser3.MDEntryType.RecoveryRateForShort:
|
|
1143
|
-
data.recoveryRateForShort = price;
|
|
1144
|
-
break;
|
|
1145
|
-
case import_fixparser3.MDEntryType.MarketBid:
|
|
1146
|
-
data.marketBid = price;
|
|
1147
|
-
break;
|
|
1148
|
-
case import_fixparser3.MDEntryType.MarketOffer:
|
|
1149
|
-
data.marketOffer = price;
|
|
1150
|
-
break;
|
|
1151
|
-
case import_fixparser3.MDEntryType.ShortSaleMinPrice:
|
|
1152
|
-
data.shortSaleMinPrice = price;
|
|
1153
|
-
break;
|
|
1154
|
-
case import_fixparser3.MDEntryType.PreviousClosingPrice:
|
|
1155
|
-
data.previousClosingPrice = price;
|
|
1156
|
-
break;
|
|
1157
|
-
case import_fixparser3.MDEntryType.ThresholdLimitPriceBanding:
|
|
1158
|
-
data.thresholdLimitPriceBanding = price;
|
|
1159
|
-
break;
|
|
1160
|
-
case import_fixparser3.MDEntryType.DailyFinancingValue:
|
|
1161
|
-
data.dailyFinancingValue = price;
|
|
1162
|
-
break;
|
|
1163
|
-
case import_fixparser3.MDEntryType.AccruedFinancingValue:
|
|
1164
|
-
data.accruedFinancingValue = price;
|
|
1165
|
-
break;
|
|
1166
|
-
case import_fixparser3.MDEntryType.TWAP:
|
|
1167
|
-
data.twap = price;
|
|
1168
|
-
break;
|
|
1169
|
-
}
|
|
1170
|
-
}
|
|
1171
|
-
data.spread = data.offer - data.bid;
|
|
1172
|
-
if (!marketDataPrices.has(symbol)) {
|
|
1173
|
-
marketDataPrices.set(symbol, []);
|
|
1174
|
-
}
|
|
1175
|
-
const prices = marketDataPrices.get(symbol);
|
|
1176
|
-
prices.push(data);
|
|
1177
|
-
if (prices.length > maxPriceHistory) {
|
|
1178
|
-
prices.splice(0, prices.length - maxPriceHistory);
|
|
1179
|
-
}
|
|
1180
|
-
onPriceUpdate?.(symbol, data);
|
|
1181
|
-
const mdReqID = message.getField(import_fixparser3.Fields.MDReqID)?.value;
|
|
1182
|
-
if (mdReqID) {
|
|
1183
|
-
const callback = pendingRequests.get(mdReqID);
|
|
1184
|
-
if (callback) {
|
|
1185
|
-
callback(message);
|
|
1186
|
-
pendingRequests.delete(mdReqID);
|
|
1187
|
-
}
|
|
1188
|
-
}
|
|
1189
|
-
} else if (msgType === import_fixparser3.Messages.ExecutionReport) {
|
|
1190
|
-
const reqId = message.getField(import_fixparser3.Fields.ClOrdID)?.value;
|
|
1191
|
-
const callback = pendingRequests.get(reqId);
|
|
1192
|
-
if (callback) {
|
|
1193
|
-
callback(message);
|
|
1194
|
-
pendingRequests.delete(reqId);
|
|
1195
|
-
}
|
|
1196
|
-
}
|
|
1197
|
-
}
|
|
1198
|
-
|
|
1199
796
|
// src/MCPLocal.ts
|
|
1200
|
-
var MCPLocal = class
|
|
1201
|
-
|
|
1202
|
-
* Map to store verified orders before execution
|
|
1203
|
-
* @private
|
|
1204
|
-
*/
|
|
1205
|
-
verifiedOrders = /* @__PURE__ */ new Map();
|
|
1206
|
-
/**
|
|
1207
|
-
* Map to store pending requests and their callbacks
|
|
1208
|
-
* @private
|
|
1209
|
-
*/
|
|
1210
|
-
pendingRequests = /* @__PURE__ */ new Map();
|
|
1211
|
-
/**
|
|
1212
|
-
* Map to store market data prices for each symbol
|
|
1213
|
-
* @private
|
|
1214
|
-
*/
|
|
1215
|
-
marketDataPrices = /* @__PURE__ */ new Map();
|
|
1216
|
-
/**
|
|
1217
|
-
* Maximum number of price history entries to keep per symbol
|
|
1218
|
-
* @private
|
|
1219
|
-
*/
|
|
1220
|
-
MAX_PRICE_HISTORY = 1e5;
|
|
797
|
+
var MCPLocal = class {
|
|
798
|
+
parser;
|
|
1221
799
|
server = new import_server.Server(
|
|
1222
800
|
{
|
|
1223
801
|
name: "fixparser",
|
|
@@ -1239,13 +817,90 @@ var MCPLocal = class extends MCPBase {
|
|
|
1239
817
|
}
|
|
1240
818
|
);
|
|
1241
819
|
transport = new import_stdio.StdioServerTransport();
|
|
820
|
+
onReady = void 0;
|
|
821
|
+
pendingRequests = /* @__PURE__ */ new Map();
|
|
822
|
+
verifiedOrders = /* @__PURE__ */ new Map();
|
|
823
|
+
marketDataPrices = /* @__PURE__ */ new Map();
|
|
824
|
+
MAX_PRICE_HISTORY = 1e5;
|
|
825
|
+
// Maximum number of price points to store per symbol
|
|
1242
826
|
constructor({ logger, onReady }) {
|
|
1243
|
-
|
|
827
|
+
if (onReady) this.onReady = onReady;
|
|
1244
828
|
}
|
|
1245
829
|
async register(parser) {
|
|
1246
830
|
this.parser = parser;
|
|
1247
831
|
this.parser.addOnMessageCallback((message) => {
|
|
1248
|
-
|
|
832
|
+
this.parser?.logger.log({
|
|
833
|
+
level: "info",
|
|
834
|
+
message: `MCP Server received message: ${message.messageType}: ${message.description}`
|
|
835
|
+
});
|
|
836
|
+
const msgType = message.messageType;
|
|
837
|
+
if (msgType === import_fixparser3.Messages.MarketDataSnapshotFullRefresh || msgType === import_fixparser3.Messages.ExecutionReport || msgType === import_fixparser3.Messages.Reject || msgType === import_fixparser3.Messages.MarketDataIncrementalRefresh) {
|
|
838
|
+
this.parser?.logger.log({
|
|
839
|
+
level: "info",
|
|
840
|
+
message: `MCP Server handling message type: ${msgType}`
|
|
841
|
+
});
|
|
842
|
+
let id;
|
|
843
|
+
if (msgType === import_fixparser3.Messages.MarketDataIncrementalRefresh || msgType === import_fixparser3.Messages.MarketDataSnapshotFullRefresh) {
|
|
844
|
+
const symbol = message.getField(import_fixparser3.Fields.Symbol);
|
|
845
|
+
const entryType = message.getField(import_fixparser3.Fields.MDEntryType);
|
|
846
|
+
const price = message.getField(import_fixparser3.Fields.MDEntryPx);
|
|
847
|
+
const size = message.getField(import_fixparser3.Fields.MDEntrySize);
|
|
848
|
+
const timestamp = message.getField(import_fixparser3.Fields.MDEntryTime)?.value || Date.now();
|
|
849
|
+
if (symbol?.value && price?.value) {
|
|
850
|
+
const symbolStr = String(symbol.value);
|
|
851
|
+
const priceNum = Number(price.value);
|
|
852
|
+
const sizeNum = size?.value ? Number(size.value) : 0;
|
|
853
|
+
const priceHistory = this.marketDataPrices.get(symbolStr) || [];
|
|
854
|
+
const lastEntry = priceHistory[priceHistory.length - 1] || {
|
|
855
|
+
timestamp: 0,
|
|
856
|
+
bid: 0,
|
|
857
|
+
offer: 0,
|
|
858
|
+
spread: 0,
|
|
859
|
+
volume: 0
|
|
860
|
+
};
|
|
861
|
+
const newEntry = {
|
|
862
|
+
timestamp: Number(timestamp),
|
|
863
|
+
bid: entryType?.value === import_fixparser3.MDEntryType.Bid ? priceNum : lastEntry.bid,
|
|
864
|
+
offer: entryType?.value === import_fixparser3.MDEntryType.Offer ? priceNum : lastEntry.offer,
|
|
865
|
+
spread: entryType?.value === import_fixparser3.MDEntryType.Offer ? priceNum - lastEntry.bid : entryType?.value === import_fixparser3.MDEntryType.Bid ? lastEntry.offer - priceNum : lastEntry.spread,
|
|
866
|
+
volume: entryType?.value === import_fixparser3.MDEntryType.TradeVolume ? sizeNum : lastEntry.volume
|
|
867
|
+
};
|
|
868
|
+
priceHistory.push(newEntry);
|
|
869
|
+
if (priceHistory.length > this.MAX_PRICE_HISTORY) {
|
|
870
|
+
priceHistory.shift();
|
|
871
|
+
}
|
|
872
|
+
this.marketDataPrices.set(symbolStr, priceHistory);
|
|
873
|
+
this.parser?.logger.log({
|
|
874
|
+
level: "info",
|
|
875
|
+
message: `MCP Server added ${symbol}: ${JSON.stringify(newEntry)}`
|
|
876
|
+
});
|
|
877
|
+
this.server.notification({
|
|
878
|
+
method: "priceUpdate",
|
|
879
|
+
params: {
|
|
880
|
+
symbol: symbolStr,
|
|
881
|
+
...newEntry
|
|
882
|
+
}
|
|
883
|
+
});
|
|
884
|
+
}
|
|
885
|
+
}
|
|
886
|
+
if (msgType === import_fixparser3.Messages.MarketDataSnapshotFullRefresh) {
|
|
887
|
+
const mdReqID = message.getField(import_fixparser3.Fields.MDReqID);
|
|
888
|
+
if (mdReqID) id = String(mdReqID.value);
|
|
889
|
+
} else if (msgType === import_fixparser3.Messages.ExecutionReport) {
|
|
890
|
+
const clOrdID = message.getField(import_fixparser3.Fields.ClOrdID);
|
|
891
|
+
if (clOrdID) id = String(clOrdID.value);
|
|
892
|
+
} else if (msgType === import_fixparser3.Messages.Reject) {
|
|
893
|
+
const refSeqNum = message.getField(import_fixparser3.Fields.RefSeqNum);
|
|
894
|
+
if (refSeqNum) id = String(refSeqNum.value);
|
|
895
|
+
}
|
|
896
|
+
if (id) {
|
|
897
|
+
const callback = this.pendingRequests.get(id);
|
|
898
|
+
if (callback) {
|
|
899
|
+
callback(message);
|
|
900
|
+
this.pendingRequests.delete(id);
|
|
901
|
+
}
|
|
902
|
+
}
|
|
903
|
+
}
|
|
1249
904
|
});
|
|
1250
905
|
this.addWorkflows();
|
|
1251
906
|
await this.server.connect(this.transport);
|
|
@@ -1260,15 +915,18 @@ var MCPLocal = class extends MCPBase {
|
|
|
1260
915
|
if (!this.server) {
|
|
1261
916
|
return;
|
|
1262
917
|
}
|
|
1263
|
-
this.server.setRequestHandler(
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
description,
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
918
|
+
this.server.setRequestHandler(
|
|
919
|
+
import_zod.z.object({ method: import_zod.z.literal("tools/list") }),
|
|
920
|
+
async (request, extra) => {
|
|
921
|
+
return {
|
|
922
|
+
tools: Object.entries(toolSchemas).map(([name, { description, schema }]) => ({
|
|
923
|
+
name,
|
|
924
|
+
description,
|
|
925
|
+
inputSchema: schema
|
|
926
|
+
}))
|
|
927
|
+
};
|
|
928
|
+
}
|
|
929
|
+
);
|
|
1272
930
|
this.server.setRequestHandler(
|
|
1273
931
|
import_zod.z.object({
|
|
1274
932
|
method: import_zod.z.literal("tools/call"),
|
|
@@ -1280,7 +938,7 @@ var MCPLocal = class extends MCPBase {
|
|
|
1280
938
|
}).optional()
|
|
1281
939
|
})
|
|
1282
940
|
}),
|
|
1283
|
-
async (request) => {
|
|
941
|
+
async (request, extra) => {
|
|
1284
942
|
const { name, arguments: args } = request.params;
|
|
1285
943
|
const toolHandlers = createToolHandlers(
|
|
1286
944
|
this.parser,
|