hvip-mcp-server 0.3.1 → 0.3.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.
Files changed (2) hide show
  1. package/dist/index.js +26 -15
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -26557,11 +26557,19 @@ async function request(method, path3, options = {}) {
26557
26557
  headers["OK-ACCESS-PASSPHRASE"] = options.auth.passphrase;
26558
26558
  if (options.auth.isDemo) headers["x-simulated-trading"] = "1";
26559
26559
  }
26560
- const res = await fetch(BASE + fullPath, {
26561
- method,
26562
- headers,
26563
- ...bodyStr ? { body: bodyStr } : {}
26564
- });
26560
+ const controller = new AbortController();
26561
+ const timer = setTimeout(() => controller.abort(), 3e4);
26562
+ let res;
26563
+ try {
26564
+ res = await fetch(BASE + fullPath, {
26565
+ method,
26566
+ headers,
26567
+ body: bodyStr || void 0,
26568
+ signal: controller.signal
26569
+ });
26570
+ } finally {
26571
+ clearTimeout(timer);
26572
+ }
26565
26573
  if (!res.ok) throw new Error(`HTTP ${res.status} ${res.statusText}`);
26566
26574
  const json = await res.json();
26567
26575
  if (json.code !== "0") throw new Error(`OKX ${json.code}: ${json.msg ?? "unknown error"}`);
@@ -30056,6 +30064,8 @@ function registerFundingTools(server, auth) {
30056
30064
  },
30057
30065
  async ({ ccy, amt, dest, toAddr, chain, fee }) => {
30058
30066
  if (!auth) return toError(AUTH_REQUIRED);
30067
+ if (dest === "4" && !toAddr) return toError(new Error("\u94FE\u4E0A\u63D0\u5E01\u5FC5\u987B\u63D0\u4F9B toAddr\uFF08\u76EE\u6807\u5730\u5740\uFF09"));
30068
+ if (dest === "4" && toAddr && !/^[A-Za-z0-9]{20,}$/.test(toAddr)) return toError(new Error(`\u76EE\u6807\u5730\u5740 "${toAddr}" \u683C\u5F0F\u65E0\u6548`));
30059
30069
  try {
30060
30070
  const body = { ccy, amt, dest };
30061
30071
  if (toAddr) body.toAddr = toAddr;
@@ -36654,7 +36664,11 @@ var WsManager = class {
36654
36664
  hint: parsed.code === "60001" ? "\u9891\u9053\u540D\u4E0D\u652F\u6301\u6216\u53C2\u6570\u9519\u8BEF\uFF0C\u8BF7\u68C0\u67E5 channel \u503C" : parsed.code === "60003" ? "\u767B\u5F55\u5DF2\u8FC7\u671F\uFF0C\u8BF7\u91CD\u8FDE" : parsed.code === "60009" ? "\u79C1\u6709\u9891\u9053\u9700\u8981\u5148 login\uFF08API Key \u7B7E\u540D\uFF09" : `OKX WS \u9519\u8BEF ${parsed.code}`
36655
36665
  }
36656
36666
  });
36657
- if (this.events.length > 1e4) this.events = this.events.slice(-5e3);
36667
+ if (this.events.length > 1e4) {
36668
+ if (this.events.length === 10001) process.stderr.write(`[WS] \u26A0\uFE0F \u4E8B\u4EF6\u7F13\u51B2\u5DF2\u6EE1(>10000)\uFF0C\u5F00\u59CB\u622A\u65AD\u65E7\u4E8B\u4EF6
36669
+ `);
36670
+ this.events = this.events.slice(-5e3);
36671
+ }
36658
36672
  return;
36659
36673
  }
36660
36674
  if (parsed.arg && parsed.data) {
@@ -36667,7 +36681,11 @@ var WsManager = class {
36667
36681
  ts: Date.now(),
36668
36682
  data: parsed.data
36669
36683
  });
36670
- if (this.events.length > 1e4) this.events = this.events.slice(-5e3);
36684
+ if (this.events.length > 1e4) {
36685
+ if (this.events.length === 10001) process.stderr.write(`[WS] \u26A0\uFE0F \u4E8B\u4EF6\u7F13\u51B2\u5DF2\u6EE1(>10000)\uFF0C\u5F00\u59CB\u622A\u65AD\u65E7\u4E8B\u4EF6
36686
+ `);
36687
+ this.events = this.events.slice(-5e3);
36688
+ }
36671
36689
  break;
36672
36690
  }
36673
36691
  }
@@ -38087,7 +38105,7 @@ async function startHttp(server, version2, auth, readOnly, skipped) {
38087
38105
  });
38088
38106
  await server.connect(transport);
38089
38107
  const httpServer = (0, import_node_http.createServer)(async (req, res) => {
38090
- res.setHeader("Access-Control-Allow-Origin", "*");
38108
+ res.setHeader("Access-Control-Allow-Origin", `http://${host}:${port}`);
38091
38109
  res.setHeader("Access-Control-Allow-Methods", "GET, POST, OPTIONS");
38092
38110
  res.setHeader("Access-Control-Allow-Headers", "Content-Type, Mcp-Session-Id");
38093
38111
  if (req.method === "OPTIONS") {
@@ -38119,13 +38137,6 @@ async function startHttp(server, version2, auth, readOnly, skipped) {
38119
38137
  }
38120
38138
  return;
38121
38139
  }
38122
- if (req.method === "GET" && req.url === "/config") {
38123
- res.writeHead(200, { "Content-Type": "application/json" });
38124
- res.end(JSON.stringify({
38125
- claudeApiKey: process.env.CLAUDE_API_KEY || ""
38126
- }));
38127
- return;
38128
- }
38129
38140
  if (req.method === "GET" && req.url === "/health") {
38130
38141
  res.writeHead(200, { "Content-Type": "application/json" });
38131
38142
  res.end(JSON.stringify({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hvip-mcp-server",
3
- "version": "0.3.1",
3
+ "version": "0.3.2",
4
4
  "description": "hvip MCP Server — 365 工具覆盖 97.7% OKX REST API,含交易/行情/资金/策略/预测市场/技术指标/Smart Money(非 OKX 官方产品)",
5
5
  "homepage": "https://github.com/okx-wallet-H/hvip-mcp",
6
6
  "repository": {