get_multiple_tokens_data
Retrieve token data for multiple contracts on specified blockchain networks to support trading decisions and portfolio analysis.
Instructions
Get data for multiple tokens by their contract addresses
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| network | Yes | Network ID (e.g., 'eth', 'bsc', 'polygon_pos') | |
| addresses | Yes | Token contract addresses, comma-separated for multiple tokens | |
| include | No | Attributes to include: 'top_pools' (optional) |
Implementation Reference
- src/toolService.js:319-338 (handler)Main MCP tool handler: validates inputs, delegates to CoinGeckoApiService, formats response with message, data, and summary.
async getMultipleTokensData(network, addresses, options = {}) { if (!network || !addresses) { throw new Error("Missing required parameters: network, addresses"); } const result = await this.coinGeckoApi.getMultipleTokensData( network, addresses, options ); return { message: "Multiple tokens data retrieved successfully", data: result, summary: `Retrieved data for ${ addresses.split(",").length } token(s) on ${network}`, includes: options.include ? options.include.split(",") : [], }; } - src/index.js:495-518 (schema)Tool schema definition in ListTools handler: input schema, description, and name registration.
{ name: TOOL_NAMES.GET_MULTIPLE_TOKENS_DATA, description: "Get data for multiple tokens by their contract addresses", inputSchema: { type: "object", properties: { network: { type: "string", description: "Network ID (e.g., 'eth', 'bsc', 'polygon_pos')", }, addresses: { type: "string", description: "Token contract addresses, comma-separated for multiple tokens", }, include: { type: "string", description: "Attributes to include: 'top_pools' (optional)", enum: ["top_pools"], }, }, required: ["network", "addresses"], }, }, - src/index.js:1090-1098 (registration)Tool dispatch registration in CallToolRequestSchema switch statement: maps tool name to handler.
case TOOL_NAMES.GET_MULTIPLE_TOKENS_DATA: result = await toolService.getMultipleTokensData( args.network, args.addresses, { include: args.include, } ); break; - Core helper: Constructs CoinGecko API URL for /networks/{network}/tokens/multi/{addresses} and performs authenticated fetch request.
async getMultipleTokensData(network, addresses, options = {}) { try { const queryParams = new URLSearchParams(); if (options.include) queryParams.append('include', options.include); const url = `${this.baseUrl}/networks/${network}/tokens/multi/${addresses}${queryParams.toString() ? '?' + queryParams.toString() : ''}`; const response = await fetch(url, { headers: { 'x-cg-demo-api-key': this.apiKey } }); if (!response.ok) { throw new Error(`HTTP ${response.status}: ${response.statusText}`); } return await response.json(); } catch (error) { throw new Error(`Failed to get multiple tokens data: ${error.message}`); } }