Skip to main content
Glama
kukapay

aster-info-mcp

get_kline

Fetch candlestick chart data for cryptocurrency trading pairs from Aster Finance API and format it as a Markdown table for analysis.

Instructions

Fetch Kline/Candlestick data from Aster Finance API and return as Markdown table text.

Parameters:
    symbol (str): Trading pair symbol (e.g., 'BTCUSDT', 'ETHUSDT'). Case-insensitive.
    interval (str): Kline interval (e.g., '1m' for 1 minute, '1h' for 1 hour, '1d' for 1 day).
    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 Klines to return (1 to 1500). If None, defaults to 500.

Returns:
    str: Markdown table containing open_time, open, high, low, and close.

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

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
symbolYes
intervalYes
startTimeNo
endTimeNo
limitNo

Implementation Reference

  • main.py:20-94 (handler)
    The handler function for the 'get_kline' tool. It is decorated with @mcp.tool() for automatic registration. Fetches candlestick (Kline) data from the Aster Finance API (/fapi/v1/klines), processes it into a pandas DataFrame, formats the data, and returns it as a Markdown table.
    async def get_kline(
        symbol: str,
        interval: str,
        startTime: Optional[int] = None,
        endTime: Optional[int] = None,
        limit: Optional[int] = None
    ) -> str:
        """
        Fetch Kline/Candlestick data from Aster Finance API and return as Markdown table text.
        
        Parameters:
            symbol (str): Trading pair symbol (e.g., 'BTCUSDT', 'ETHUSDT'). Case-insensitive.
            interval (str): Kline interval (e.g., '1m' for 1 minute, '1h' for 1 hour, '1d' for 1 day).
            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 Klines to return (1 to 1500). If None, defaults to 500.
        
        Returns:
            str: Markdown table containing open_time, open, high, low, and close.
        
        Raises:
            Exception: If the API request fails or data processing encounters an error.
        """
        endpoint = "/fapi/v1/klines"
        
        # Construct query parameters
        params = {
            "symbol": symbol.upper(),  # Ensure symbol is uppercase (e.g., BTCUSDT)
            "interval": interval,      # e.g., 1m, 1h, 1d
        }
        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
                kline_data: List[List[Any]] = response.json()
                
                # Create pandas DataFrame
                df = pd.DataFrame(kline_data, columns=[
                    "open_time", "open", "high", "low", "close", "volume",
                    "close_time", "quote_asset_volume", "number_of_trades",
                    "taker_buy_base_asset_volume", "taker_buy_quote_asset_volume", "ignore"
                ])
                
                # Convert timestamps to readable format
                df["open_time"] = pd.to_datetime(df["open_time"], unit="ms")
                
                # Select relevant columns and format numbers
                df = df[["open_time", "open", "high", "low", "close"]]
                df["open"] = df["open"].astype(float).round(8)
                df["high"] = df["high"].astype(float).round(8)
                df["low"] = df["low"].astype(float).round(8)
                df["close"] = df["close"].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 Kline data: {str(e)}")
  • main.py:20-20 (registration)
    The @mcp.tool() decorator registers the get_kline function as an MCP tool.
    async def get_kline(
  • main.py:21-26 (schema)
    The function signature defines the input schema with typed parameters and return type.
        symbol: str,
        interval: str,
        startTime: Optional[int] = None,
        endTime: Optional[int] = None,
        limit: Optional[int] = None
    ) -> str:
Behavior3/5

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

With no annotations provided, the description carries full burden. It discloses that the tool fetches from an external API and returns formatted data, mentions default behaviors for optional parameters, and notes error conditions. However, it lacks details about rate limits, authentication requirements, data freshness, or what happens when parameters are invalid beyond the generic Exception mention.

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 clear sections (purpose, parameters, returns, raises) and efficiently conveys necessary information. Every sentence earns its place, though the 'Raises' section could be more specific about error types. It's appropriately sized for a 5-parameter tool with no annotations.

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 tool's moderate complexity (5 parameters, API call, data transformation) and absence of both annotations and output schema, the description does well by explaining parameters thoroughly and specifying the return format. It could improve by detailing the table structure more or mentioning performance characteristics, but it's largely complete for basic usage.

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 semantics for all 5 parameters. Each parameter gets clear explanations with examples (e.g., 'BTCUSDT', '1m'), optionality indications, value ranges ('1 to 1500'), and default behaviors. This adds substantial 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 tool's purpose with specific verb ('Fetch') and resource ('Kline/Candlestick data from Aster Finance API'), and distinguishes it from siblings by specifying it returns data as a Markdown table. It's not a tautology and provides concrete details about what the tool does.

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 the 10 sibling tools listed. While it mentions what the tool does, it doesn't indicate scenarios where this specific Kline data fetching would be preferred over alternatives like get_latest_price, get_order_book, or other Kline variants (get_index_price_kline, get_mark_price_kline).

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