Skip to main content
Glama
edkdev

DeFi Trading Agent MCP Server

by edkdev

get_pool_ohlcv

Retrieve OHLCV (Open, High, Low, Close, Volume) data for DeFi liquidity pools across multiple blockchains to analyze price movements and trading activity.

Instructions

Get OHLCV (Open, High, Low, Close, Volume) data for a pool

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
networkYesNetwork ID (e.g., 'eth', 'bsc', 'polygon_pos')
poolAddressYesPool contract address
timeframeYesTimeframe for OHLCV data: 'day', 'hour', 'minute'
aggregateNoAggregate interval (optional, default: '1')
before_timestampNoGet data before this timestamp (optional)
limitNoLimit number of results (optional, max: 1000)
currencyNoCurrency for price data: 'usd', 'token' (optional, default: 'usd')
tokenNoToken for price data: 'base', 'quote' (optional, default: 'base')
include_empty_intervalsNoInclude empty intervals (optional, default: false)

Implementation Reference

  • Tool schema definition including input validation schema and description, registered in the MCP server's ListToolsRequestHandler.
    {
      name: TOOL_NAMES.GET_POOL_OHLCV,
      description:
        "Get OHLCV (Open, High, Low, Close, Volume) data for a pool",
      inputSchema: {
        type: "object",
        properties: {
          network: {
            type: "string",
            description: "Network ID (e.g., 'eth', 'bsc', 'polygon_pos')",
          },
          poolAddress: {
            type: "string",
            description: "Pool contract address",
          },
          timeframe: {
            type: "string",
            description: "Timeframe for OHLCV data: 'day', 'hour', 'minute'",
            enum: ["day", "hour", "minute"],
          },
          aggregate: {
            type: "string",
            description: "Aggregate interval (optional, default: '1')",
          },
          before_timestamp: {
            type: "integer",
            description: "Get data before this timestamp (optional)",
          },
          limit: {
            type: "integer",
            description: "Limit number of results (optional, max: 1000)",
          },
          currency: {
            type: "string",
            description:
              "Currency for price data: 'usd', 'token' (optional, default: 'usd')",
            enum: ["usd", "token"],
          },
          token: {
            type: "string",
            description:
              "Token for price data: 'base', 'quote' (optional, default: 'base')",
            enum: ["base", "quote"],
          },
          include_empty_intervals: {
            type: "boolean",
            description: "Include empty intervals (optional, default: false)",
          },
        },
        required: ["network", "poolAddress", "timeframe"],
      },
    },
  • Primary handler function for the get_pool_ohlcv tool. Validates parameters, calls the CoinGecko API service, and formats the response.
    async getPoolOHLCV(network, poolAddress, timeframe, options = {}) {
      if (!network || !poolAddress || !timeframe) {
        throw new Error(
          "Missing required parameters: network, poolAddress, timeframe"
        );
      }
    
      const result = await this.coinGeckoApi.getPoolOHLCV(
        network,
        poolAddress,
        timeframe,
        options
      );
    
      return {
        message: `OHLCV data for pool ${poolAddress} retrieved successfully`,
        data: result,
        summary: `Retrieved ${timeframe} OHLCV data for pool on ${network}`,
        timeframe: timeframe,
        aggregate: options.aggregate || "1",
        currency: options.currency || "usd",
        token: options.token || "base",
      };
    }
  • src/index.js:1111-1125 (registration)
    Registration and dispatching logic in the MCP server's CallToolRequestHandler switch statement that routes tool calls to the handler.
    case TOOL_NAMES.GET_POOL_OHLCV:
      result = await toolService.getPoolOHLCV(
        args.network,
        args.poolAddress,
        args.timeframe,
        {
          aggregate: args.aggregate,
          before_timestamp: args.before_timestamp,
          limit: args.limit,
          currency: args.currency,
          token: args.token,
          include_empty_intervals: args.include_empty_intervals,
        }
      );
      break;
  • Supporting helper that constructs the CoinGecko API URL and performs the HTTP fetch request for pool OHLCV data.
    async getPoolOHLCV(network, poolAddress, timeframe, options = {}) {
      try {
        const queryParams = new URLSearchParams();
        
        if (options.aggregate) queryParams.append('aggregate', options.aggregate);
        if (options.before_timestamp) queryParams.append('before_timestamp', options.before_timestamp);
        if (options.limit) queryParams.append('limit', options.limit);
        if (options.currency) queryParams.append('currency', options.currency);
        if (options.token) queryParams.append('token', options.token);
        if (options.include_empty_intervals) queryParams.append('include_empty_intervals', options.include_empty_intervals);
    
        const url = `${this.baseUrl}/networks/${network}/pools/${poolAddress}/ohlcv/${timeframe}${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 pool OHLCV: ${error.message}`);
      }
    }
  • src/constants.js:35-35 (registration)
    Tool name constant used for registration across the codebase.
    GET_POOL_OHLCV: "get_pool_ohlcv",
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It states what data is retrieved but omits critical details: whether this is a read-only operation, rate limits, authentication requirements, error handling, or the format/structure of returned OHLCV data. For a tool with 9 parameters and no output schema, this is a significant gap.

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 directly states the tool's purpose without redundancy. It's appropriately sized and front-loaded with the core functionality.

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?

Given the tool's complexity (9 parameters, financial data retrieval), lack of annotations, and absence of an output schema, the description is insufficient. It doesn't address behavioral aspects, return format, error conditions, or usage context, leaving significant gaps for an AI agent to understand how to properly invoke and interpret results.

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 all parameters are documented in the schema. The description adds no additional parameter semantics beyond implying OHLCV data retrieval. It doesn't explain relationships between parameters (e.g., how 'timeframe' interacts with 'aggregate') or provide usage examples.

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 ('OHLCV data for a pool'), making the purpose unambiguous. It doesn't explicitly distinguish from siblings like 'get_pool_trades' or 'get_multiple_pools_data', but the specific focus on OHLCV data provides implicit differentiation.

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?

No guidance is provided on when to use this tool versus alternatives like 'get_pool_trades' (for trade data) or 'get_multiple_pools_data' (for batch queries). The description lacks context about prerequisites, typical use cases, or performance considerations.

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