@aicoin/opendata-mcp 1.0.1 → 1.0.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/.env.example CHANGED
@@ -1,9 +1,7 @@
1
1
  # AiCoin OpenData MCP - API credentials
2
- # NOTE: AiCoin 后台的字段名和这里的变量名是反的!
3
- # 后台 "api_key" → 填到 AICOIN_ACCESS_KEY(用作 AccessKeyId)
4
- # 后台 "access_key" → 填到 AICOIN_ACCESS_SECRET(用作 HMAC 签名密钥)
5
- AICOIN_ACCESS_KEY=your_api_key_from_aicoin
6
- AICOIN_ACCESS_SECRET=your_access_key_from_aicoin
2
+ # https://www.aicoin.com/openapi 获取
3
+ AICOIN_ACCESS_KEY_ID=your_access_key_id
4
+ AICOIN_ACCESS_SECRET=your_access_secret
7
5
 
8
- # Optional: API base URL (default: https://open.aicoin.com/api/v2)
9
- # AICOIN_BASE_URL=https://open.aicoin.com/api/v2
6
+ # Optional: API base URL (default: https://open.aicoin.com)
7
+ # AICOIN_BASE_URL=https://open.aicoin.com
package/README.md CHANGED
@@ -22,7 +22,7 @@ npm start
22
22
  ## Environment Variables
23
23
 
24
24
  ```bash
25
- AICOIN_ACCESS_KEY=your_access_key_id
25
+ AICOIN_ACCESS_KEY_ID=your_access_key_id
26
26
  AICOIN_ACCESS_SECRET=your_access_secret
27
27
  ```
28
28
 
@@ -156,9 +156,7 @@ AICOIN_ACCESS_SECRET=your_access_secret
156
156
 
157
157
  ## Client Configuration
158
158
 
159
- > **Note:** AiCoin 后台字段名和环境变量是反的:
160
- > - 后台 `api_key` → `AICOIN_ACCESS_KEY`
161
- > - 后台 `access_key` → `AICOIN_ACCESS_SECRET`
159
+ > Get your API credentials at [AiCoin OpenAPI](https://www.aicoin.com/openapi)
162
160
 
163
161
  ### Claude Desktop
164
162
 
@@ -171,8 +169,8 @@ Add to `~/Library/Application Support/Claude/claude_desktop_config.json`:
171
169
  "command": "npx",
172
170
  "args": ["-y", "@aicoin/opendata-mcp"],
173
171
  "env": {
174
- "AICOIN_ACCESS_KEY": "your_api_key_from_aicoin",
175
- "AICOIN_ACCESS_SECRET": "your_access_key_from_aicoin"
172
+ "AICOIN_ACCESS_KEY_ID": "your_access_key_id",
173
+ "AICOIN_ACCESS_SECRET": "your_access_secret"
176
174
  }
177
175
  }
178
176
  }
@@ -190,8 +188,8 @@ Add to `.cursor/mcp.json`:
190
188
  "command": "npx",
191
189
  "args": ["-y", "@aicoin/opendata-mcp"],
192
190
  "env": {
193
- "AICOIN_ACCESS_KEY": "your_api_key_from_aicoin",
194
- "AICOIN_ACCESS_SECRET": "your_access_key_from_aicoin"
191
+ "AICOIN_ACCESS_KEY_ID": "your_access_key_id",
192
+ "AICOIN_ACCESS_SECRET": "your_access_secret"
195
193
  }
196
194
  }
197
195
  }
@@ -214,8 +212,8 @@ Add to `.vscode/mcp.json`:
214
212
  "command": "npx",
215
213
  "args": ["-y", "@aicoin/opendata-mcp"],
216
214
  "env": {
217
- "AICOIN_ACCESS_KEY": "your_api_key_from_aicoin",
218
- "AICOIN_ACCESS_SECRET": "your_access_key_from_aicoin"
215
+ "AICOIN_ACCESS_KEY_ID": "your_access_key_id",
216
+ "AICOIN_ACCESS_SECRET": "your_access_secret"
219
217
  }
220
218
  }
221
219
  }
package/build/index.js CHANGED
@@ -28,11 +28,11 @@ function generateSignature(accessKeyId, accessSecret) {
28
28
  // src/client/api.ts
29
29
  var DOMAIN = process.env.AICOIN_BASE_URL || "https://open.aicoin.com";
30
30
  function getCredentials() {
31
- const key = process.env.AICOIN_ACCESS_KEY;
31
+ const key = process.env.AICOIN_ACCESS_KEY_ID || process.env.AICOIN_ACCESS_KEY;
32
32
  const secret = process.env.AICOIN_ACCESS_SECRET;
33
33
  if (!key || !secret) {
34
34
  throw new Error(
35
- "Missing AICOIN_ACCESS_KEY or AICOIN_ACCESS_SECRET"
35
+ "Missing AICOIN_ACCESS_KEY_ID or AICOIN_ACCESS_SECRET. Register at https://www.aicoin.com/openapi to get your API credentials."
36
36
  );
37
37
  }
38
38
  return { key, secret };
@@ -2248,6 +2248,196 @@ function registerHyperliquidTools(server2) {
2248
2248
  );
2249
2249
  }
2250
2250
 
2251
+ // src/tools/guide.ts
2252
+ import { z as z6 } from "zod";
2253
+ function registerGuideTools(server2) {
2254
+ server2.tool(
2255
+ "guide_get_api_key",
2256
+ "Guide user to register AiCoin account and generate OpenAPI key. Call this when API returns 401/403 or credentials are missing.",
2257
+ {},
2258
+ async () => {
2259
+ const guide = `# AiCoin OpenAPI Key Setup Guide
2260
+
2261
+ ## Step 1: Register / Login
2262
+ Visit https://www.aicoin.com and create an account (or log in).
2263
+
2264
+ ## Step 2: Go to OpenAPI Management
2265
+ Visit https://www.aicoin.com/openapi to manage your API keys.
2266
+
2267
+ ## Step 3: Create API Key
2268
+ Click "Create Key" and select your desired tier:
2269
+
2270
+ | Tier | Price | Rate Limit | Features |
2271
+ |------|-------|------------|----------|
2272
+ | Basic | Free | 10 req/min | Market data, news, basic indicators |
2273
+ | Normal | \xA599/mo | 60 req/min | + Funding rate, liquidation data |
2274
+ | Premium | \xA5299/mo | 120 req/min | + Depth data, whale tracking |
2275
+ | Professional | \xA5999/mo | 300 req/min | + Full depth, all features |
2276
+
2277
+ ## Step 4: Configure MCP Server
2278
+ After creating the key, you will get two values:
2279
+ - **accessKeyId** \u2014 your public key ID
2280
+ - **accessSecret** \u2014 your signing secret
2281
+
2282
+ Add them to your MCP client config:
2283
+
2284
+ \`\`\`json
2285
+ {
2286
+ "mcpServers": {
2287
+ "aicoin-opendata": {
2288
+ "command": "npx",
2289
+ "args": ["-y", "@aicoin/opendata-mcp"],
2290
+ "env": {
2291
+ "AICOIN_ACCESS_KEY_ID": "<your accessKeyId>",
2292
+ "AICOIN_ACCESS_SECRET": "<your accessSecret>"
2293
+ }
2294
+ }
2295
+ }
2296
+ }
2297
+ \`\`\`
2298
+
2299
+ After updating the config, restart your MCP client to apply.`;
2300
+ return {
2301
+ content: [{ type: "text", text: guide }]
2302
+ };
2303
+ }
2304
+ );
2305
+ server2.tool(
2306
+ "guide_upgrade_tier",
2307
+ "Guide user to upgrade API tier when current tier lacks permission for certain endpoints. Call this when API returns 403 or feature is tier-restricted.",
2308
+ {
2309
+ current_error: z6.string().optional().describe("The error message received"),
2310
+ endpoint: z6.string().optional().describe("The endpoint that returned 403")
2311
+ },
2312
+ async ({ current_error, endpoint }) => {
2313
+ const guide = `# AiCoin API Tier Upgrade Guide
2314
+
2315
+ ## Current Issue
2316
+ ${current_error ? `Error: ${current_error}` : "Your current API tier does not have permission for this endpoint."}
2317
+ ${endpoint ? `Endpoint: ${endpoint}` : ""}
2318
+
2319
+ ## API Tier Comparison
2320
+
2321
+ | Feature | Basic (Free) | Normal (\xA599) | Premium (\xA5299) | Professional (\xA5999) |
2322
+ |---------|:---:|:---:|:---:|:---:|
2323
+ | Market tickers & K-lines | \u2705 | \u2705 | \u2705 | \u2705 |
2324
+ | News & flash | \u2705 | \u2705 | \u2705 | \u2705 |
2325
+ | Index data | \u2705 | \u2705 | \u2705 | \u2705 |
2326
+ | Funding rate history | \u274C | \u2705 | \u2705 | \u2705 |
2327
+ | Liquidation data | \u274C | \u2705 | \u2705 | \u2705 |
2328
+ | OI history | \u274C | \u2705 | \u2705 | \u2705 |
2329
+ | Whale order tracking | \u274C | \u274C | \u2705 | \u2705 |
2330
+ | Depth data | \u274C | \u274C | \u2705 | \u2705 |
2331
+ | Strategy signals | \u274C | \u274C | \u274C | \u2705 |
2332
+ | Full depth & grouped | \u274C | \u274C | \u274C | \u2705 |
2333
+
2334
+ ## How to Upgrade
2335
+ 1. Visit https://www.aicoin.com/openapi
2336
+ 2. Go to your API key management page
2337
+ 3. Click "Upgrade" on your current key
2338
+ 4. Select the tier that includes the features you need
2339
+ 5. Complete payment
2340
+
2341
+ After upgrading, your existing key will be automatically upgraded. No config changes needed.`;
2342
+ return {
2343
+ content: [{ type: "text", text: guide }]
2344
+ };
2345
+ }
2346
+ );
2347
+ server2.tool(
2348
+ "guide_setup_ccxt_trade",
2349
+ "Guide user to set up the AiCoin Trade MCP server (CCXT-based) for executing trades. Includes exchange API key setup and local proxy configuration.",
2350
+ {
2351
+ exchange: z6.string().optional().describe(
2352
+ "Target exchange: binance, okx, bybit, bitget, gate, huobi, pionex, hyperliquid"
2353
+ )
2354
+ },
2355
+ async ({ exchange }) => {
2356
+ const ex = exchange?.toLowerCase() || "binance";
2357
+ const needsPass = ex === "okx" || ex === "bitget";
2358
+ const EX = ex.toUpperCase();
2359
+ let keyBlock = `${EX}_API_KEY=your_api_key
2360
+ ${EX}_SECRET=your_secret`;
2361
+ if (needsPass) keyBlock += `
2362
+ ${EX}_PASSPHRASE=your_passphrase`;
2363
+ let envJson = ` "${EX}_API_KEY": "<your_api_key>",
2364
+ "${EX}_SECRET": "<your_secret>"`;
2365
+ if (needsPass) {
2366
+ envJson += `,
2367
+ "${EX}_PASSPHRASE": "<your_passphrase>"`;
2368
+ }
2369
+ const guide = getTradeGuide(ex, EX, keyBlock, envJson);
2370
+ return {
2371
+ content: [{ type: "text", text: guide }]
2372
+ };
2373
+ }
2374
+ );
2375
+ }
2376
+ function getExchangeGuide(ex) {
2377
+ const guides = {
2378
+ binance: '1. Log in to https://www.binance.com\n2. Go to Account \u2192 API Management\n3. Create API key, enable "Spot Trading" permission\n4. Recommended: set IP whitelist',
2379
+ okx: '1. Log in to https://www.okx.com\n2. Go to Account \u2192 API \u2192 Create API Key\n3. Set passphrase, enable "Trade" permission\n4. Note: OKX requires a passphrase in addition to key/secret',
2380
+ bybit: '1. Log in to https://www.bybit.com\n2. Go to Account \u2192 API Management\n3. Create API key with "Trade" permission',
2381
+ bitget: '1. Log in to https://www.bitget.com\n2. Go to Account \u2192 API Management\n3. Create API key with passphrase, enable "Trade"\n4. Note: Bitget requires a passphrase',
2382
+ gate: '1. Log in to https://www.gate.io\n2. Go to Account \u2192 API Management\n3. Create API key with "Spot Trade" permission',
2383
+ huobi: '1. Log in to https://www.huobi.com\n2. Go to Account \u2192 API Management\n3. Create API key with "Trade" permission',
2384
+ pionex: "1. Log in to https://www.pionex.com\n2. Go to Account \u2192 API Management\n3. Create API key",
2385
+ hyperliquid: "1. Visit https://app.hyperliquid.xyz\n2. Connect your wallet\n3. Go to API \u2192 Generate API Key"
2386
+ };
2387
+ return guides[ex] || guides.binance;
2388
+ }
2389
+ function getTradeGuide(ex, EX, keyBlock, envJson) {
2390
+ return `# AiCoin Trade MCP Setup Guide (CCXT)
2391
+
2392
+ > All API keys are stored locally only. They are never sent to AiCoin servers.
2393
+
2394
+ ## Step 1: Get Exchange API Key
2395
+
2396
+ ${getExchangeGuide(ex)}
2397
+
2398
+ \`\`\`
2399
+ ${keyBlock}
2400
+ \`\`\`
2401
+
2402
+ ## Step 2: Proxy Configuration
2403
+
2404
+ Many exchanges require proxy access in certain regions.
2405
+ If you are in mainland China or behind a firewall, you likely need a local proxy.
2406
+
2407
+ - If YES: set \`USE_PROXY=true\` and \`PROXY_URL\` (default: \`http://127.0.0.1:7890\`)
2408
+ - If NO: set \`USE_PROXY=false\` or leave it unset
2409
+
2410
+ Common proxy ports:
2411
+ - Clash: 7890
2412
+ - V2Ray: 10808
2413
+ - Shadowsocks: 1080
2414
+
2415
+ ## Step 3: Configure MCP Client
2416
+
2417
+ \`\`\`json
2418
+ {
2419
+ "mcpServers": {
2420
+ "aicoin-trade": {
2421
+ "command": "npx",
2422
+ "args": ["-y", "@aicoin/trade-mcp"],
2423
+ "env": {
2424
+ "DEFAULT_EXCHANGE": "${ex}",
2425
+ ${envJson},
2426
+ "USE_PROXY": "true",
2427
+ "PROXY_URL": "http://127.0.0.1:7890"
2428
+ }
2429
+ }
2430
+ }
2431
+ }
2432
+ \`\`\`
2433
+
2434
+ ## Security Notes
2435
+ - API keys are stored in your local MCP config only
2436
+ - Never share your secret key with anyone
2437
+ - Enable IP whitelist on the exchange if possible
2438
+ - For trading, enable "Trade" permission; disable "Withdraw"`;
2439
+ }
2440
+
2251
2441
  // src/tools/index.ts
2252
2442
  function registerAllTools(server2) {
2253
2443
  registerCoinTools(server2);
@@ -2255,6 +2445,7 @@ function registerAllTools(server2) {
2255
2445
  registerMarketTools(server2);
2256
2446
  registerFeatureTools(server2);
2257
2447
  registerHyperliquidTools(server2);
2448
+ registerGuideTools(server2);
2258
2449
  }
2259
2450
 
2260
2451
  // src/index.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aicoin/opendata-mcp",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "AiCoin OpenData MCP Server - crypto market data via AiCoin Open API",
5
5
  "main": "build/index.js",
6
6
  "type": "module",