@okx_ai/okx-trade-mcp 1.3.3 → 1.3.4-beta.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
@@ -2131,14 +2131,16 @@ var OKX_INST_TYPES = [
2131
2131
  function publicRateLimit(key, rps = 20) {
2132
2132
  return {
2133
2133
  key: `public:${key}`,
2134
- capacity: rps,
2134
+ capacity: Math.max(1, rps),
2135
+ // capacity >= 1 so the token bucket can fire at least once before refilling
2135
2136
  refillPerSecond: rps
2136
2137
  };
2137
2138
  }
2138
2139
  function privateRateLimit(key, rps = 10) {
2139
2140
  return {
2140
2141
  key: `private:${key}`,
2141
- capacity: rps,
2142
+ capacity: Math.max(1, rps),
2143
+ // capacity >= 1 so the token bucket can fire at least once before refilling
2142
2144
  refillPerSecond: rps
2143
2145
  };
2144
2146
  }
@@ -9324,6 +9326,58 @@ function registerMarketFilterTools() {
9324
9326
  );
9325
9327
  return normalizeResponse(response);
9326
9328
  }
9329
+ },
9330
+ // ─────────────────────────────────────────────────────────────────────────
9331
+ // market_get_pair_spread — /api/v5/aigc/mcp/pair-spread
9332
+ // ─────────────────────────────────────────────────────────────────────────
9333
+ {
9334
+ name: "market_get_pair_spread",
9335
+ module: "market",
9336
+ description: "Compute spread statistics between two instruments over a lookback window. Returns absolute and ratio spread (mean / stdDev / median / min / max) plus an optional realtime spread snapshot. Use to size pairs trades, detect mean-reversion setups, or compare cross-listed contracts. Results are cached ~60s per (pair, bar, window) tuple. Read-only, no credentials required.\nDo NOT use to fetch raw candles (use market_get_candles) or single-instrument OI/funding (use market_get_oi_history / market_filter_oi_change).",
9337
+ isWrite: false,
9338
+ inputSchema: {
9339
+ type: "object",
9340
+ properties: {
9341
+ instIdA: {
9342
+ type: "string",
9343
+ description: "First instrument ID, e.g. BTC-USDT-SWAP"
9344
+ },
9345
+ instIdB: {
9346
+ type: "string",
9347
+ description: "Second instrument ID; must differ from instIdA"
9348
+ },
9349
+ bar: {
9350
+ type: "string",
9351
+ enum: ["5m", "15m"],
9352
+ description: "Bar size for the spread series. Default 15m. 1m is not supported."
9353
+ },
9354
+ window: {
9355
+ type: "string",
9356
+ description: "Lookback window. Format <n><unit>, units m/H/D/W (case-sensitive), max 1W. Default 1W."
9357
+ },
9358
+ backtestTime: {
9359
+ type: "number",
9360
+ description: "Anchor timestamp (ms epoch) for backtest mode. When provided, realtime is omitted."
9361
+ }
9362
+ },
9363
+ required: ["instIdA", "instIdB"]
9364
+ },
9365
+ handler: async (rawArgs, context) => {
9366
+ const args = asRecord(rawArgs);
9367
+ const body = compactObject({
9368
+ instIdA: requireString(args, "instIdA"),
9369
+ instIdB: requireString(args, "instIdB"),
9370
+ bar: readString(args, "bar"),
9371
+ window: readString(args, "window"),
9372
+ backtestTime: readNumber(args, "backtestTime")
9373
+ });
9374
+ const response = await context.client.publicPost(
9375
+ "/api/v5/aigc/mcp/pair-spread",
9376
+ body,
9377
+ publicRateLimit("market_get_pair_spread", 5)
9378
+ );
9379
+ return normalizeResponse(response);
9380
+ }
9327
9381
  }
9328
9382
  ];
9329
9383
  }
@@ -9332,6 +9386,219 @@ var NEWS_DETAIL = "/api/v5/orbit/news-detail";
9332
9386
  var NEWS_DOMAINS = "/api/v5/orbit/news-platform";
9333
9387
  var SENTIMENT_QUERY = "/api/v5/orbit/currency-sentiment-query";
9334
9388
  var SENTIMENT_RANKING = "/api/v5/orbit/currency-sentiment-ranking";
9389
+ var ECONOMIC_CALENDAR = "/api/v5/public/economic-calendar";
9390
+ var CALENDAR_REGIONS = [
9391
+ "afghanistan",
9392
+ "albania",
9393
+ "algeria",
9394
+ "andorra",
9395
+ "angola",
9396
+ "antigua_and_barbuda",
9397
+ "argentina",
9398
+ "armenia",
9399
+ "aruba",
9400
+ "australia",
9401
+ "austria",
9402
+ "azerbaijan",
9403
+ "bahamas",
9404
+ "bahrain",
9405
+ "bangladesh",
9406
+ "barbados",
9407
+ "belarus",
9408
+ "belgium",
9409
+ "belize",
9410
+ "benin",
9411
+ "bermuda",
9412
+ "bhutan",
9413
+ "bolivia",
9414
+ "bosnia_and_herzegovina",
9415
+ "botswana",
9416
+ "brazil",
9417
+ "brunei",
9418
+ "bulgaria",
9419
+ "burkina_faso",
9420
+ "burundi",
9421
+ "cambodia",
9422
+ "cameroon",
9423
+ "canada",
9424
+ "cape_verde",
9425
+ "cayman_islands",
9426
+ "central_african_republic",
9427
+ "chad",
9428
+ "chile",
9429
+ "china",
9430
+ "colombia",
9431
+ "comoros",
9432
+ "congo",
9433
+ "costa_rica",
9434
+ "croatia",
9435
+ "cuba",
9436
+ "cyprus",
9437
+ "czech_republic",
9438
+ "denmark",
9439
+ "djibouti",
9440
+ "dominica",
9441
+ "dominican_republic",
9442
+ "east_timor",
9443
+ "ecuador",
9444
+ "egypt",
9445
+ "el_salvador",
9446
+ "equatorial_guinea",
9447
+ "eritrea",
9448
+ "estonia",
9449
+ "ethiopia",
9450
+ "euro_area",
9451
+ "european_union",
9452
+ "faroe_islands",
9453
+ "fiji",
9454
+ "finland",
9455
+ "france",
9456
+ "g20",
9457
+ "g7",
9458
+ "gabon",
9459
+ "gambia",
9460
+ "georgia",
9461
+ "germany",
9462
+ "ghana",
9463
+ "greece",
9464
+ "greenland",
9465
+ "grenada",
9466
+ "guatemala",
9467
+ "guinea",
9468
+ "guinea_bissau",
9469
+ "guyana",
9470
+ "haiti",
9471
+ "honduras",
9472
+ "hong_kong",
9473
+ "hungary",
9474
+ "iceland",
9475
+ "imf",
9476
+ "india",
9477
+ "indonesia",
9478
+ "iran",
9479
+ "iraq",
9480
+ "ireland",
9481
+ "isle_of_man",
9482
+ "israel",
9483
+ "italy",
9484
+ "ivory_coast",
9485
+ "jamaica",
9486
+ "japan",
9487
+ "jordan",
9488
+ "kazakhstan",
9489
+ "kenya",
9490
+ "kiribati",
9491
+ "kosovo",
9492
+ "kuwait",
9493
+ "kyrgyzstan",
9494
+ "laos",
9495
+ "latvia",
9496
+ "lebanon",
9497
+ "lesotho",
9498
+ "liberia",
9499
+ "libya",
9500
+ "liechtenstein",
9501
+ "lithuania",
9502
+ "luxembourg",
9503
+ "macau",
9504
+ "macedonia",
9505
+ "madagascar",
9506
+ "malawi",
9507
+ "malaysia",
9508
+ "maldives",
9509
+ "mali",
9510
+ "malta",
9511
+ "mauritania",
9512
+ "mauritius",
9513
+ "mexico",
9514
+ "micronesia",
9515
+ "moldova",
9516
+ "monaco",
9517
+ "mongolia",
9518
+ "montenegro",
9519
+ "morocco",
9520
+ "mozambique",
9521
+ "myanmar",
9522
+ "namibia",
9523
+ "nepal",
9524
+ "netherlands",
9525
+ "new_caledonia",
9526
+ "new_zealand",
9527
+ "nicaragua",
9528
+ "niger",
9529
+ "nigeria",
9530
+ "north_korea",
9531
+ "northern_mariana_islands",
9532
+ "norway",
9533
+ "oman",
9534
+ "opec",
9535
+ "pakistan",
9536
+ "palau",
9537
+ "palestine",
9538
+ "panama",
9539
+ "papua_new_guinea",
9540
+ "paraguay",
9541
+ "peru",
9542
+ "philippines",
9543
+ "poland",
9544
+ "portugal",
9545
+ "puerto_rico",
9546
+ "qatar",
9547
+ "republic_of_the_congo",
9548
+ "romania",
9549
+ "russia",
9550
+ "rwanda",
9551
+ "samoa",
9552
+ "san_marino",
9553
+ "sao_tome_and_principe",
9554
+ "saudi_arabia",
9555
+ "senegal",
9556
+ "serbia",
9557
+ "seychelles",
9558
+ "sierra_leone",
9559
+ "singapore",
9560
+ "slovakia",
9561
+ "slovenia",
9562
+ "solomon_islands",
9563
+ "somalia",
9564
+ "south_africa",
9565
+ "south_korea",
9566
+ "south_sudan",
9567
+ "spain",
9568
+ "sri_lanka",
9569
+ "st_kitts_and_nevis",
9570
+ "st_lucia",
9571
+ "sudan",
9572
+ "suriname",
9573
+ "swaziland",
9574
+ "sweden",
9575
+ "switzerland",
9576
+ "syria",
9577
+ "taiwan",
9578
+ "tajikistan",
9579
+ "tanzania",
9580
+ "thailand",
9581
+ "togo",
9582
+ "tonga",
9583
+ "trinidad_and_tobago",
9584
+ "tunisia",
9585
+ "turkey",
9586
+ "turkmenistan",
9587
+ "uganda",
9588
+ "ukraine",
9589
+ "united_arab_emirates",
9590
+ "united_kingdom",
9591
+ "united_states",
9592
+ "uruguay",
9593
+ "uzbekistan",
9594
+ "vanuatu",
9595
+ "venezuela",
9596
+ "vietnam",
9597
+ "world",
9598
+ "yemen",
9599
+ "zambia",
9600
+ "zimbabwe"
9601
+ ];
9335
9602
  var NEWS_LANGUAGE = ["en-US", "zh-CN"];
9336
9603
  function langHeader(lang) {
9337
9604
  if (lang === "zh-CN" || lang === "zh_CN") return { "Accept-Language": "zh-CN" };
@@ -9629,12 +9896,61 @@ function registerNewsTools() {
9629
9896
  );
9630
9897
  return normalizeResponse(response);
9631
9898
  }
9899
+ },
9900
+ // -----------------------------------------------------------------------
9901
+ // Economic calendar
9902
+ // -----------------------------------------------------------------------
9903
+ {
9904
+ name: "news_list_calendar_regions",
9905
+ module: "news",
9906
+ description: "List all valid region values for the economic calendar. Returns a string array of snake_case region codes. Call this when economic-calendar returns empty results to verify the region value, or to help the user pick a valid region. Do NOT use to list news source platforms \u2014 use news_get_domains instead.",
9907
+ isWrite: false,
9908
+ inputSchema: { type: "object", properties: {}, required: [] },
9909
+ handler: async () => ({ data: CALENDAR_REGIONS })
9910
+ },
9911
+ {
9912
+ name: "news_get_economic_calendar",
9913
+ module: "news",
9914
+ description: "Get macro-economic calendar data (GDP, CPI, NFP, interest rate decisions, PMI, etc.). Returns scheduled and released economic events with forecast, previous, and actual values. Use when user asks about economic calendar, macro data, or specific indicators like NFP/CPI/GDP/FOMC. Do NOT use for news articles or sentiment \u2014 use news_get_latest or news_search instead.",
9915
+ isWrite: false,
9916
+ inputSchema: {
9917
+ type: "object",
9918
+ properties: {
9919
+ region: { type: "string", description: "Country/region filter in snake_case (e.g. united_states, euro_area, japan). Invalid values return empty results silently. If empty results, call news_list_calendar_regions to verify the value." },
9920
+ importance: { type: "string", enum: ["1", "2", "3"], description: "Importance level: 1=low, 2=medium, 3=high. Omit for all levels." },
9921
+ before: { type: "string", description: "Lower time bound \u2014 returns events NEWER than this timestamp (reversed semantics). Pair with 'after' for future-event windows. Unix ms." },
9922
+ after: { type: "string", description: "Upper time bound \u2014 returns events OLDER than this timestamp (reversed semantics). Default=now (returns past events). Pair with 'before' for a bounded window. Unix ms." },
9923
+ limit: { type: "number", minimum: 1, maximum: 100, description: "Number of results (default 100, max 100)." }
9924
+ },
9925
+ required: []
9926
+ },
9927
+ handler: async (rawArgs, context) => {
9928
+ const args = asRecord(rawArgs);
9929
+ const rawLimit = readNumber(args, "limit");
9930
+ const limit = rawLimit !== void 0 ? Math.min(rawLimit, 100) : void 0;
9931
+ const response = await context.client.privateGet(
9932
+ ECONOMIC_CALENDAR,
9933
+ compactObject({
9934
+ region: readString(args, "region"),
9935
+ importance: readString(args, "importance"),
9936
+ before: readString(args, "before"),
9937
+ after: readString(args, "after"),
9938
+ limit
9939
+ }),
9940
+ publicRateLimit("news_get_economic_calendar", 0.2)
9941
+ );
9942
+ return normalizeResponse(response);
9943
+ }
9632
9944
  }
9633
9945
  ];
9634
- const domainsIdx = tools.findIndex((t) => t.name === "news_get_domains");
9635
- if (domainsIdx === -1) throw new Error("news_get_domains not found in tools list");
9636
- const [domainsTool] = tools.splice(domainsIdx, 1);
9637
- return [...tools.map(withNewsDemoGuard), domainsTool];
9946
+ const exempt = /* @__PURE__ */ new Set(["news_get_domains", "news_list_calendar_regions"]);
9947
+ const exempted = [];
9948
+ const guarded = [];
9949
+ for (const t of tools) {
9950
+ if (exempt.has(t.name)) exempted.push(t);
9951
+ else guarded.push(t);
9952
+ }
9953
+ return [...guarded.map(withNewsDemoGuard), ...exempted];
9638
9954
  }
9639
9955
  var NEWS_DEMO_MESSAGE = "News features are not available in demo/simulated trading mode.";
9640
9956
  var NEWS_DEMO_SUGGESTION = "Switch to a live profile to use News features.";
@@ -11752,7 +12068,7 @@ var _require = createRequire(import.meta.url);
11752
12068
  var pkg = _require("../package.json");
11753
12069
  var SERVER_NAME = "okx-trade-mcp";
11754
12070
  var SERVER_VERSION = pkg.version;
11755
- var GIT_HASH = true ? "e6ad1d1e" : "dev";
12071
+ var GIT_HASH = true ? "0566db8f" : "dev";
11756
12072
 
11757
12073
  // src/server.ts
11758
12074
  import { Server } from "@modelcontextprotocol/sdk/server/index.js";