Labsco
IQAIcom logo

MCP-ABI

โ˜… 2

from IQAIcom

Interact with Ethereum-compatible smart contracts using their ABI.

๐Ÿ”ฅ๐Ÿ”ฅ๐Ÿ”ฅโœ“ VerifiedFreeAdvanced setup

๐Ÿ”— ABI MCP Server

๐Ÿ“– Overview

The ABI MCP Server enables AI agents to interact with any Ethereum-compatible smart contract using its ABI (Application Binary Interface). This server dynamically generates MCP tools from contract ABIs, allowing seamless interaction with any smart contract without requiring custom tool implementations.

By implementing the Model Context Protocol (MCP), this server allows Large Language Models (LLMs) to read contract state, execute transactions, and interact with decentralized applications directly through their context window.

โœจ Features

  • Dynamic Tool Generation: Automatically creates MCP tools from any contract ABI at runtime.
  • Read Functions: Query contract state (view/pure functions) without sending transactions.
  • Write Functions: Execute state-changing transactions with wallet signing support.
  • Multi-Chain Support: Works with any EVM-compatible blockchain via configurable RPC endpoints.
  • Type-Safe Interactions: Validates function arguments against ABI specifications.

๐Ÿ› ๏ธ MCP Tools

Tools are dynamically generated based on the provided contract ABI. Each function in the ABI becomes an MCP tool:

  • Read Functions (view/pure): Tools prefixed with contract name (e.g., erc20_balanceOf, erc20_totalSupply)
  • Write Functions: Tools for state-changing operations (e.g., erc20_transfer, erc20_approve)

Example tool names for an ERC20 contract with CONTRACT_NAME=ERC20:

  • erc20_balanceOf - Query token balance
  • erc20_transfer - Transfer tokens
  • erc20_approve - Approve spending
  • erc20_allowance - Check allowance

Note: Tools are generated dynamically based on the loaded contract ABI. The tool names follow the pattern {contractname}_{functionname}.

Dynamic Tool Generation

When you load a contract ABI, tools are automatically created for each function in the ABI:

  • Read functions become query tools (no gas required)
  • Write functions become execution tools (requires wallet)

Common Parameters

All generated tools accept the same parameter schema:

ParameterTypeRequiredDefaultDescription
argsarrayNo[]Function arguments as an array. Example: ["0x123...", 100, true]

Example Generated Tools

If you load an ERC-20 token contract named "USDC", the following tools would be generated:

  • usdc_name - Query the token name
  • usdc_symbol - Query the token symbol
  • usdc_decimals - Query token decimals
  • usdc_totalSupply - Query total token supply
  • usdc_balanceOf - Query balance of an address
  • usdc_transfer - Transfer tokens to an address
  • usdc_approve - Approve spending allowance
  • usdc_transferFrom - Transfer tokens on behalf of another address

Tool Response Format

Read Functions:

โœ… Successfully queried {functionName}

๐Ÿ“Š Result:
{JSON result}

Write Functions:

โœ… Successfully executed {functionName}

๐Ÿ”— Transaction Hash: {hash}
๐Ÿ“ฆ Block Number: {blockNumber}
โ›ฝ Gas Used: {gasUsed}
โœ… Status: Success

๐Ÿ‘จโ€๐Ÿ’ป Development

๐Ÿ—๏ธ Build Project

pnpm run build

๐Ÿ‘๏ธ Development Mode (Watch)

pnpm run watch

โœ… Linting & Formatting

pnpm run lint
pnpm run format

๐Ÿ“ Project Structure

  • src/tools/: Tool generation logic
  • src/services/: Contract interaction service
  • src/lib/: Shared utilities
  • src/index.ts: Server entry point

๐Ÿ“š Resources

โš ๏ธ Disclaimer

This tool interacts with blockchain smart contracts and can execute real transactions. Store private keys securely and never commit them to version control. Always test interactions on testnets before mainnet deployment. Trading and interacting with smart contracts involves risk.

๐Ÿ“„ License

ISC