Skip to main content
Glama
gagarinyury

MCP Bitget Trading Server

by gagarinyury

getCandles

Retrieve historical candlestick data for cryptocurrency trading pairs on Bitget to analyze price movements and market trends.

Instructions

Get historical candlestick/OHLCV data

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
symbolYesTrading pair symbol
intervalYesCandle interval
limitNoNumber of candles (default: 100)

Implementation Reference

  • MCP server handler for getCandles tool: parses arguments using schema, calls BitgetRestClient.getCandles, returns JSON stringified candles data.
    case 'getCandles': {
      const { symbol, interval, limit = 100 } = GetCandlesSchema.parse(args);
      const candles = await this.bitgetClient.getCandles(symbol, interval, limit);
      return {
        content: [
          {
            type: 'text',
            text: JSON.stringify(candles, null, 2),
          },
        ],
      } as CallToolResult;
    }
  • Zod schema definition for getCandles tool input parameters: symbol, interval (enum), optional limit.
    export const GetCandlesSchema = z.object({
      symbol: z.string().describe('Trading pair symbol (BTCUSDT for spot, BTCUSDT_UMCBL for futures)'),
      interval: z.enum([
        // Minutes (lowercase)
        '1m', '3m', '5m', '15m', '30m',
        // Hours (can be lowercase, will be converted)
        '1h', '4h', '6h', '12h', '1H', '4H', '6H', '12H',
        // Days/Weeks/Months (can be lowercase, will be converted)
        '1d', '1w', '1D', '1W', '1M',
        // UTC variants
        '6Hutc', '12Hutc', '1Dutc', '3Dutc', '1Wutc', '1Mutc'
      ]).describe('Candle interval - API will auto-format to correct case'),
      limit: z.number().optional().describe('Number of candles (default: 100)')
    });
  • src/server.ts:137-148 (registration)
    Tool registration in MCP server's listTools response: defines name, description, and inputSchema for getCandles.
    {
      name: 'getCandles',
      description: 'Get historical candlestick/OHLCV data',
      inputSchema: {
        type: 'object',
        properties: {
          symbol: { type: 'string', description: 'Trading pair symbol' },
          interval: { type: 'string', enum: ['1m', '5m', '15m', '30m', '1h', '4h', '1d'], description: 'Candle interval' },
          limit: { type: 'number', description: 'Number of candles (default: 100)' }
        },
        required: ['symbol', 'interval']
      },
  • Core implementation of getCandles in BitgetRestClient: handles spot and futures candles via Bitget v2 API, formats intervals appropriately, maps raw API data to Candle[] type.
    async getCandles(symbol: string, interval: string, limit: number = 100): Promise<Candle[]> {
      if (this.isFuturesSymbol(symbol)) {
        // Futures candles - use v2 API with productType
        // Remove _UMCBL suffix if present for v2 API
        const cleanSymbol = symbol.replace('_UMCBL', '');
        const response = await this.request<string[][]>('GET', '/api/v2/mix/market/candles', {
          productType: 'USDT-FUTURES',
          symbol: cleanSymbol,
          granularity: this.formatIntervalForFuturesAPI(interval), // Format interval for futures API
          limit: limit.toString()
        });
    
        if (!response.data || response.data.length === 0) {
          return [];
        }
    
        return response.data.map(candle => ({
          symbol: symbol, // Keep original symbol format
          timestamp: parseInt(candle[0]),
          open: candle[1],
          high: candle[2],
          low: candle[3],
          close: candle[4],
          volume: candle[5]
        }));
      } else {
        // Spot candles
        const response = await this.request<string[][]>('GET', '/api/v2/spot/market/candles', {
          symbol,
          granularity: this.formatIntervalForSpotAPI(interval), // Format interval for spot API
          limit: limit.toString()
        });
    
        if (!response.data || response.data.length === 0) {
          return [];
        }
    
        return response.data.map(candle => ({
          symbol,
          timestamp: parseInt(candle[0]),
          open: candle[1],
          high: candle[2],
          low: candle[3],
          close: candle[4],
          volume: candle[5]
        }));
      }
    }
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 implies a read-only operation ('Get') but doesn't specify whether this requires authentication, has rate limits, returns paginated data, or includes error handling. For a data-fetching tool with zero annotation coverage, this leaves significant gaps in understanding its behavior.

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 function without unnecessary words. It's front-loaded with the core purpose, making it easy to parse quickly, and every part of the sentence contributes essential information.

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 (fetching historical financial data with three parameters) and the absence of both annotations and an output schema, the description is insufficient. It doesn't explain what the output looks like (e.g., array of candles with OHLCV fields), potential errors, or behavioral traits like data freshness or availability, leaving the agent with incomplete context for reliable 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 input schema fully documents all parameters (symbol, interval, limit) with descriptions and an enum for interval. The description adds no additional parameter semantics beyond what the schema provides, such as explaining symbol formats or limit constraints, but this is acceptable given the high schema coverage.

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 action ('Get') and the resource ('historical candlestick/OHLCV data'), making the purpose immediately understandable. However, it doesn't differentiate this tool from potential siblings like 'getTicker' or 'getPrice' beyond specifying the type of financial data returned.

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 like 'getTicker' (current price) or 'getOrderBook' (market depth). It doesn't mention prerequisites, such as needing a valid trading symbol, or exclusions, leaving the agent to infer usage from context alone.

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/gagarinyury/MCP-bitget-trading'

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