Skip to main content
Glama
edkdev

DeFi Trading Agent MCP Server

by edkdev

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
NameRequiredDescriptionDefault
networkYesNetwork ID (e.g., 'eth', 'bsc', 'polygon_pos')
addressYesToken contract address
includeNoAttributes to include: 'top_pools' (optional)

Implementation Reference

  • 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"], }, },
  • 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;
  • 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",

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