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",
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden. It mentions 'top pools' but doesn't clarify what 'top' means (e.g., by volume, transactions, liquidity), though the schema hints at sorting options. It lacks critical behavioral details like pagination behavior, rate limits, authentication needs, or what the output format looks like.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that gets straight to the point with zero wasted words. It's appropriately sized for a straightforward data retrieval tool and is perfectly front-loaded.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a tool with 5 parameters, no annotations, and no output schema, the description is insufficient. It doesn't explain what constitutes 'top' pools, how results are returned, pagination details, or error conditions. The agent would lack critical context to use this tool effectively despite the good schema coverage.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already fully documents all 5 parameters. The description adds no additional parameter semantics beyond what's in the schema (e.g., it doesn't explain what 'top' means in relation to the 'sort' parameter or provide examples of DEX IDs). Baseline 3 is appropriate when the schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Get top pools') and the target resource ('on a specific DEX'), making the purpose immediately understandable. It distinguishes from siblings like 'get_top_pools_by_token' by specifying the DEX focus, though it doesn't explicitly contrast with other pool-related tools like 'get_trending_pools' or 'search_pools'.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. With siblings like 'get_top_pools_by_token', 'get_trending_pools', and 'search_pools', there's no indication of which tool is appropriate for different scenarios (e.g., DEX-specific ranking vs. token-specific pools vs. general search).

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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