Skip to main content
Glama

get_total_supply

Retrieve the total supply of a cryptocurrency token by providing its blockchain address and chain ID.

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 get_total_supply tool logic by querying the Etherscan API for the token total supply using the provided chain ID and token address.
    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}`,
                    },
                ],
            };
        }
    }
  • ToolDefinition for get_total_supply, including name, description, and input schema requiring chain_id (integer) and token_address (string).
    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)
    Registers get_total_supply in the toolDefinitions object, which is used in the MCP server capabilities for tool listing.
    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)
    Registers the handleGetTotalSupply handler for the get_total_supply tool in the switch statement of the callToolHandler.
    case getTotalSupply.name:
        return await handleGetTotalSupply(req, apiKey);

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