Skip to content

🔗 MCP ABI

Package: @iqai/mcp-abi
Purpose: Smart contract ABI interactions for Ethereum-compatible blockchains

  • 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

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
  • Write Functions: Execute state-changing transactions
    • Example: ERC20_TRANSFER, ERC20_APPROVE, ERC20_MINT
VariableDescriptionRequired
WALLET_PRIVATE_KEYPrivate key for transaction signingFor write functions
CONTRACT_ABIJSON string of the contract’s ABIYes
CONTRACT_ADDRESSDeployed contract addressYes
CONTRACT_NAMEFriendly name for tool prefixesOptional (defaults to “CONTRACT”)
CHAIN_IDBlockchain network chain IDOptional (defaults to Fraxtal - 252)
RPC_URLCustom RPC endpoint URLOptional
{
"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"
}
}
}
}
  • Check balance: ERC20_BALANCE_OF with address parameter
  • Transfer tokens: ERC20_TRANSFER with recipient and amount
  • Check allowances: ERC20_ALLOWANCE with owner and spender
  • Approve spending: ERC20_APPROVE with spender and amount
  • Check ownership: NFT_OWNER_OF with token ID
  • Transfer NFT: NFT_TRANSFER_FROM with from, to, and token ID
  • Mint token: NFT_MINT with recipient and metadata

Read Function Response:

✅ Successfully called balanceOf
Result: "1000000000000000000"

Write Function Response:

✅ Successfully executed transfer
Transaction hash: 0x123abc...
You can view this transaction on the blockchain explorer.

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]”