Skip to main content
Glama
edkdev

DeFi Trading Agent MCP Server

by edkdev

get_top_pools_by_token

Find the most active liquidity pools for any token by contract address across multiple blockchains to analyze trading opportunities.

Instructions

Get top pools for a specific token by contract address

Input Schema

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

Implementation Reference

  • Main handler function for the 'get_top_pools_by_token' MCP tool. Validates inputs, calls CoinGecko API service, and formats the response.
    async getTopPoolsByToken(network, tokenAddress, options = {}) {
      if (!network || !tokenAddress) {
        throw new Error("Missing required parameters: network, tokenAddress");
      }
    
      const result = await this.coinGeckoApi.getTopPoolsByToken(
        network,
        tokenAddress,
        options
      );
    
      return {
        message: `Top pools for token ${tokenAddress} on ${network} retrieved successfully`,
        data: result,
        summary: `Found ${
          result.data?.length || 0
        } pools for token ${tokenAddress}`,
        sort: options.sort || "h24_volume_usd_liquidity_desc",
      };
    }
  • Input schema and description definition for the 'get_top_pools_by_token' tool in MCP tool listing.
      name: TOOL_NAMES.GET_TOP_POOLS_BY_TOKEN,
      description: "Get top pools for a specific token by contract address",
      inputSchema: {
        type: "object",
        properties: {
          network: {
            type: "string",
            description: "Network ID (e.g., 'eth', 'bsc', 'polygon_pos')",
          },
          tokenAddress: {
            type: "string",
            description: "Token contract address",
          },
          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_volume_usd_liquidity_desc', 'h24_tx_count_desc', 'h24_volume_usd_desc' (optional, default: 'h24_volume_usd_liquidity_desc')",
            enum: [
              "h24_volume_usd_liquidity_desc",
              "h24_tx_count_desc",
              "h24_volume_usd_desc",
            ],
          },
        },
        required: ["network", "tokenAddress"],
      },
    },
  • src/index.js:1072-1082 (registration)
    Tool execution registration in the MCP CallToolRequestHandler switch statement, mapping tool name to handler.
    case TOOL_NAMES.GET_TOP_POOLS_BY_TOKEN:
      result = await toolService.getTopPoolsByToken(
        args.network,
        args.tokenAddress,
        {
          include: args.include,
          page: args.page,
          sort: args.sort,
        }
      );
      break;
  • Core helper function that performs the HTTP request to CoinGecko's onchain API to fetch top pools for a given token.
    async getTopPoolsByToken(network, tokenAddress, 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}/tokens/${tokenAddress}/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 token: ${error.message}`);
      }
    }
  • src/constants.js:30-30 (registration)
    Constant definition for the tool name used in registration and handler mapping.
    GET_TOP_POOLS_BY_TOKEN: "get_top_pools_by_token",
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. It states what the tool does but reveals nothing about pagination behavior (implied by 'page' parameter but not explained), rate limits, authentication requirements, error conditions, or what 'top' means quantitatively. The description doesn't explain what constitutes 'top' pools or how many are returned.

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 states the core functionality without unnecessary words. It's appropriately sized for a tool with good schema documentation and gets straight to the point. Every word earns its place in conveying the essential purpose.

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 'top' means, how results are ranked, what data is returned, or any behavioral aspects. While the schema covers parameter definitions well, the description fails to provide the contextual understanding needed for effective tool selection and use.

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 documents all 5 parameters thoroughly. The description adds no additional parameter semantics beyond what's in the schema - it mentions 'contract address' which maps to tokenAddress parameter but provides no extra context. Baseline 3 is appropriate when 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 verb 'Get' and resource 'top pools for a specific token', making the purpose immediately understandable. It specifies 'by contract address' which distinguishes it from other pool-related tools like get_top_pools_by_dex or get_trending_pools. However, it doesn't explicitly differentiate from get_multiple_pools_data or search_pools which might have overlapping functionality.

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 multiple pool-related sibling tools (get_top_pools_by_dex, get_trending_pools, search_pools, get_multiple_pools_data), there's no indication of when this specific token-focused pool retrieval is preferred over other pool discovery methods. No prerequisites or exclusions are mentioned.

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