Skip to main content
Glama
kukapay

aster-info-mcp

get_index_price_kline

Retrieve index price candlestick data for specified pairs and intervals, formatted as a Markdown table with open, high, low, and close values, via the Aster Finance API.

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
endTimeNo
intervalYes
limitNo
pairYes
startTimeNo

Implementation Reference

  • main.py:96-169 (handler)
    Implementation of the 'get_index_price_kline' tool handler. This async function is decorated with @mcp.tool() for automatic registration in the FastMCP server. It 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 prices.
    @mcp.tool() 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 in the FastMCP server.
    async def get_index_price_kline(
  • Input schema defined by function parameters with type hints: pair (str), interval (str), optional startTime/endTime/limit (int), returns str (Markdown table).
    async def get_index_price_kline( pair: str, interval: str, startTime: Optional[int] = None, endTime: Optional[int] = None, limit: Optional[int] = None ) -> str:

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