Skip to main content
Glama
kukapay

aster-info-mcp

get_aggregated_trades

Fetch aggregated trades data for cryptocurrency pairs from Aster Finance API and format results as a Markdown table with trade details including price, quantity, and timestamps.

Instructions

Fetch aggregated trades data from Aster Finance API and return as Markdown table text.

Parameters:
    symbol (str): Trading pair symbol (e.g., 'BTCUSDT', 'ETHUSDT'). Case-insensitive.
    fromId (Optional[int]): Aggregated trade ID to start from. If None, uses time-based query or most recent trades.
    startTime (Optional[int]): Start time in milliseconds since Unix epoch. If None, defaults to API behavior.
    endTime (Optional[int]): End time in milliseconds since Unix epoch. If None, defaults to API behavior.
    limit (Optional[int]): Number of aggregated trades to return (1 to 1000). If None, defaults to 500.

Returns:
    str: Markdown table containing aggTradeId, price, qty, firstTradeId, lastTradeId, time, and isBuyerMaker.

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

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
symbolYes
fromIdNo
startTimeNo
endTimeNo
limitNo

Implementation Reference

  • main.py:688-768 (handler)
    The handler function for the 'get_aggregated_trades' tool. It fetches aggregated trade data from the Aster Finance API (/fapi/v1/aggTrades), processes the response using pandas to create a formatted Markdown table with columns aggTradeId, price, qty, firstTradeId, lastTradeId, time, and isBuyerMaker. It handles input parameters for filtering trades and includes error handling for API requests.
    @mcp.tool()
    async def get_aggregated_trades(
        symbol: str,
        fromId: Optional[int] = None,
        startTime: Optional[int] = None,
        endTime: Optional[int] = None,
        limit: Optional[int] = None
    ) -> str:
        """
        Fetch aggregated trades data from Aster Finance API and return as Markdown table text.
        
        Parameters:
            symbol (str): Trading pair symbol (e.g., 'BTCUSDT', 'ETHUSDT'). Case-insensitive.
            fromId (Optional[int]): Aggregated trade ID to start from. If None, uses time-based query or most recent trades.
            startTime (Optional[int]): Start time in milliseconds since Unix epoch. If None, defaults to API behavior.
            endTime (Optional[int]): End time in milliseconds since Unix epoch. If None, defaults to API behavior.
            limit (Optional[int]): Number of aggregated trades to return (1 to 1000). If None, defaults to 500.
        
        Returns:
            str: Markdown table containing aggTradeId, price, qty, firstTradeId, lastTradeId, time, and isBuyerMaker.
        
        Raises:
            Exception: If the API request fails or data processing encounters an error.
        """
        endpoint = "/fapi/v1/aggTrades"
        
        # Construct query parameters
        params = {
            "symbol": symbol.upper(),  # Ensure symbol is uppercase (e.g., BTCUSDT)
        }
        if fromId is not None:
            params["fromId"] = fromId
        if startTime is not None:
            params["startTime"] = startTime
        if endTime is not None:
            params["endTime"] = endTime
        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
                trades_data = response.json()
                
                # Create pandas DataFrame with API response keys
                df = pd.DataFrame(trades_data, columns=["a", "p", "q", "f", "l", "T", "m"])
                
                # Convert time to readable format
                df["T"] = pd.to_datetime(df["T"], unit="ms")
                
                # Select and rename columns for clarity
                df = df[["a", "p", "q", "f", "l", "T", "m"]]
                df = df.rename(columns={
                    "a": "aggTradeId",
                    "p": "price",
                    "q": "qty",
                    "f": "firstTradeId",
                    "l": "lastTradeId",
                    "T": "time",
                    "m": "isBuyerMaker"
                })
                
                # Format numbers
                df["price"] = df["price"].astype(float).round(8)
                df["qty"] = df["qty"].astype(float).round(8)
                
                # 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 aggregated trades data: {str(e)}")   
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 key behaviors: it specifies the return format (Markdown table), lists the exact fields returned, mentions error handling ('Raises: Exception'), and notes parameter defaults and API fallbacks. However, it doesn't cover rate limits, authentication needs, or pagination details.

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

Conciseness4/5

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

The description is well-structured with sections for purpose, parameters, returns, and raises. It's front-loaded with the core functionality. Some sentences could be more concise (e.g., the parameter explanations are slightly verbose), but overall it's efficient with minimal waste.

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 5 parameters with 0% schema coverage and no output schema, the description provides strong compensation: it fully documents parameters, specifies the return format and fields, and mentions error handling. It lacks details on authentication, rate limits, or sibling tool differentiation, but for a data-fetching tool, it's largely complete.

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?

Schema description coverage is 0%, so the description must compensate fully. It does so excellently by explaining all 5 parameters with clear semantics: symbol (trading pair examples), fromId (ID-based start), startTime/endTime (time ranges in milliseconds), and limit (range 1-1000 with default). Each parameter's purpose, format, and default behavior are explicitly documented.

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 aggregated trades data'), source ('from Aster Finance API'), and output format ('return as Markdown table text'). It distinguishes this tool from siblings like get_recent_trades or get_kline by focusing on aggregated trades with specific return fields.

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 like get_recent_trades or get_kline. It mentions the tool's purpose but doesn't specify scenarios where aggregated trades are preferred over other data types, nor does it mention prerequisites 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/kukapay/aster-info-mcp'

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