Skip to main content
Glama

Rootstock MCP Server

by cuongpo
simple-test.jsโ€ข7.1 kB
#!/usr/bin/env node /** * Simple test to demonstrate MCP server functionality */ import { RootstockClient } from './build/rootstock-client.js'; import { WalletManager } from './build/wallet-manager.js'; async function testBalanceDirectly() { console.log('๐Ÿงช Testing Rootstock Client Balance Functionality'); console.log('================================================\n'); try { // Initialize the Rootstock client with a public RPC endpoint const config = { rpcUrl: 'https://eth.llamarpc.com', // Public Ethereum RPC chainId: 1, networkName: 'Ethereum Mainnet' }; console.log('๐Ÿ”— Connecting to Ethereum network...'); const client = new RootstockClient(config); // Test with Vitalik's well-known address const testAddress = '0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045'; console.log(`๐Ÿ“ Testing balance for address: ${testAddress}`); console.log('โณ Fetching balance...\n'); // Test native balance const balance = await client.getBalance(testAddress); console.log('โœ… Native Balance Retrieved:'); console.log(` Address: ${testAddress}`); console.log(` Balance: ${balance} ETH\n`); // Test network info console.log('๐ŸŒ Getting network information...'); const networkInfo = await client.getNetworkInfo(); console.log('โœ… Network Info Retrieved:'); console.log(` Network: ${networkInfo.networkName}`); console.log(` Chain ID: ${networkInfo.chainId}`); console.log(` Latest Block: ${networkInfo.blockNumber}`); console.log(` Connected: ${networkInfo.isConnected}\n`); // Test gas estimation console.log('โ›ฝ Testing gas estimation...'); const gasEstimate = await client.estimateGas( '0x1234567890123456789012345678901234567890', '0.1' ); console.log('โœ… Gas Estimate Retrieved:'); console.log(` Gas Limit: ${gasEstimate.gasLimit}`); console.log(` Gas Price: ${gasEstimate.gasPrice} wei`); console.log(` Estimated Cost: ${gasEstimate.estimatedCost} ETH\n`); console.log('๐ŸŽ‰ All tests completed successfully!'); return true; } catch (error) { console.log('โŒ Test failed:', error.message); console.log('๐Ÿ’ก This might be due to network connectivity or RPC limits'); return false; } } async function testWalletManager() { console.log('๐Ÿ” Testing Wallet Manager Functionality'); console.log('======================================\n'); try { const walletManager = new WalletManager(); // Test wallet creation console.log('๐Ÿ‘› Creating a new test wallet...'); const newWallet = walletManager.createWallet('TestWallet'); console.log('โœ… Wallet Created:'); console.log(` Address: ${newWallet.address}`); console.log(` Mnemonic: ${newWallet.mnemonic?.substring(0, 20)}...`); console.log(` Has Private Key: ${!!newWallet.privateKey}\n`); // Test wallet listing console.log('๐Ÿ“‹ Listing all wallets...'); const wallets = walletManager.listWallets(); console.log('โœ… Wallets Listed:'); wallets.forEach((wallet, index) => { console.log(` ${index + 1}. ${wallet.address}`); }); console.log(); // Test current wallet console.log('๐ŸŽฏ Getting current wallet...'); const currentAddress = walletManager.getCurrentAddress(); console.log('โœ… Current Wallet:'); console.log(` Address: ${currentAddress}\n`); console.log('๐ŸŽ‰ Wallet manager tests completed successfully!'); return true; } catch (error) { console.log('โŒ Wallet test failed:', error.message); return false; } } async function demonstrateMCPTools() { console.log('๐Ÿ› ๏ธ MCP Tools Demonstration'); console.log('===========================\n'); const tools = [ { name: 'create_wallet', description: 'Create a new wallet with mnemonic phrase', example: '{ name: "MyWallet" }' }, { name: 'get_balance', description: 'Get wallet balance (native or ERC20)', example: '{ address: "0x...", tokenAddress: "0x..." }' }, { name: 'send_transaction', description: 'Send tokens to another address', example: '{ to: "0x...", amount: "0.1" }' }, { name: 'get_transaction', description: 'Get transaction details by hash', example: '{ hash: "0x..." }' }, { name: 'get_network_info', description: 'Get current network information', example: '{}' }, { name: 'estimate_gas', description: 'Estimate transaction gas costs', example: '{ to: "0x...", value: "0.1" }' }, { name: 'call_contract', description: 'Call smart contract method (read-only)', example: '{ contractAddress: "0x...", methodName: "balanceOf" }' } ]; console.log('๐Ÿ“‹ Available MCP Tools:\n'); tools.forEach((tool, index) => { console.log(`${index + 1}. ${tool.name}`); console.log(` ๐Ÿ“ ${tool.description}`); console.log(` ๐Ÿ’ก Example: ${tool.example}\n`); }); console.log('๐Ÿ”— Integration Examples:\n'); console.log('๐Ÿ“ฑ Claude Desktop Integration:'); console.log(`{ "mcpServers": { "rootstock-mcp": { "command": "node", "args": ["build/index.js"], "env": { "ROOTSTOCK_RPC_URL": "https://your-rpc-url", "ROOTSTOCK_PRIVATE_KEYS": "your_private_key" } } } }\n`); console.log('๐Ÿณ Docker Usage:'); console.log('docker run -e ROOTSTOCK_RPC_URL=your_url rootstock-mcp\n'); console.log('๐ŸŒ Web Dashboard:'); console.log('cd dashboard && npm run dev\n'); } async function main() { console.log('๐Ÿš€ Rootstock MCP Server - Comprehensive Test Suite'); console.log('==================================================\n'); const args = process.argv.slice(2); if (args.includes('--demo') || args.includes('-d')) { await demonstrateMCPTools(); } else if (args.includes('--wallet') || args.includes('-w')) { await testWalletManager(); } else if (args.includes('--balance') || args.includes('-b')) { await testBalanceDirectly(); } else { // Run all tests console.log('๐ŸŽฏ Running all tests...\n'); const walletTest = await testWalletManager(); console.log('โ”€'.repeat(50) + '\n'); const balanceTest = await testBalanceDirectly(); console.log('โ”€'.repeat(50) + '\n'); await demonstrateMCPTools(); console.log('๐Ÿ“Š Test Summary:'); console.log(` Wallet Manager: ${walletTest ? 'โœ… PASSED' : 'โŒ FAILED'}`); console.log(` Balance Check: ${balanceTest ? 'โœ… PASSED' : 'โŒ FAILED'}`); console.log(` Tools Demo: โœ… COMPLETED\n`); } console.log('๐Ÿ Test suite completed!'); console.log('\n๐Ÿ’ก Usage options:'); console.log(' node simple-test.js --balance # Test balance functionality'); console.log(' node simple-test.js --wallet # Test wallet management'); console.log(' node simple-test.js --demo # Show MCP tools demo'); console.log(' node simple-test.js # Run all tests'); } main().catch(console.error);

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/cuongpo/rootstock-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server