@alfe.ai/ctrader-mcp 0.2.0 → 0.2.1

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/proto/ctrader.proto +48 -29
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alfe.ai/ctrader-mcp",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "cTrader MCP server — full trading (place/modify/close orders + read) over the cTrader Open API (protobuf/TLS)",
5
5
  "type": "module",
6
6
  "main": "./dist/server.js",
@@ -119,11 +119,16 @@ message ProtoOACtidTraderAccount {
119
119
  optional string brokerTitleShort = 6;
120
120
  }
121
121
 
122
+ // Canonical: permissionScope=3 (an enum upstream; we don't read it, kept as a
123
+ // scalar), ctidTraderAccount=4. This response is declared for completeness but
124
+ // is NOT on the live path — accounts come from AgentApiClient.getCTraderAccounts(),
125
+ // not this socket call. Field numbers corrected to match canonical anyway so a
126
+ // future decode of this message reads the account list at the right field.
122
127
  message ProtoOAGetAccountListByAccessTokenRes {
123
128
  optional uint32 payloadType = 1;
124
129
  required string accessToken = 2;
125
- repeated ProtoOACtidTraderAccount ctidTraderAccount = 3;
126
- optional bool permissionScope = 4;
130
+ optional uint32 permissionScope = 3;
131
+ repeated ProtoOACtidTraderAccount ctidTraderAccount = 4;
127
132
  }
128
133
 
129
134
  // ── Trader (balance / account details) ──────────────────────────────────
@@ -194,30 +199,33 @@ message ProtoOAPosition {
194
199
  optional bool trailingStopLoss = 16;
195
200
  }
196
201
 
202
+ // NOTE: canonical ProtoOAOrder has NO field 5 — it jumps orderStatus=4 → expirationTimestamp=6.
203
+ // Field numbers below are transcribed verbatim from Spotware's ProtoOAOrder
204
+ // (relativeStopLoss/relativeTakeProfit are int64, not double, upstream).
197
205
  message ProtoOAOrder {
198
206
  required int64 orderId = 1;
199
207
  required ProtoOATradeData tradeData = 2;
200
208
  required ProtoOAOrderType orderType = 3;
201
209
  required uint32 orderStatus = 4;
202
- optional int64 expirationTimestamp = 5;
203
- optional double executionPrice = 6;
204
- optional int64 executedVolume = 7;
205
- optional int64 utcLastUpdateTimestamp = 8;
206
- optional double baseSlippagePrice = 9;
207
- optional int64 slippageInPoints = 10;
208
- optional bool closingOrder = 11;
209
- optional double limitPrice = 12;
210
- optional double stopPrice = 13;
211
- optional double stopLoss = 14;
212
- optional double takeProfit = 15;
213
- optional string clientOrderId = 16;
214
- optional uint32 timeInForce = 17;
215
- optional int64 positionId = 18;
216
- optional double relativeStopLoss = 19;
217
- optional double relativeTakeProfit = 20;
218
- optional bool isStopOut = 21;
219
- optional bool trailingStopLoss = 22;
220
- optional uint32 stopTriggerMethod = 23;
210
+ optional int64 expirationTimestamp = 6;
211
+ optional double executionPrice = 7;
212
+ optional int64 executedVolume = 8;
213
+ optional int64 utcLastUpdateTimestamp = 9;
214
+ optional double baseSlippagePrice = 10;
215
+ optional int64 slippageInPoints = 11;
216
+ optional bool closingOrder = 12;
217
+ optional double limitPrice = 13;
218
+ optional double stopPrice = 14;
219
+ optional double stopLoss = 15;
220
+ optional double takeProfit = 16;
221
+ optional string clientOrderId = 17;
222
+ optional uint32 timeInForce = 18;
223
+ optional int64 positionId = 19;
224
+ optional int64 relativeStopLoss = 20;
225
+ optional int64 relativeTakeProfit = 21;
226
+ optional bool isStopOut = 22;
227
+ optional bool trailingStopLoss = 23;
228
+ optional uint32 stopTriggerMethod = 24;
221
229
  }
222
230
 
223
231
  message ProtoOAReconcileReq {
@@ -278,7 +286,10 @@ message ProtoOASymbol {
278
286
  optional int64 minVolume = 10;
279
287
  optional int64 stepVolume = 11;
280
288
  optional int64 maxExposure = 12;
281
- optional int64 lotSize = 21;
289
+ // lotSize is canonical field 30 (NOT 21 — field 21 is the deprecated
290
+ // minCommission). Reading it at 21 yields 0 for XAUUSD → SYMBOL_NO_LOTSIZE
291
+ // and mis-sizes volume for any symbol where field 21 is non-zero.
292
+ optional int64 lotSize = 30;
282
293
  }
283
294
 
284
295
  message ProtoOASymbolByIdReq {
@@ -421,14 +432,18 @@ message ProtoOACancelOrderReq {
421
432
  required int64 orderId = 3;
422
433
  }
423
434
 
435
+ // errorCode is canonical field 9 and isServerEvent field 10 (fields 6/7/8 are
436
+ // deal / bonusDepositWithdraw / depositWithdraw upstream, which we don't decode).
437
+ // An order-op rejection can ride here with errorCode set, so the field number
438
+ // is on the money path — reading errorCode at 8 misses the reject entirely.
424
439
  message ProtoOAExecutionEvent {
425
440
  optional uint32 payloadType = 1;
426
441
  required int64 ctidTraderAccountId = 2;
427
442
  required uint32 executionType = 3;
428
443
  optional ProtoOAPosition position = 4;
429
444
  optional ProtoOAOrder order = 5;
430
- optional string errorCode = 8;
431
- optional bool isServerEvent = 9;
445
+ optional string errorCode = 9;
446
+ optional bool isServerEvent = 10;
432
447
  }
433
448
 
434
449
  // ── Order-error event (payloadType 2132) ────────────────────────────────
@@ -437,11 +452,15 @@ message ProtoOAExecutionEvent {
437
452
  // hours, insufficient margin, etc.). Field numbers/types transcribed from
438
453
  // Spotware's ProtoOAOrderErrorEvent (OpenApiMessages.proto). This is a REJECT
439
454
  // on a money path — it MUST map to a CTraderError, never resolve as success.
455
+ // Canonical field numbers are NOT sequential: errorCode=2, orderId=3,
456
+ // ctidTraderAccountId=5, positionId=6, description=7. Getting these wrong
457
+ // means the reject decodes to an empty errorCode and fails to map to a
458
+ // CTraderError — reintroducing the 2132 phantom-success bug.
440
459
  message ProtoOAOrderErrorEvent {
441
460
  optional uint32 payloadType = 1;
442
- required int64 ctidTraderAccountId = 2;
443
- required string errorCode = 3;
444
- optional int64 orderId = 4;
445
- optional int64 positionId = 5;
446
- optional string description = 6;
461
+ required string errorCode = 2;
462
+ optional int64 orderId = 3;
463
+ required int64 ctidTraderAccountId = 5;
464
+ optional int64 positionId = 6;
465
+ optional string description = 7;
447
466
  }