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
| Name | Required | Description | Default |
|---|---|---|---|
| symbol | Yes | ||
| interval | Yes | ||
| limit | No |
Implementation Reference
- src/tools/market.ts:29-42 (handler)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); } } };
- src/tools/market.ts:7-11 (schema)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; } }, }); });