whhwhh8023-glitch/mcp-server
If you are the rightful owner of mcp-server and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to dayong@mcphub.com.
A simple Rust-based MCP server for querying Ethereum balances and simulating token swaps.
以太坊交易 MCP 服务器
一个基于 Rust 的简单 MCP(Model Context Protocol)服务器,用于查询以太坊余额和模拟代币兑换操作。
功能特性
查询 ETH 余额
查询 ERC20 代币余额
获取代币价格信息
模拟 Uniswap 代币兑换
结构化日志记录
环境要求
Rust 1.70+
安装步骤
克隆项目
bash
git clone <repository-url>
cd mcp-server
配置环境变量(可选)
bash
cp .env.example .env
# 编辑 .env 文件(如果需要自定义配置)
构建项目
bash
cargo build
运行测试
bash
cargo test
启动服务器
bash
cargo run
API 使用指南
- 查询余额 请求示例:
json { "method": "get_balance", "params": { "address": "0x742d35Cc6634C0532925a3b8D4D7D3C9b1451fB5", "token_address": "0xdAC17F958D2ee523a2206206994597C13D831ec7" } } 响应示例:
json { "address": "0x742d35Cc6634C0532925a3b8D4D7D3C9b1451fB5", "eth_balance": "1.5", "token_balances": { "0xdAC17F958D2ee523a2206206994597C13D831ec7": "1000.0" } } 2. 获取代币价格 请求示例:
json { "method": "get_token_price", "params": { "token_symbol": "ETH" } } 响应示例:
json { "token_symbol": "ETH", "price_usd": "3500.0", "price_eth": "1.0" } 3. 模拟代币兑换 请求示例:
json { "method": "swap_tokens", "params": { "from_token": "ETH", "to_token": "USDT", "amount": "1.0", "slippage_tolerance": "0.5" } } 响应示例:
json { "from_token": "ETH", "to_token": "USDT", "input_amount": "1.0", "estimated_output": "3495.9", "gas_estimate": 150000, "gas_price": "0.000000025", "total_cost_eth": "0.00375", "transaction_data": "0x737761705f4554485f746f5f555344545f315f302e35" }