Skip to main content
Glama
kukapay

aster-info-mcp

get_funding_rate_history

Retrieve historical funding rate data for specific trading pairs from Aster Finance API, formatted as a Markdown table. Specify symbol, time range, and record limit for precise results.

Instructions

Fetch Funding Rate History data from Aster Finance API and return as Markdown table text. Parameters: symbol (str): Trading pair symbol (e.g., 'BTCUSDT', 'ETHUSDT'). Case-insensitive. 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 funding rate records to return (1 to 1000). If None, defaults to 100. Returns: str: Markdown table containing symbol, fundingTime, and fundingRate. Raises: Exception: If the API request fails or data processing encounters an error.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
endTimeNo
limitNo
startTimeNo
symbolYes

Implementation Reference

  • main.py:310-375 (handler)
    The complete handler implementation for the 'get_funding_rate_history' tool. It is registered via the @mcp.tool() decorator and fetches historical funding rate data from the Aster Finance API endpoint '/fapi/v1/fundingRate'. The function processes the JSON response into a pandas DataFrame, formats timestamps and rates, and returns a Markdown table. Input parameters are validated via type hints serving as the schema.
    @mcp.tool() async def get_funding_rate_history( symbol: str, startTime: Optional[int] = None, endTime: Optional[int] = None, limit: Optional[int] = None ) -> str: """ Fetch Funding Rate History data from Aster Finance API and return as Markdown table text. Parameters: symbol (str): Trading pair symbol (e.g., 'BTCUSDT', 'ETHUSDT'). Case-insensitive. 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 funding rate records to return (1 to 1000). If None, defaults to 100. Returns: str: Markdown table containing symbol, fundingTime, and fundingRate. Raises: Exception: If the API request fails or data processing encounters an error. """ endpoint = "/fapi/v1/fundingRate" # Construct query parameters params = { "symbol": symbol.upper(), # Ensure symbol is uppercase (e.g., BTCUSDT) } 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 funding_data: List[dict] = response.json() # Create pandas DataFrame df = pd.DataFrame(funding_data) # Convert fundingTime to readable format df["fundingTime"] = pd.to_datetime(df["fundingTime"], unit="ms") # Select relevant columns and format numbers df = df[["symbol", "fundingTime", "fundingRate"]] df["fundingRate"] = df["fundingRate"].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 Funding Rate data: {str(e)}")

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