Skip to main content
Glama

get_token_balance

Retrieve the token balance for a specific Ethereum address using the Etherscan MCP. Input chain ID, token address, and wallet address to obtain accurate balance details.

Instructions

Get the balance of a specific token for a specific address

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
addressYesThe address to check the balance for
chain_idYesThe chain ID
token_addressYesThe address of the token

Implementation Reference

  • Registers the 'account__tokenbalance' tool, which is the implementation for getting the balance of an ERC-20 token for a specific address. This matches the functionality of 'get_token_balance'.
    server.addTool({ name: "account__tokenbalance", description: "Returns the current balance of an ERC-20 token of an address.", parameters: z.object({ contractaddress: z.string().describe("the `contract address` of the ERC-20 token"), address: z.string().describe("the `string` representing the address to check for token balance"), chainid: z.string().optional().default("1").describe("chain id, default 1 ( Ethereum )"), }), execute: async (params) => { const fullParams = { ...params, module: "account", action: "tokenbalance", tag: "latest" }; return await apiCall(fullParams); } });
  • The execute handler logic that calls the Etherscan API with module 'account' and action 'tokenbalance' to retrieve the token balance.
    execute: async (params) => { const fullParams = { ...params, module: "account", action: "tokenbalance", tag: "latest" }; return await apiCall(fullParams); }
  • Higher-level registration call that invokes registerTokensTools, including the get_token_balance tool.
    tools.registerTokensTools(server);
  • Helper function apiCall used by all tools, including tokenbalance, to make the API request to Etherscan and format response.
    export async function apiCall(params = {}): Promise<TextContent> { const data = await makeApiRequest(params); return formatResponse(data); }
  • Zod schema for input parameters of the token balance tool.
    parameters: z.object({ contractaddress: z.string().describe("the `contract address` of the ERC-20 token"), address: z.string().describe("the `string` representing the address to check for token balance"), chainid: z.string().optional().default("1").describe("chain id, default 1 ( Ethereum )"), }),

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/xiaok/etherscan-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server