sbtobb/eth_trading_mcp
3.1
If you are the rightful owner of eth_trading_mcp 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.
This Rust-based MCP server provides tools for Ethereum balance checking, token price retrieval, and Uniswap swap simulations over standard input/output.
Tools
3
Resources
0
Prompts
0
Ethereum Trading MCP Server
Rust MCP server that exposes Ethereum balance, price, and Uniswap swap simulation tools over stdio.
Setup
- Requirements: Rust toolchain (1.80+), network access to an Ethereum RPC endpoint.
- Env vars:
ETH_RPC_URL– HTTPS mainnet endpoint (Infura/Alchemy/public RPC). Defaults tohttps://eth.llamarpc.comif unset.CALLER_ADDRESS(optional) – Wallet address used asmsg.senderduring swap simulations; defaults to the zero address if omitted.- Optional overrides for non-mainnet/debugging:
ROUTER_V2_ADDRESS,ROUTER_V3_ADDRESS,UNIVERSAL_ROUTER_ADDRESS,QUOTER_V3_ADDRESS,WETH_ADDRESS,USDC_ADDRESS,DAI_ADDRESS. Default configs are provided for mainnet and Sepolia.
- Install deps and format:
cargo fmt - Run server (stdio):
cargo run
Tools
get_balance: wallet address + optional token address → ETH or ERC20 balance with decimals.get_token_price: token (symbol or address) and quote ("USD" default or "ETH") → Uniswap V2/V3 price path; tries V2 direct/WETH bridge and V3 fee tiers (500/3000/10000).swap_tokens: from/to token, amount, slippage% → chooses best of V2/V3 (single or WETH-bridged hop) and returns calldata, simulated output/min-output, and gas estimate (eth_call). No signing or broadcast occurs.
Example MCP call
{
"method": "tools/call",
"params": {
"name": "get_balance",
"arguments": {
"wallet_address": "0x00000000219ab540356cBB839Cbe05303d7705Fa"
}
}
}
Design notes
- Uses
rmcpmacros for declarative tool routing and JSON Schema generation. - Ethereum access via
alloy(provider + contract sol! bindings) with asynctokioruntime; Uniswap V2 + V3 routing with WETH bridging when direct pools are missing; chain-aware defaults for mainnet/Sepolia plus env overrides. - Financial values formatted with
rust_decimal/format_unitsto avoid float drift. - Structured logging through
tracing+EnvFilter. - Swap simulation returns calldata and gas estimates only; no transaction signing or payload emission.
Known limitations
- Swap simulation will surface
eth_callfailures when balances/allowances are missing; gas estimates may still be absent in that case. - Routing covers direct pools and single WETH bridges across V2/V3; deeper multi-hop search or Universal Router command encoding is not implemented.
- Token metadata cache is in-memory per process; new tokens are fetched on-demand each run.
Tests
- Offline and guarded tests:
cargo test(covers slippage handling, amount formatting, path building). The live price quote test is skipped unlessETH_RPC_URLandCALLER_ADDRESSare set.