Skip to main content
Glama

Binance MCP Server

tickerBookTicker.ts1.8 kB
// src/tools/binance-spot/market-api/tickerBookTicker.ts import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; import { z } from "zod"; import { spotClient } from "../../../config/binanceClient.js"; export function registerBinanceTickerBookTicker(server: McpServer) { server.tool( "BinanceTickerBookTicker", "Get best price/quantity on the order book for a symbol or all symbols.", { symbol: z.string().optional().describe("Symbol of the trading pair (e.g., BTCUSDT)") }, async ({ symbol }) => { try { const params: any = {}; if (symbol) params.symbol = symbol; const response = await spotClient.restAPI.tickerBookTicker(params); const data = await response.data(); const isArray = Array.isArray(data); const responseText = isArray ? `Retrieved best price/quantity on the order book for all symbols. Total items: ${data.length}.` : `Retrieved best price/quantity on the order book for ${symbol}.`; return { content: [ { type: "text", text: `${responseText} Response: ${JSON.stringify(data)}` } ] }; } catch (error) { const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Failed to retrieve book ticker: ${errorMessage}` } ], isError: true }; } } ); }

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

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