Skip to main content
Glama

order_book

Retrieve live order book data showing top 20 bids and asks with spread to analyze market depth and liquidity for trading pairs.

Instructions

Get live order book — top 20 bids and asks with spread. Shows market depth and liquidity.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
symbolYesTrading pair (BTC, ETHUSDT, etc.)

Implementation Reference

  • Handler function that fetches and processes live order book data from Binance.
    async function getOrderBook(symbol) {
      const pair = symbol.toUpperCase().replace('/', '');
      const formatted = pair.includes('USDT') ? pair : pair + 'USDT';
    
      try {
        const data = await fetch(
          `https://api.binance.us/api/v3/depth?symbol=${formatted}&limit=20`
        );
        return {
          symbol: formatted,
          bids: data.bids.map(b => ({ price: parseFloat(b[0]), quantity: parseFloat(b[1]) })),
          asks: data.asks.map(a => ({ price: parseFloat(a[0]), quantity: parseFloat(a[1]) })),
          spread: parseFloat(data.asks[0][0]) - parseFloat(data.bids[0][0]),
          spread_pct: ((parseFloat(data.asks[0][0]) - parseFloat(data.bids[0][0])) / parseFloat(data.bids[0][0]) * 100).toFixed(4) + '%',
          mid_price: (parseFloat(data.asks[0][0]) + parseFloat(data.bids[0][0])) / 2,
        };
      } catch (e) {
        return { error: `Could not fetch order book for ${formatted}: ${e.message}` };
      }
    }
  • Tool registration and schema definition for 'order_book'.
      name: 'order_book',
      description: 'Get live order book — top 20 bids and asks with spread. Shows market depth and liquidity.',
      inputSchema: {
        type: 'object',
        properties: {
          symbol: { type: 'string', description: 'Trading pair (BTC, ETHUSDT, etc.)' }
        },
        required: ['symbol']
      }
    },
  • index.js:326-327 (registration)
    Switch case in handleToolCall that maps 'order_book' tool name to its handler.
    case 'order_book':
      return await getOrderBook(args.symbol);
Behavior3/5

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

With no annotations provided, the description carries the full disclosure burden. It successfully adds critical behavioral constraints: the 'top 20' limit (scope restriction) and 'spread' calculation (derived metric). However, it fails to mention other behavioral aspects like rate limits, data freshness frequency despite saying 'live,' or error conditions for invalid symbols.

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 consists of two highly efficient sentences. The first uses an em-dash to compactly convey action, scope, and key data points (bids/asks/spread). The second sentence justifies utility (depth/liquidity). There is zero redundancy or wasted verbiage.

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

Completeness4/5

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

Given the absence of an output schema, the description adequately explains the return structure ('bids and asks with spread') and conceptual meaning ('market depth'). For a single-parameter read operation, this is reasonably complete, though mentioning the expected format of the symbol or error behaviors would improve it further.

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?

The input schema has 100% description coverage for its single 'symbol' parameter, documenting the trading pair format. The description text adds no information about the parameter itself. With complete schema coverage, the baseline score of 3 is appropriate; the description relies on the schema for parameter semantics.

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 uses a specific verb ('Get') and resource ('order book') and clearly defines the scope ('top 20 bids and asks with spread'). It distinguishes itself from sibling tools like 'price' or 'candles' by emphasizing 'market depth and liquidity,' implying this is for order book analysis rather than simple price checks or historical data. However, it does not explicitly name siblings or provide direct comparison.

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

Usage Guidelines3/5

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

The description implies usage context through phrases like 'market depth and liquidity,' suggesting when an agent might need this (analyzing supply/demand walls). However, it lacks explicit guidance such as 'Use this instead of price when you need depth information' or warnings about the 20-level limit being insufficient for full market analysis.

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/ShipItAndPray/mcp-market-data'

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