About Ethereum Trading MCP Server
Ethereum Trading MCP Server is an MCP server published by a67793581 in the Blockchain category: build a Model Context Protocol (MCP) server in Rust that enables AI agents to query balances and execute token swaps on Ethereum.
The repository has 2 stars and 0 forks, with the last commit 11 months ago. Six months or more without a commit doesn't mean the server is broken, but check the open issues before depending on it in production.
Install
git clone https://github.com/a67793581/Ethereum-Trading-MCP-ServerThis server has no ConduID identity, so agent calls to it are not receipted. Pin the version you install and review the source before granting it credentials.
Ask AI
Ask AI about Ethereum Trading MCP Server
Powered by Claude · Grounded in docs
Security checks
- ✓README presentThe repository ships documentation.
5 checks have not been run yet.
README
Programming Assignment: Ethereum Trading MCP Server
Overview
This project is a Model Context Protocol (MCP) server built in Rust that enables AI agents to query balances and execute token swaps on Ethereum.
Features
get_balance: Query ETH and ERC20 token balances.get_token_price: Get current token price in USD using Chainlink price feeds.swap_tokens: Simulate a token swap on Uniswap V2.
Technical Stack
- Rust with Tokio for async runtime.
- ethers-rs for Ethereum RPC communication.
- rmcp for the MCP server framework.
- rust_decimal for financial precision.
- dotenv for managing environment variables.
Setup
-
Install Rust:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -
Clone the repository:
git clone <repository-url> cd <repository-name> -
Set up environment variables: Create a
.envfile in the root of the project and add your Ethereum RPC endpoint and a private key for simulations. You can use a service like Infura or Alchemy.# .env INFURA_PROJECT_ID=your_infura_project_id PRIVATE_KEY=your_wallet_private_key -
Build the project:
cargo build --release -
Run the server:
cargo run --releaseThe server will start on
127.0.0.1:8080.
Example MCP Tool Call
Here is an example of calling the get_balance tool using curl.
Request:
curl -X POST -H "Content-Type: application/json" -d '{
"jsonrpc": "2.0",
"method": "get_balance",
"params": {
"wallet_address": "0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B"
},
"id": 1
}' http://127.0.0.1:8080
Response:
{
"jsonrpc": "2.0",
"result": {
"balance": "..."
},
"id": 1
}
Design Decisions
- ethers-rs vs. alloy: I chose
ethers-rsas it is more mature and has extensive documentation, which is beneficial for a project with a tight deadline. - Uniswap V2 for Swaps: I implemented swaps using Uniswap V2 for simplicity. The V2 router provides straightforward functions like
swapExactTokensForTokens, which is easier to integrate than V3's more complex architecture. - Environment Variables for Secrets: Sensitive information like the Infura project ID and private keys are managed through a
.envfile, which is a standard and secure practice.
Known Limitations
- Limited Token Support: The
get_token_priceandswap_tokenstools currently support a hardcoded list of tokens (ETH, DAI, USDC). This could be extended by using a dynamic token list or a discovery mechanism. - Uniswap V2 Only: The swap functionality is limited to Uniswap V2. Adding V3 support would require a more complex implementation to handle concentrated liquidity and path finding.
- Basic Error Handling: The error handling is basic. A production-ready server would need more robust error handling and reporting.
Tests
To run the tests, use the following command:
cargo test
The tests cover the core functionality of the MCP tools. Note that the tests require a valid INFURA_PROJECT_ID and PRIVATE_KEY in the .env file to run.
README copy captured when this server was indexed; it may lag the repository. The original is authoritative.