Skip to main content
Glama

get_token_holders_count

Retrieve the total number of token holders for a specific token address on a chosen blockchain network using chain ID and token address inputs.

Instructions

Get the number of token holders for a given token address

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
chain_idYesThe chain ID
token_addressYesThe address of the token

Implementation Reference

  • Handler function that implements the tool logic by querying the Etherscan API for the number of token holders given chain ID and token address.
    async function handleGetTokenHoldersCount(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=token&action=tokenholdercount&contractaddress=${tokenAddress}&apikey=${apiKey}` ); if (response.data.status === "1") { const tokenHoldersCount = response.data.result; return { content: [ { type: "text", text: `Number of token holders for token ${tokenAddress} on chain ${chainId}: ${tokenHoldersCount}`, }, ], }; } else { return { content: [ { type: "text", text: `Failed to get token holders count: ${response.data.message}`, }, ], }; } } catch (error) { return { content: [ { type: "text", text: `Failed to get token holders count: ${error}`, }, ], }; } }
  • ToolDefinition providing the input schema, name, and description for the tool.
    const getTokenHoldersCount: ToolDefinition = { name: "get_token_holders_count", description: "Get the number of token holders for a given token 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-223 (registration)
    Registration of the tool in the toolDefinitions map, which is used in server capabilities for listing tools.
    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:489-490 (registration)
    Registration in the switch statement dispatcher that routes calls to the handler function.
    case getTokenHoldersCount.name: return await handleGetTokenHoldersCount(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