@toromarket/mcp-server 0.2.1 → 0.2.2

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/dist/index.js CHANGED
@@ -65,7 +65,9 @@ var placeOrderSchema = z.object({
65
65
  side: z.enum(["BUY", "SELL"]),
66
66
  type: z.enum(["LIMIT", "MARKET"]).default("LIMIT"),
67
67
  price: z.coerce.number().min(0).max(1).optional(),
68
- quantity: z.coerce.number().positive().max(1e5)
68
+ quantity: z.coerce.number().positive().max(1e5),
69
+ reasoning: sanitized(1e3),
70
+ confidence: z.coerce.number().min(0).max(1)
69
71
  });
70
72
  var cancelOrderSchema = z.object({
71
73
  marketId: id,
@@ -74,7 +76,9 @@ var cancelOrderSchema = z.object({
74
76
  var tradeCryptoSchema = z.object({
75
77
  symbol: sanitized(20),
76
78
  side: z.enum(["BUY", "SELL"]),
77
- quantity: z.coerce.number().positive().max(1e5)
79
+ quantity: z.coerce.number().positive().max(1e5),
80
+ reasoning: sanitized(1e3),
81
+ confidence: z.coerce.number().min(0).max(1)
78
82
  });
79
83
  var postMarketCommentSchema = z.object({
80
84
  marketId: id,
@@ -196,9 +200,11 @@ var PHASE1_TOOLS = [
196
200
  type: "number",
197
201
  description: "Price per share (0-1). Required for LIMIT orders. Ignored for MARKET orders."
198
202
  },
199
- quantity: { type: "number", description: "Share quantity" }
203
+ quantity: { type: "number", description: "Share quantity" },
204
+ reasoning: { type: "string", description: "Why you are making this trade \u2014 your thesis and key signals" },
205
+ confidence: { type: "number", description: "Confidence level 0-1 in this trade decision" }
200
206
  },
201
- required: ["marketId", "outcomeId", "side", "quantity"]
207
+ required: ["marketId", "outcomeId", "side", "quantity", "reasoning", "confidence"]
202
208
  }
203
209
  },
204
210
  {
@@ -247,9 +253,11 @@ var PHASE1_TOOLS = [
247
253
  properties: {
248
254
  symbol: { type: "string", description: "Symbol like BTC" },
249
255
  side: { type: "string", enum: ["BUY", "SELL"] },
250
- quantity: { type: "number", description: "Order size" }
256
+ quantity: { type: "number", description: "Order size" },
257
+ reasoning: { type: "string", description: "Why you are making this trade \u2014 your thesis and key signals" },
258
+ confidence: { type: "number", description: "Confidence level 0-1 in this trade decision" }
251
259
  },
252
- required: ["symbol", "side", "quantity"]
260
+ required: ["symbol", "side", "quantity", "reasoning", "confidence"]
253
261
  }
254
262
  }
255
263
  ];
@@ -617,13 +625,17 @@ var placeFundOrderSchema = z.object({
617
625
  side: z.enum(["BUY", "SELL"]),
618
626
  type: z.enum(["LIMIT", "MARKET"]).default("LIMIT"),
619
627
  price: z.coerce.number().min(0).max(1).optional(),
620
- quantity: z.coerce.number().positive().max(1e5)
628
+ quantity: z.coerce.number().positive().max(1e5),
629
+ reasoning: sanitized(1e3),
630
+ confidence: z.coerce.number().min(0).max(1)
621
631
  });
622
632
  var tradeFundCryptoSchema = z.object({
623
633
  fundId: id,
624
634
  symbol: sanitized(20),
625
635
  side: z.enum(["BUY", "SELL"]),
626
- quantity: z.coerce.number().positive().max(1e5)
636
+ quantity: z.coerce.number().positive().max(1e5),
637
+ reasoning: sanitized(1e3),
638
+ confidence: z.coerce.number().min(0).max(1)
627
639
  });
628
640
  var FUND_TRADING_TOOLS = [
629
641
  {
@@ -645,9 +657,11 @@ var FUND_TRADING_TOOLS = [
645
657
  type: "number",
646
658
  description: "Price per share (0-1). Required for LIMIT orders. Ignored for MARKET orders."
647
659
  },
648
- quantity: { type: "number", description: "Share quantity" }
660
+ quantity: { type: "number", description: "Share quantity" },
661
+ reasoning: { type: "string", description: "Why you are making this trade \u2014 your thesis and key signals" },
662
+ confidence: { type: "number", description: "Confidence level 0-1 in this trade decision" }
649
663
  },
650
- required: ["fundId", "marketId", "outcomeId", "side", "quantity"]
664
+ required: ["fundId", "marketId", "outcomeId", "side", "quantity", "reasoning", "confidence"]
651
665
  }
652
666
  },
653
667
  {
@@ -659,9 +673,11 @@ var FUND_TRADING_TOOLS = [
659
673
  fundId: { type: "string", description: "Your fund ID (from list_funds myFundId)" },
660
674
  symbol: { type: "string", description: "Symbol like BTC" },
661
675
  side: { type: "string", enum: ["BUY", "SELL"] },
662
- quantity: { type: "number", description: "Order size" }
676
+ quantity: { type: "number", description: "Order size" },
677
+ reasoning: { type: "string", description: "Why you are making this trade \u2014 your thesis and key signals" },
678
+ confidence: { type: "number", description: "Confidence level 0-1 in this trade decision" }
663
679
  },
664
- required: ["fundId", "symbol", "side", "quantity"]
680
+ required: ["fundId", "symbol", "side", "quantity", "reasoning", "confidence"]
665
681
  }
666
682
  },
667
683
  {
@@ -2488,7 +2504,9 @@ async function executeTool(client, baseUrl2, name, rawArgs, options) {
2488
2504
  side: input.side,
2489
2505
  type: input.type,
2490
2506
  price: Number(price),
2491
- quantity: Number(input.quantity)
2507
+ quantity: Number(input.quantity),
2508
+ reasoning: input.reasoning,
2509
+ confidence: input.confidence
2492
2510
  });
2493
2511
  const remainingBalance = await fetchRemainingBalance(client);
2494
2512
  return { ...result, remainingBalance };
@@ -2515,7 +2533,13 @@ async function executeTool(client, baseUrl2, name, rawArgs, options) {
2515
2533
  }
2516
2534
  case "trade_crypto": {
2517
2535
  const input = tradeCryptoSchema.parse(args);
2518
- const result = await client.portfolio.trade(input);
2536
+ const result = await client.portfolio.trade({
2537
+ symbol: input.symbol,
2538
+ side: input.side,
2539
+ quantity: input.quantity,
2540
+ reasoning: input.reasoning,
2541
+ confidence: input.confidence
2542
+ });
2519
2543
  const remainingBalance = await fetchRemainingBalance(client);
2520
2544
  return { ...result, remainingBalance };
2521
2545
  }
@@ -2709,7 +2733,9 @@ async function executeTool(client, baseUrl2, name, rawArgs, options) {
2709
2733
  side: input.side,
2710
2734
  type: input.type,
2711
2735
  price,
2712
- quantity: input.quantity
2736
+ quantity: input.quantity,
2737
+ reasoning: input.reasoning,
2738
+ confidence: input.confidence
2713
2739
  });
2714
2740
  const fundOrderBalance = await fetchRemainingBalance(client);
2715
2741
  return { ...fundOrderResult, remainingBalance: fundOrderBalance };
@@ -2719,7 +2745,9 @@ async function executeTool(client, baseUrl2, name, rawArgs, options) {
2719
2745
  const fundTradeResult = await client.funds.tradeCrypto(input.fundId, {
2720
2746
  symbol: input.symbol,
2721
2747
  side: input.side,
2722
- quantity: input.quantity
2748
+ quantity: input.quantity,
2749
+ reasoning: input.reasoning,
2750
+ confidence: input.confidence
2723
2751
  });
2724
2752
  const fundTradeBalance = await fetchRemainingBalance(client);
2725
2753
  return { ...fundTradeResult, remainingBalance: fundTradeBalance };
@@ -4133,8 +4161,18 @@ var TraceCollector = class {
4133
4161
  ...signals !== void 0 ? { signals } : {}
4134
4162
  };
4135
4163
  }
4136
- async beforeExecute(toolName) {
4137
- if (STATE_CHANGING_TOOLS.has(toolName) && !this.pendingReasoning) {
4164
+ async beforeExecute(toolName, args) {
4165
+ if (!STATE_CHANGING_TOOLS.has(toolName)) return;
4166
+ if (!this.pendingReasoning && args && typeof args === "object") {
4167
+ const a = args;
4168
+ if (typeof a.reasoning === "string" && a.reasoning.length > 0) {
4169
+ this.setReasoning(
4170
+ a.reasoning,
4171
+ typeof a.confidence === "number" ? a.confidence : void 0
4172
+ );
4173
+ }
4174
+ }
4175
+ if (!this.pendingReasoning) {
4138
4176
  throw new ToromarketError8(
4139
4177
  "Call log_reasoning before trading. Every trade requires a reasoning explanation.",
4140
4178
  400,