@aicoin/opendata-mcp 1.0.5 → 1.0.6

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/build/index.js +40 -10
  2. package/package.json +1 -1
package/build/index.js CHANGED
@@ -27,6 +27,19 @@ function generateSignature(accessKeyId, accessSecret) {
27
27
 
28
28
  // src/client/api.ts
29
29
  var DOMAIN = process.env.AICOIN_BASE_URL || "https://open.aicoin.com";
30
+ var AUTH_GUIDE = "\n\n--- How to fix ---\n1. Visit https://www.aicoin.com/opendata\n2. Register/login and create an API key\n3. Set AICOIN_ACCESS_KEY_ID and AICOIN_ACCESS_SECRET in your MCP config\n4. Restart your MCP client";
31
+ var UPGRADE_GUIDE = "\n\n--- How to fix ---\nYour current API tier lacks permission for this endpoint.\n1. Visit https://www.aicoin.com/opendata\n2. Upgrade your API key tier\nTiers: Basic(free) | Normal(\xA599) | Premium(\xA5299) | Professional(\xA5999)";
32
+ function throwApiError(status, body, path) {
33
+ let msg = `API ${status}: ${body}`;
34
+ if (status === 401) {
35
+ msg += AUTH_GUIDE;
36
+ } else if (status === 403) {
37
+ msg += UPGRADE_GUIDE;
38
+ msg += `
39
+ Endpoint: ${path}`;
40
+ }
41
+ throw new Error(msg);
42
+ }
30
43
  function getCredentials() {
31
44
  const key = process.env.AICOIN_ACCESS_KEY_ID;
32
45
  const secret = process.env.AICOIN_ACCESS_SECRET;
@@ -48,7 +61,7 @@ async function apiGet(path, params = {}) {
48
61
  const res = await fetch(url);
49
62
  if (!res.ok) {
50
63
  const body = await res.text();
51
- throw new Error(`API ${res.status}: ${body}`);
64
+ throwApiError(res.status, body, path);
52
65
  }
53
66
  const text = await res.text();
54
67
  try {
@@ -68,7 +81,7 @@ async function apiPost(path, body = {}) {
68
81
  });
69
82
  if (!res.ok) {
70
83
  const txt2 = await res.text();
71
- throw new Error(`API ${res.status}: ${txt2}`);
84
+ throwApiError(res.status, txt2, path);
72
85
  }
73
86
  const txt = await res.text();
74
87
  try {
@@ -890,19 +903,36 @@ function registerMarketTools(server2) {
890
903
  "get_indicator_kline_data",
891
904
  "Get indicator K-line data records",
892
905
  {
893
- trading_pair: z3.string().describe("Trading pair key"),
894
- indicator: z3.string().describe("Indicator name"),
895
- period: z3.string().optional().describe("Period: 1min,5min,15min,1hour,4hour,1day"),
896
- limit: z3.string().optional().describe("Number of records")
906
+ symbol: z3.string().describe(
907
+ "Trading pair, e.g. btcswapusdt:binance"
908
+ ),
909
+ indicator_key: z3.string().describe(
910
+ "Indicator key: fundflow, aiaggtrade, fr, etc."
911
+ ),
912
+ period: z3.string().optional().describe(
913
+ "Period in seconds: 900=15min, 3600=1h, 14400=4h, 86400=1d"
914
+ ),
915
+ size: z3.string().optional().describe("Number of records, 1-500"),
916
+ since: z3.string().optional().describe("Start timestamp"),
917
+ open_time: z3.string().optional().describe("Open time offset: 0 or 8")
897
918
  },
898
- async ({ trading_pair, indicator, period, limit }) => {
919
+ async ({
920
+ symbol,
921
+ indicator_key,
922
+ period,
923
+ size,
924
+ since,
925
+ open_time
926
+ }) => {
899
927
  try {
900
928
  const params = {
901
- trading_pair,
902
- indicator
929
+ symbol,
930
+ indicator_key
903
931
  };
904
932
  if (period) params.period = period;
905
- if (limit) params.limit = limit;
933
+ if (size) params.size = size;
934
+ if (since) params.since = since;
935
+ if (open_time) params.open_time = open_time;
906
936
  return ok3(
907
937
  await apiGet(
908
938
  "/api/v2/indicatorKline/dataRecords",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aicoin/opendata-mcp",
3
- "version": "1.0.5",
3
+ "version": "1.0.6",
4
4
  "description": "AiCoin OpenData MCP Server - crypto market data via AiCoin Open API",
5
5
  "main": "build/index.js",
6
6
  "type": "module",