Skip to main content
Glama
Nayshins

Cryptocurrency Market Data MCP Server

by Nayshins

get-historical-ohlcv

Retrieve historical OHLCV candlestick data for cryptocurrency trading pairs to analyze market trends and price movements across multiple exchanges.

Instructions

Get historical OHLCV (candlestick) data for a trading pair

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
symbolYesTrading pair symbol (e.g., BTC/USDT, ETH/USDT)
timeframeNoTimeframe for candlesticks (e.g., 1m, 5m, 15m, 1h, 4h, 1d)1h
days_backNoNumber of days of historical data to fetch (default: 7, max: 30)
exchangeNoExchange to use (supported: binance, coinbase, kraken, kucoin, hyperliquid, huobi, bitfinex, bybit, okx, mexc)binance

Implementation Reference

  • Handler logic for the get-historical-ohlcv tool: parses arguments, fetches OHLCV data from the exchange using ccxt, formats it with helper, and returns formatted text content.
    elif name == "get-historical-ohlcv":
        symbol = arguments.get("symbol", "").upper()
        timeframe = arguments.get("timeframe", "1h")
        days_back = min(int(arguments.get("days_back", 7)), 30)
    
        # Calculate timestamps
        since = int((datetime.now() - timedelta(days=days_back)).timestamp() * 1000)
    
        # Fetch historical data
        ohlcv = await exchange.fetch_ohlcv(symbol, timeframe, since=since)
    
        formatted_data = format_ohlcv_data(ohlcv, timeframe)
        return [
            types.TextContent(
                type="text",
                text=f"Historical OHLCV data for {symbol} ({timeframe}) on {exchange_id.upper()}:\n\n{formatted_data}"
            )
        ]
  • src/server.py:158-184 (registration)
    Registration of the get-historical-ohlcv tool in the list_tools handler, including description and input schema definition.
    types.Tool(
        name="get-historical-ohlcv",
        description="Get historical OHLCV (candlestick) data for a trading pair",
        inputSchema={
            "type": "object",
            "properties": {
                "symbol": {
                    "type": "string",
                    "description": "Trading pair symbol (e.g., BTC/USDT, ETH/USDT)",
                },
                "timeframe": {
                    "type": "string",
                    "description": "Timeframe for candlesticks (e.g., 1m, 5m, 15m, 1h, 4h, 1d)",
                    "enum": ["1m", "5m", "15m", "1h", "4h", "1d"],
                    "default": "1h"
                },
                "days_back": {
                    "type": "number",
                    "description": "Number of days of historical data to fetch (default: 7, max: 30)",
                    "default": 7,
                    "maximum": 30
                },
                "exchange": get_exchange_schema()
            },
            "required": ["symbol"],
        },
    ),
  • Input schema definition for the get-historical-ohlcv tool, specifying parameters like symbol, timeframe, days_back, and exchange.
        "type": "object",
        "properties": {
            "symbol": {
                "type": "string",
                "description": "Trading pair symbol (e.g., BTC/USDT, ETH/USDT)",
            },
            "timeframe": {
                "type": "string",
                "description": "Timeframe for candlesticks (e.g., 1m, 5m, 15m, 1h, 4h, 1d)",
                "enum": ["1m", "5m", "15m", "1h", "4h", "1d"],
                "default": "1h"
            },
            "days_back": {
                "type": "number",
                "description": "Number of days of historical data to fetch (default: 7, max: 30)",
                "default": 7,
                "maximum": 30
            },
            "exchange": get_exchange_schema()
        },
        "required": ["symbol"],
    },
  • Helper function used by the handler to format the raw OHLCV data into a human-readable string with timestamps, OHLCV values, and price changes.
    def format_ohlcv_data(ohlcv_data: List[List], timeframe: str) -> str:
        """Format OHLCV data into a readable string with price changes."""
        formatted_data = []
    
        for i, candle in enumerate(ohlcv_data):
            timestamp, open_price, high, low, close, volume = candle
    
            # Calculate price change from previous close if available
            price_change = ""
            if i > 0:
                prev_close = ohlcv_data[i-1][4]
                change_pct = ((close - prev_close) / prev_close) * 100
                price_change = f"Change: {change_pct:+.2f}%"
    
            # Format the candle data
            dt = datetime.fromtimestamp(timestamp/1000).strftime('%Y-%m-%d %H:%M:%S')
            candle_str = (
                f"Time: {dt}\n"
                f"Open: {open_price:.8f}\n"
                f"High: {high:.8f}\n"
                f"Low: {low:.8f}\n"
                f"Close: {close:.8f}\n"
                f"Volume: {volume:.2f}\n"
                f"{price_change}\n"
                "---"
            )
            formatted_data.append(candle_str)
    
        return "\n".join(formatted_data)
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 the tool does but lacks details on traits like rate limits, authentication needs, data freshness, or error handling. This is a significant gap for a data-fetching tool with multiple parameters.

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 front-loads the core purpose without any wasted words. It's appropriately sized for the tool's complexity, making it easy to parse and understand quickly.

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

Completeness3/5

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

Given the tool's moderate complexity (4 parameters, no output schema, no annotations), the description is minimally adequate. It states the purpose but lacks behavioral context and usage guidelines, which are important for an agent to invoke it correctly in a server with multiple market data tools.

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?

The description adds no parameter-specific information beyond what's in the input schema, which has 100% coverage with detailed descriptions, enums, defaults, and constraints. This meets the baseline score of 3, as the schema adequately documents the parameters without needing extra explanation in the description.

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 ('historical OHLCV (candlestick) data for a trading pair'), making the purpose specific and understandable. However, it doesn't explicitly differentiate from sibling tools like 'get-price' or 'get-volume-history', which might also provide related market data, so it doesn't reach the highest score.

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. It doesn't mention sibling tools or contexts where this tool is preferred, such as for chart analysis or historical trends, leaving the agent without explicit usage instructions.

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/Nayshins/mcp-server-ccxt'

If you have feedback or need assistance with the MCP directory API, please join our Discord server