Skip to main content
Glama
ethancod1ng

Binance MCP Server

by ethancod1ng

get_orderbook

Retrieve real-time order book depth data for specified trading pairs from Binance to analyze market liquidity and price levels.

Instructions

获取订单簿深度数据

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
limitNo深度限制,默认100
symbolYes交易对符号,如 BTCUSDT

Implementation Reference

  • The main handler function for the 'get_orderbook' tool. It validates the input using GetOrderBookSchema, fetches the order book data from the Binance client, slices and maps the bids and asks to the requested limit, and returns formatted data with timestamp. Handles errors using handleBinanceError.
    handler: async (binanceClient: any, args: unknown) => {
      const input = validateInput(GetOrderBookSchema, args);
      validateSymbol(input.symbol);
    
      try {
        const orderBook = await binanceClient.book({
          symbol: input.symbol,
          limit: input.limit,
        });
    
        return {
          symbol: input.symbol,
          lastUpdateId: orderBook.lastUpdateId,
          bids: orderBook.bids.slice(0, input.limit).map((bid: any) => ({
            price: bid.price,
            quantity: bid.quantity,
          })),
          asks: orderBook.asks.slice(0, input.limit).map((ask: any) => ({
            price: ask.price,
            quantity: ask.quantity,
          })),
          timestamp: Date.now(),
        };
      } catch (error) {
        handleBinanceError(error);
      }
    },
  • Zod schema definition for GetOrderBook input validation, used in the handler to parse and validate arguments: requires symbol (string), optional limit (number, default 100).
    export const GetOrderBookSchema = z.object({
      symbol: z.string().describe('交易对符号,如 BTCUSDT'),
      limit: z.number().optional().default(100).describe('深度限制,默认100'),
    });
  • Tool registration within marketDataTools array: defines name 'get_orderbook', description, JSON inputSchema compatible with MCP, and references the handler function.
    {
      name: 'get_orderbook',
      description: '获取订单簿深度数据',
      inputSchema: {
        type: 'object',
        properties: {
          symbol: {
            type: 'string',
            description: '交易对符号,如 BTCUSDT',
          },
          limit: {
            type: 'number',
            description: '深度限制,默认100',
            default: 100,
          },
        },
        required: ['symbol'],
      },
      handler: async (binanceClient: any, args: unknown) => {
        const input = validateInput(GetOrderBookSchema, args);
        validateSymbol(input.symbol);
    
        try {
          const orderBook = await binanceClient.book({
            symbol: input.symbol,
            limit: input.limit,
          });
    
          return {
            symbol: input.symbol,
            lastUpdateId: orderBook.lastUpdateId,
            bids: orderBook.bids.slice(0, input.limit).map((bid: any) => ({
              price: bid.price,
              quantity: bid.quantity,
            })),
            asks: orderBook.asks.slice(0, input.limit).map((ask: any) => ({
              price: ask.price,
              quantity: ask.quantity,
            })),
            timestamp: Date.now(),
          };
        } catch (error) {
          handleBinanceError(error);
        }
      },
    },
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure but offers minimal information. It doesn't indicate whether this is a read-only operation, if it requires authentication, what rate limits apply, or what format the depth data returns. The description only states what data is retrieved without any operational context.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is extremely concise - a single Chinese phrase that directly states the tool's purpose. There's zero wasted language or unnecessary elaboration. It's front-loaded with the essential information and doesn't contain any redundant or verbose elements.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a financial data retrieval tool with no annotations and no output schema, the description is insufficient. It doesn't explain what 'depth data' includes (bid/ask levels, quantities, timestamps), whether the data is real-time or delayed, or how to interpret the results. The agent would need to guess about the return format and data characteristics.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

With 100% schema description coverage, both parameters are well-documented in the schema itself. The description adds no additional parameter information beyond what's already in the schema (symbol as trading pair, limit as depth limit with default 100). This meets the baseline expectation when schema coverage is complete.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description '获取订单簿深度数据' clearly states the tool's purpose as retrieving order book depth data. It specifies both the verb ('获取' - get/retrieve) and resource ('订单簿深度数据' - order book depth data), making the function unambiguous. However, it doesn't explicitly differentiate from sibling tools like get_price or get_klines, which prevents a perfect score.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. There's no mention of when to prefer get_orderbook over get_price for price information, or how it differs from get_klines for market data. The agent must infer usage from the tool name alone without any contextual guidance.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other 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/ethancod1ng/binance-mcp-server'

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