Skip to main content
Glama
kukapay

aster-info-mcp

get_index_price_kline

Fetch historical candlestick data for index pairs from Aster Finance API. Retrieve open, high, low, and close prices in a structured Markdown table format for analysis.

Instructions

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

Parameters:
    pair (str): Index pair (e.g., 'BTCUSD', 'ETHUSD'). 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
pairYes
intervalYes
startTimeNo
endTimeNo
limitNo

Implementation Reference

  • main.py:97-169 (handler)
    The core handler function for the 'get_index_price_kline' tool. It is decorated with @mcp.tool() which registers it with the MCP server. Fetches index price kline data from the Aster Finance API (/fapi/v1/indexPriceKlines), processes the JSON response into a pandas DataFrame, formats it, and returns a Markdown table of open_time, open, high, low, close.
    async def get_index_price_kline(
        pair: str,
        interval: str,
        startTime: Optional[int] = None,
        endTime: Optional[int] = None,
        limit: Optional[int] = None
    ) -> str:
        """
        Fetch Index Price Kline/Candlestick data from Aster Finance API and return as Markdown table text.
        
        Parameters:
            pair (str): Index pair (e.g., 'BTCUSD', 'ETHUSD'). 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/indexPriceKlines"
        
        # Construct query parameters
        params = {
            "pair": pair.upper(),  # Ensure pair is uppercase (e.g., BTCUSD)
            "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", "ignore1", "ignore2", "ignore3", "ignore4", "ignore5"
                ])
                
                # 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 Index Price Kline data: {str(e)}")
  • main.py:97-97 (registration)
    The @mcp.tool() decorator registers the get_index_price_kline function as an MCP tool.
    async def get_index_price_kline(
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 return format ('Markdown table containing open_time, open, high, low, and close'), error handling ('Raises: Exception'), and API-specific defaults. It doesn't mention rate limits, authentication needs, or data freshness, but covers core behavioral aspects adequately.

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 organized sections for Parameters, Returns, and Raises. Every sentence adds value—no redundancy or fluff. It's appropriately sized for a 5-parameter tool with complex semantics.

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, no annotations, no output schema), the description provides strong coverage of purpose, parameters, returns, and errors. It doesn't explain sibling tool relationships or advanced usage scenarios, but for a data-fetching tool, it's nearly complete. The lack of output schema is mitigated by the clear return format description.

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?

The description adds substantial meaning beyond the 0% schema description coverage. It explains each parameter's purpose, provides examples ('e.g., 'BTCUSD', '1m''), clarifies case-sensitivity, defines time formats ('milliseconds since Unix epoch'), specifies value ranges ('1 to 1500'), and documents default behaviors. This fully compensates for the schema's lack of descriptions.

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 Index Price Kline/Candlestick data'), resource ('from Aster Finance API'), and output format ('return as Markdown table text'). It distinguishes from siblings by specifying 'Index Price' data rather than other market data types like trades, order books, or funding rates.

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 parameter explanations (e.g., 'If None, defaults to API behavior'), but doesn't explicitly state when to use this tool versus alternatives like 'get_kline' or 'get_mark_price_kline'. It provides technical guidance but lacks comparative decision-making context.

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