Skip to main content
Glama
kukapay

aster-info-mcp

get_order_book

Fetch real-time order book data for trading pairs and display it as a structured Markdown table with bid/ask prices and quantities.

Instructions

Fetch order book data from Aster Finance API and return as Markdown table text.

Parameters:
    symbol (str): Trading pair symbol (e.g., 'BTCUSDT', 'ETHUSDT'). Case-insensitive.
    limit (Optional[int]): Number of order book entries to return (5, 10, 20, 50, 100, 500, 1000, 5000).
                          If None, defaults to 100.

Returns:
    str: Markdown table containing side (bid or ask), price, and quantity.

Raises:
    Exception: If the API request fails or data processing encounters an error.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
symbolYes
limitNo

Implementation Reference

  • main.py:554-623 (handler)
    The handler function 'get_order_book' fetches order book data from the Aster Finance API (/fapi/v1/depth), processes bids and asks into a pandas DataFrame, formats it, and returns a Markdown table. The @mcp.tool() decorator registers the tool and infers the input schema from the function signature (symbol: str, optional limit: int).
    @mcp.tool()
    async def get_order_book(
        symbol: str,
        limit: Optional[int] = None
    ) -> str:
        """
        Fetch order book data from Aster Finance API and return as Markdown table text.
        
        Parameters:
            symbol (str): Trading pair symbol (e.g., 'BTCUSDT', 'ETHUSDT'). Case-insensitive.
            limit (Optional[int]): Number of order book entries to return (5, 10, 20, 50, 100, 500, 1000, 5000).
                                  If None, defaults to 100.
        
        Returns:
            str: Markdown table containing side (bid or ask), price, and quantity.
        
        Raises:
            Exception: If the API request fails or data processing encounters an error.
        """
        endpoint = "/fapi/v1/depth"
        
        # Construct query parameters
        params = {
            "symbol": symbol.upper(),  # Ensure symbol is uppercase (e.g., BTCUSDT)
        }
        if limit is not None:
            params["limit"] = limit
    
        async with httpx.AsyncClient() as client:
            try:
                # Make GET request to the API
                response = await client.get(f"{BASE_URL}{endpoint}", params=params)
                response.raise_for_status()  # Raise exception for 4xx/5xx errors
                
                # Parse JSON response
                order_book_data = response.json()
                
                # Extract bids and asks
                bids = order_book_data.get("bids", [])
                asks = order_book_data.get("asks", [])
                
                # Create DataFrames for bids and asks
                bids_df = pd.DataFrame(bids, columns=["price", "quantity"])
                bids_df["side"] = "bid"
                asks_df = pd.DataFrame(asks, columns=["price", "quantity"])
                asks_df["side"] = "ask"
                
                # Combine bids and asks, sorting by price (descending for bids, ascending for asks)
                df = pd.concat([bids_df, asks_df], ignore_index=True)
                df["price"] = df["price"].astype(float)
                df = df.sort_values(by=["side", "price"], ascending=[True, False])
                
                # Format numbers
                df["price"] = df["price"].round(8)
                df["quantity"] = df["quantity"].astype(float).round(8)
                
                # Reorder columns
                df = df[["side", "price", "quantity"]]
                
                # Convert DataFrame to Markdown table
                markdown_table = df.to_markdown(index=False)
                
                return markdown_table
            
            except httpx.HTTPStatusError as e:
                # Handle HTTP errors (e.g., 400, 429)
                raise Exception(f"API request failed: {e.response.status_code} - {e.response.text}")
            except Exception as e:
                # Handle other errors (e.g., network issues, pandas errors)
                raise Exception(f"Error processing order book data: {str(e)}")            
  • main.py:554-554 (registration)
    The @mcp.tool() decorator on get_order_book registers it as an MCP tool.
    @mcp.tool()
  • Input schema inferred from type hints: required 'symbol' (str), optional 'limit' (int). Output: str (Markdown table).
    async def get_order_book(
        symbol: str,
        limit: Optional[int] = None
    ) -> str:
Behavior4/5

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

With no annotations provided, the description carries full burden and does well by disclosing: the API source (Aster Finance), output format (Markdown table), error conditions (API failures or processing errors), and default behavior (limit defaults to 100). It doesn't mention authentication requirements, rate limits, or whether this is a real-time or cached data source.

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 efficiently structured with a clear purpose statement followed by well-organized sections for Parameters, Returns, and Raises. Every sentence adds value with no redundancy or unnecessary information.

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?

For a 2-parameter tool with no annotations and no output schema, the description provides good coverage of what the tool does, parameters, return format, and error conditions. It could be more complete by mentioning authentication requirements, rate limits, or data freshness, but covers the essential aspects well given the context.

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

Parameters5/5

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

With 0% schema description coverage, the description fully compensates by providing detailed parameter information: symbol meaning (trading pair with examples), limit options (specific enumerated values 5-5000), default behavior (100 if None), and case-insensitivity for symbol. This adds significant value beyond the bare schema.

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 specific action ('Fetch order book data'), resource ('from Aster Finance API'), and output format ('return as Markdown table text'). It distinguishes this tool from sibling tools like get_latest_price or get_recent_trades by focusing on order book depth data rather than price quotes or trade history.

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 for obtaining order book data but doesn't explicitly state when to use this tool versus alternatives like get_order_book_ticker (which might provide summary data) or get_latest_price (for single price points). No guidance is given about prerequisites, rate limits, or specific use cases.

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/kukapay/aster-info-mcp'

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