Skip to main content
Glama

Binance Cryptocurrency MCP

by snjyor

get_order_book

Fetch real-time order book data for Binance cryptocurrency trading pairs, including price levels and quantities, to analyze market depth and liquidity efficiently.

Input Schema

NameRequiredDescriptionDefault
limitNoOrder book depth, default 100, max 5000
symbolYesTrading pair symbol, e.g. BTCUSDT

Input Schema (JSON Schema)

{ "$schema": "http://json-schema.org/draft-07/schema#", "additionalProperties": false, "properties": { "limit": { "description": "Order book depth, default 100, max 5000", "type": "number" }, "symbol": { "description": "Trading pair symbol, e.g. BTCUSDT", "type": "string" } }, "required": [ "symbol" ], "type": "object" }

Implementation Reference

  • The handler function for the 'get_order_book' tool. It makes an HTTP GET request to Binance's /api/v3/depth endpoint with the provided symbol and optional limit parameters, fetches the order book data, and returns it as formatted JSON. Handles errors by returning an error message.
    async (args: { symbol: string; limit?: number }) => { try { const response = await axios.get(`${BASE_URL}/api/v3/depth`, { params: { symbol: args.symbol, limit: args.limit }, proxy: getProxy(), }); return { content: [{ type: "text", text: JSON.stringify(response.data, null, 2) }] }; } catch (error: any) { return { content: [{ type: "text", text: `Failed to get order book: ${error.message}` }], isError: true }; } }
  • Zod schema defining the input parameters for the 'get_order_book' tool: 'symbol' (required string, e.g., BTCUSDT) and 'limit' (optional number, default 100, max 5000).
    symbol: z.string().describe("Trading pair symbol, e.g. BTCUSDT"), limit: z.number().optional().describe("Order book depth, default 100, max 5000") },
  • src/index.ts:15-39 (registration)
    Registration of the 'get_order_book' tool using McpServer's tool() method, specifying the tool name, input schema, and handler function.
    "get_order_book", { symbol: z.string().describe("Trading pair symbol, e.g. BTCUSDT"), limit: z.number().optional().describe("Order book depth, default 100, max 5000") }, async (args: { symbol: string; limit?: number }) => { try { const response = await axios.get(`${BASE_URL}/api/v3/depth`, { params: { symbol: args.symbol, limit: args.limit }, proxy: getProxy(), }); return { content: [{ type: "text", text: JSON.stringify(response.data, null, 2) }] }; } catch (error: any) { return { content: [{ type: "text", text: `Failed to get order book: ${error.message}` }], isError: true }; } } );

Other Tools

Related Tools

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

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