asrai-mcp 1.2.1 → 1.3.0

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/README.md CHANGED
@@ -79,8 +79,47 @@ Each API call costs **$0.005 USDC** from your wallet on Base mainnet. Make sure
79
79
  | `chain_tokens(chain, max_mcap)` | Low-cap tokens on a specific chain | $0.005 |
80
80
  | `portfolio` | Abu's curated model portfolio — investment reference | $0.005 |
81
81
  | `ask_ai(question)` | AI analyst freeform answer | $0.01 |
82
+ | `positions` | Your live open positions across connected exchanges (MEXC, Binance, Lighter) — requires exchange keys configured via /exchange_apis in Telegram | $0.005–$0.015 |
82
83
  | `indicator_guide(name)` | Reference guide for Asrai-specific indicators | FREE |
83
84
 
85
+ ## Exchange positions (`positions` tool)
86
+
87
+ To use the `positions` tool, add your exchange API keys to `~/.env`:
88
+
89
+ ```
90
+ # MEXC
91
+ MEXC_API_KEY=mx0vgl...
92
+ MEXC_SECRET_KEY=your_secret...
93
+
94
+ # Binance
95
+ BINANCE_API_KEY=your_api_key...
96
+ BINANCE_SECRET_KEY=your_secret...
97
+
98
+ # Lighter
99
+ LIGHTER_L1_ADDRESS=0x...
100
+ LIGHTER_API_PRIVATE_KEY=0x...
101
+ ```
102
+
103
+ Or pass them in the Claude Desktop config `env` block:
104
+
105
+ ```json
106
+ {
107
+ "mcpServers": {
108
+ "asrai": {
109
+ "command": "npx",
110
+ "args": ["-y", "asrai-mcp@latest"],
111
+ "env": {
112
+ "ASRAI_PRIVATE_KEY": "0x<your_base_wallet_private_key>",
113
+ "MEXC_API_KEY": "mx0vgl...",
114
+ "MEXC_SECRET_KEY": "your_secret..."
115
+ }
116
+ }
117
+ }
118
+ }
119
+ ```
120
+
121
+ Only configure the exchanges you use — the tool auto-detects which keys are set and fetches only those.
122
+
84
123
  ## Spend limit
85
124
 
86
125
  Default session cap: **$2.00 USDC**. To change:
package/bin/asrai.js CHANGED
@@ -38,7 +38,8 @@ if (!tool) {
38
38
  console.error('Usage: asrai <tool> [args...]');
39
39
  console.error('Tools: ask_ai, technical_analysis, sentiment, forecast, market_overview,');
40
40
  console.error(' coin_info, screener, smart_money, elliott_wave, ichimoku, cashflow,');
41
- console.error(' dexscreener, chain_tokens, portfolio, channel_summary, indicator_guide');
41
+ console.error(' dexscreener, chain_tokens, portfolio, channel_summary, indicator_guide,');
42
+ console.error(' positions (requires MEXC_API_KEY, BINANCE_API_KEY, or LIGHTER_L1_ADDRESS in ~/.env)');
42
43
  process.exit(1);
43
44
  }
44
45
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "asrai-mcp",
3
- "version": "1.2.1",
3
+ "version": "1.3.0",
4
4
  "description": "Asrai crypto analysis MCP server — pay-per-use via x402 on Base. Zero install: just npx.",
5
5
  "keywords": [
6
6
  "mcp",
package/skill/SKILL.md CHANGED
@@ -36,6 +36,7 @@ Use Asrai tools when the user asks about crypto prices, market analysis, trading
36
36
  | "unlocked coins" / vesting pressure | `late_unlocked_coins` | — |
37
37
  | "low cap gems" / DEX / chain tokens | `chain_tokens` | `dexscreener`, `high_volume_low_cap` |
38
38
  | "portfolio" / "Abu's picks" | `portfolio` | `coin_info` |
39
+ | "my positions" / "open trades" / "my PnL" / "what am I trading" | `positions` | — |
39
40
 
40
41
  **Important:** For buy opportunity questions ALWAYS call `trade_signals` — it combines trending movers, bounces, SAR & MACD entries, RSI, and Galaxy Score in one call.
41
42
 
@@ -103,8 +104,28 @@ Requires `ASRAI_PRIVATE_KEY` set in `~/.env` or environment. Payment is signed a
103
104
  | `chain_tokens(chain, max_mcap)` | Low-cap tokens on a specific chain | $0.005 |
104
105
  | `portfolio` | Abu's curated model portfolio — investment reference | $0.005 |
105
106
  | `ask_ai(question)` | AI analyst freeform answer | $0.01 |
107
+ | `positions` | Your live open positions across connected exchanges (MEXC, Binance, Lighter) — requires exchange keys configured via /exchange_apis in Telegram | $0.005–$0.015 |
106
108
  | `indicator_guide(name)` | Reference guide for Asrai-specific indicators | FREE |
107
109
 
110
+ ## Exchange positions setup
111
+
112
+ To use the `positions` tool, add exchange API keys to `~/.env`:
113
+
114
+ ```
115
+ # MEXC
116
+ MEXC_API_KEY=mx0vgl...
117
+ MEXC_SECRET_KEY=your_secret...
118
+
119
+ # Binance
120
+ BINANCE_API_KEY=your_api_key...
121
+ BINANCE_SECRET_KEY=your_secret...
122
+
123
+ # Lighter
124
+ LIGHTER_L1_ADDRESS=0x...
125
+ LIGHTER_API_PRIVATE_KEY=0x...
126
+ ```
127
+
128
+ Only configure the exchanges you use — tool auto-detects which keys are set.
108
129
 
109
130
  🎨 Output Style — Human-Friendly Format
110
131
 
@@ -74,6 +74,11 @@ x402 automatic — $0.005 USDC per endpoint on Base mainnet ($0.01 for `/ai`)
74
74
  - `GET /api/portfolio/` — full portfolio
75
75
  - `GET /api/portfolio/<symbol>` — portfolio for specific coin
76
76
 
77
+ ### Exchange Positions
78
+ - `GET /api/exchange/<exchange>/<api_key>/<secret_key>` — live positions for exchange (`mexc`, `binance`, `lighter`)
79
+ - Keys read from `~/.env` automatically: `MEXC_API_KEY`, `MEXC_SECRET_KEY`, `BINANCE_API_KEY`, `BINANCE_SECRET_KEY`, `LIGHTER_L1_ADDRESS`, `LIGHTER_API_PRIVATE_KEY`
80
+ - Returns: account info, open positions, unrealized PnL, leverage, margin, liquidation price
81
+
77
82
  ### AI
78
83
  - `POST /ai` body: `{"message": "<question>"}` — AI analyst ($0.01)
79
84
 
@@ -251,6 +251,15 @@ export const TOOLS = [
251
251
  required: [],
252
252
  },
253
253
  },
254
+ {
255
+ name: "positions",
256
+ description:
257
+ "Get your live open positions across connected exchanges (MEXC, Binance, Lighter). " +
258
+ "Shows entry price, mark price, unrealized PnL, leverage, margin, and liquidation price for each position. " +
259
+ "Requires exchange API keys to be configured — add them via /exchange_apis in the Asrai Telegram bot. " +
260
+ "Use when asked: 'show my positions', 'what am I trading', 'my open trades', 'my PnL', 'my exchange positions'.",
261
+ inputSchema: { type: "object", properties: {}, required: [] },
262
+ },
254
263
  {
255
264
  name: "indicator_guide",
256
265
  description:
package/src/tools.js CHANGED
@@ -102,3 +102,41 @@ export const {
102
102
  export async function ask_ai(question) {
103
103
  return JSON.stringify(await _post("/ai", { message: question }), null, 2);
104
104
  }
105
+
106
+ // ── positions — fetch live exchange positions from env-configured keys ─────────
107
+
108
+ export async function positions() {
109
+ const exchanges = [
110
+ {
111
+ name: "mexc",
112
+ api_key: process.env.MEXC_API_KEY,
113
+ secret_key: process.env.MEXC_SECRET_KEY,
114
+ },
115
+ {
116
+ name: "binance",
117
+ api_key: process.env.BINANCE_API_KEY,
118
+ secret_key: process.env.BINANCE_SECRET_KEY,
119
+ },
120
+ {
121
+ name: "lighter",
122
+ api_key: process.env.LIGHTER_L1_ADDRESS,
123
+ secret_key: process.env.LIGHTER_API_PRIVATE_KEY,
124
+ },
125
+ ].filter(e => e.api_key && e.secret_key);
126
+
127
+ if (exchanges.length === 0) {
128
+ return JSON.stringify({ error: "No exchange keys configured. Set MEXC_API_KEY/MEXC_SECRET_KEY, BINANCE_API_KEY/BINANCE_SECRET_KEY, or LIGHTER_L1_ADDRESS/LIGHTER_API_PRIVATE_KEY in your ~/.env" });
129
+ }
130
+
131
+ const results = {};
132
+ await Promise.allSettled(exchanges.map(async ({ name, api_key, secret_key }) => {
133
+ try {
134
+ const data = await _get(`/api/exchange/${encodeURIComponent(name)}/${encodeURIComponent(api_key)}/${encodeURIComponent(secret_key)}`);
135
+ results[name] = data;
136
+ } catch (err) {
137
+ results[name] = { error: err.message };
138
+ }
139
+ }));
140
+
141
+ return JSON.stringify(results, null, 2);
142
+ }