cryptoiz-mcp 4.13.3 → 4.14.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.
Files changed (2) hide show
  1. package/index.js +131 -0
  2. package/package.json +7 -13
package/index.js ADDED
@@ -0,0 +1,131 @@
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 { CallToolRequestSchema, ListToolsRequestSchema } from '@modelcontextprotocol/sdk/types.js';
6
+ import { Connection, Keypair, PublicKey, Transaction } from '@solana/web3.js';
7
+ import bs58 from 'bs58';
8
+
9
+ const EDGE_FUNCTION_URL = 'https://rehqwsypjnjirhuiapqh.supabase.co/functions/v1/mcp-x402-gateway';
10
+ const DEV_SECRET = process.env.CRYPTOIZ_DEV_KEY || null;
11
+ const SVM_PRIVATE_KEY = process.env.SVM_PRIVATE_KEY || null;
12
+ const CRYPTOIZ_WALLET = 'DsKmdkYx49Xc1WhqMUAztwhdYPTqieyC98VmnnJdgpXX';
13
+ const USDC_MINT = 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v';
14
+ const SOLANA_RPC = 'https://api.mainnet-beta.solana.com';
15
+ const TOKEN_PROGRAM_ID = new PublicKey('TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA');
16
+ const ATA_PROGRAM_ID = new PublicKey('ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL');
17
+
18
+ function getKeypair() {
19
+ if (!SVM_PRIVATE_KEY) return null;
20
+ try { return Keypair.fromSecretKey(bs58.decode(SVM_PRIVATE_KEY)); }
21
+ catch(e) { console.error('[Payment] Bad key:', e.message); return null; }
22
+ }
23
+
24
+ function findATA(wallet, mint) {
25
+ const [addr] = PublicKey.findProgramAddressSync(
26
+ [new PublicKey(wallet).toBuffer(), TOKEN_PROGRAM_ID.toBuffer(), new PublicKey(mint).toBuffer()],
27
+ ATA_PROGRAM_ID
28
+ );
29
+ return addr;
30
+ }
31
+
32
+ async function sendUSDC(amount) {
33
+ const kp = getKeypair();
34
+ if (!kp) throw new Error('SVM_PRIVATE_KEY not set');
35
+ const conn = new Connection(SOLANA_RPC, 'confirmed');
36
+ const payerATA = findATA(kp.publicKey.toString(), USDC_MINT);
37
+ const recipATA = findATA(CRYPTOIZ_WALLET, USDC_MINT);
38
+ const tx = new Transaction();
39
+ const recipInfo = await conn.getAccountInfo(recipATA);
40
+ if (!recipInfo) {
41
+ tx.add({ keys:[
42
+ {pubkey:kp.publicKey,isSigner:true,isWritable:true},
43
+ {pubkey:recipATA,isSigner:false,isWritable:true},
44
+ {pubkey:new PublicKey(CRYPTOIZ_WALLET),isSigner:false,isWritable:false},
45
+ {pubkey:new PublicKey(USDC_MINT),isSigner:false,isWritable:false},
46
+ {pubkey:new PublicKey('11111111111111111111111111111111'),isSigner:false,isWritable:false},
47
+ {pubkey:TOKEN_PROGRAM_ID,isSigner:false,isWritable:false},
48
+ {pubkey:new PublicKey('SysvarRent111111111111111111111111111111111'),isSigner:false,isWritable:false},
49
+ ], programId:ATA_PROGRAM_ID, data:Buffer.alloc(0) });
50
+ }
51
+ const data = Buffer.alloc(9); data.writeUInt8(3,0); data.writeBigUInt64LE(BigInt(amount),1);
52
+ tx.add({ keys:[
53
+ {pubkey:payerATA,isSigner:false,isWritable:true},
54
+ {pubkey:recipATA,isSigner:false,isWritable:true},
55
+ {pubkey:kp.publicKey,isSigner:true,isWritable:false},
56
+ ], programId:TOKEN_PROGRAM_ID, data });
57
+ const {blockhash} = await conn.getLatestBlockhash('confirmed');
58
+ tx.recentBlockhash = blockhash; tx.feePayer = kp.publicKey; tx.sign(kp);
59
+ const sig = await conn.sendRawTransaction(tx.serialize(), {skipPreflight:false,preflightCommitment:'confirmed'});
60
+ await conn.confirmTransaction(sig, 'confirmed');
61
+ console.error('[Payment] Sent ' + amount + ' micro-USDC. Sig: ' + sig);
62
+ return sig;
63
+ }
64
+
65
+ class CryptoIZMCPServer {
66
+ constructor() {
67
+ this.server = new Server(
68
+ { name: 'cryptoiz-mcp', version: '4.14.0' },
69
+ { capabilities: { tools: {} } }
70
+ );
71
+ this.setupToolHandlers();
72
+ this.server.onerror = (error) => console.error('[MCP Error]', error);
73
+ process.on('SIGINT', async () => { await this.server.close(); process.exit(0); });
74
+ }
75
+ setupToolHandlers() {
76
+ this.server.setRequestHandler(ListToolsRequestSchema, async () => ({
77
+ tools: [
78
+ { name:'get_alpha_scanner', description:'Get top 20 smart money signals. Cost: $0.05 USDC.', inputSchema:{type:'object',properties:{}} },
79
+ { name:'get_divergence', description:'Get top 20 divergence signals. Cost: $0.02 USDC.', inputSchema:{type:'object',properties:{tf:{type:'string',description:'4h or 1d',enum:['4h','1d']}}} },
80
+ { name:'get_accumulation', description:'Get top 20 accumulation tokens with holder delta. Cost: $0.02 USDC.', inputSchema:{type:'object',properties:{}} },
81
+ { name:'get_btc_regime', description:'Get BTC macro regime analysis. Cost: $0.01 USDC.', inputSchema:{type:'object',properties:{}} },
82
+ { name:'get_token_ca', description:'Lookup token CA by name. FREE.', inputSchema:{type:'object',properties:{name:{type:'string',description:'Token name'}},required:['name']} },
83
+ { name:'get_status', description:'Server status and pricing. FREE.', inputSchema:{type:'object',properties:{}} },
84
+ ],
85
+ }));
86
+ this.server.setRequestHandler(CallToolRequestSchema, async (request) => {
87
+ const { name, arguments: args } = request.params;
88
+ try {
89
+ const url = new URL(EDGE_FUNCTION_URL);
90
+ url.searchParams.set('tool', name);
91
+ if (name === 'get_divergence' && args.tf) url.searchParams.set('tf', args.tf);
92
+ if (name === 'get_token_ca' && args.name) url.searchParams.set('name', args.name);
93
+ const headers = { 'Content-Type': 'application/json' };
94
+ if (DEV_SECRET) headers['x-dev-key'] = DEV_SECRET;
95
+
96
+ let response = await fetch(url.toString(), { headers });
97
+
98
+ if (response.status === 402 && SVM_PRIVATE_KEY && !DEV_SECRET) {
99
+ const payInfo = await response.json();
100
+ const accepts = payInfo.accepts;
101
+ if (!accepts || !accepts.length) throw new Error('No payment options');
102
+ const amt = parseInt(accepts[0].amount);
103
+ console.error('[Payment] ' + name + ' requires ' + amt + ' micro-USDC');
104
+ const sig = await sendUSDC(amt);
105
+ const proof = Buffer.from(JSON.stringify({ signature: sig })).toString('base64');
106
+ response = await fetch(url.toString(), { headers: { 'Content-Type':'application/json', 'x-payment': proof } });
107
+ if (!response.ok) {
108
+ const err = await response.text();
109
+ throw new Error('Payment OK but data failed (' + response.status + '): ' + err + ' Sig: ' + sig);
110
+ }
111
+ console.error('[Payment] Success! ' + name + ' paid & received.');
112
+ }
113
+
114
+ if (response.status === 402) {
115
+ return { content:[{type:'text',text:'Payment required. Set SVM_PRIVATE_KEY in config.\nSetup: https://cryptoiz.org/McpLanding'}] };
116
+ }
117
+ if (!response.ok) throw new Error('HTTP ' + response.status + ': ' + (await response.text()));
118
+ return { content:[{type:'text',text:JSON.stringify(await response.json(), null, 2)}] };
119
+ } catch (error) {
120
+ return { content:[{type:'text',text:'Error calling ' + name + ': ' + error.message}], isError:true };
121
+ }
122
+ });
123
+ }
124
+ async run() {
125
+ const transport = new StdioServerTransport();
126
+ await this.server.connect(transport);
127
+ console.error('CryptoIZ MCP Server v4.14.0 running on stdio');
128
+ }
129
+ }
130
+ const server = new CryptoIZMCPServer();
131
+ server.run().catch(console.error);
package/package.json CHANGED
@@ -1,26 +1,20 @@
1
- {
1
+ {
2
2
  "name": "cryptoiz-mcp",
3
- "version": "4.13.3",
3
+ "version": "4.14.0",
4
4
  "description": "CryptoIZ MCP Server - AI-powered Solana DEX trading intelligence with x402 micropayments",
5
5
  "main": "index.js",
6
6
  "type": "module",
7
- "bin": {
8
- "cryptoiz-mcp": "./index.js"
9
- },
7
+ "bin": { "cryptoiz-mcp": "./index.js" },
8
+ "files": ["index.js", "package.json", "README.md"],
10
9
  "keywords": ["mcp", "claude", "solana", "dex", "crypto", "x402"],
11
10
  "author": "CryptoIZ",
12
11
  "license": "MIT",
13
- "repository": {
14
- "type": "git",
15
- "url": "https://github.com/cryptoiz/cryptoiz-mcp"
16
- },
17
12
  "homepage": "https://cryptoiz.org/McpLanding",
18
13
  "dependencies": {
19
14
  "@modelcontextprotocol/sdk": "^1.0.4",
15
+ "@dexterai/x402": "latest",
20
16
  "@solana/web3.js": "^1.95.8",
21
17
  "bs58": "^6.0.0"
22
18
  },
23
- "engines": {
24
- "node": ">=18.0.0"
25
- }
26
- }
19
+ "engines": { "node": ">=18.0.0" }
20
+ }