11# EVM MCP Server
22
33![ License: MIT] ( https://img.shields.io/badge/License-MIT-blue.svg )
4- ![ EVM Networks] ( https://img.shields.io/badge/Networks-30+-green )
5- ![ TypeScript] ( https://img.shields.io/badge/TypeScript-5.0+-3178C6 )
6- ![ Viem] ( https://img.shields.io/badge/Viem-1.0+-green )
4+ ![ EVM Networks] ( https://img.shields.io/badge/Networks-60+-green )
5+ ![ TypeScript] ( https://img.shields.io/badge/TypeScript-5.8+-3178C6 )
6+ ![ MCP] ( https://img.shields.io/badge/MCP-1.22.0+-blue )
7+ ![ Viem] ( https://img.shields.io/badge/Viem-2.39.3+-green )
78
8- A comprehensive Model Context Protocol (MCP) server that provides blockchain services across multiple EVM-compatible networks. This server enables AI agents to interact with Ethereum, Optimism, Arbitrum, Base, Polygon, and many other EVM chains with a unified interface.
9+ A comprehensive Model Context Protocol (MCP) server that provides blockchain services across 60+ EVM-compatible networks. This server enables AI agents to interact with Ethereum, Optimism, Arbitrum, Base, Polygon, and many other EVM chains with a unified interface through 22 tools and 10 AI-guided prompts .
910
1011## 📋 Contents
1112
@@ -14,10 +15,13 @@ A comprehensive Model Context Protocol (MCP) server that provides blockchain ser
1415- [ Supported Networks] ( #supported-networks )
1516- [ Prerequisites] ( #prerequisites )
1617- [ Installation] ( #installation )
17- - [ Server Configuration] ( #server-configuration )
18+ - [ Configuration] ( #configuration )
19+ - [ Environment Variables] ( #environment-variables )
20+ - [ Server Configuration] ( #server-configuration )
1821- [ Usage] ( #usage )
1922- [ API Reference] ( #api-reference )
2023 - [ Tools] ( #tools )
24+ - [ Prompts] ( #prompts )
2125 - [ Resources] ( #resources )
2226- [ Security Considerations] ( #security-considerations )
2327- [ Project Structure] ( #project-structure )
@@ -29,19 +33,20 @@ A comprehensive Model Context Protocol (MCP) server that provides blockchain ser
2933The MCP EVM Server leverages the Model Context Protocol to provide blockchain services to AI agents. It supports a wide range of services including:
3034
3135- Reading blockchain state (balances, transactions, blocks, etc.)
32- - Interacting with smart contracts
36+ - Interacting with smart contracts with ** automatic ABI fetching ** from block explorers
3337- Transferring tokens (native, ERC20, ERC721, ERC1155)
3438- Querying token metadata and balances
35- - Chain-specific services across 30 + EVM networks
39+ - Chain-specific services across 60 + EVM networks (34 mainnets + 26 testnets)
3640- ** ENS name resolution** for all address parameters (use human-readable names like 'vitalik.eth' instead of addresses)
41+ - ** AI-friendly prompts** that guide agents through complex workflows
3742
38- All services are exposed through a consistent interface of MCP tools and resources , making it easy for AI agents to discover and use blockchain functionality. ** Every tool that accepts Ethereum addresses also supports ENS names** , automatically resolving them to addresses behind the scenes.
43+ All services are exposed through a consistent interface of MCP tools, resources, and prompts , making it easy for AI agents to discover and use blockchain functionality. ** Every tool that accepts Ethereum addresses also supports ENS names** , automatically resolving them to addresses behind the scenes. The server includes intelligent ABI fetching, eliminating the need to know contract ABIs in advance .
3944
4045## ✨ Features
4146
4247### Blockchain Data Access
4348
44- - ** Multi-chain support** for 30 + EVM-compatible networks
49+ - ** Multi-chain support** for 60 + EVM-compatible networks (34 mainnets + 26 testnets)
4550- ** Chain information** including blockNumber, chainId, and RPCs
4651- ** Block data** access by number, hash, or latest
4752- ** Transaction details** and receipts with decoded logs
@@ -70,17 +75,30 @@ All services are exposed through a consistent interface of MCP tools and resourc
7075### Smart Contract Interactions
7176
7277- ** Read contract state** through view/pure functions
73- - ** Write services ** with private key signing
78+ - ** Write to contracts ** - Execute any state-changing function with automatic ABI fetching
7479- ** Contract verification** to distinguish from EOAs
7580- ** Event logs** retrieval and filtering
81+ - ** Automatic ABI fetching** from Etherscan v2 API across all 60+ networks (no need to know ABIs in advance)
82+ - ** ABI parsing and validation** with function discovery
7683
7784### Comprehensive Transaction Support
7885
86+ - ** Flexible Wallet Support** - Configure with Private Key or Mnemonic (BIP-39) with HD path support
7987- ** Native token transfers** across all supported networks
8088- ** Gas estimation** for transaction planning
8189- ** Transaction status** and receipt information
8290- ** Error handling** with descriptive messages
8391
92+ ### AI-Guided Workflows (Prompts)
93+
94+ - ** Transaction preparation** - Guidance for planning and executing transfers
95+ - ** Wallet analysis** - Tools for analyzing wallet activity and holdings
96+ - ** Smart contract exploration** - Interactive ABI fetching and contract analysis
97+ - ** Contract interaction** - Safe execution of write operations on smart contracts
98+ - ** Network information** - Learning about EVM networks and comparisons
99+ - ** Approval auditing** - Reviewing and managing token approvals
100+ - ** Error diagnosis** - Troubleshooting transaction failures
101+
84102## 🌐 Supported Networks
85103
86104### Mainnets
@@ -144,8 +162,9 @@ All services are exposed through a consistent interface of MCP tools and resourc
144162
145163## 🛠️ Prerequisites
146164
147- - [ Bun] ( https://bun.sh/ ) 1.0.0 or higher
148- - Node.js 18.0.0 or higher (if not using Bun)
165+ - [ Bun] ( https://bun.sh/ ) 1.0.0 or higher (recommended)
166+ - Node.js 20.0.0 or higher (if not using Bun)
167+ - Optional: [ Etherscan API key] ( https://etherscan.io/apis ) for ABI fetching
149168
150169## 📦 Installation
151170
@@ -161,7 +180,63 @@ bun install
161180npm install
162181```
163182
164- ## ⚙️ Server Configuration
183+ ## ⚙️ Configuration
184+
185+ ### Environment Variables
186+
187+ The server uses the following environment variables. For write operations and ABI fetching, you must configure these variables:
188+
189+ #### Wallet Configuration (For Write Operations)
190+
191+ You can configure your wallet using ** either** a private key or a mnemonic phrase:
192+
193+ ** Option 1: Private Key**
194+
195+ ``` bash
196+ export EVM_PRIVATE_KEY=" 0x..." # Your private key in hex format (with or without 0x prefix)
197+ ```
198+
199+ ** Option 2: Mnemonic Phrase (Recommended for HD Wallets)**
200+
201+ ``` bash
202+ export EVM_MNEMONIC=" word1 word2 word3 ... word12" # Your 12 or 24 word BIP-39 mnemonic
203+ export EVM_ACCOUNT_INDEX=" 0" # Optional: Account index for HD wallet derivation (default: 0)
204+ ```
205+
206+ The mnemonic option supports hierarchical deterministic (HD) wallet derivation:
207+ - Uses BIP-39 standard mnemonic phrases (12 or 24 words)
208+ - Supports BIP-44 derivation path: ` m/44'/60'/0'/0/{accountIndex} `
209+ - ` EVM_ACCOUNT_INDEX ` allows you to derive different accounts from the same mnemonic
210+ - Default account index is 0 (first account)
211+
212+ ** Wallet is used for:**
213+ - Transferring native tokens (` transfer_native ` tool)
214+ - Transferring ERC20 tokens (` transfer_erc20 ` tool)
215+ - Approving token spending (` approve_token_spending ` tool)
216+ - Writing to smart contracts (` write_contract ` tool)
217+
218+ ⚠️ ** Security** :
219+ - Never commit your private key or mnemonic to version control
220+ - Use environment variables or a secure key management system
221+ - Store mnemonics securely - they provide access to all derived accounts
222+ - Consider using different account indices for different purposes
223+
224+ #### API Keys (For ABI Fetching)
225+
226+ ``` bash
227+ export ETHERSCAN_API_KEY=" your-api-key-here"
228+ ```
229+
230+ This API key is optional but required for:
231+ - Automatic ABI fetching from block explorers (` get_contract_abi ` tool)
232+ - Auto-fetching ABIs when reading contracts (` read_contract ` tool with ` abiJson ` parameter)
233+ - The ` fetch_and_analyze_abi ` prompt
234+
235+ Get your free API key from:
236+ - [ Etherscan] ( https://etherscan.io/apis ) - For Ethereum and compatible chains
237+ - The same key works across all 60+ EVM networks via the Etherscan v2 API
238+
239+ ### Server Configuration
165240
166241The server uses the following default configuration:
167242
@@ -389,36 +464,69 @@ console.log(result);
389464
390465### Tools
391466
392- The server provides the following MCP tools for agents. ** All tools that accept address parameters support both Ethereum addresses and ENS names.**
467+ The server provides 22 focused MCP tools for agents. ** All tools that accept address parameters support both Ethereum addresses and ENS names.**
393468
394- #### Token services
469+ #### Wallet Information
395470
396471| Tool Name | Description | Key Parameters |
397472| -----------| -------------| ----------------|
398- | ` get-token-info ` | Get ERC20 token metadata | ` tokenAddress ` (address/ENS), ` network ` |
399- | ` get-token-balance ` | Check ERC20 token balance | ` tokenAddress ` (address/ENS), ` ownerAddress ` (address/ENS), ` network ` |
400- | ` transfer-token ` | Transfer ERC20 tokens | ` privateKey ` , ` tokenAddress ` (address/ENS), ` toAddress ` (address/ENS), ` amount ` , ` network ` |
401- | ` approve-token-spending ` | Approve token allowances | ` privateKey ` , ` tokenAddress ` (address/ENS), ` spenderAddress ` (address/ENS), ` amount ` , ` network ` |
402- | ` get-nft-info ` | Get NFT metadata | ` tokenAddress ` (address/ENS), ` tokenId ` , ` network ` |
403- | ` check-nft-ownership ` | Verify NFT ownership | ` tokenAddress ` (address/ENS), ` tokenId ` , ` ownerAddress ` (address/ENS), ` network ` |
404- | ` transfer-nft ` | Transfer an NFT | ` privateKey ` , ` tokenAddress ` (address/ENS), ` tokenId ` , ` toAddress ` (address/ENS), ` network ` |
405- | ` get-nft-balance ` | Count NFTs owned | ` tokenAddress ` (address/ENS), ` ownerAddress ` (address/ENS), ` network ` |
406- | ` get-erc1155-token-uri ` | Get ERC1155 metadata | ` tokenAddress ` (address/ENS), ` tokenId ` , ` network ` |
407- | ` get-erc1155-balance ` | Check ERC1155 balance | ` tokenAddress ` (address/ENS), ` tokenId ` , ` ownerAddress ` (address/ENS), ` network ` |
408- | ` transfer-erc1155 ` | Transfer ERC1155 tokens | ` privateKey ` , ` tokenAddress ` (address/ENS), ` tokenId ` , ` amount ` , ` toAddress ` (address/ENS), ` network ` |
409-
410- #### Blockchain services
473+ | ` get_wallet_address ` | Get the address of the configured wallet (from EVM_PRIVATE_KEY) | none |
474+
475+ #### Network Information
476+
477+ | Tool Name | Description | Key Parameters |
478+ | -----------| -------------| ----------------|
479+ | ` get_chain_info ` | Get network information | ` network ` |
480+ | ` get_supported_networks ` | List all supported EVM networks | none |
481+ | ` get_gas_price ` | Get current gas prices on a network | ` network ` |
482+
483+ #### ENS Services
484+
485+ | Tool Name | Description | Key Parameters |
486+ | -----------| -------------| ----------------|
487+ | ` resolve_ens_name ` | Resolve ENS name to address | ` ensName ` , ` network ` |
488+ | ` lookup_ens_address ` | Reverse lookup address to ENS name | ` address ` , ` network ` |
489+
490+ #### Block & Transaction Information
491+
492+ | Tool Name | Description | Key Parameters |
493+ | -----------| -------------| ----------------|
494+ | ` get_block ` | Get block data | ` blockNumber ` or ` blockHash ` , ` network ` |
495+ | ` get_latest_block ` | Get latest block data | ` network ` |
496+ | ` get_transaction ` | Get transaction details | ` txHash ` , ` network ` |
497+ | ` get_transaction_receipt ` | Get transaction receipt with logs | ` txHash ` , ` network ` |
498+ | ` wait_for_transaction ` | Wait for transaction confirmation | ` txHash ` , ` confirmations ` , ` network ` |
499+
500+ #### Balance & Token Information
501+
502+ | Tool Name | Description | Key Parameters |
503+ | -----------| -------------| ----------------|
504+ | ` get_balance ` | Get native token balance | ` address ` (address/ENS), ` network ` |
505+ | ` get_token_balance ` | Check ERC20 token balance | ` tokenAddress ` (address/ENS), ` ownerAddress ` (address/ENS), ` network ` |
506+ | ` get_allowance ` | Check token spending allowance | ` tokenAddress ` (address/ENS), ` ownerAddress ` (address/ENS), ` spenderAddress ` (address/ENS), ` network ` |
507+
508+ #### Smart Contract Interactions
509+
510+ | Tool Name | Description | Key Parameters |
511+ | -----------| -------------| ----------------|
512+ | ` get_contract_abi ` | Fetch contract ABI from block explorer (60+ networks) | ` contractAddress ` (address/ENS), ` network ` |
513+ | ` read_contract ` | Read smart contract state (auto-fetches ABI if needed) | ` contractAddress ` , ` functionName ` , ` args[] ` , ` abiJson ` (optional), ` network ` |
514+ | ` write_contract ` | Execute state-changing functions (auto-fetches ABI if needed) | ` contractAddress ` , ` functionName ` , ` args[] ` , ` value ` (optional), ` abiJson ` (optional), ` network ` |
515+
516+ #### Token Transfers
517+
518+ | Tool Name | Description | Key Parameters |
519+ | -----------| -------------| ----------------|
520+ | ` transfer_native ` | Send native tokens (ETH, etc.) | ` to ` (address/ENS), ` amount ` , ` network ` |
521+ | ` transfer_erc20 ` | Transfer ERC20 tokens | ` tokenAddress ` (address/ENS), ` to ` (address/ENS), ` amount ` , ` network ` |
522+ | ` approve_token_spending ` | Approve token allowances | ` tokenAddress ` (address/ENS), ` spenderAddress ` (address/ENS), ` amount ` , ` network ` |
523+
524+ #### NFT Services
411525
412526| Tool Name | Description | Key Parameters |
413527| -----------| -------------| ----------------|
414- | ` get-chain-info ` | Get network information | ` network ` |
415- | ` get-balance ` | Get native token balance | ` address ` (address/ENS), ` network ` |
416- | ` transfer-eth ` | Send native tokens | ` privateKey ` , ` to ` (address/ENS), ` amount ` , ` network ` |
417- | ` get-transaction ` | Get transaction details | ` txHash ` , ` network ` |
418- | ` read-contract ` | Read smart contract state | ` contractAddress ` (address/ENS), ` abi ` , ` functionName ` , ` args ` , ` network ` |
419- | ` write-contract ` | Write to smart contract | ` contractAddress ` (address/ENS), ` abi ` , ` functionName ` , ` args ` , ` privateKey ` , ` network ` |
420- | ` is-contract ` | Check if address is a contract | ` address ` (address/ENS), ` network ` |
421- | ` resolve-ens ` | Resolve ENS name to address | ` ensName ` , ` network ` |
528+ | ` get_nft_info ` | Get NFT (ERC721) metadata | ` tokenAddress ` (address/ENS), ` tokenId ` , ` network ` |
529+ | ` get_erc1155_balance ` | Check ERC1155 balance | ` tokenAddress ` (address/ENS), ` tokenId ` , ` ownerAddress ` (address/ENS), ` network ` |
422530
423531### Resources
424532
0 commit comments