Skip to main content
Glama
edkdev

DeFi Trading Agent MCP Server

by edkdev

get_trending_pools_by_network

Identify trending liquidity pools on a specific blockchain network to discover trading opportunities based on recent activity metrics.

Instructions

Get trending pools on a specific network

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
networkYesNetwork ID (e.g., 'eth', 'bsc', 'polygon_pos')
includeNoAttributes to include: 'base_token', 'quote_token', 'dex' (comma-separated)
pageNoPage number for pagination (optional, default: 1)
durationNoDuration for trending: '5m', '1h', '6h', '24h' (optional, default: '24h')

Implementation Reference

  • The primary handler function for the 'get_trending_pools_by_network' tool. It validates the network parameter, calls the CoinGecko API service, and returns a formatted response with message, data, summary, and duration.
    async getTrendingPoolsByNetwork(network, options = {}) {
      if (!network) {
        throw new Error("network is required");
      }
    
      const result = await this.coinGeckoApi.getTrendingPoolsByNetwork(
        network,
        options
      );
    
      return {
        message: `Trending pools for ${network} retrieved successfully`,
        data: result,
        summary: `Found ${result.data?.length || 0} trending pools on ${network}`,
        duration: options.duration || "24h",
      };
    }
  • The input schema definition for the tool registration in the MCP server tools array, specifying parameters: network (required), include, page, duration.
    name: TOOL_NAMES.GET_TRENDING_POOLS_BY_NETWORK,
    description: "Get trending pools on a specific network",
    inputSchema: {
      type: "object",
      properties: {
        network: {
          type: "string",
          description: "Network ID (e.g., 'eth', 'bsc', 'polygon_pos')",
        },
        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)",
        },
        duration: {
          type: "string",
          description:
            "Duration for trending: '5m', '1h', '6h', '24h' (optional, default: '24h')",
          enum: ["5m", "1h", "6h", "24h"],
        },
      },
      required: ["network"],
    },
  • src/index.js:1030-1036 (registration)
    Tool handler registration in the MCP CallToolRequest switch statement, mapping the tool name to the toolService method call.
    case TOOL_NAMES.GET_TRENDING_POOLS_BY_NETWORK:
      result = await toolService.getTrendingPoolsByNetwork(args.network, {
        include: args.include,
        page: args.page,
        duration: args.duration,
      });
      break;
  • Helper function in CoinGeckoApiService that makes the HTTP request to CoinGecko's trending pools endpoint for a specific network, handling query parameters and API key.
    async getTrendingPoolsByNetwork(network, options = {}) {
      try {
        const queryParams = new URLSearchParams();
        
        if (options.include) queryParams.append('include', options.include);
        if (options.page) queryParams.append('page', options.page);
        if (options.duration) queryParams.append('duration', options.duration);
    
        const url = `${this.baseUrl}/networks/${network}/trending_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 trending pools by network: ${error.message}`);
      }
    }
  • src/constants.js:23-23 (registration)
    Constant defining the exact tool name string used throughout the codebase for registration and dispatching.
    GET_TRENDING_POOLS_BY_NETWORK: "get_trending_pools_by_network",

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