get_token_data
Retrieve token information by contract address to analyze DeFi assets, including network data and optional liquidity pool details for trading decisions.
Instructions
Get specific token data by contract address
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| network | Yes | Network ID (e.g., 'eth', 'bsc', 'polygon_pos') | |
| address | Yes | Token contract address | |
| include | No | Attributes to include: 'top_pools' (optional) |
Implementation Reference
- src/index.js:473-494 (schema)Input schema and description for the 'get_token_data' tool, registered in MCP server's tools list.name: TOOL_NAMES.GET_TOKEN_DATA, description: "Get specific token data by contract address", inputSchema: { type: "object", properties: { network: { type: "string", description: "Network ID (e.g., 'eth', 'bsc', 'polygon_pos')", }, address: { type: "string", description: "Token contract address", }, include: { type: "string", description: "Attributes to include: 'top_pools' (optional)", enum: ["top_pools"], }, }, required: ["network", "address"], }, },
- src/index.js:1084-1088 (handler)MCP request handler dispatch case that executes the tool by calling toolService.getTokenData with input arguments.case TOOL_NAMES.GET_TOKEN_DATA: result = await toolService.getTokenData(args.network, args.address, { include: args.include, }); break;
- src/toolService.js:298-317 (helper)ToolService wrapper that invokes CoinGecko API service and wraps the response with additional metadata.async getTokenData(network, address, options = {}) { if (!network || !address) { throw new Error("Missing required parameters: network, address"); } const result = await this.coinGeckoApi.getTokenData( network, address, options ); return { message: `Token data for ${address} on ${network} retrieved successfully`, data: result, summary: `Retrieved data for token ${ result.data?.attributes?.symbol || address }`, includes: options.include ? options.include.split(",") : [], }; }
- Core handler implementation: Makes HTTP request to CoinGecko API to fetch token data by network and address.async getTokenData(network, address, options = {}) { try { const queryParams = new URLSearchParams(); if (options.include) queryParams.append('include', options.include); const url = `${this.baseUrl}/networks/${network}/tokens/${address}${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 token data: ${error.message}`); } }
- src/constants.js:31-31 (registration)TOOL_NAMES constant defining the tool name 'get_token_data' used in registration and dispatch.GET_TOKEN_DATA: "get_token_data",