fixparser-plugin-mcp 9.1.7-2eb6d03c → 9.1.7-3302db05
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 +886 -609
- package/build/cjs/MCPLocal.js.map +4 -4
- package/build/esm/MCPLocal.mjs +876 -624
- package/build/esm/MCPLocal.mjs.map +4 -4
- package/build-examples/cjs/example_mcp_local.js +14 -3
- package/build-examples/cjs/example_mcp_local.js.map +4 -4
- package/build-examples/esm/example_mcp_local.mjs +14 -3
- package/build-examples/esm/example_mcp_local.mjs.map +4 -4
- package/package.json +12 -11
- package/types/MCPLocal.d.ts +3 -1
- package/types/schemas/index.d.ts +15 -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 +12 -0
- package/types/tools/parse.d.ts +5 -0
- package/types/tools/parseToJSON.d.ts +5 -0
package/build/esm/MCPLocal.mjs
CHANGED
|
@@ -1,194 +1,767 @@
|
|
|
1
1
|
// src/MCPLocal.ts
|
|
2
2
|
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
3
3
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
OrdType,
|
|
18
|
-
SubscriptionRequestType,
|
|
19
|
-
TimeInForce
|
|
20
|
-
} from "fixparser";
|
|
21
|
-
var parseInputSchema = {
|
|
22
|
-
type: "object",
|
|
23
|
-
properties: {
|
|
24
|
-
fixString: {
|
|
25
|
-
type: "string",
|
|
26
|
-
description: "FIX message string to parse"
|
|
4
|
+
import { Fields as Fields3, MDEntryType as MDEntryType2, Messages as Messages3 } from "fixparser";
|
|
5
|
+
import { z } from "zod";
|
|
6
|
+
|
|
7
|
+
// src/schemas/schemas.ts
|
|
8
|
+
var toolSchemas = {
|
|
9
|
+
parse: {
|
|
10
|
+
description: "Parses a FIX message and describes it in plain language",
|
|
11
|
+
schema: {
|
|
12
|
+
type: "object",
|
|
13
|
+
properties: {
|
|
14
|
+
fixString: { type: "string" }
|
|
15
|
+
},
|
|
16
|
+
required: ["fixString"]
|
|
27
17
|
}
|
|
28
18
|
},
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
19
|
+
parseToJSON: {
|
|
20
|
+
description: "Parses a FIX message into JSON",
|
|
21
|
+
schema: {
|
|
22
|
+
type: "object",
|
|
23
|
+
properties: {
|
|
24
|
+
fixString: { type: "string" }
|
|
25
|
+
},
|
|
26
|
+
required: ["fixString"]
|
|
37
27
|
}
|
|
38
28
|
},
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
"
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
enum: ["1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F", "G", "H"],
|
|
98
|
-
description: "Order side (1=Buy, 2=Sell)"
|
|
99
|
-
},
|
|
100
|
-
symbol: {
|
|
101
|
-
type: "string",
|
|
102
|
-
description: "Trading symbol"
|
|
103
|
-
},
|
|
104
|
-
timeInForce: {
|
|
105
|
-
type: "string",
|
|
106
|
-
enum: ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C"],
|
|
107
|
-
default: TimeInForce.Day,
|
|
108
|
-
description: "Time in force"
|
|
29
|
+
verifyOrder: {
|
|
30
|
+
description: "Verifies order parameters before execution. verifyOrder must be called before executeOrder.",
|
|
31
|
+
schema: {
|
|
32
|
+
type: "object",
|
|
33
|
+
properties: {
|
|
34
|
+
clOrdID: { type: "string" },
|
|
35
|
+
handlInst: {
|
|
36
|
+
type: "string",
|
|
37
|
+
enum: ["1", "2", "3"],
|
|
38
|
+
description: "Handling Instructions: 1=Automated Execution No Intervention, 2=Automated Execution Intervention OK, 3=Manual Order"
|
|
39
|
+
},
|
|
40
|
+
quantity: { type: "string" },
|
|
41
|
+
price: { type: "string" },
|
|
42
|
+
ordType: {
|
|
43
|
+
type: "string",
|
|
44
|
+
enum: [
|
|
45
|
+
"1",
|
|
46
|
+
"2",
|
|
47
|
+
"3",
|
|
48
|
+
"4",
|
|
49
|
+
"5",
|
|
50
|
+
"6",
|
|
51
|
+
"7",
|
|
52
|
+
"8",
|
|
53
|
+
"9",
|
|
54
|
+
"A",
|
|
55
|
+
"B",
|
|
56
|
+
"C",
|
|
57
|
+
"D",
|
|
58
|
+
"E",
|
|
59
|
+
"F",
|
|
60
|
+
"G",
|
|
61
|
+
"H",
|
|
62
|
+
"I",
|
|
63
|
+
"J",
|
|
64
|
+
"K",
|
|
65
|
+
"L",
|
|
66
|
+
"M",
|
|
67
|
+
"P",
|
|
68
|
+
"Q",
|
|
69
|
+
"R",
|
|
70
|
+
"S"
|
|
71
|
+
],
|
|
72
|
+
description: "Order Type: 1=Market, 2=Limit, 3=Stop, 4=StopLimit, 5=MarketOnClose, 6=WithOrWithout, 7=LimitOrBetter, 8=LimitWithOrWithout, 9=OnBasis, A=OnClose, B=LimitOnClose, C=ForexMarket, D=PreviouslyQuoted, E=PreviouslyIndicated, F=ForexLimit, G=ForexSwap, H=ForexPreviouslyQuoted, I=Funari, J=MarketIfTouched, K=MarketWithLeftOverAsLimit, L=PreviousFundValuationPoint, M=NextFundValuationPoint, P=Pegged, Q=CounterOrderSelection, R=StopOnBidOrOffer, S=StopLimitOnBidOrOffer"
|
|
73
|
+
},
|
|
74
|
+
side: {
|
|
75
|
+
type: "string",
|
|
76
|
+
enum: ["1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F", "G", "H"],
|
|
77
|
+
description: "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"
|
|
78
|
+
},
|
|
79
|
+
symbol: { type: "string" },
|
|
80
|
+
timeInForce: {
|
|
81
|
+
type: "string",
|
|
82
|
+
enum: ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C"],
|
|
83
|
+
description: "Time In Force: 0=Day, 1=GoodTillCancel, 2=AtTheOpening, 3=ImmediateOrCancel, 4=FillOrKill, 5=GoodTillCrossing, 6=GoodTillDate, 7=AtTheClose, 8=GoodThroughCrossing, 9=AtCrossing, A=GoodForTime, B=GoodForAuction, C=GoodForMonth"
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
required: ["clOrdID", "handlInst", "quantity", "price", "ordType", "side", "symbol", "timeInForce"]
|
|
109
87
|
}
|
|
110
88
|
},
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
"
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
"V",
|
|
170
|
-
"W",
|
|
171
|
-
"X",
|
|
172
|
-
"Y",
|
|
173
|
-
"Z",
|
|
174
|
-
"a",
|
|
175
|
-
"b",
|
|
176
|
-
"c",
|
|
177
|
-
"d",
|
|
178
|
-
"e",
|
|
179
|
-
"g",
|
|
180
|
-
"h",
|
|
181
|
-
"i",
|
|
182
|
-
"t"
|
|
183
|
-
],
|
|
184
|
-
default: MDEntryType.Bid,
|
|
185
|
-
description: "Market data entry type"
|
|
89
|
+
executeOrder: {
|
|
90
|
+
description: "Executes a verified order. verifyOrder must be called before executeOrder. user has to explicitly allow executeOrder.",
|
|
91
|
+
schema: {
|
|
92
|
+
type: "object",
|
|
93
|
+
properties: {
|
|
94
|
+
clOrdID: { type: "string" },
|
|
95
|
+
handlInst: {
|
|
96
|
+
type: "string",
|
|
97
|
+
enum: ["1", "2", "3"],
|
|
98
|
+
description: "Handling Instructions: 1=Automated Execution No Intervention, 2=Automated Execution Intervention OK, 3=Manual Order"
|
|
99
|
+
},
|
|
100
|
+
quantity: { type: "string" },
|
|
101
|
+
price: { type: "string" },
|
|
102
|
+
ordType: {
|
|
103
|
+
type: "string",
|
|
104
|
+
enum: [
|
|
105
|
+
"1",
|
|
106
|
+
"2",
|
|
107
|
+
"3",
|
|
108
|
+
"4",
|
|
109
|
+
"5",
|
|
110
|
+
"6",
|
|
111
|
+
"7",
|
|
112
|
+
"8",
|
|
113
|
+
"9",
|
|
114
|
+
"A",
|
|
115
|
+
"B",
|
|
116
|
+
"C",
|
|
117
|
+
"D",
|
|
118
|
+
"E",
|
|
119
|
+
"F",
|
|
120
|
+
"G",
|
|
121
|
+
"H",
|
|
122
|
+
"I",
|
|
123
|
+
"J",
|
|
124
|
+
"K",
|
|
125
|
+
"L",
|
|
126
|
+
"M",
|
|
127
|
+
"P",
|
|
128
|
+
"Q",
|
|
129
|
+
"R",
|
|
130
|
+
"S"
|
|
131
|
+
],
|
|
132
|
+
description: "Order Type: 1=Market, 2=Limit, 3=Stop, 4=StopLimit, 5=MarketOnClose, 6=WithOrWithout, 7=LimitOrBetter, 8=LimitWithOrWithout, 9=OnBasis, A=OnClose, B=LimitOnClose, C=ForexMarket, D=PreviouslyQuoted, E=PreviouslyIndicated, F=ForexLimit, G=ForexSwap, H=ForexPreviouslyQuoted, I=Funari, J=MarketIfTouched, K=MarketWithLeftOverAsLimit, L=PreviousFundValuationPoint, M=NextFundValuationPoint, P=Pegged, Q=CounterOrderSelection, R=StopOnBidOrOffer, S=StopLimitOnBidOrOffer"
|
|
133
|
+
},
|
|
134
|
+
side: {
|
|
135
|
+
type: "string",
|
|
136
|
+
enum: ["1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F", "G", "H"],
|
|
137
|
+
description: "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"
|
|
138
|
+
},
|
|
139
|
+
symbol: { type: "string" },
|
|
140
|
+
timeInForce: {
|
|
141
|
+
type: "string",
|
|
142
|
+
enum: ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C"],
|
|
143
|
+
description: "Time In Force: 0=Day, 1=GoodTillCancel, 2=AtTheOpening, 3=ImmediateOrCancel, 4=FillOrKill, 5=GoodTillCrossing, 6=GoodTillDate, 7=AtTheClose, 8=GoodThroughCrossing, 9=AtCrossing, A=GoodForTime, B=GoodForAuction, C=GoodForMonth"
|
|
144
|
+
}
|
|
145
|
+
},
|
|
146
|
+
required: ["clOrdID", "handlInst", "quantity", "price", "ordType", "side", "symbol", "timeInForce"]
|
|
186
147
|
}
|
|
187
148
|
},
|
|
188
|
-
|
|
149
|
+
marketDataRequest: {
|
|
150
|
+
description: "Requests market data for specified symbols",
|
|
151
|
+
schema: {
|
|
152
|
+
type: "object",
|
|
153
|
+
properties: {
|
|
154
|
+
mdUpdateType: {
|
|
155
|
+
type: "string",
|
|
156
|
+
enum: ["0", "1"],
|
|
157
|
+
description: "Market Data Update Type: 0=Full Refresh, 1=Incremental Refresh"
|
|
158
|
+
},
|
|
159
|
+
symbols: { type: "array", items: { type: "string" } },
|
|
160
|
+
mdReqID: { type: "string" },
|
|
161
|
+
subscriptionRequestType: {
|
|
162
|
+
type: "string",
|
|
163
|
+
enum: ["0", "1", "2"],
|
|
164
|
+
description: "Subscription Request Type: 0=Snapshot, 1=Snapshot + Updates, 2=Disable Previous Snapshot + Update Request"
|
|
165
|
+
},
|
|
166
|
+
mdEntryTypes: {
|
|
167
|
+
type: "array",
|
|
168
|
+
items: {
|
|
169
|
+
type: "string",
|
|
170
|
+
enum: [
|
|
171
|
+
"0",
|
|
172
|
+
"1",
|
|
173
|
+
"2",
|
|
174
|
+
"3",
|
|
175
|
+
"4",
|
|
176
|
+
"5",
|
|
177
|
+
"6",
|
|
178
|
+
"7",
|
|
179
|
+
"8",
|
|
180
|
+
"9",
|
|
181
|
+
"A",
|
|
182
|
+
"B",
|
|
183
|
+
"C",
|
|
184
|
+
"D",
|
|
185
|
+
"E",
|
|
186
|
+
"F",
|
|
187
|
+
"G",
|
|
188
|
+
"H",
|
|
189
|
+
"I",
|
|
190
|
+
"J",
|
|
191
|
+
"K",
|
|
192
|
+
"L",
|
|
193
|
+
"M",
|
|
194
|
+
"N",
|
|
195
|
+
"O",
|
|
196
|
+
"P",
|
|
197
|
+
"Q",
|
|
198
|
+
"R",
|
|
199
|
+
"S",
|
|
200
|
+
"T",
|
|
201
|
+
"U",
|
|
202
|
+
"V",
|
|
203
|
+
"W",
|
|
204
|
+
"X",
|
|
205
|
+
"Y",
|
|
206
|
+
"Z"
|
|
207
|
+
]
|
|
208
|
+
},
|
|
209
|
+
description: "Market Data Entry Types: 0=Bid, 1=Offer, 2=Trade, 3=Index Value, 4=Opening Price, 5=Closing Price, 6=Settlement Price, 7=High Price, 8=Low Price, 9=Trade Volume, A=Open Interest, B=Simulated Sell Price, C=Simulated Buy Price, D=Empty Book, E=Session High Bid, F=Session Low Offer, G=Fixing Price, H=Electronic Volume, I=Threshold Limits and Price Band Variation, J=Clearing Price, K=Open Interest Change, L=Last Trade Price, M=Last Trade Volume, N=Last Trade Time, O=Last Trade Tick, P=Last Trade Exchange, Q=Last Trade ID, R=Last Trade Side, S=Last Trade Price Change, T=Last Trade Price Change Percent, U=Last Trade Price Change Basis Points, V=Last Trade Price Change Points, W=Last Trade Price Change Ticks, X=Last Trade Price Change Ticks Percent, Y=Last Trade Price Change Ticks Basis Points, Z=Last Trade Price Change Ticks Points"
|
|
210
|
+
}
|
|
211
|
+
},
|
|
212
|
+
required: ["mdUpdateType", "symbols", "mdReqID", "subscriptionRequestType"]
|
|
213
|
+
}
|
|
214
|
+
},
|
|
215
|
+
getStockGraph: {
|
|
216
|
+
description: "Generates a price chart for a given symbol",
|
|
217
|
+
schema: {
|
|
218
|
+
type: "object",
|
|
219
|
+
properties: {
|
|
220
|
+
symbol: { type: "string" }
|
|
221
|
+
},
|
|
222
|
+
required: ["symbol"]
|
|
223
|
+
}
|
|
224
|
+
},
|
|
225
|
+
getStockPriceHistory: {
|
|
226
|
+
description: "Returns price history for a given symbol",
|
|
227
|
+
schema: {
|
|
228
|
+
type: "object",
|
|
229
|
+
properties: {
|
|
230
|
+
symbol: { type: "string" }
|
|
231
|
+
},
|
|
232
|
+
required: ["symbol"]
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
};
|
|
236
|
+
|
|
237
|
+
// src/tools/marketData.ts
|
|
238
|
+
import { Field, Fields, MDEntryType, Messages } from "fixparser";
|
|
239
|
+
import QuickChart from "quickchart-js";
|
|
240
|
+
var createMarketDataRequestHandler = (parser, pendingRequests) => {
|
|
241
|
+
return async (args) => {
|
|
242
|
+
try {
|
|
243
|
+
const response = new Promise((resolve) => {
|
|
244
|
+
pendingRequests.set(args.mdReqID, resolve);
|
|
245
|
+
});
|
|
246
|
+
const entryTypes = args.mdEntryTypes || [MDEntryType.Bid, MDEntryType.Offer, MDEntryType.TradeVolume];
|
|
247
|
+
const messageFields = [
|
|
248
|
+
new Field(Fields.MsgType, Messages.MarketDataRequest),
|
|
249
|
+
new Field(Fields.SenderCompID, parser.sender),
|
|
250
|
+
new Field(Fields.MsgSeqNum, parser.getNextTargetMsgSeqNum()),
|
|
251
|
+
new Field(Fields.TargetCompID, parser.target),
|
|
252
|
+
new Field(Fields.SendingTime, parser.getTimestamp()),
|
|
253
|
+
new Field(Fields.MDReqID, args.mdReqID),
|
|
254
|
+
new Field(Fields.SubscriptionRequestType, args.subscriptionRequestType),
|
|
255
|
+
new Field(Fields.MarketDepth, 0),
|
|
256
|
+
new Field(Fields.MDUpdateType, args.mdUpdateType)
|
|
257
|
+
];
|
|
258
|
+
messageFields.push(new Field(Fields.NoRelatedSym, args.symbols.length));
|
|
259
|
+
args.symbols.forEach((symbol) => {
|
|
260
|
+
messageFields.push(new Field(Fields.Symbol, symbol));
|
|
261
|
+
});
|
|
262
|
+
messageFields.push(new Field(Fields.NoMDEntryTypes, entryTypes.length));
|
|
263
|
+
entryTypes.forEach((entryType) => {
|
|
264
|
+
messageFields.push(new Field(Fields.MDEntryType, entryType));
|
|
265
|
+
});
|
|
266
|
+
const mdr = parser.createMessage(...messageFields);
|
|
267
|
+
if (!parser.connected) {
|
|
268
|
+
return {
|
|
269
|
+
content: [
|
|
270
|
+
{
|
|
271
|
+
type: "text",
|
|
272
|
+
text: "Error: Not connected. Ignoring message.",
|
|
273
|
+
uri: "marketDataRequest"
|
|
274
|
+
}
|
|
275
|
+
],
|
|
276
|
+
isError: true
|
|
277
|
+
};
|
|
278
|
+
}
|
|
279
|
+
parser.send(mdr);
|
|
280
|
+
const fixData = await response;
|
|
281
|
+
return {
|
|
282
|
+
content: [
|
|
283
|
+
{
|
|
284
|
+
type: "text",
|
|
285
|
+
text: `Market data for ${args.symbols.join(", ")}: ${JSON.stringify(fixData.toFIXJSON())}`,
|
|
286
|
+
uri: "marketDataRequest"
|
|
287
|
+
}
|
|
288
|
+
]
|
|
289
|
+
};
|
|
290
|
+
} catch (error) {
|
|
291
|
+
return {
|
|
292
|
+
content: [
|
|
293
|
+
{
|
|
294
|
+
type: "text",
|
|
295
|
+
text: `Error: ${error instanceof Error ? error.message : "Failed to request market data"}`,
|
|
296
|
+
uri: "marketDataRequest"
|
|
297
|
+
}
|
|
298
|
+
],
|
|
299
|
+
isError: true
|
|
300
|
+
};
|
|
301
|
+
}
|
|
302
|
+
};
|
|
303
|
+
};
|
|
304
|
+
var createGetStockGraphHandler = (marketDataPrices) => {
|
|
305
|
+
return async (args) => {
|
|
306
|
+
try {
|
|
307
|
+
const symbol = args.symbol;
|
|
308
|
+
const priceHistory = marketDataPrices.get(symbol) || [];
|
|
309
|
+
if (priceHistory.length === 0) {
|
|
310
|
+
return {
|
|
311
|
+
content: [
|
|
312
|
+
{
|
|
313
|
+
type: "text",
|
|
314
|
+
text: `No price data available for ${symbol}`,
|
|
315
|
+
uri: "getStockGraph"
|
|
316
|
+
}
|
|
317
|
+
]
|
|
318
|
+
};
|
|
319
|
+
}
|
|
320
|
+
const chart = new QuickChart();
|
|
321
|
+
chart.setWidth(1200);
|
|
322
|
+
chart.setHeight(600);
|
|
323
|
+
chart.setBackgroundColor("transparent");
|
|
324
|
+
const labels = priceHistory.map((point) => new Date(point.timestamp).toLocaleTimeString());
|
|
325
|
+
const bidData = priceHistory.map((point) => point.bid);
|
|
326
|
+
const offerData = priceHistory.map((point) => point.offer);
|
|
327
|
+
const spreadData = priceHistory.map((point) => point.spread);
|
|
328
|
+
const volumeData = priceHistory.map((point) => point.volume);
|
|
329
|
+
const config = {
|
|
330
|
+
type: "line",
|
|
331
|
+
data: {
|
|
332
|
+
labels,
|
|
333
|
+
datasets: [
|
|
334
|
+
{
|
|
335
|
+
label: "Bid",
|
|
336
|
+
data: bidData,
|
|
337
|
+
borderColor: "#28a745",
|
|
338
|
+
backgroundColor: "rgba(40, 167, 69, 0.1)",
|
|
339
|
+
fill: false,
|
|
340
|
+
tension: 0.4
|
|
341
|
+
},
|
|
342
|
+
{
|
|
343
|
+
label: "Offer",
|
|
344
|
+
data: offerData,
|
|
345
|
+
borderColor: "#dc3545",
|
|
346
|
+
backgroundColor: "rgba(220, 53, 69, 0.1)",
|
|
347
|
+
fill: false,
|
|
348
|
+
tension: 0.4
|
|
349
|
+
},
|
|
350
|
+
{
|
|
351
|
+
label: "Spread",
|
|
352
|
+
data: spreadData,
|
|
353
|
+
borderColor: "#6c757d",
|
|
354
|
+
backgroundColor: "rgba(108, 117, 125, 0.1)",
|
|
355
|
+
fill: false,
|
|
356
|
+
tension: 0.4
|
|
357
|
+
},
|
|
358
|
+
{
|
|
359
|
+
label: "Volume",
|
|
360
|
+
data: volumeData,
|
|
361
|
+
borderColor: "#007bff",
|
|
362
|
+
backgroundColor: "rgba(0, 123, 255, 0.1)",
|
|
363
|
+
fill: true,
|
|
364
|
+
tension: 0.4
|
|
365
|
+
}
|
|
366
|
+
]
|
|
367
|
+
},
|
|
368
|
+
options: {
|
|
369
|
+
responsive: true,
|
|
370
|
+
plugins: {
|
|
371
|
+
title: {
|
|
372
|
+
display: true,
|
|
373
|
+
text: `${symbol} Market Data`
|
|
374
|
+
}
|
|
375
|
+
},
|
|
376
|
+
scales: {
|
|
377
|
+
y: {
|
|
378
|
+
beginAtZero: false
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
};
|
|
383
|
+
chart.setConfig(config);
|
|
384
|
+
const imageBuffer = await chart.toBinary();
|
|
385
|
+
const base64 = imageBuffer.toString("base64");
|
|
386
|
+
return {
|
|
387
|
+
content: [
|
|
388
|
+
{
|
|
389
|
+
type: "resource",
|
|
390
|
+
resource: {
|
|
391
|
+
uri: "resource://graph",
|
|
392
|
+
mimeType: "image/png",
|
|
393
|
+
blob: base64
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
]
|
|
397
|
+
};
|
|
398
|
+
} catch (error) {
|
|
399
|
+
return {
|
|
400
|
+
content: [
|
|
401
|
+
{
|
|
402
|
+
type: "text",
|
|
403
|
+
text: `Error: ${error instanceof Error ? error.message : "Failed to generate chart"}`,
|
|
404
|
+
uri: "getStockGraph"
|
|
405
|
+
}
|
|
406
|
+
],
|
|
407
|
+
isError: true
|
|
408
|
+
};
|
|
409
|
+
}
|
|
410
|
+
};
|
|
411
|
+
};
|
|
412
|
+
var createGetStockPriceHistoryHandler = (marketDataPrices) => {
|
|
413
|
+
return async (args) => {
|
|
414
|
+
try {
|
|
415
|
+
const symbol = args.symbol;
|
|
416
|
+
const priceHistory = marketDataPrices.get(symbol) || [];
|
|
417
|
+
if (priceHistory.length === 0) {
|
|
418
|
+
return {
|
|
419
|
+
content: [
|
|
420
|
+
{
|
|
421
|
+
type: "text",
|
|
422
|
+
text: `No price data available for ${symbol}`,
|
|
423
|
+
uri: "getStockPriceHistory"
|
|
424
|
+
}
|
|
425
|
+
]
|
|
426
|
+
};
|
|
427
|
+
}
|
|
428
|
+
return {
|
|
429
|
+
content: [
|
|
430
|
+
{
|
|
431
|
+
type: "text",
|
|
432
|
+
text: JSON.stringify(
|
|
433
|
+
{
|
|
434
|
+
symbol,
|
|
435
|
+
count: priceHistory.length,
|
|
436
|
+
data: priceHistory.map((point) => ({
|
|
437
|
+
timestamp: new Date(point.timestamp).toISOString(),
|
|
438
|
+
bid: point.bid,
|
|
439
|
+
offer: point.offer,
|
|
440
|
+
spread: point.spread,
|
|
441
|
+
volume: point.volume
|
|
442
|
+
}))
|
|
443
|
+
},
|
|
444
|
+
null,
|
|
445
|
+
2
|
|
446
|
+
),
|
|
447
|
+
uri: "getStockPriceHistory"
|
|
448
|
+
}
|
|
449
|
+
]
|
|
450
|
+
};
|
|
451
|
+
} catch (error) {
|
|
452
|
+
return {
|
|
453
|
+
content: [
|
|
454
|
+
{
|
|
455
|
+
type: "text",
|
|
456
|
+
text: `Error: ${error instanceof Error ? error.message : "Failed to get stock price history"}`,
|
|
457
|
+
uri: "getStockPriceHistory"
|
|
458
|
+
}
|
|
459
|
+
],
|
|
460
|
+
isError: true
|
|
461
|
+
};
|
|
462
|
+
}
|
|
463
|
+
};
|
|
464
|
+
};
|
|
465
|
+
|
|
466
|
+
// src/tools/order.ts
|
|
467
|
+
import { Field as Field2, Fields as Fields2, Messages as Messages2 } from "fixparser";
|
|
468
|
+
var ordTypeNames = {
|
|
469
|
+
"1": "Market",
|
|
470
|
+
"2": "Limit",
|
|
471
|
+
"3": "Stop",
|
|
472
|
+
"4": "StopLimit",
|
|
473
|
+
"5": "MarketOnClose",
|
|
474
|
+
"6": "WithOrWithout",
|
|
475
|
+
"7": "LimitOrBetter",
|
|
476
|
+
"8": "LimitWithOrWithout",
|
|
477
|
+
"9": "OnBasis",
|
|
478
|
+
A: "OnClose",
|
|
479
|
+
B: "LimitOnClose",
|
|
480
|
+
C: "ForexMarket",
|
|
481
|
+
D: "PreviouslyQuoted",
|
|
482
|
+
E: "PreviouslyIndicated",
|
|
483
|
+
F: "ForexLimit",
|
|
484
|
+
G: "ForexSwap",
|
|
485
|
+
H: "ForexPreviouslyQuoted",
|
|
486
|
+
I: "Funari",
|
|
487
|
+
J: "MarketIfTouched",
|
|
488
|
+
K: "MarketWithLeftOverAsLimit",
|
|
489
|
+
L: "PreviousFundValuationPoint",
|
|
490
|
+
M: "NextFundValuationPoint",
|
|
491
|
+
P: "Pegged",
|
|
492
|
+
Q: "CounterOrderSelection",
|
|
493
|
+
R: "StopOnBidOrOffer",
|
|
494
|
+
S: "StopLimitOnBidOrOffer"
|
|
495
|
+
};
|
|
496
|
+
var sideNames = {
|
|
497
|
+
"1": "Buy",
|
|
498
|
+
"2": "Sell",
|
|
499
|
+
"3": "BuyMinus",
|
|
500
|
+
"4": "SellPlus",
|
|
501
|
+
"5": "SellShort",
|
|
502
|
+
"6": "SellShortExempt",
|
|
503
|
+
"7": "Undisclosed",
|
|
504
|
+
"8": "Cross",
|
|
505
|
+
"9": "CrossShort",
|
|
506
|
+
A: "CrossShortExempt",
|
|
507
|
+
B: "AsDefined",
|
|
508
|
+
C: "Opposite",
|
|
509
|
+
D: "Subscribe",
|
|
510
|
+
E: "Redeem",
|
|
511
|
+
F: "Lend",
|
|
512
|
+
G: "Borrow",
|
|
513
|
+
H: "SellUndisclosed"
|
|
514
|
+
};
|
|
515
|
+
var timeInForceNames = {
|
|
516
|
+
"0": "Day",
|
|
517
|
+
"1": "GoodTillCancel",
|
|
518
|
+
"2": "AtTheOpening",
|
|
519
|
+
"3": "ImmediateOrCancel",
|
|
520
|
+
"4": "FillOrKill",
|
|
521
|
+
"5": "GoodTillCrossing",
|
|
522
|
+
"6": "GoodTillDate",
|
|
523
|
+
"7": "AtTheClose",
|
|
524
|
+
"8": "GoodThroughCrossing",
|
|
525
|
+
"9": "AtCrossing",
|
|
526
|
+
A: "GoodForTime",
|
|
527
|
+
B: "GoodForAuction",
|
|
528
|
+
C: "GoodForMonth"
|
|
529
|
+
};
|
|
530
|
+
var handlInstNames = {
|
|
531
|
+
"1": "AutomatedExecutionNoIntervention",
|
|
532
|
+
"2": "AutomatedExecutionInterventionOK",
|
|
533
|
+
"3": "ManualOrder"
|
|
534
|
+
};
|
|
535
|
+
var createVerifyOrderHandler = (parser, verifiedOrders) => {
|
|
536
|
+
return async (args) => {
|
|
537
|
+
try {
|
|
538
|
+
verifiedOrders.set(args.clOrdID, {
|
|
539
|
+
clOrdID: args.clOrdID,
|
|
540
|
+
handlInst: args.handlInst,
|
|
541
|
+
quantity: Number.parseFloat(String(args.quantity)),
|
|
542
|
+
price: Number.parseFloat(String(args.price)),
|
|
543
|
+
ordType: args.ordType,
|
|
544
|
+
side: args.side,
|
|
545
|
+
symbol: args.symbol,
|
|
546
|
+
timeInForce: args.timeInForce
|
|
547
|
+
});
|
|
548
|
+
return {
|
|
549
|
+
content: [
|
|
550
|
+
{
|
|
551
|
+
type: "text",
|
|
552
|
+
text: `VERIFICATION: All parameters valid. Ready to proceed with order execution.
|
|
553
|
+
|
|
554
|
+
Parameters verified:
|
|
555
|
+
- ClOrdID: ${args.clOrdID}
|
|
556
|
+
- HandlInst: ${args.handlInst} (${handlInstNames[args.handlInst]})
|
|
557
|
+
- Quantity: ${args.quantity}
|
|
558
|
+
- Price: ${args.price}
|
|
559
|
+
- OrdType: ${args.ordType} (${ordTypeNames[args.ordType]})
|
|
560
|
+
- Side: ${args.side} (${sideNames[args.side]})
|
|
561
|
+
- Symbol: ${args.symbol}
|
|
562
|
+
- TimeInForce: ${args.timeInForce} (${timeInForceNames[args.timeInForce]})
|
|
563
|
+
|
|
564
|
+
To execute this order, call the executeOrder tool with these exact same parameters.`,
|
|
565
|
+
uri: "verifyOrder"
|
|
566
|
+
}
|
|
567
|
+
]
|
|
568
|
+
};
|
|
569
|
+
} catch (error) {
|
|
570
|
+
return {
|
|
571
|
+
content: [
|
|
572
|
+
{
|
|
573
|
+
type: "text",
|
|
574
|
+
text: `Error: ${error instanceof Error ? error.message : "Failed to verify order parameters"}`,
|
|
575
|
+
uri: "verifyOrder"
|
|
576
|
+
}
|
|
577
|
+
],
|
|
578
|
+
isError: true
|
|
579
|
+
};
|
|
580
|
+
}
|
|
581
|
+
};
|
|
582
|
+
};
|
|
583
|
+
var createExecuteOrderHandler = (parser, verifiedOrders, pendingRequests) => {
|
|
584
|
+
return async (args) => {
|
|
585
|
+
try {
|
|
586
|
+
const verifiedOrder = verifiedOrders.get(args.clOrdID);
|
|
587
|
+
if (!verifiedOrder) {
|
|
588
|
+
return {
|
|
589
|
+
content: [
|
|
590
|
+
{
|
|
591
|
+
type: "text",
|
|
592
|
+
text: `Error: Order ${args.clOrdID} has not been verified. Please call verifyOrder first.`,
|
|
593
|
+
uri: "executeOrder"
|
|
594
|
+
}
|
|
595
|
+
],
|
|
596
|
+
isError: true
|
|
597
|
+
};
|
|
598
|
+
}
|
|
599
|
+
if (verifiedOrder.handlInst !== args.handlInst || verifiedOrder.quantity !== Number.parseFloat(String(args.quantity)) || verifiedOrder.price !== Number.parseFloat(String(args.price)) || verifiedOrder.ordType !== args.ordType || verifiedOrder.side !== args.side || verifiedOrder.symbol !== args.symbol || verifiedOrder.timeInForce !== args.timeInForce) {
|
|
600
|
+
return {
|
|
601
|
+
content: [
|
|
602
|
+
{
|
|
603
|
+
type: "text",
|
|
604
|
+
text: "Error: Order parameters do not match the verified order. Please use the exact same parameters that were verified.",
|
|
605
|
+
uri: "executeOrder"
|
|
606
|
+
}
|
|
607
|
+
],
|
|
608
|
+
isError: true
|
|
609
|
+
};
|
|
610
|
+
}
|
|
611
|
+
const response = new Promise((resolve) => {
|
|
612
|
+
pendingRequests.set(args.clOrdID, resolve);
|
|
613
|
+
});
|
|
614
|
+
const order = parser.createMessage(
|
|
615
|
+
new Field2(Fields2.MsgType, Messages2.NewOrderSingle),
|
|
616
|
+
new Field2(Fields2.MsgSeqNum, parser.getNextTargetMsgSeqNum()),
|
|
617
|
+
new Field2(Fields2.SenderCompID, parser.sender),
|
|
618
|
+
new Field2(Fields2.TargetCompID, parser.target),
|
|
619
|
+
new Field2(Fields2.SendingTime, parser.getTimestamp()),
|
|
620
|
+
new Field2(Fields2.ClOrdID, args.clOrdID),
|
|
621
|
+
new Field2(Fields2.Side, args.side),
|
|
622
|
+
new Field2(Fields2.Symbol, args.symbol),
|
|
623
|
+
new Field2(Fields2.OrderQty, Number.parseFloat(String(args.quantity))),
|
|
624
|
+
new Field2(Fields2.Price, Number.parseFloat(String(args.price))),
|
|
625
|
+
new Field2(Fields2.OrdType, args.ordType),
|
|
626
|
+
new Field2(Fields2.HandlInst, args.handlInst),
|
|
627
|
+
new Field2(Fields2.TimeInForce, args.timeInForce),
|
|
628
|
+
new Field2(Fields2.TransactTime, parser.getTimestamp())
|
|
629
|
+
);
|
|
630
|
+
if (!parser.connected) {
|
|
631
|
+
return {
|
|
632
|
+
content: [
|
|
633
|
+
{
|
|
634
|
+
type: "text",
|
|
635
|
+
text: "Error: Not connected. Ignoring message.",
|
|
636
|
+
uri: "executeOrder"
|
|
637
|
+
}
|
|
638
|
+
],
|
|
639
|
+
isError: true
|
|
640
|
+
};
|
|
641
|
+
}
|
|
642
|
+
parser.send(order);
|
|
643
|
+
const fixData = await response;
|
|
644
|
+
verifiedOrders.delete(args.clOrdID);
|
|
645
|
+
return {
|
|
646
|
+
content: [
|
|
647
|
+
{
|
|
648
|
+
type: "text",
|
|
649
|
+
text: fixData.messageType === Messages2.Reject ? `Reject message for order ${args.clOrdID}: ${JSON.stringify(fixData.toFIXJSON())}` : `Execution Report for order ${args.clOrdID}: ${JSON.stringify(fixData.toFIXJSON())}`,
|
|
650
|
+
uri: "executeOrder"
|
|
651
|
+
}
|
|
652
|
+
]
|
|
653
|
+
};
|
|
654
|
+
} catch (error) {
|
|
655
|
+
return {
|
|
656
|
+
content: [
|
|
657
|
+
{
|
|
658
|
+
type: "text",
|
|
659
|
+
text: `Error: ${error instanceof Error ? error.message : "Failed to execute order"}`,
|
|
660
|
+
uri: "executeOrder"
|
|
661
|
+
}
|
|
662
|
+
],
|
|
663
|
+
isError: true
|
|
664
|
+
};
|
|
665
|
+
}
|
|
666
|
+
};
|
|
189
667
|
};
|
|
668
|
+
|
|
669
|
+
// src/tools/parse.ts
|
|
670
|
+
var createParseHandler = (parser) => {
|
|
671
|
+
return async (args) => {
|
|
672
|
+
try {
|
|
673
|
+
const parsedMessage = parser.parse(args.fixString);
|
|
674
|
+
if (!parsedMessage || parsedMessage.length === 0) {
|
|
675
|
+
return {
|
|
676
|
+
content: [
|
|
677
|
+
{
|
|
678
|
+
type: "text",
|
|
679
|
+
text: "Error: Failed to parse FIX string",
|
|
680
|
+
uri: "parse"
|
|
681
|
+
}
|
|
682
|
+
],
|
|
683
|
+
isError: true
|
|
684
|
+
};
|
|
685
|
+
}
|
|
686
|
+
return {
|
|
687
|
+
content: [
|
|
688
|
+
{
|
|
689
|
+
type: "text",
|
|
690
|
+
text: `${parsedMessage[0].description}
|
|
691
|
+
${parsedMessage[0].messageTypeDescription}`,
|
|
692
|
+
uri: "parse"
|
|
693
|
+
}
|
|
694
|
+
]
|
|
695
|
+
};
|
|
696
|
+
} catch (error) {
|
|
697
|
+
return {
|
|
698
|
+
content: [
|
|
699
|
+
{
|
|
700
|
+
type: "text",
|
|
701
|
+
text: `Error: ${error instanceof Error ? error.message : "Failed to parse FIX string"}`,
|
|
702
|
+
uri: "parse"
|
|
703
|
+
}
|
|
704
|
+
],
|
|
705
|
+
isError: true
|
|
706
|
+
};
|
|
707
|
+
}
|
|
708
|
+
};
|
|
709
|
+
};
|
|
710
|
+
|
|
711
|
+
// src/tools/parseToJSON.ts
|
|
712
|
+
var createParseToJSONHandler = (parser) => {
|
|
713
|
+
return async (args) => {
|
|
714
|
+
try {
|
|
715
|
+
const parsedMessage = parser.parse(args.fixString);
|
|
716
|
+
if (!parsedMessage || parsedMessage.length === 0) {
|
|
717
|
+
return {
|
|
718
|
+
content: [
|
|
719
|
+
{
|
|
720
|
+
type: "text",
|
|
721
|
+
text: "Error: Failed to parse FIX string",
|
|
722
|
+
uri: "parseToJSON"
|
|
723
|
+
}
|
|
724
|
+
],
|
|
725
|
+
isError: true
|
|
726
|
+
};
|
|
727
|
+
}
|
|
728
|
+
return {
|
|
729
|
+
content: [
|
|
730
|
+
{
|
|
731
|
+
type: "text",
|
|
732
|
+
text: `${parsedMessage[0].toFIXJSON()}`,
|
|
733
|
+
uri: "parseToJSON"
|
|
734
|
+
}
|
|
735
|
+
]
|
|
736
|
+
};
|
|
737
|
+
} catch (error) {
|
|
738
|
+
return {
|
|
739
|
+
content: [
|
|
740
|
+
{
|
|
741
|
+
type: "text",
|
|
742
|
+
text: `Error: ${error instanceof Error ? error.message : "Failed to parse FIX string"}`,
|
|
743
|
+
uri: "parseToJSON"
|
|
744
|
+
}
|
|
745
|
+
],
|
|
746
|
+
isError: true
|
|
747
|
+
};
|
|
748
|
+
}
|
|
749
|
+
};
|
|
750
|
+
};
|
|
751
|
+
|
|
752
|
+
// src/tools/index.ts
|
|
753
|
+
var createToolHandlers = (parser, verifiedOrders, pendingRequests, marketDataPrices) => ({
|
|
754
|
+
parse: createParseHandler(parser),
|
|
755
|
+
parseToJSON: createParseToJSONHandler(parser),
|
|
756
|
+
verifyOrder: createVerifyOrderHandler(parser, verifiedOrders),
|
|
757
|
+
executeOrder: createExecuteOrderHandler(parser, verifiedOrders, pendingRequests),
|
|
758
|
+
marketDataRequest: createMarketDataRequestHandler(parser, pendingRequests),
|
|
759
|
+
getStockGraph: createGetStockGraphHandler(marketDataPrices),
|
|
760
|
+
getStockPriceHistory: createGetStockPriceHistoryHandler(marketDataPrices)
|
|
761
|
+
});
|
|
762
|
+
|
|
763
|
+
// src/MCPLocal.ts
|
|
190
764
|
var MCPLocal = class {
|
|
191
|
-
logger;
|
|
192
765
|
parser;
|
|
193
766
|
server = new Server(
|
|
194
767
|
{
|
|
@@ -196,39 +769,106 @@ var MCPLocal = class {
|
|
|
196
769
|
version: "1.0.0"
|
|
197
770
|
},
|
|
198
771
|
{
|
|
199
|
-
capabilities: {
|
|
772
|
+
capabilities: {
|
|
773
|
+
tools: Object.entries(toolSchemas).reduce(
|
|
774
|
+
(acc, [name, { description, schema }]) => {
|
|
775
|
+
acc[name] = {
|
|
776
|
+
description,
|
|
777
|
+
parameters: schema
|
|
778
|
+
};
|
|
779
|
+
return acc;
|
|
780
|
+
},
|
|
781
|
+
{}
|
|
782
|
+
)
|
|
783
|
+
}
|
|
200
784
|
}
|
|
201
785
|
);
|
|
202
786
|
transport = new StdioServerTransport();
|
|
203
787
|
onReady = void 0;
|
|
204
788
|
pendingRequests = /* @__PURE__ */ new Map();
|
|
789
|
+
verifiedOrders = /* @__PURE__ */ new Map();
|
|
790
|
+
marketDataPrices = /* @__PURE__ */ new Map();
|
|
791
|
+
MAX_PRICE_HISTORY = 1e5;
|
|
792
|
+
// Maximum number of price points to store per symbol
|
|
205
793
|
constructor({ logger, onReady }) {
|
|
206
|
-
if (logger) this.logger = logger;
|
|
207
794
|
if (onReady) this.onReady = onReady;
|
|
208
795
|
}
|
|
209
796
|
async register(parser) {
|
|
210
797
|
this.parser = parser;
|
|
211
798
|
this.parser.addOnMessageCallback((message) => {
|
|
212
|
-
this.logger
|
|
799
|
+
this.parser?.logger.log({
|
|
213
800
|
level: "info",
|
|
214
|
-
message: `
|
|
801
|
+
message: `MCP Server received message: ${message.messageType}: ${message.description}`
|
|
215
802
|
});
|
|
216
803
|
const msgType = message.messageType;
|
|
217
|
-
if (msgType ===
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
804
|
+
if (msgType === Messages3.MarketDataSnapshotFullRefresh || msgType === Messages3.ExecutionReport || msgType === Messages3.Reject || msgType === Messages3.MarketDataIncrementalRefresh) {
|
|
805
|
+
this.parser?.logger.log({
|
|
806
|
+
level: "info",
|
|
807
|
+
message: `MCP Server handling message type: ${msgType}`
|
|
808
|
+
});
|
|
809
|
+
let id;
|
|
810
|
+
if (msgType === Messages3.MarketDataIncrementalRefresh || msgType === Messages3.MarketDataSnapshotFullRefresh) {
|
|
811
|
+
const symbol = message.getField(Fields3.Symbol);
|
|
812
|
+
const entryType = message.getField(Fields3.MDEntryType);
|
|
813
|
+
const price = message.getField(Fields3.MDEntryPx);
|
|
814
|
+
const size = message.getField(Fields3.MDEntrySize);
|
|
815
|
+
const timestamp = message.getField(Fields3.MDEntryTime)?.value || Date.now();
|
|
816
|
+
if (symbol?.value && price?.value) {
|
|
817
|
+
const symbolStr = String(symbol.value);
|
|
818
|
+
const priceNum = Number(price.value);
|
|
819
|
+
const sizeNum = size?.value ? Number(size.value) : 0;
|
|
820
|
+
const priceHistory = this.marketDataPrices.get(symbolStr) || [];
|
|
821
|
+
const lastEntry = priceHistory[priceHistory.length - 1] || {
|
|
822
|
+
timestamp: 0,
|
|
823
|
+
bid: 0,
|
|
824
|
+
offer: 0,
|
|
825
|
+
spread: 0,
|
|
826
|
+
volume: 0
|
|
827
|
+
};
|
|
828
|
+
const newEntry = {
|
|
829
|
+
timestamp: Number(timestamp),
|
|
830
|
+
bid: entryType?.value === MDEntryType2.Bid ? priceNum : lastEntry.bid,
|
|
831
|
+
offer: entryType?.value === MDEntryType2.Offer ? priceNum : lastEntry.offer,
|
|
832
|
+
spread: entryType?.value === MDEntryType2.Offer ? priceNum - lastEntry.bid : entryType?.value === MDEntryType2.Bid ? lastEntry.offer - priceNum : lastEntry.spread,
|
|
833
|
+
volume: entryType?.value === MDEntryType2.TradeVolume ? sizeNum : lastEntry.volume
|
|
834
|
+
};
|
|
835
|
+
priceHistory.push(newEntry);
|
|
836
|
+
if (priceHistory.length > this.MAX_PRICE_HISTORY) {
|
|
837
|
+
priceHistory.shift();
|
|
226
838
|
}
|
|
839
|
+
this.marketDataPrices.set(symbolStr, priceHistory);
|
|
840
|
+
this.parser?.logger.log({
|
|
841
|
+
level: "info",
|
|
842
|
+
message: `MCP Server added ${symbol}: ${JSON.stringify(newEntry)}`
|
|
843
|
+
});
|
|
844
|
+
this.server.notification({
|
|
845
|
+
method: "priceUpdate",
|
|
846
|
+
params: {
|
|
847
|
+
symbol: symbolStr,
|
|
848
|
+
...newEntry
|
|
849
|
+
}
|
|
850
|
+
});
|
|
851
|
+
}
|
|
852
|
+
}
|
|
853
|
+
if (msgType === Messages3.MarketDataSnapshotFullRefresh) {
|
|
854
|
+
const mdReqID = message.getField(Fields3.MDReqID);
|
|
855
|
+
if (mdReqID) id = String(mdReqID.value);
|
|
856
|
+
} else if (msgType === Messages3.ExecutionReport) {
|
|
857
|
+
const clOrdID = message.getField(Fields3.ClOrdID);
|
|
858
|
+
if (clOrdID) id = String(clOrdID.value);
|
|
859
|
+
} else if (msgType === Messages3.Reject) {
|
|
860
|
+
const refSeqNum = message.getField(Fields3.RefSeqNum);
|
|
861
|
+
if (refSeqNum) id = String(refSeqNum.value);
|
|
862
|
+
}
|
|
863
|
+
if (id) {
|
|
864
|
+
const callback = this.pendingRequests.get(id);
|
|
865
|
+
if (callback) {
|
|
866
|
+
callback(message);
|
|
867
|
+
this.pendingRequests.delete(id);
|
|
227
868
|
}
|
|
228
869
|
}
|
|
229
870
|
}
|
|
230
871
|
});
|
|
231
|
-
this.logger = parser.logger;
|
|
232
872
|
this.addWorkflows();
|
|
233
873
|
await this.server.connect(this.transport);
|
|
234
874
|
if (this.onReady) {
|
|
@@ -237,450 +877,62 @@ var MCPLocal = class {
|
|
|
237
877
|
}
|
|
238
878
|
addWorkflows() {
|
|
239
879
|
if (!this.parser) {
|
|
240
|
-
this.logger?.log({
|
|
241
|
-
level: "error",
|
|
242
|
-
message: "FIXParser (MCP): -- FIXParser instance not initialized. Ignoring setup of workflows..."
|
|
243
|
-
});
|
|
244
880
|
return;
|
|
245
881
|
}
|
|
246
882
|
if (!this.server) {
|
|
247
|
-
this.logger?.log({
|
|
248
|
-
level: "error",
|
|
249
|
-
message: "FIXParser (MCP): -- MCP Server not initialized. Ignoring setup of workflows..."
|
|
250
|
-
});
|
|
251
883
|
return;
|
|
252
884
|
}
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
} else if (prop.default !== void 0) {
|
|
264
|
-
result[key] = prop.default;
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
return result;
|
|
268
|
-
};
|
|
269
|
-
this.server.setRequestHandler(ListResourcesRequestSchema, async () => {
|
|
270
|
-
return {
|
|
271
|
-
resources: []
|
|
272
|
-
};
|
|
273
|
-
});
|
|
274
|
-
this.server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
275
|
-
return {
|
|
276
|
-
tools: [
|
|
277
|
-
{
|
|
278
|
-
name: "parse",
|
|
279
|
-
description: "Parses a FIX message and describes it in plain language",
|
|
280
|
-
inputSchema: parseInputSchema
|
|
281
|
-
},
|
|
282
|
-
{
|
|
283
|
-
name: "parseToJSON",
|
|
284
|
-
description: "Parses a FIX message into JSON",
|
|
285
|
-
inputSchema: parseToJSONInputSchema
|
|
286
|
-
},
|
|
287
|
-
{
|
|
288
|
-
name: "newOrderSingle",
|
|
289
|
-
description: "Creates and sends a New Order Single",
|
|
290
|
-
inputSchema: newOrderSingleInputSchema
|
|
291
|
-
},
|
|
292
|
-
{
|
|
293
|
-
name: "marketDataRequest",
|
|
294
|
-
description: "Sends a request for Market Data with the given symbol",
|
|
295
|
-
inputSchema: marketDataRequestInputSchema
|
|
296
|
-
}
|
|
297
|
-
]
|
|
298
|
-
};
|
|
299
|
-
});
|
|
300
|
-
this.server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
301
|
-
const { name, arguments: args } = request.params;
|
|
302
|
-
switch (name) {
|
|
303
|
-
case "parse": {
|
|
304
|
-
try {
|
|
305
|
-
const { fixString } = validateArgs(args, parseInputSchema);
|
|
306
|
-
const parsedMessage = this.parser?.parse(fixString);
|
|
307
|
-
if (!parsedMessage || parsedMessage.length === 0) {
|
|
308
|
-
return {
|
|
309
|
-
isError: true,
|
|
310
|
-
content: [{ type: "text", text: "Error: Failed to parse FIX string" }]
|
|
311
|
-
};
|
|
312
|
-
}
|
|
313
|
-
return {
|
|
314
|
-
content: [
|
|
315
|
-
{
|
|
316
|
-
type: "text",
|
|
317
|
-
text: `Parsed FIX message: ${fixString} (placeholder implementation)`
|
|
318
|
-
}
|
|
319
|
-
]
|
|
320
|
-
};
|
|
321
|
-
} catch (error) {
|
|
322
|
-
return {
|
|
323
|
-
isError: true,
|
|
324
|
-
content: [
|
|
325
|
-
{
|
|
326
|
-
type: "text",
|
|
327
|
-
text: `Error: ${error instanceof Error ? error.message : "Failed to parse FIX string"}`
|
|
328
|
-
}
|
|
329
|
-
]
|
|
330
|
-
};
|
|
331
|
-
}
|
|
332
|
-
}
|
|
333
|
-
case "parseToJSON": {
|
|
334
|
-
try {
|
|
335
|
-
const { fixString } = validateArgs(args, parseToJSONInputSchema);
|
|
336
|
-
const parsedMessage = this.parser?.parse(fixString);
|
|
337
|
-
if (!parsedMessage || parsedMessage.length === 0) {
|
|
338
|
-
return {
|
|
339
|
-
isError: true,
|
|
340
|
-
content: [{ type: "text", text: "Error: Failed to parse FIX string" }]
|
|
341
|
-
};
|
|
342
|
-
}
|
|
343
|
-
return {
|
|
344
|
-
content: [
|
|
345
|
-
{
|
|
346
|
-
type: "text",
|
|
347
|
-
text: JSON.stringify({ fixString, parsed: "placeholder" })
|
|
348
|
-
}
|
|
349
|
-
]
|
|
350
|
-
};
|
|
351
|
-
} catch (error) {
|
|
352
|
-
return {
|
|
353
|
-
isError: true,
|
|
354
|
-
content: [
|
|
355
|
-
{
|
|
356
|
-
type: "text",
|
|
357
|
-
text: `Error: ${error instanceof Error ? error.message : "Failed to parse FIX string"}`
|
|
358
|
-
}
|
|
359
|
-
]
|
|
360
|
-
};
|
|
361
|
-
}
|
|
362
|
-
}
|
|
363
|
-
case "newOrderSingle": {
|
|
364
|
-
try {
|
|
365
|
-
const { clOrdID, handlInst, quantity, price, ordType, side, symbol, timeInForce } = validateArgs(args, newOrderSingleInputSchema);
|
|
366
|
-
const response = new Promise((resolve) => {
|
|
367
|
-
this.pendingRequests.set(clOrdID, resolve);
|
|
368
|
-
});
|
|
369
|
-
const order = this.parser?.createMessage(
|
|
370
|
-
new Field(Fields.MsgType, Messages.NewOrderSingle),
|
|
371
|
-
new Field(Fields.MsgSeqNum, this.parser?.getNextTargetMsgSeqNum()),
|
|
372
|
-
new Field(Fields.SenderCompID, this.parser?.sender),
|
|
373
|
-
new Field(Fields.TargetCompID, this.parser?.target),
|
|
374
|
-
new Field(Fields.SendingTime, this.parser?.getTimestamp()),
|
|
375
|
-
new Field(Fields.ClOrdID, clOrdID),
|
|
376
|
-
new Field(Fields.Side, side),
|
|
377
|
-
new Field(Fields.Symbol, symbol),
|
|
378
|
-
new Field(Fields.OrderQty, quantity),
|
|
379
|
-
new Field(Fields.Price, price),
|
|
380
|
-
new Field(Fields.OrdType, ordType),
|
|
381
|
-
new Field(Fields.HandlInst, handlInst),
|
|
382
|
-
new Field(Fields.TimeInForce, timeInForce),
|
|
383
|
-
new Field(Fields.TransactTime, this.parser?.getTimestamp())
|
|
384
|
-
);
|
|
385
|
-
if (!this.parser?.connected) {
|
|
386
|
-
this.logger?.log({
|
|
387
|
-
level: "error",
|
|
388
|
-
message: "FIXParser (MCP): -- Not connected. Ignoring message."
|
|
389
|
-
});
|
|
390
|
-
return {
|
|
391
|
-
isError: true,
|
|
392
|
-
content: [
|
|
393
|
-
{
|
|
394
|
-
type: "text",
|
|
395
|
-
text: "Error: Not connected. Ignoring message."
|
|
396
|
-
}
|
|
397
|
-
]
|
|
398
|
-
};
|
|
399
|
-
}
|
|
400
|
-
this.parser?.send(order);
|
|
401
|
-
this.logger?.log({
|
|
402
|
-
level: "info",
|
|
403
|
-
message: `FIXParser (MCP): (${this.parser?.protocol?.toUpperCase()}): >> sent ${order?.description}`
|
|
404
|
-
});
|
|
405
|
-
const fixData = await response;
|
|
406
|
-
return {
|
|
407
|
-
content: [
|
|
408
|
-
{
|
|
409
|
-
type: "text",
|
|
410
|
-
text: `Execution Report for order ${clOrdID}: ${JSON.stringify(fixData.toFIXJSON())}`
|
|
411
|
-
}
|
|
412
|
-
]
|
|
413
|
-
};
|
|
414
|
-
} catch (error) {
|
|
415
|
-
return {
|
|
416
|
-
isError: true,
|
|
417
|
-
content: [
|
|
418
|
-
{
|
|
419
|
-
type: "text",
|
|
420
|
-
text: `Error: ${error instanceof Error ? error.message : "Failed to create order"}`
|
|
421
|
-
}
|
|
422
|
-
]
|
|
423
|
-
};
|
|
424
|
-
}
|
|
425
|
-
}
|
|
426
|
-
case "marketDataRequest": {
|
|
427
|
-
try {
|
|
428
|
-
const { mdUpdateType, symbol, mdReqID, subscriptionRequestType, mdEntryType } = validateArgs(
|
|
429
|
-
args,
|
|
430
|
-
marketDataRequestInputSchema
|
|
431
|
-
);
|
|
432
|
-
const response = new Promise((resolve) => {
|
|
433
|
-
this.pendingRequests.set(mdReqID, resolve);
|
|
434
|
-
});
|
|
435
|
-
const marketDataRequest = this.parser?.createMessage(
|
|
436
|
-
new Field(Fields.MsgType, Messages.MarketDataRequest),
|
|
437
|
-
new Field(Fields.SenderCompID, this.parser?.sender),
|
|
438
|
-
new Field(Fields.MsgSeqNum, this.parser?.getNextTargetMsgSeqNum()),
|
|
439
|
-
new Field(Fields.TargetCompID, this.parser?.target),
|
|
440
|
-
new Field(Fields.SendingTime, this.parser?.getTimestamp()),
|
|
441
|
-
new Field(Fields.MarketDepth, 0),
|
|
442
|
-
new Field(Fields.MDUpdateType, mdUpdateType),
|
|
443
|
-
new Field(Fields.NoRelatedSym, 1),
|
|
444
|
-
new Field(Fields.Symbol, symbol),
|
|
445
|
-
new Field(Fields.MDReqID, mdReqID),
|
|
446
|
-
new Field(Fields.SubscriptionRequestType, subscriptionRequestType),
|
|
447
|
-
new Field(Fields.NoMDEntryTypes, 1),
|
|
448
|
-
new Field(Fields.MDEntryType, mdEntryType)
|
|
449
|
-
);
|
|
450
|
-
if (!this.parser?.connected) {
|
|
451
|
-
this.logger?.log({
|
|
452
|
-
level: "error",
|
|
453
|
-
message: "FIXParser (MCP): -- Not connected. Ignoring message."
|
|
454
|
-
});
|
|
455
|
-
return {
|
|
456
|
-
isError: true,
|
|
457
|
-
content: [
|
|
458
|
-
{
|
|
459
|
-
type: "text",
|
|
460
|
-
text: "Error: Not connected. Ignoring message."
|
|
461
|
-
}
|
|
462
|
-
]
|
|
463
|
-
};
|
|
464
|
-
}
|
|
465
|
-
this.parser?.send(marketDataRequest);
|
|
466
|
-
this.logger?.log({
|
|
467
|
-
level: "info",
|
|
468
|
-
message: `FIXParser (MCP): (${this.parser?.protocol?.toUpperCase()}): >> sent ${marketDataRequest?.description}`
|
|
469
|
-
});
|
|
470
|
-
const fixData = await response;
|
|
471
|
-
return {
|
|
472
|
-
content: [
|
|
473
|
-
{
|
|
474
|
-
type: "text",
|
|
475
|
-
text: `Market data for ${symbol}: ${JSON.stringify(fixData.toFIXJSON())}`
|
|
476
|
-
}
|
|
477
|
-
]
|
|
478
|
-
};
|
|
479
|
-
} catch (error) {
|
|
480
|
-
return {
|
|
481
|
-
isError: true,
|
|
482
|
-
content: [
|
|
483
|
-
{
|
|
484
|
-
type: "text",
|
|
485
|
-
text: `Error: ${error instanceof Error ? error.message : "Failed to request market data"}`
|
|
486
|
-
}
|
|
487
|
-
]
|
|
488
|
-
};
|
|
489
|
-
}
|
|
490
|
-
}
|
|
491
|
-
default:
|
|
492
|
-
throw new Error(`Unknown tool: ${name}`);
|
|
885
|
+
this.server.setRequestHandler(
|
|
886
|
+
z.object({ method: z.literal("tools/list") }),
|
|
887
|
+
async (request, extra) => {
|
|
888
|
+
return {
|
|
889
|
+
tools: Object.entries(toolSchemas).map(([name, { description, schema }]) => ({
|
|
890
|
+
name,
|
|
891
|
+
description,
|
|
892
|
+
inputSchema: schema
|
|
893
|
+
}))
|
|
894
|
+
};
|
|
493
895
|
}
|
|
494
|
-
|
|
495
|
-
this.server.setRequestHandler(
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
required: true
|
|
517
|
-
}
|
|
518
|
-
]
|
|
519
|
-
},
|
|
520
|
-
{
|
|
521
|
-
name: "newOrderSingle",
|
|
522
|
-
description: "Creates and sends a New Order Single",
|
|
523
|
-
arguments: [
|
|
524
|
-
{
|
|
525
|
-
name: "clOrdID",
|
|
526
|
-
description: "Client Order ID",
|
|
527
|
-
required: true
|
|
528
|
-
},
|
|
529
|
-
{
|
|
530
|
-
name: "handlInst",
|
|
531
|
-
description: "Handling instruction",
|
|
532
|
-
required: false
|
|
533
|
-
},
|
|
534
|
-
{
|
|
535
|
-
name: "quantity",
|
|
536
|
-
description: "Order quantity",
|
|
537
|
-
required: true
|
|
538
|
-
},
|
|
539
|
-
{
|
|
540
|
-
name: "price",
|
|
541
|
-
description: "Order price",
|
|
542
|
-
required: true
|
|
543
|
-
},
|
|
544
|
-
{
|
|
545
|
-
name: "ordType",
|
|
546
|
-
description: "Order type",
|
|
547
|
-
required: false
|
|
548
|
-
},
|
|
549
|
-
{
|
|
550
|
-
name: "side",
|
|
551
|
-
description: "Order side (1=Buy, 2=Sell)",
|
|
552
|
-
required: true
|
|
553
|
-
},
|
|
554
|
-
{
|
|
555
|
-
name: "symbol",
|
|
556
|
-
description: "Trading symbol",
|
|
557
|
-
required: true
|
|
558
|
-
},
|
|
559
|
-
{
|
|
560
|
-
name: "timeInForce",
|
|
561
|
-
description: "Time in force",
|
|
562
|
-
required: false
|
|
563
|
-
}
|
|
564
|
-
]
|
|
565
|
-
},
|
|
566
|
-
{
|
|
567
|
-
name: "marketDataRequest",
|
|
568
|
-
description: "Sends a request for Market Data with the given symbol",
|
|
569
|
-
arguments: [
|
|
570
|
-
{
|
|
571
|
-
name: "mdUpdateType",
|
|
572
|
-
description: "Market data update type",
|
|
573
|
-
required: false
|
|
574
|
-
},
|
|
575
|
-
{
|
|
576
|
-
name: "symbol",
|
|
577
|
-
description: "Trading symbol",
|
|
578
|
-
required: true
|
|
579
|
-
},
|
|
580
|
-
{
|
|
581
|
-
name: "mdReqID",
|
|
582
|
-
description: "Market data request ID",
|
|
583
|
-
required: true
|
|
584
|
-
},
|
|
585
|
-
{
|
|
586
|
-
name: "subscriptionRequestType",
|
|
587
|
-
description: "Subscription request type",
|
|
588
|
-
required: false
|
|
589
|
-
},
|
|
590
|
-
{
|
|
591
|
-
name: "mdEntryType",
|
|
592
|
-
description: "Market data entry type",
|
|
593
|
-
required: false
|
|
594
|
-
}
|
|
595
|
-
]
|
|
596
|
-
}
|
|
597
|
-
]
|
|
598
|
-
};
|
|
599
|
-
});
|
|
600
|
-
this.server.setRequestHandler(GetPromptRequestSchema, async (request) => {
|
|
601
|
-
const { name, arguments: args } = request.params;
|
|
602
|
-
switch (name) {
|
|
603
|
-
case "parse": {
|
|
604
|
-
const fixString = args?.fixString || "";
|
|
605
|
-
return {
|
|
606
|
-
messages: [
|
|
607
|
-
{
|
|
608
|
-
role: "user",
|
|
609
|
-
content: {
|
|
610
|
-
type: "text",
|
|
611
|
-
text: `Please parse and explain this FIX message: ${fixString}`
|
|
612
|
-
}
|
|
613
|
-
}
|
|
614
|
-
]
|
|
615
|
-
};
|
|
616
|
-
}
|
|
617
|
-
case "parseToJSON": {
|
|
618
|
-
const fixString = args?.fixString || "";
|
|
619
|
-
return {
|
|
620
|
-
messages: [
|
|
621
|
-
{
|
|
622
|
-
role: "user",
|
|
623
|
-
content: {
|
|
624
|
-
type: "text",
|
|
625
|
-
text: `Please parse the FIX message to JSON: ${fixString}`
|
|
626
|
-
}
|
|
627
|
-
}
|
|
628
|
-
]
|
|
629
|
-
};
|
|
630
|
-
}
|
|
631
|
-
case "newOrderSingle": {
|
|
632
|
-
const { clOrdID, handlInst, quantity, price, ordType, side, symbol, timeInForce } = args || {};
|
|
896
|
+
);
|
|
897
|
+
this.server.setRequestHandler(
|
|
898
|
+
z.object({
|
|
899
|
+
method: z.literal("tools/call"),
|
|
900
|
+
params: z.object({
|
|
901
|
+
name: z.string(),
|
|
902
|
+
arguments: z.any(),
|
|
903
|
+
_meta: z.object({
|
|
904
|
+
progressToken: z.number()
|
|
905
|
+
}).optional()
|
|
906
|
+
})
|
|
907
|
+
}),
|
|
908
|
+
async (request, extra) => {
|
|
909
|
+
const { name, arguments: args } = request.params;
|
|
910
|
+
const toolHandlers = createToolHandlers(
|
|
911
|
+
this.parser,
|
|
912
|
+
this.verifiedOrders,
|
|
913
|
+
this.pendingRequests,
|
|
914
|
+
this.marketDataPrices
|
|
915
|
+
);
|
|
916
|
+
const handler = toolHandlers[name];
|
|
917
|
+
if (!handler) {
|
|
633
918
|
return {
|
|
634
|
-
|
|
919
|
+
content: [
|
|
635
920
|
{
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
text: [
|
|
640
|
-
"Create a New Order Single FIX message with the following parameters:",
|
|
641
|
-
`- ClOrdID: ${clOrdID}`,
|
|
642
|
-
`- HandlInst: ${handlInst ?? "default"}`,
|
|
643
|
-
`- Quantity: ${quantity}`,
|
|
644
|
-
`- Price: ${price}`,
|
|
645
|
-
`- OrdType: ${ordType ?? "default (Market)"}`,
|
|
646
|
-
`- Side: ${side}`,
|
|
647
|
-
`- Symbol: ${symbol}`,
|
|
648
|
-
`- TimeInForce: ${timeInForce ?? "default (Day)"}`,
|
|
649
|
-
"",
|
|
650
|
-
"Format the response as a JSON object with FIX tag numbers as keys and their corresponding values."
|
|
651
|
-
].join("\n")
|
|
652
|
-
}
|
|
921
|
+
type: "text",
|
|
922
|
+
text: `Tool not found: ${name}`,
|
|
923
|
+
uri: name
|
|
653
924
|
}
|
|
654
|
-
]
|
|
655
|
-
|
|
656
|
-
}
|
|
657
|
-
case "marketDataRequest": {
|
|
658
|
-
const { mdUpdateType, symbol, mdReqID, subscriptionRequestType, mdEntryType } = args || {};
|
|
659
|
-
return {
|
|
660
|
-
messages: [
|
|
661
|
-
{
|
|
662
|
-
role: "user",
|
|
663
|
-
content: {
|
|
664
|
-
type: "text",
|
|
665
|
-
text: [
|
|
666
|
-
"Create a Market Data Request FIX message with the following parameters:",
|
|
667
|
-
`- MDUpdateType: ${mdUpdateType ?? "default (0 = FullRefresh)"}`,
|
|
668
|
-
`- Symbol: ${symbol}`,
|
|
669
|
-
`- MDReqID: ${mdReqID}`,
|
|
670
|
-
`- SubscriptionRequestType: ${subscriptionRequestType ?? "default (0 = Snapshot + Updates)"}`,
|
|
671
|
-
`- MDEntryType: ${mdEntryType ?? "default (0 = Bid)"}`,
|
|
672
|
-
"",
|
|
673
|
-
"Format the response as a JSON object with FIX tag numbers as keys and their corresponding values."
|
|
674
|
-
].join("\n")
|
|
675
|
-
}
|
|
676
|
-
}
|
|
677
|
-
]
|
|
925
|
+
],
|
|
926
|
+
isError: true
|
|
678
927
|
};
|
|
679
928
|
}
|
|
680
|
-
|
|
681
|
-
|
|
929
|
+
const result = await handler(args);
|
|
930
|
+
return {
|
|
931
|
+
content: result.content,
|
|
932
|
+
isError: result.isError
|
|
933
|
+
};
|
|
682
934
|
}
|
|
683
|
-
|
|
935
|
+
);
|
|
684
936
|
process.on("SIGINT", async () => {
|
|
685
937
|
await this.server.close();
|
|
686
938
|
process.exit(0);
|