Skip to main content
Glama

binance_market_price

Retrieve current cryptocurrency prices from Binance for trading pairs like BTCUSDT to monitor market values and inform investment decisions.

Instructions

Get the latest price for a symbol (e.g. BTCUSDT).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
symbolYes

Implementation Reference

  • The main handler for the 'binance_market_price' tool. Defines the tool object with name, description, input schema reference, and the async run function that validates input, fetches the ticker price via the binance client, returns the data, or throws a wrapped error.
    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); } } };
  • Zod schema for input validation: requires a 'symbol' string (e.g., BTCUSDT). Used in the tool's parameters and parsed in the run handler.
    const priceSchema = z.object({ symbol: z.string().min(1) });
  • src/index.ts:15-23 (registration)
    The tool_market_price is imported (line 3) and included in the array of tools to be registered with the MCP server.
    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)
    Loop that registers each tool (including binance_market_price) to the FastMCP server, copying name/desc/schema and wrapping the tool's run method in an execute handler that stringifies output and handles errors.
    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