binance.market.price
Retrieve current cryptocurrency prices from Binance to monitor market movements and inform trading decisions.
Instructions
Get the latest price for a symbol (e.g. BTCUSDT).
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| symbol | Yes |
Implementation Reference
- src/tools/market.ts:14-27 (handler)The tool handler: defines the 'binance.market.price' tool object with description, parameters schema reference, and the 'run' function that validates input, fetches ticker price via binance client, and handles errors.export const tool_market_price: BinanceTool = { name: "binance.market.price", description: "Get the latest price for a symbol (e.g. BTCUSDT).", parameters: priceSchema, async run(input) { const params = priceSchema.parse(input); try { const res = await binance.tickerPrice(params.symbol); return res.data; } catch (err) { throw toToolError(err); } } };
- src/tools/market.ts:6-6 (schema)Zod input schema requiring a 'symbol' string (e.g., BTCUSDT). Used in the tool's parameters.const priceSchema = z.object({ symbol: z.string().min(1) });
- src/index.ts:14-22 (registration)Array of all tools including 'tool_market_price' prepared 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:24-39 (registration)Registration loop: adds each tool (including binance.market.price) to the FastMCP server with a wrapper execute function that calls the tool's run method and formats output.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; } }, }); });