Skip to main content
Glama
edkdev

DeFi Trading Agent MCP Server

by edkdev

get_top_pools_by_dex

Retrieve the most active liquidity pools on a specific decentralized exchange to analyze trading opportunities and market trends.

Instructions

Get top pools on a specific DEX

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
networkYesNetwork ID (e.g., 'eth', 'bsc', 'polygon_pos')
dexYesDEX ID (e.g., 'uniswap_v3', 'sushiswap')
includeNoAttributes to include: 'base_token', 'quote_token', 'dex' (comma-separated)
pageNoPage number for pagination (optional, default: 1)
sortNoSort by: 'h24_tx_count_desc', 'h24_volume_usd_desc' (optional, default: 'h24_tx_count_desc')

Implementation Reference

  • Core implementation of getTopPoolsByDex: makes HTTP request to CoinGecko API /networks/{network}/dexes/{dex}/pools endpoint with query params
    async getTopPoolsByDex(network, dex, options = {}) {
      try {
        const queryParams = new URLSearchParams();
        
        if (options.include) queryParams.append('include', options.include);
        if (options.page) queryParams.append('page', options.page);
        if (options.sort) queryParams.append('sort', options.sort);
    
        const url = `${this.baseUrl}/networks/${network}/dexes/${dex}/pools${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 top pools by DEX: ${error.message}`);
      }
    }
  • MCP tool schema definition including input validation for network, dex, include, page, sort parameters
    name: TOOL_NAMES.GET_TOP_POOLS_BY_DEX,
    description: "Get top pools on a specific DEX",
    inputSchema: {
      type: "object",
      properties: {
        network: {
          type: "string",
          description: "Network ID (e.g., 'eth', 'bsc', 'polygon_pos')",
        },
        dex: {
          type: "string",
          description: "DEX ID (e.g., 'uniswap_v3', 'sushiswap')",
        },
        include: {
          type: "string",
          description:
            "Attributes to include: 'base_token', 'quote_token', 'dex' (comma-separated)",
        },
        page: {
          type: "integer",
          description: "Page number for pagination (optional, default: 1)",
        },
        sort: {
          type: "string",
          description:
            "Sort by: 'h24_tx_count_desc', 'h24_volume_usd_desc' (optional, default: 'h24_tx_count_desc')",
          enum: ["h24_tx_count_desc", "h24_volume_usd_desc"],
        },
      },
      required: ["network", "dex"],
    },
  • src/index.js:1049-1055 (registration)
    Registration in MCP CallToolRequestHandler: switch case dispatches to toolService.getTopPoolsByDex
    case TOOL_NAMES.GET_TOP_POOLS_BY_DEX:
      result = await toolService.getTopPoolsByDex(args.network, args.dex, {
        include: args.include,
        page: args.page,
        sort: args.sort,
      });
      break;
  • ToolService wrapper that validates params, calls CoinGeckoApiService, and formats response
    async getTopPoolsByDex(network, dex, options = {}) {
      if (!network || !dex) {
        throw new Error("Missing required parameters: network, dex");
      }
    
      const result = await this.coinGeckoApi.getTopPoolsByDex(
        network,
        dex,
        options
      );
    
      return {
        message: `Top pools for ${dex} on ${network} retrieved successfully`,
        data: result,
        summary: `Found ${result.data?.length || 0} pools on ${dex}`,
        sort: options.sort || "h24_tx_count_desc",
      };
    }
  • src/constants.js:25-25 (registration)
    TOOL_NAMES constant defining the tool name string"get_top_pools_by_dex"
    GET_TOP_POOLS_BY_DEX: "get_top_pools_by_dex",

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