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",

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