get_total_supply
Retrieve the total supply of a token by specifying its address and chain ID using the Etherscan MCP Tool's blockchain data interaction feature.
Instructions
Get the total supply of a token given its address
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| chain_id | Yes | The chain ID | |
| token_address | Yes | The address of the token |
Implementation Reference
- index.ts:434-473 (handler)The handler function that executes the tool logic by querying the Etherscan API for the token's total supply.async function handleGetTotalSupply(req: any, apiKey: string) { const chainId = req.params.arguments.chain_id; const tokenAddress = req.params.arguments.token_address; try { const response = await axios.get( `https://api.etherscan.io/v2/api?chainid=${chainId}&module=stats&action=tokensupply&contractaddress=${tokenAddress}&apikey=${apiKey}` ); if (response.data.status === "1") { const totalSupply = response.data.result; return { content: [ { type: "text", text: `Total supply of token ${tokenAddress} on chain ${chainId}: ${totalSupply}`, }, ], }; } else { return { content: [ { type: "text", text: `Failed to get total supply: ${response.data.message}`, }, ], }; } } catch (error) { return { content: [ { type: "text", text: `Failed to get total supply: ${error}`, }, ], }; } }
- index.ts:112-129 (schema)The ToolDefinition object defining the input schema, name, and description for the get_total_supply tool.const getTotalSupply: ToolDefinition = { name: "get_total_supply", description: "Get the total supply of a token given its address", inputSchema: { type: "object", properties: { chain_id: { type: "integer", description: "The chain ID", }, token_address: { type: "string", description: "The address of the token", }, }, required: ["chain_id", "token_address"], }, };
- index.ts:216-222 (registration)Registration of the get_total_supply tool in the toolDefinitions object, which is exposed via server capabilities.const toolDefinitions: { [key: string]: ToolDefinition } = { [getFilteredRpcList.name]: getFilteredRpcList, [getChainId.name]: getChainId, [getTotalSupply.name]: getTotalSupply, [getTokenBalance.name]: getTokenBalance, [getTokenHolders.name]: getTokenHolders, [getTokenHoldersCount.name]: getTokenHoldersCount
- index.ts:483-484 (registration)Dispatcher registration: the switch case that routes calls to the get_total_supply handler in the callToolRequest handler.case getTotalSupply.name: return await handleGetTotalSupply(req, apiKey);