Skip to main content
Glama

order_book

Retrieve live order book for any trading pair. View top 20 bids and asks with spread to assess market depth and liquidity.

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

  • The 'getOrderBook' function that fetches live order book depth (bids/asks) from Binance API and returns formatted data including spread and mid-price.
    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}` };
      }
    }
  • Schema definition for the 'order_book' tool, defining the input schema with a required 'symbol' parameter.
    {
      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:261-274 (registration)
    The 'order_book' tool is registered as part of the tool definitions list in the getToolDefinitions() method of the MCPMarketServer class.
    {
      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']
      }
    },
    {
      name: 'market_cap',
      description: 'Get top cryptocurrencies ranked by market cap with prices, volumes, and 24h changes.',
  • The dispatch case in handleToolCall that routes 'order_book' to the getOrderBook handler function.
    case 'order_book':
      return await getOrderBook(args.symbol);
Behavior2/5

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

With no annotations, the description carries full burden. It mentions 'live' and shows top 20 bids/asks but does not disclose if it's read-only, rate limits, or error handling 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?

Two sentences with no fluff, front-loaded with key information. Every sentence earns its place.

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

Completeness3/5

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

No output schema; description does not explain return structure beyond top 20 bids/asks with spread. For a low-complexity tool, it is somewhat adequate but lacks detail on response format.

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?

Schema coverage is 100% (one parameter 'symbol' described as trading pair). The description adds no additional meaning beyond the schema, so baseline 3 is appropriate.

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

Purpose5/5

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

The description clearly states the tool gets a live order book, specifying top 20 bids and asks with spread, and mentions market depth and liquidity. It is distinct from siblings like price or candles.

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?

No explicit guidance on when or when not to use this tool versus alternatives. The description implies it's for real-time market depth but lacks comparisons or exclusions.

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