🔗 MCP ABI
Package: @iqai/mcp-abi
Purpose: Smart contract ABI interactions for Ethereum-compatible blockchains
Features
Section titled “Features”- Dynamically generates MCP tools based on contract ABI
- Supports both read (view/pure) and write functions
- Automatic tool naming with contract prefixes
- Compatible with any Ethereum-compatible blockchain
- Comprehensive error handling and transaction management
🔧 Available Tools
Section titled “🔧 Available Tools”The server automatically creates tools for each function in the provided ABI:
- Read Functions: Query contract state without transactions
- Example:
ERC20_BALANCE_OF,ERC20_TOTAL_SUPPLY,ERC20_NAME
- Example:
- Write Functions: Execute state-changing transactions
- Example:
ERC20_TRANSFER,ERC20_APPROVE,ERC20_MINT
- Example:
Environment Variables
Section titled “Environment Variables”| Variable | Description | Required |
|---|---|---|
WALLET_PRIVATE_KEY | Private key for transaction signing | For write functions |
CONTRACT_ABI | JSON string of the contract’s ABI | Yes |
CONTRACT_ADDRESS | Deployed contract address | Yes |
CONTRACT_NAME | Friendly name for tool prefixes | Optional (defaults to “CONTRACT”) |
CHAIN_ID | Blockchain network chain ID | Optional (defaults to Fraxtal - 252) |
RPC_URL | Custom RPC endpoint URL | Optional |
Configuration Example
Section titled “Configuration Example”{ "mcpServers": { "smart-contract-abi": { "command": "pnpm", "args": ["dlx", "@iqai/mcp-abi"], "env": { "WALLET_PRIVATE_KEY": "your_wallet_private_key_here", "CONTRACT_ABI": "[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"balanceOf\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"}]", "CONTRACT_ADDRESS": "0xaB195B090Cc60C1EFd4d1cEE94Bf441F5931C01b", "CONTRACT_NAME": "ERC20", "CHAIN_ID": "252", "RPC_URL": "https://rpc.frax.com" } } }}🎯 Usage Examples
Section titled “🎯 Usage Examples”ERC20 Token Contract
Section titled “ERC20 Token Contract”- Check balance:
ERC20_BALANCE_OFwith address parameter - Transfer tokens:
ERC20_TRANSFERwith recipient and amount - Check allowances:
ERC20_ALLOWANCEwith owner and spender - Approve spending:
ERC20_APPROVEwith spender and amount
NFT Contract (ERC721)
Section titled “NFT Contract (ERC721)”- Check ownership:
NFT_OWNER_OFwith token ID - Transfer NFT:
NFT_TRANSFER_FROMwith from, to, and token ID - Mint token:
NFT_MINTwith recipient and metadata
📊 Response Examples
Section titled “📊 Response Examples”Read Function Response:
✅ Successfully called balanceOfResult: "1000000000000000000"Write Function Response:
✅ Successfully executed transferTransaction hash: 0x123abc...You can view this transaction on the blockchain explorer.❌ Error Handling
Section titled “❌ Error Handling”The server provides comprehensive error handling for various blockchain interaction scenarios:
- 🚨 Invalid function arguments - ”❌ Error parsing arguments: [specific error]”
- 🔄 Transaction failures - ”❌ Error with [function]: [error message]”
- 🔒 Access control errors - ”❌ Error with [function]: execution reverted”
- 🌐 Network errors - ”❌ Error with [function]: network connection failed”
- 💲 Insufficient funds - ”❌ Error with [function]: insufficient funds for gas”
- 📄 ABI parsing errors - ”❌ Invalid ABI format: [specific error]”
- 🏠 Contract address errors - ”❌ Invalid contract address: [address]”