MCP Tools
Model Context Protocol (MCP) tools for AI agent integration with WalletAgent.
Overview
WalletAgent provides a comprehensive set of MCP tools that enable AI agents to interact with Ethereum-compatible blockchains. These tools are designed for safe, reliable blockchain operations with built-in validation and error handling.
Tool Categories
Core wallet management and connection tools.
get_accounts- List available mock accountsconnect_wallet- Connect to a wallet using addressdisconnect_wallet- Disconnect current walletget_current_account- Get connected account infoget_balance- Get native token balanceget_wallet_info- Get current wallet configurationimport_private_key- Import a private key walletset_wallet_type- Switch between mock and private key wallets
Transaction creation, monitoring, and utilities.
send_transaction- Send native token transactionsestimate_gas- Estimate gas for transactionsget_transaction_status- Check transaction statusget_transaction_receipt- Get detailed transaction receiptsimulate_transaction- Simulate contract transactionssign_message- Sign arbitrary messagessign_typed_data- Sign EIP-712 typed data
Smart contract interaction and management.
load_wagmi_config- Load Wagmi-generated contract configurationlist_contracts- List available contractsread_contract- Read from smart contractswrite_contract- Write to smart contracts
ERC-20 and ERC-721 token operations.
ERC-20 Operations:
transfer_token- Transfer ERC-20 tokensapprove_token- Approve token spendingget_token_balance- Get token balanceget_token_info- Get token metadata
ERC-721 Operations:
transfer_nft- Transfer NFTsget_nft_owner- Get NFT ownerget_nft_info- Get NFT metadata
Blockchain network management and switching.
switch_chain- Switch between supported blockchainsget_wallet_info- Get current chain and wallet information
Enterprise-grade encrypted private key management.
create_encrypted_keystore- Create encrypted key store with master passwordunlock_keystore- Unlock encrypted key store for operationslock_keystore- Lock encrypted key store for securityget_keystore_status- Get keystore status and session informationimport_encrypted_private_key- Import private key into encrypted storelist_encrypted_keys- List all keys in encrypted storeremove_encrypted_key- Remove key from encrypted storeupdate_key_label- Update label/name for encrypted keychange_keystore_password- Change master password for keystore
Decentralized perpetual futures trading on Hyperliquid exchange.
hl_import_wallet- Import wallet for Hyperliquid tradinghl_get_account_info- Get account information and balanceshl_place_order- Place limit or market ordershl_cancel_order- Cancel open ordershl_get_open_orders- Get all open ordershl_get_positions- Get current positions and PnLhl_transfer- Transfer USDC on Hyperliquidhl_get_all_mids- Get mid prices for all trading pairshl_get_user_fills- Get trade execution history
Development and testing utilities.
simulate_transaction- Test transactions before executionestimate_gas- Gas estimation for planningget_transaction_receipt- Detailed transaction analysis
Tool Naming Convention
All MCP tools follow the pattern:
Examples:
mcp__wallet-agent__connect_walletmcp__wallet-agent__send_transactionmcp__wallet-agent__read_contract
Common Parameters
Address Format
All Ethereum addresses must be valid 40-character hex strings:
Example:
0x742d35Cc6634C0532925a3b8D7389C4e0C5F0532
Amount Format
Token amounts are specified as strings in the token's base unit:
1.5for 1.5 ETH1000for 1000 tokens0.001for 0.001 ETH
Chain ID Format
Chain IDs are specified as integers:
1for Ethereum Mainnet137for Polygon31337for Anvil Local
Response Format
All tools return responses in a consistent format:
Success Response
Tools return structured data including:
address- Wallet or contract addressesbalance- Token balances as stringstxHash- Transaction hashes for submitted transactionsAdditional tool-specific fields
Error Response
Error responses include:
error.code- Standard MCP error codeerror.message- Human-readable error descriptionerror.data- Optional additional error details
Error Codes
-32602
InvalidParams
Invalid or missing parameters
-32600
InvalidRequest
Missing prerequisites (wallet not connected)
-32603
InternalError
Execution error (network, contract revert)
-32601
MethodNotFound
Unknown tool name
Authentication Setup
Mock Wallet Setup
For development and testing, you can use mock wallets:
"Show me the available test accounts"
The AI will list mock accounts with their addresses and balances
"Connect to the first test account"
The AI will connect to a mock wallet for testing
"Check my wallet balance"
The AI will show your current balance after connection
Private Key Wallet Setup
For real blockchain operations:
"Import my private key from environment variable WALLET_PRIVATE_KEY"
The AI will securely import your private key from an environment variable
"Switch to using real wallets instead of mock wallets"
The AI will change the wallet mode to use imported private keys
"Show me my current account information"
The AI will display your connected account details
Security Considerations
Private Key Handling
Private keys are stored in memory only
Never logged or exposed in error messages
Automatically cleared when disconnecting
Parameter Validation
All addresses are validated for proper format
Amounts are checked for valid numeric format
Chain IDs are verified against supported chains
Network Security
HTTPS RPC endpoints recommended for production
Built-in retry logic for network failures
Rate limiting protection
Common Workflows
Basic Transaction
"Send 0.1 ETH to 0x742d35Cc6634C0532925a3b8D7389C4e0C5F0532"
The AI will connect your wallet, send the transaction, and provide the transaction hash
"Check the status of transaction 0x123abc..."
The AI will monitor the transaction and show you the receipt when it's mined
Contract Interaction
"Load the smart contract configuration from ./src/generated.ts"
The AI will load your Wagmi-generated contract ABIs and addresses
"Read the current number from the Counter contract"
The AI will call the read-only function and show you the current value
"Call the increment function on the Counter contract"
The AI will send a transaction to write to the contract and provide the transaction hash
Token Operations
"Check my USDC balance"
The AI will show your current USDC token balance
"Transfer 100 USDC to 0x742d35Cc6634C0532925a3b8D7389C4e0C5F0532"
The AI will send the token transfer transaction and provide confirmation
Multi-Chain Operations
"Switch to Polygon network"
The AI will change to Polygon for subsequent operations
"Switch to Sepolia testnet"
The AI will change to Sepolia testnet for testing
"Check my balance on Polygon"
The AI will show your balance using POL (Polygon's native currency)
Testing and Development
Test Environment Setup
"Switch to mock wallet mode for testing"
The AI will configure the system to use test accounts instead of real wallets
"Connect to a test account with some balance"
The AI will connect to a mock account with test funds for development
Transaction Simulation
"Simulate calling the riskyFunction on MyContract before actually doing it"
The AI will test the transaction to see if it would succeed or fail
"If the simulation looks good, go ahead and call the riskyFunction for real"
The AI will execute the actual transaction only if the simulation was successful
Error Handling Best Practices
Retry Logic
"Try sending that transaction again if it fails due to network issues"
The AI will automatically retry failed transactions up to 3 times with exponential backoff
Only network errors (code -32603) are retried, not validation errors
Graceful Degradation
"If you can't get my balance, just show 0 instead of failing"
The AI will provide fallback values when non-critical operations fail
Warnings are shown but the workflow continues
Performance Optimization
Batch Operations
"Check my ETH balance, USDC balance, and who owns NFT #1 from MyNFT contract all at once"
The AI will execute multiple independent operations in parallel for faster results
Saves time by not waiting for each operation to complete sequentially
Cache Management
The AI automatically optimizes performance by:
Caching contract addresses and ABIs after first load
Reusing RPC connections for the same blockchain
Clearing caches when you switch configurations or chains
Integration Examples
Claude Code Integration
When using Claude Code, interact with the wallet through prompts:
"What's my current balance?"
Claude Code directly calls the wallet tools and shows your balance
"Send 0.1 ETH to 0x742d35Cc6634C0532925a3b8D7389C4e0C5F0532"
Claude Code handles the transaction and provides the transaction hash
Custom AI Agent Integration
For custom AI implementations:
Connect to the MCP server using standard MCP protocol
Tools are called with the prefix
mcp__wallet-agent__All operations follow the same conversational interface patterns
Troubleshooting
Common Issues
Wallet Not Connected
Error: "No wallet connected"
Solution: Ask the AI to "Connect to a wallet first"
Invalid Chain
Error: "Chain not supported"
Solution: Ask the AI to "Add support for chain ID X" or "Switch to a supported chain"
Contract Not Found
Error: "Contract not loaded"
Solution: Tell the AI to "Load the contract configuration from my generated file"
Insufficient Balance
Error: "Insufficient funds"
Solution: Ask the AI to "Check my balance first" before attempting transactions
Common Troubleshooting Requests
"Why did my transaction fail?"
The AI will check the transaction status and explain the failure reason
"Show me detailed information about transaction 0x123abc..."
The AI will retrieve the full transaction receipt with gas usage and events
"What's wrong with my wallet connection?"
The AI will check your wallet status and suggest fixes
Next Steps
Explore specific tool categories:
Last updated
