Skip to main content
Glama

binance_market_klines

Retrieve historical candlestick data for Binance trading pairs to analyze market trends and price movements over specified time intervals.

Instructions

Get historical klines/candles for a symbol and interval.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
symbolYes
intervalYes
limitNo

Implementation Reference

  • The complete implementation of the tool, including the handler function `run` that validates input and fetches klines data from the Binance client.
    export const tool_market_klines: BinanceTool = { name: "binance_market_klines", description: "Get historical klines/candles for a symbol and interval.", parameters: klinesSchema, async run(input) { const params = klinesSchema.parse(input); try { const res = await binance.klines(params.symbol, params.interval, { limit: params.limit }); return res.data; } catch (err) { throw toToolError(err); } } };
  • Zod input schema used by the binance_market_klines tool for parameter validation.
    const klinesSchema = z.object({ symbol: z.string().min(1), interval: z.string().min(1), limit: z.number().int().min(1).max(1000).default(200) });
  • src/index.ts:15-23 (registration)
    Inclusion of tool_market_klines in the tools array for registration.
    const tools = [ tool_market_price, tool_market_klines, tool_exchange_info, tool_account_balances, tool_open_orders, tool_place_order, tool_cancel_order, ];
  • src/index.ts:25-40 (registration)
    Registration loop that adds the tool to the FastMCP server, delegating execution to the tool's `run` method.
    tools.forEach((tool) => { server.addTool({ name: tool.name, description: tool.description, parameters: tool.parameters, execute: async (args) => { try { const result = await tool.run(args); return JSON.stringify(result, null, 2); } catch (error) { const handled = error instanceof ToolError ? error : new ToolError((error as Error).message); throw handled; } }, }); });

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/Valerio357/binance-mcp'

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