get_token_holders
Retrieve token holder addresses for a specific token by providing its chain ID and token address to access blockchain data.
Instructions
Get the token holders for a given token 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:307-349 (handler)Handler function that executes the get_token_holders tool by calling Etherscan API to fetch top 10 token holders.async function handleGetTokenHolders(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=tokenholderlist&contractaddress=${tokenAddress}&page=1&offset=10&apikey=${apiKey}` ); if (response.data.status === "1") { const tokenHolders = response.data.result.map((holder: any) => { return `${holder.TokenHolderAddress}: ${holder.TokenHolderQuantity}`; }).join("\n"); return { content: [ { type: "text", text: `Token holders for token ${tokenAddress} on chain ${chainId}: ${tokenHolders}`, }, ], }; } else { return { content: [ { type: "text", text: `Failed to get token holders: ${response.data.message}`, }, ], }; } } catch (error) { return { content: [ { type: "text", text: `Failed to get token holders: ${error}`, }, ], }; } }
- index.ts:154-171 (schema)ToolDefinition object defining the schema, name, and description for get_token_holders.const getTokenHolders: ToolDefinition = { name: "get_token_holders", description: "Get the 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-222 (registration)Registration of all tools including get_token_holders in the toolDefinitions map used for MCP 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:505-510 (registration)Server initialization where tools are registered via capabilities.tools.const server = new Server({ name: "etherscan-mcp", version: "1.0.3" }, { capabilities: { tools: toolDefinitions,
- index.ts:487-488 (registration)Dispatcher switch case that routes calls to get_token_holders to its handler.case getTokenHolders.name: return await handleGetTokenHolders(req, apiKey);