MCP ABI
Interact with deployed smart contracts on Ethereum-compatible blockchains using their ABI.
- Package:
@iqai/mcp-abi - Provider: IQ AI
Overview
The ABI MCP server lets your agent read from and write to deployed smart contracts on any EVM-compatible blockchain. You supply the contract ABI and address, and the server exposes tools to call contract functions, query state, and submit transactions.
Private Key Security
Only set WALLET_PRIVATE_KEY when write operations are needed. Never commit
private keys to source control — use .env files that are excluded from
version control.
Getting Started
Install the package:
pnpm add @iqai/mcp-abiUse the server in your agent:
import { McpAbi } from "@iqai/adk";
const toolset = McpAbi({
env: {
CONTRACT_ABI: process.env.CONTRACT_ABI,
CONTRACT_ADDRESS: process.env.CONTRACT_ADDRESS,
WALLET_PRIVATE_KEY: process.env.WALLET_PRIVATE_KEY,
},
});
const tools = await toolset.getTools();import { McpToolset } from "@iqai/adk";
const toolset = new McpToolset({
name: "ABI MCP Client",
description: "Client for smart contract ABI interactions",
transport: {
mode: "stdio",
command: "npx",
args: ["-y", "@iqai/mcp-abi"],
env: {
CONTRACT_ABI: process.env.CONTRACT_ABI,
CONTRACT_ADDRESS: process.env.CONTRACT_ADDRESS,
CONTRACT_NAME: process.env.CONTRACT_NAME,
CHAIN_ID: process.env.CHAIN_ID,
RPC_URL: process.env.RPC_URL,
WALLET_PRIVATE_KEY: process.env.WALLET_PRIVATE_KEY,
PATH: process.env.PATH || "",
},
},
});
const tools = await toolset.getTools();{
"mcpServers": {
"abi-mcp-server": {
"command": "npx",
"args": ["-y", "@iqai/mcp-abi"],
"env": {
"CONTRACT_ABI": "your_contract_abi_json",
"CONTRACT_ADDRESS": "your_contract_address",
"WALLET_PRIVATE_KEY": "your_wallet_private_key"
}
}
}
}Environment Variables
| Variable | Required | Description |
|---|---|---|
CONTRACT_ABI | Yes | JSON ABI of the smart contract |
CONTRACT_ADDRESS | Yes | Deployed contract address |
CONTRACT_NAME | No | Human-readable name for the contract |
CHAIN_ID | No | Chain ID of the target network (default: 1 for Ethereum mainnet) |
RPC_URL | No | Custom RPC endpoint URL |
WALLET_PRIVATE_KEY | No | Private key for signing transactions (required for write calls) |
Available Tools
Tools Unavailable
Tool data for this MCP server could not be loaded. This may be a local or custom server. Please check your configuration or try regenerating tool data.
Integration Example
import { AgentBuilder, McpAbi } from "@iqai/adk";
import * as dotenv from "dotenv";
dotenv.config();
async function main() {
// Initialize McpAbi toolset
const toolset = McpAbi({
env: {
CONTRACT_ABI: process.env.CONTRACT_ABI,
CONTRACT_ADDRESS: process.env.CONTRACT_ADDRESS,
WALLET_PRIVATE_KEY: process.env.WALLET_PRIVATE_KEY,
},
});
// Get available McpAbi tools
const abiTools = await toolset.getTools();
// Create agent with McpAbi tools
const { runner } = await AgentBuilder.create("abi_agent")
.withModel("gemini-2.5-flash")
.withDescription("An agent that interacts with EVM smart contracts")
.withTools(...abiTools)
.build();
const response = await runner.ask(
"Read the token balance for address 0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045",
);
console.log(response);
}
main().catch(console.error);