Skip to main content
Glama

fetchOrderBook

Retrieve real-time order book data for a specific trading symbol on a cryptocurrency exchange using specified exchange ID and optional limit. Enables informed trading decisions through MCP server integration.

Instructions

Fetch order book for a symbol on an exchange

Input Schema

NameRequiredDescriptionDefault
exchangeIdYesExchange ID (e.g., 'binance', 'coinbase')
limitNoLimit the number of orders returned (optional)
symbolYesTrading symbol (e.g., 'BTC/USDT')

Input Schema (JSON Schema)

{ "$schema": "http://json-schema.org/draft-07/schema#", "additionalProperties": false, "properties": { "exchangeId": { "description": "Exchange ID (e.g., 'binance', 'coinbase')", "type": "string" }, "limit": { "description": "Limit the number of orders returned (optional)", "type": "number" }, "symbol": { "description": "Trading symbol (e.g., 'BTC/USDT')", "type": "string" } }, "required": [ "exchangeId", "symbol" ], "type": "object" }

Implementation Reference

  • The handler function that fetches the order book data from the CCXT exchange instance for the given symbol and optional limit, formats it as JSON text response or returns an error.
    async ({ exchangeId, symbol, limit }) => { try { // 공개 인스턴스 사용 const exchange = ccxtServer.getPublicExchangeInstance(exchangeId); const orderbook = await exchange.fetchOrderBook(symbol, limit); return { content: [ { type: "text", text: JSON.stringify(orderbook, null, 2) } ] }; } catch (error) { return { content: [ { type: "text", text: `Error fetching order book: ${(error as Error).message}` } ], isError: true }; } }
  • Zod input schema defining parameters for the fetchOrderBook tool: exchangeId (string), symbol (string), limit (optional number).
    { exchangeId: z.string().describe("Exchange ID (e.g., 'binance', 'coinbase')"), symbol: z.string().describe("Trading symbol (e.g., 'BTC/USDT')"), limit: z.number().optional().describe("Limit the number of orders returned (optional)") },
  • Full registration of the fetchOrderBook MCP tool via server.tool(), specifying name, description, input schema, and inline handler function.
    server.tool( "fetchOrderBook", "Fetch order book for a symbol on an exchange", { exchangeId: z.string().describe("Exchange ID (e.g., 'binance', 'coinbase')"), symbol: z.string().describe("Trading symbol (e.g., 'BTC/USDT')"), limit: z.number().optional().describe("Limit the number of orders returned (optional)") }, async ({ exchangeId, symbol, limit }) => { try { // 공개 인스턴스 사용 const exchange = ccxtServer.getPublicExchangeInstance(exchangeId); const orderbook = await exchange.fetchOrderBook(symbol, limit); return { content: [ { type: "text", text: JSON.stringify(orderbook, null, 2) } ] }; } catch (error) { return { content: [ { type: "text", text: `Error fetching order book: ${(error as Error).message}` } ], isError: true }; } } );
  • src/server.ts:372-372 (registration)
    Top-level call to registerMarketTools within the CcxtMcpServer's registerTools method, which includes registering the fetchOrderBook tool.
    registerMarketTools(this.server, this);

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/lazy-dinosaur/ccxt-mcp'

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