Skip to main content
Glama

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
NameRequiredDescriptionDefault
chain_idYesThe chain ID
token_addressYesThe address of the token

Implementation Reference

  • 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}`, }, ], }; } }
  • 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);

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/septemhill/etherscan-mcp'

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