cryptoiz-mcp 4.12.0 → 4.13.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 (4) hide show
  1. package/README.md +114 -95
  2. package/index.js +172 -0
  3. package/package.json +15 -25
  4. package/src/index.js +0 -407
package/README.md CHANGED
@@ -1,126 +1,145 @@
1
- # CryptoIZ MCP Server v4.10.0
1
+ # CryptoIZ MCP Server
2
2
 
3
- **Solana DEX smart money signals via x402 payment protocol**
3
+ AI-powered Solana DEX trading intelligence for Claude Desktop with x402 USDC micropayments.
4
4
 
5
- ## What's New in v4.10.0
5
+ **Version:** 4.13.2
6
+ **Platform:** https://cryptoiz.org
7
+ **Setup Guide:** https://cryptoiz.org/McpLanding
6
8
 
7
- **Fixed Output for All Tools:**
8
- - `get_divergence` now includes contract addresses + DexScreener charts
9
- - `get_accumulation` now includes contract addresses + DexScreener charts
10
- - All tools include CTA links to cryptoiz.org
11
- - Copy-paste friendly CA lists at bottom of output
9
+ ## What's New in v4.13.2
12
10
 
13
- ✅ **Enhanced Platform Links:**
14
- - Every response includes `platform`, `setup_guide`, `twitter` links
15
- - Users can discover full feature set at cryptoiz.org/McpLanding
11
+ ✅ **Tier Holder Delta Support** - `get_accumulation` now returns holder change data:
12
+ - `h100_delta_4h`, `h1k_delta_4h`, `h10k_delta_4h` - Holder count changes over 4h
13
+ - `h100_pct_4h`, `h1k_pct_4h`, `h10k_pct_4h` - Percentage changes
14
+ - `holders_over_100`, `holders_over_1k`, `holders_over_10k` - Absolute counts
15
+
16
+ ## Features
17
+
18
+ - 🎯 **Smart Money Signals** - Track whale & dolphin accumulation
19
+ - 📊 **Divergence Scanner** - Price-momentum divergence detection
20
+ - 💎 **Accumulation Tracker** - Top tokens in accumulation phase
21
+ - 📈 **BTC Regime** - Bitcoin macro analysis
22
+ - 🔗 **DexScreener Integration** - Direct chart links for all tokens
23
+ - 💰 **x402 Micropayments** - Pay-per-call with Solana USDC
16
24
 
17
25
  ## Installation
18
26
 
19
27
  ```bash
20
- npm install -g cryptoiz-mcp@4.10.0
28
+ npm install -g cryptoiz-mcp
21
29
  ```
22
30
 
23
- Or latest:
24
- ```bash
25
- npm install -g cryptoiz-mcp@latest
31
+ ## Claude Desktop Setup
32
+
33
+ Add to `claude_desktop_config.json`:
34
+
35
+ ```json
36
+ {
37
+ "mcpServers": {
38
+ "cryptoiz": {
39
+ "command": "npx",
40
+ "args": ["-y", "cryptoiz-mcp@4.13.2"],
41
+ "env": {
42
+ "CRYPTOIZ_DEV_KEY": "your-dev-key-here"
43
+ }
44
+ }
45
+ }
46
+ }
26
47
  ```
27
48
 
28
- ## Setup Claude Desktop
29
-
30
- 1. **Generate Solana Keypair:**
31
- ```bash
32
- node -e "
33
- const { Keypair } = require('@solana/web3.js');
34
- const { encode } = require('bs58');
35
- const kp = Keypair.generate();
36
- console.log('Address:', kp.publicKey.toString());
37
- console.log('Private Key:', encode(kp.secretKey));
38
- "
39
- ```
40
-
41
- 2. **Fund wallet with:**
42
- - 0.01+ SOL (for gas)
43
- - 1+ USDC (for testing)
44
-
45
- 3. **Update Claude Desktop config** (`%APPDATA%\Claude\claude_desktop_config.json`):
46
- ```json
47
- {
48
- "mcpServers": {
49
- "cryptoiz": {
50
- "command": "npx",
51
- "args": ["-y", "cryptoiz-mcp@4.10.0"],
52
- "env": {
53
- "SVM_PRIVATE_KEY": "your_base58_private_key_here"
54
- }
55
- }
56
- }
57
- }
58
- ```
59
-
60
- 4. **Restart Claude Desktop**
49
+ **Development Mode:** Set `CRYPTOIZ_DEV_KEY` to bypass payments (contact team@cryptoiz.org)
50
+ **Production Mode:** Remove `CRYPTOIZ_DEV_KEY` to enable x402 USDC payments
61
51
 
62
52
  ## Available Tools
63
53
 
64
- | Tool | Cost | What It Does |
65
- |------|------|-------------|
66
- | `get_alpha_scanner` | $0.05 USDC | Top 20 Solana smart money signals |
67
- | `get_divergence` | $0.02 USDC | 3 divergence types (4h/1d) |
68
- | `get_accumulation` | $0.02 USDC | Accumulation scores |
69
- | `get_btc_regime` | $0.01 USDC | BTC macro + Fear & Greed |
70
- | `get_token_ca` | FREE | Lookup contract address |
71
- | `get_status` | FREE | Server info & pricing |
72
-
73
- ## How It Works
74
-
75
- ```
76
- Claude Desktop Request
77
-
78
- cryptoiz-mcp signs transaction (using your private key)
79
-
80
- Solana blockchain confirms payment ($0.05 USDC)
81
-
82
- CryptoIZ edge function verifies + returns data
83
-
84
- Formatted output in Claude
54
+ ### 1. get_alpha_scanner
55
+ **Cost:** $0.05 USDC
56
+ **Returns:** 20 smart money signals with:
57
+ - Alpha score, entry class (EARLY/BUILDING/WATCHLIST)
58
+ - Whale/dolphin deltas, accumulation/timing/safety scores
59
+ - Phase alignment, confidence, risk metrics
60
+ - DexScreener chart links
61
+
62
+ ### 2. get_divergence
63
+ **Cost:** $0.02 USDC
64
+ **Params:** `tf` - Timeframe ("4h" or "1d")
65
+ **Returns:** 20 divergence signals across 3 types:
66
+ - HIDDEN_ACCUMULATION - Whales buying while price flat
67
+ - BREAKOUT_ACCUMULATION - Whales buying on breakout
68
+ - CLASSIC_DIVERGENCE - Price and smart money opposite
69
+
70
+ ### 3. get_accumulation
71
+ **Cost:** $0.02 USDC
72
+ **Returns:** 20 accumulation tokens with:
73
+ - Composite/structure/holder/market scores
74
+ - Strength labels (VERY_STRONG_SMART_MONEY, FORMING, WEAK_OR_NOISY)
75
+ - **NEW:** Tier holder delta data over 4h
76
+ - DexScreener chart links
77
+
78
+ **Example Output:**
79
+ ```json
80
+ {
81
+ "name": "gsd",
82
+ "ca": "8116V1BW9zaXUM6pVhWVaAduKrLcEBi3RGXedKTrBAGS",
83
+ "chart": "https://dexscreener.com/solana/8116V1BW9zaXUM6pVhWVaAduKrLcEBi3RGXedKTrBAGS",
84
+ "strength": "VERY_STRONG_SMART_MONEY",
85
+ "score_composite": "86.12",
86
+ "h100_delta_4h": 17,
87
+ "h100_pct_4h": "3.6",
88
+ "h1k_delta_4h": 10,
89
+ "h1k_pct_4h": "5.1",
90
+ "h10k_delta_4h": 2,
91
+ "h10k_pct_4h": "8.0",
92
+ "holders_over_100": 491,
93
+ "holders_over_1k": 206,
94
+ "holders_over_10k": 27
95
+ }
85
96
  ```
86
97
 
87
- ## Key Features
88
-
89
- - ✅ **No API keys** — just USDC
90
- - **No signup** pay per call
91
- - **Instant settlement** — Solana blockchain
92
- - **Zero friction** — automatic discovery
93
- - ✅ **Multi-tool** — alpha, divergence, accumulation, BTC
98
+ ### 4. get_btc_regime
99
+ **Cost:** $0.01 USDC
100
+ **Returns:** Bitcoin macro analysis:
101
+ - State (bull/bear/neutral), score, price, trend
102
+ - Fear & Greed Index
103
+ - Funding rates, open interest
104
+ - RSI, EMA, MACD indicators
94
105
 
95
- ## Platform Links
106
+ ### 5. get_token_ca
107
+ **Cost:** FREE
108
+ **Params:** `name` - Token name
109
+ **Returns:** Contract address lookup with alpha score & chart link
96
110
 
97
- - 🌐 **Website:** https://cryptoiz.org
98
- - 📚 **Setup Guide:** https://cryptoiz.org/McpLanding
99
- - 💰 **Pricing:** https://cryptoiz.org/Pricing
100
- - 🐦 **Twitter:** @cryptoiz_IDN
111
+ ### 6. get_status
112
+ **Cost:** FREE
113
+ **Returns:** Server status, version, tools list, pricing
101
114
 
102
- ## Network Support
115
+ ## Payment: x402 Protocol
103
116
 
104
- - **Primary:** Solana Mainnet (fee-sponsored by Dexter)
105
- - **Alternative:** Base, Polygon, Arbitrum, Optimism (EVM chains)
117
+ CryptoIZ MCP uses the x402 payment protocol with Solana USDC:
118
+ - **Network:** Solana mainnet
119
+ - **Currency:** USDC (EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v)
120
+ - **Minimum:** 0.01 USDC per call
121
+ - **Facilitator:** Dexter (https://x402.dexter.cash)
106
122
 
107
- ## Troubleshooting
123
+ No setup required - Claude Desktop handles payments automatically when x402 is configured.
108
124
 
109
- **"SVM_PRIVATE_KEY not set"**
110
- - Check Claude Desktop config at `%APPDATA%\Claude\claude_desktop_config.json`
111
- - Verify env variable is set correctly
125
+ ## Changelog
112
126
 
113
- **"Insufficient USDC"**
114
- - You need minimum $0.05 USDC for alpha scanner, $0.02 for other tools
115
- - Get USDC at: https://jup.ag
127
+ ### 4.13.2 (2026-04-05)
128
+ - Added tier holder delta fields to `get_accumulation`
129
+ - Fixed data source from `gs_holder_series_4h` to `v_holder_deltas_4h_v1`
130
+ - ✅ New fields: h100/h1k/h10k delta counts, percentages, and absolute holders
116
131
 
117
- **"TX expired"**
118
- - Network latency issue — retry the request
132
+ ### 4.9.0
133
+ - Initial public release
134
+ - x402 micropayment integration
135
+ - 6 trading intelligence tools
119
136
 
120
137
  ## Support
121
138
 
122
- - GitHub Issues: https://github.com/cryptoiz/cryptoiz-mcp/issues
123
- - Twitter DM: @cryptoiz_IDN
139
+ - **Website:** https://cryptoiz.org
140
+ - **Setup Guide:** https://cryptoiz.org/McpLanding
141
+ - **Twitter:** @cryptoiz_IDN
142
+ - **Email:** team@cryptoiz.org
124
143
 
125
144
  ## License
126
145
 
package/index.js ADDED
@@ -0,0 +1,172 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { Server } from '@modelcontextprotocol/sdk/server/index.js';
4
+ import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
5
+ import {
6
+ CallToolRequestSchema,
7
+ ListToolsRequestSchema,
8
+ } from '@modelcontextprotocol/sdk/types.js';
9
+
10
+ const EDGE_FUNCTION_URL = 'https://rehqwsypjnjirhuiapqh.supabase.co/functions/v1/mcp-x402-gateway';
11
+ const DEV_SECRET = process.env.CRYPTOIZ_DEV_KEY || null;
12
+
13
+ class CryptoIZMCPServer {
14
+ constructor() {
15
+ this.server = new Server(
16
+ {
17
+ name: 'cryptoiz-mcp',
18
+ version: '4.13.2',
19
+ },
20
+ {
21
+ capabilities: {
22
+ tools: {},
23
+ },
24
+ }
25
+ );
26
+
27
+ this.setupToolHandlers();
28
+ this.server.onerror = (error) => console.error('[MCP Error]', error);
29
+ process.on('SIGINT', async () => {
30
+ await this.server.close();
31
+ process.exit(0);
32
+ });
33
+ }
34
+
35
+ setupToolHandlers() {
36
+ this.server.setRequestHandler(ListToolsRequestSchema, async () => ({
37
+ tools: [
38
+ {
39
+ name: 'get_alpha_scanner',
40
+ description: 'Get top 20 smart money accumulation signals from CryptoIZ Alpha Scanner. Returns tokens with whale/dolphin buying activity, phase alignment, and safety scores. Cost: $0.05 USDC per call.',
41
+ inputSchema: {
42
+ type: 'object',
43
+ properties: {},
44
+ },
45
+ },
46
+ {
47
+ name: 'get_divergence',
48
+ description: 'Get top 20 price-momentum divergence signals across 3 types: HIDDEN_ACCUMULATION (whales buying while price flat), BREAKOUT_ACCUMULATION (whales buying on breakout), CLASSIC_DIVERGENCE (price and smart money opposite). Cost: $0.02 USDC per call.',
49
+ inputSchema: {
50
+ type: 'object',
51
+ properties: {
52
+ tf: {
53
+ type: 'string',
54
+ description: 'Timeframe: "4h" (default) or "1d"',
55
+ enum: ['4h', '1d'],
56
+ },
57
+ },
58
+ },
59
+ },
60
+ {
61
+ name: 'get_accumulation',
62
+ description: 'Get top 20 tokens in accumulation phase ranked by composite score. Includes structure/holder/market scores, strength labels, and tier holder delta data (h100_delta_4h, h1k_delta_4h, h10k_delta_4h with percentage changes). Cost: $0.02 USDC per call.',
63
+ inputSchema: {
64
+ type: 'object',
65
+ properties: {},
66
+ },
67
+ },
68
+ {
69
+ name: 'get_btc_regime',
70
+ description: 'Get Bitcoin macro regime analysis including state (bull/bear/neutral), fear & greed index, funding rates, open interest, and technical indicators (RSI, EMA, MACD). Cost: $0.01 USDC per call.',
71
+ inputSchema: {
72
+ type: 'object',
73
+ properties: {},
74
+ },
75
+ },
76
+ {
77
+ name: 'get_token_ca',
78
+ description: 'Lookup Solana token contract address by name. Returns CA, DexScreener chart link, alpha score, entry class, and phase. FREE - no payment required.',
79
+ inputSchema: {
80
+ type: 'object',
81
+ properties: {
82
+ name: {
83
+ type: 'string',
84
+ description: 'Token name to search for',
85
+ },
86
+ },
87
+ required: ['name'],
88
+ },
89
+ },
90
+ {
91
+ name: 'get_status',
92
+ description: 'Get CryptoIZ MCP server status, version, available tools, and pricing. FREE - no payment required.',
93
+ inputSchema: {
94
+ type: 'object',
95
+ properties: {},
96
+ },
97
+ },
98
+ ],
99
+ }));
100
+
101
+ this.server.setRequestHandler(CallToolRequestSchema, async (request) => {
102
+ const { name, arguments: args } = request.params;
103
+
104
+ try {
105
+ const url = new URL(EDGE_FUNCTION_URL);
106
+ url.searchParams.set('tool', name);
107
+
108
+ if (name === 'get_divergence' && args.tf) {
109
+ url.searchParams.set('tf', args.tf);
110
+ }
111
+
112
+ if (name === 'get_token_ca' && args.name) {
113
+ url.searchParams.set('name', args.name);
114
+ }
115
+
116
+ const headers = { 'Content-Type': 'application/json' };
117
+
118
+ if (DEV_SECRET) {
119
+ headers['x-dev-key'] = DEV_SECRET;
120
+ }
121
+
122
+ const response = await fetch(url.toString(), { headers });
123
+
124
+ if (response.status === 402) {
125
+ const paymentInfo = await response.json();
126
+ return {
127
+ content: [
128
+ {
129
+ type: 'text',
130
+ text: `Payment required: ${JSON.stringify(paymentInfo, null, 2)}\n\nThis tool requires x402 micropayment. Set CRYPTOIZ_DEV_KEY environment variable for free development access, or configure x402 payment in Claude Desktop.\n\nSee setup guide: https://cryptoiz.org/McpLanding`,
131
+ },
132
+ ],
133
+ };
134
+ }
135
+
136
+ if (!response.ok) {
137
+ throw new Error(`HTTP ${response.status}: ${await response.text()}`);
138
+ }
139
+
140
+ const data = await response.json();
141
+
142
+ return {
143
+ content: [
144
+ {
145
+ type: 'text',
146
+ text: JSON.stringify(data, null, 2),
147
+ },
148
+ ],
149
+ };
150
+ } catch (error) {
151
+ return {
152
+ content: [
153
+ {
154
+ type: 'text',
155
+ text: `Error calling ${name}: ${error.message}`,
156
+ },
157
+ ],
158
+ isError: true,
159
+ };
160
+ }
161
+ });
162
+ }
163
+
164
+ async run() {
165
+ const transport = new StdioServerTransport();
166
+ await this.server.connect(transport);
167
+ console.error('CryptoIZ MCP Server v4.13.2 running on stdio');
168
+ }
169
+ }
170
+
171
+ const server = new CryptoIZMCPServer();
172
+ server.run().catch(console.error);
package/package.json CHANGED
@@ -1,46 +1,36 @@
1
1
  {
2
2
  "name": "cryptoiz-mcp",
3
- "version": "4.12.0",
4
- "description": "CryptoIZ MCP Server - Solana DEX smart money signals via x402 payment protocol",
5
- "main": "src/index.js",
3
+ "version": "4.13.2",
4
+ "description": "CryptoIZ MCP Server - AI-powered Solana DEX trading intelligence with x402 micropayments",
5
+ "main": "index.js",
6
6
  "type": "module",
7
7
  "bin": {
8
- "cryptoiz-mcp": "src/index.js"
9
- },
10
- "scripts": {
11
- "start": "node src/index.js",
12
- "test": "echo 'Testing MCP connection...' && node -e \"console.log('v4.10.0 ready')\"",
13
- "publish": "npm publish --access public"
8
+ "cryptoiz-mcp": "./index.js"
14
9
  },
15
10
  "keywords": [
16
11
  "mcp",
12
+ "model-context-protocol",
13
+ "claude",
17
14
  "solana",
18
15
  "dex",
16
+ "crypto",
17
+ "trading",
19
18
  "x402",
20
- "payment",
21
- "cryptoiz",
22
- "alpha",
23
- "signals"
19
+ "micropayment",
20
+ "usdc"
24
21
  ],
25
- "author": "CryptoIZ (https://cryptoiz.org)",
22
+ "author": "CryptoIZ",
26
23
  "license": "MIT",
27
24
  "repository": {
28
25
  "type": "git",
29
26
  "url": "https://github.com/cryptoiz/cryptoiz-mcp"
30
27
  },
31
- "bugs": {
32
- "url": "https://github.com/cryptoiz/cryptoiz-mcp/issues"
33
- },
34
28
  "homepage": "https://cryptoiz.org/McpLanding",
35
- "engines": {
36
- "node": ">=18.0.0"
37
- },
38
29
  "dependencies": {
39
- "@solana/web3.js": "^1.98.4",
40
- "bs58": "^6.0.0",
41
- "dotenv": "^16.3.1"
30
+ "@modelcontextprotocol/sdk": "^1.0.4",
31
+ "@solana/web3.js": "^1.95.8"
42
32
  },
43
- "devDependencies": {
44
- "eslint": "^8.54.0"
33
+ "engines": {
34
+ "node": ">=18.0.0"
45
35
  }
46
36
  }
package/src/index.js DELETED
@@ -1,407 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- import { Keypair } from '@solana/web3.js';
4
- import { encode } from 'bs58';
5
-
6
- // ========== CONSTANTS ==========
7
- const PRICES = {
8
- get_alpha_scanner: 50000, // $0.05
9
- get_divergence: 20000, // $0.02
10
- get_accumulation: 20000, // $0.02
11
- get_btc_regime: 10000, // $0.01
12
- };
13
-
14
- const CRYPTOIZ_WALLET = 'DsKmdkYx49Xc1WhqMUAztwhdYPTqieyC98VmnnJdgpXX';
15
- const USDC_MINT = 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v';
16
- const SOL_MINT = 'So11111111111111111111111111111111111111112';
17
- const SOLANA_NETWORK = 'solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp';
18
- const GATEWAY_URL = 'https://rehqwsypjnjirhuiapqh.supabase.co/functions/v1/mcp-x402-gateway';
19
- const DEXTER_FACILITATOR = 'https://x402.dexter.cash';
20
- const VERSION = 'v4.10.0';
21
-
22
- // ========== HELPER FUNCTIONS ==========
23
-
24
- async function payAndFetch(url, tool) {
25
- const privKeyEnv = process.env.SVM_PRIVATE_KEY;
26
- if (!privKeyEnv) {
27
- throw new Error('SVM_PRIVATE_KEY not set in environment');
28
- }
29
-
30
- let keypair;
31
- try {
32
- const decoded = Buffer.from(privKeyEnv, 'base58');
33
- keypair = Keypair.fromSecretKey(new Uint8Array(decoded));
34
- } catch (err) {
35
- throw new Error(`Invalid SVM_PRIVATE_KEY: ${err.message}`);
36
- }
37
-
38
- // Step 1: Fetch without payment header to get 402 response
39
- const initialRes = await fetch(url, {
40
- method: 'GET',
41
- headers: { 'Content-Type': 'application/json' },
42
- });
43
-
44
- if (initialRes.status === 402) {
45
- const requirements = await initialRes.json();
46
- console.log(`\n💰 Payment required for ${tool}: ${PRICES[tool]/1_000_000} USDC`);
47
- console.log('📝 Setting up payment transaction...\n');
48
-
49
- // Step 2: Create payment payload (VersionedTransaction format)
50
- const paymentPayload = {
51
- x402Version: 2,
52
- payload: {
53
- transaction: Buffer.from('mock-tx-data').toString('base64'),
54
- payer: keypair.publicKey.toString(),
55
- },
56
- };
57
-
58
- const paymentHeader = Buffer.from(JSON.stringify(paymentPayload)).toString('base64');
59
-
60
- // Step 3: Retry with payment header
61
- const res = await fetch(url, {
62
- method: 'GET',
63
- headers: {
64
- 'Content-Type': 'application/json',
65
- 'x-payment': paymentHeader,
66
- },
67
- });
68
-
69
- const data = await res.json();
70
- if (!res.ok) {
71
- throw new Error(`Payment failed: ${data.error}`);
72
- }
73
-
74
- return data;
75
- }
76
-
77
- return await initialRes.json();
78
- }
79
-
80
- // ========== OUTPUT FORMATTERS ==========
81
-
82
- function formatAlpha(data) {
83
- if (!data.signals || data.signals.length === 0) {
84
- return '⚠️ No signals available';
85
- }
86
-
87
- let output = `\n🔍 **CryptoIZ Alpha Scanner** (${VERSION})\n`;
88
- output += `Paid: ${data.price_paid}\n`;
89
- output += `Platform: ${data.platform}\n`;
90
- output += `Setup: ${data.setup_guide}\n`;
91
- output += `Twitter: ${data.twitter}\n\n`;
92
-
93
- output += `📊 Summary: ${data.summary.alpha_early} Early + ${data.summary.alpha_building} Building + ${data.summary.watchlist_only} Watchlist\n\n`;
94
-
95
- data.signals.forEach((sig, i) => {
96
- output += `**${i + 1}. ${sig.name}** (Score: ${sig.alpha_score})\n`;
97
- output += ` CA: \`${sig.contract_address}\`\n`;
98
- output += ` Chart: ${sig.chart_dexscreener}\n`;
99
- output += ` Phase: ${sig.phase} | Confidence: ${sig.confidence_pct}%\n`;
100
- output += ` Market Cap: ${sig.market_cap_now}\n\n`;
101
- });
102
-
103
- if (data.contract_address_list) {
104
- output += `\n**Copy-Paste Friendly CA List:**\n`;
105
- output += `\`\`\`\n${data.contract_address_list}\n\`\`\`\n`;
106
- }
107
-
108
- output += `\n👉 Learn more: ${data.platform}\n`;
109
-
110
- return output;
111
- }
112
-
113
- function formatDivergence(data) {
114
- if (!data.signals_by_type || Object.keys(data.signals_by_type).length === 0) {
115
- return '⚠️ No divergence signals available';
116
- }
117
-
118
- let output = `\n🔄 **CryptoIZ Divergence Scanner (${data.timeframe})** (${VERSION})\n`;
119
- output += `Paid: ${data.price_paid}\n`;
120
- output += `Platform: ${data.platform}\n`;
121
- output += `Setup: ${data.setup_guide}\n`;
122
- output += `Twitter: ${data.twitter}\n\n`;
123
-
124
- const typeNames = {
125
- HIDDEN_ACCUMULATION: '🐋 Hidden Accumulation (whales buying quietly)',
126
- BREAKOUT_ACCUMULATION: '📈 Breakout Accumulation (whales buying breakout)',
127
- CLASSIC_DIVERGENCE: '📊 Classic Divergence (price & smart money opposite)',
128
- };
129
-
130
- for (const [type, signals] of Object.entries(data.signals_by_type)) {
131
- output += `\n### ${typeNames[type] || type}\n`;
132
- signals.forEach((sig, i) => {
133
- output += `**${i + 1}. ${sig.name}** (Score: ${sig.divergence_score})\n`;
134
- output += ` CA: \`${sig.contract_address}\`\n`;
135
- output += ` Chart: ${sig.chart_dexscreener}\n`;
136
- output += ` Whale Delta: ${sig.whale_delta} | Dolphin Delta: ${sig.dolphin_delta}\n`;
137
- output += ` Price Change: ${sig.price_change_pct}% | MC: ${sig.market_cap}\n\n`;
138
- });
139
- }
140
-
141
- if (data.contract_address_list) {
142
- output += `\n**Copy-Paste Friendly CA List:**\n`;
143
- output += `\`\`\`\n${data.contract_address_list}\n\`\`\`\n`;
144
- }
145
-
146
- output += `\n👉 Learn more: ${data.platform}\n`;
147
-
148
- return output;
149
- }
150
-
151
- function formatAccumulation(data) {
152
- if (!data.tokens || data.tokens.length === 0) {
153
- return '⚠️ No accumulation signals available';
154
- }
155
-
156
- let output = `\n📊 **CryptoIZ Accumulation Scores** (${VERSION})\n`;
157
- output += `Paid: ${data.price_paid}\n`;
158
- output += `Platform: ${data.platform}\n`;
159
- output += `Setup: ${data.setup_guide}\n`;
160
- output += `Twitter: ${data.twitter}\n\n`;
161
-
162
- data.tokens.forEach((token, i) => {
163
- output += `**${i + 1}. ${token.name}** (Composite: ${token.score_composite})\n`;
164
- output += ` CA: \`${token.contract_address}\`\n`;
165
- output += ` Chart: ${token.chart_dexscreener}\n`;
166
- output += ` Strength: ${token.strength} | Status: ${token.accdist}\n`;
167
- output += ` Holder Score: ${token.score_holder} | Market Score: ${token.score_market}\n`;
168
- output += ` Price: ${token.price_usd} | MC: ${token.market_cap}\n\n`;
169
- });
170
-
171
- if (data.contract_address_list) {
172
- output += `\n**Copy-Paste Friendly CA List:**\n`;
173
- output += `\`\`\`\n${data.contract_address_list}\n\`\`\`\n`;
174
- }
175
-
176
- output += `\n👉 Learn more: ${data.platform}\n`;
177
-
178
- return output;
179
- }
180
-
181
- function formatBTC(data) {
182
- let output = `\n📈 **BTC Macro Regime** (${VERSION})\n`;
183
- output += `Regime: ${data.btc_regime}\n`;
184
- output += `Price: $${data.btc_price_usd}\n`;
185
- output += `Fear & Greed: ${data.fear_greed_label} (${data.fear_greed_index})\n`;
186
- output += `Funding Rate: ${data.funding_rate}\n`;
187
- output += `RSI 1H: ${data.rsi_1h} | EMA20: ${data.ema20_1h}\n\n`;
188
- output += `👉 Learn more: ${data.platform}\n`;
189
-
190
- return output;
191
- }
192
-
193
- function formatStatus() {
194
- let output = `\n✅ **CryptoIZ MCP Server** (${VERSION})\n\n`;
195
- output += `**Available Tools:**\n`;
196
- output += `• get_alpha_scanner — $0.05 USDC (top 20 signals)\n`;
197
- output += `• get_divergence — $0.02 USDC (3 divergence types)\n`;
198
- output += `• get_accumulation — $0.02 USDC (accumulation scores)\n`;
199
- output += `• get_btc_regime — $0.01 USDC (macro analysis)\n`;
200
- output += `• get_token_ca — FREE (lookup contract address)\n\n`;
201
- output += `**Links:**\n`;
202
- output += `📱 Platform: https://cryptoiz.org\n`;
203
- output += `🚀 Setup: https://cryptoiz.org/McpLanding\n`;
204
- output += `💰 Pricing: https://cryptoiz.org/Pricing\n`;
205
- output += `🐦 Twitter: @cryptoiz_IDN\n`;
206
-
207
- return output;
208
- }
209
-
210
- function getTokenCA(name, data) {
211
- // Search in alpha signals for token lookup
212
- if (!data.signals) {
213
- return `⚠️ Token "${name}" not found. Use get_alpha_scanner first.`;
214
- }
215
-
216
- const match = data.signals.find(
217
- (s) => s.name.toLowerCase().includes(name.toLowerCase())
218
- );
219
-
220
- if (!match) {
221
- return `⚠️ Token "${name}" not found in recent signals.`;
222
- }
223
-
224
- return `✅ **${match.name}**\nCA: \`${match.contract_address}\`\nChart: ${match.chart_dexscreener}`;
225
- }
226
-
227
- // ========== MCP TOOL DEFINITIONS ==========
228
-
229
- const tools = [
230
- {
231
- name: 'get_alpha_scanner',
232
- description: 'Top 20 Solana smart money signals (ALPHA_EARLY + ALPHA_BUILDING)',
233
- inputSchema: {
234
- type: 'object',
235
- properties: {
236
- min_score: { type: 'number', description: 'Minimum alpha score (default 0)' },
237
- },
238
- },
239
- },
240
- {
241
- name: 'get_divergence',
242
- description:
243
- 'Divergence signals (3 types: Hidden Accum, Breakout Accum, Classic Divergence)',
244
- inputSchema: {
245
- type: 'object',
246
- properties: {
247
- tf: { type: 'string', enum: ['4h', '1d'], description: 'Timeframe (default 4h)' },
248
- },
249
- },
250
- },
251
- {
252
- name: 'get_accumulation',
253
- description: 'Accumulation scores for tokens currently forming',
254
- inputSchema: { type: 'object', properties: {} },
255
- },
256
- {
257
- name: 'get_btc_regime',
258
- description: 'BTC macro regime, Fear & Greed, OI, funding rate',
259
- inputSchema: { type: 'object', properties: {} },
260
- },
261
- {
262
- name: 'get_token_ca',
263
- description: 'Look up contract address by token name (FREE)',
264
- inputSchema: {
265
- type: 'object',
266
- properties: {
267
- name: { type: 'string', description: 'Token name to search' },
268
- },
269
- required: ['name'],
270
- },
271
- },
272
- {
273
- name: 'get_status',
274
- description: 'Server status, pricing, available tools (FREE)',
275
- inputSchema: { type: 'object', properties: {} },
276
- },
277
- ];
278
-
279
- // ========== MAIN MCP SERVER ==========
280
-
281
- async function processTool(toolName, toolInput) {
282
- if (toolName === 'get_status') {
283
- return { content: [{ type: 'text', text: formatStatus() }] };
284
- }
285
-
286
- let url = `${GATEWAY_URL}?tool=${toolName}`;
287
- if (toolName === 'get_divergence' && toolInput?.tf) {
288
- url += `&tf=${toolInput.tf}`;
289
- }
290
- if (toolName === 'get_token_ca' && toolInput?.name) {
291
- url += `&name=${encodeURIComponent(toolInput.name)}`;
292
- }
293
-
294
- try {
295
- const data = await payAndFetch(url, toolName);
296
-
297
- let formatted;
298
- if (toolName === 'get_alpha_scanner') {
299
- formatted = formatAlpha(data);
300
- } else if (toolName === 'get_divergence') {
301
- formatted = formatDivergence(data);
302
- } else if (toolName === 'get_accumulation') {
303
- formatted = formatAccumulation(data);
304
- } else if (toolName === 'get_btc_regime') {
305
- formatted = formatBTC(data);
306
- } else if (toolName === 'get_token_ca') {
307
- formatted = getTokenCA(toolInput?.name, data);
308
- }
309
-
310
- return { content: [{ type: 'text', text: formatted }] };
311
- } catch (error) {
312
- return {
313
- content: [
314
- {
315
- type: 'text',
316
- text: `❌ Error: ${error.message}\n\n💡 Troubleshooting:\n• Verify SVM_PRIVATE_KEY is set\n• Check USDC balance in wallet\n• Verify Claude Desktop config\n\n📖 Setup guide: https://cryptoiz.org/McpLanding`,
317
- },
318
- ],
319
- };
320
- }
321
- }
322
-
323
- // ========== MCP SERVER IMPLEMENTATION ==========
324
-
325
- async function main() {
326
- const stdio = process.stdin;
327
-
328
- console.error(`[CryptoIZ MCP ${VERSION}] Server starting...`);
329
- console.error(`Wallet: ${process.env.SVM_PRIVATE_KEY ? '✓ Configured' : '✗ Missing'}`);
330
-
331
- // Minimal readline server for MCP protocol
332
- const readline = require('readline');
333
- const rl = readline.createInterface({
334
- input: process.stdin,
335
- output: process.stdout,
336
- terminal: false,
337
- });
338
-
339
- let buffer = '';
340
-
341
- rl.on('line', async (line) => {
342
- buffer += line;
343
-
344
- try {
345
- const message = JSON.parse(buffer);
346
- buffer = '';
347
-
348
- if (message.jsonrpc === '2.0') {
349
- let result;
350
-
351
- if (message.method === 'initialize') {
352
- result = {
353
- jsonrpc: '2.0',
354
- id: message.id,
355
- result: {
356
- protocolVersion: '2024-11-05',
357
- capabilities: {},
358
- serverInfo: {
359
- name: 'CryptoIZ MCP',
360
- version: VERSION,
361
- },
362
- },
363
- };
364
- } else if (message.method === 'tools/list') {
365
- result = {
366
- jsonrpc: '2.0',
367
- id: message.id,
368
- result: { tools },
369
- };
370
- } else if (message.method === 'tools/call') {
371
- const toolResult = await processTool(
372
- message.params.name,
373
- message.params.arguments
374
- );
375
- result = {
376
- jsonrpc: '2.0',
377
- id: message.id,
378
- result: toolResult,
379
- };
380
- } else {
381
- result = {
382
- jsonrpc: '2.0',
383
- id: message.id,
384
- error: { code: -32601, message: 'Method not found' },
385
- };
386
- }
387
-
388
- console.log(JSON.stringify(result));
389
- }
390
- } catch (e) {
391
- if (e instanceof SyntaxError) {
392
- // Incomplete JSON, wait for more data
393
- } else {
394
- console.error('[Error]', e.message);
395
- }
396
- }
397
- });
398
-
399
- rl.on('close', () => {
400
- process.exit(0);
401
- });
402
- }
403
-
404
- main().catch((err) => {
405
- console.error('[Fatal Error]', err.message);
406
- process.exit(1);
407
- });