Skip to main content
Glama

DeFi Trading Agent MCP Server

by edkdev

get_token_data

Retrieve detailed token data by contract address on specified blockchain networks, including optional top pools information, for DeFi trading and analysis.

Instructions

Get specific token data by contract address

Input Schema

NameRequiredDescriptionDefault
addressYesToken contract address
includeNoAttributes to include: 'top_pools' (optional)
networkYesNetwork ID (e.g., 'eth', 'bsc', 'polygon_pos')

Input Schema (JSON Schema)

{ "properties": { "address": { "description": "Token contract address", "type": "string" }, "include": { "description": "Attributes to include: 'top_pools' (optional)", "enum": [ "top_pools" ], "type": "string" }, "network": { "description": "Network ID (e.g., 'eth', 'bsc', 'polygon_pos')", "type": "string" } }, "required": [ "network", "address" ], "type": "object" }

Implementation Reference

  • The primary handler function for the 'get_token_data' tool. Validates input parameters, delegates to CoinGeckoApiService, and returns a formatted response with success message, data, summary, and included attributes.
    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(",") : [], }; }
  • Input schema definition for the 'get_token_data' tool, registered in the MCP server's ListTools handler. Specifies required 'network' and 'address' parameters, optional 'include' for top_pools.
    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 (registration)
    Registration/dispatch logic in the MCP server's CallTool handler switch statement. Maps 'get_token_data' tool calls to the toolService.getTokenData method.
    case TOOL_NAMES.GET_TOKEN_DATA: result = await toolService.getTokenData(args.network, args.address, { include: args.include, }); break;
  • Helper function in CoinGeckoApiService that performs the actual HTTP request to CoinGecko's onchain API for token data (/networks/{network}/tokens/{address}), handles query params like 'include', and error handling.
    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}`); } }

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/edkdev/defi-trading-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server