Skip to main content
Glama
kukapay

aster-info-mcp

get_premium_index

Fetch premium index data including mark price, index price, and funding rates for trading pairs from Aster Finance. Returns results as a Markdown table for analysis.

Instructions

Fetch Premium Index data from Aster Finance API and return as Markdown table text.

Parameters:
    symbol (Optional[str]): Trading pair symbol (e.g., 'BTCUSDT', 'ETHUSDT'). Case-insensitive.
                           If None, returns data for all symbols.

Returns:
    str: Markdown table containing symbol, markPrice, indexPrice, lastFundingRate, and nextFundingTime.

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

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
symbolNo

Implementation Reference

  • main.py:248-307 (handler)
    Handler function for the get_premium_index tool. It fetches premium index data from the Aster Finance API endpoint /fapi/v1/premiumIndex, processes the JSON response using pandas to create a formatted Markdown table with columns: symbol, markPrice, indexPrice, lastFundingRate, nextFundingTime. Supports optional symbol parameter or all symbols. Includes error handling for HTTP and processing errors. The @mcp.tool() decorator registers it as an MCP tool.
    @mcp.tool()
    async def get_premium_index(
        symbol: Optional[str] = None
    ) -> str:
        """
        Fetch Premium Index data from Aster Finance API and return as Markdown table text.
        
        Parameters:
            symbol (Optional[str]): Trading pair symbol (e.g., 'BTCUSDT', 'ETHUSDT'). Case-insensitive.
                                   If None, returns data for all symbols.
        
        Returns:
            str: Markdown table containing symbol, markPrice, indexPrice, lastFundingRate, and nextFundingTime.
        
        Raises:
            Exception: If the API request fails or data processing encounters an error.
        """
        endpoint = "/fapi/v1/premiumIndex"
        
        # Construct query parameters
        params = {}
        if symbol is not None:
            params["symbol"] = symbol.upper()  # Ensure symbol is uppercase (e.g., BTCUSDT)
    
        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
                premium_data = response.json()
                
                # Handle single symbol (dict) or all symbols (list of dicts)
                if isinstance(premium_data, dict):
                    premium_data = [premium_data]
                
                # Create pandas DataFrame
                df = pd.DataFrame(premium_data)
                
                # Convert nextFundingTime to readable format
                df["nextFundingTime"] = pd.to_datetime(df["nextFundingTime"], unit="ms")
                
                # Select relevant columns and format numbers
                df = df[["symbol", "markPrice", "indexPrice", "lastFundingRate", "nextFundingTime"]]
                df["markPrice"] = df["markPrice"].astype(float).round(8)
                df["indexPrice"] = df["indexPrice"].astype(float).round(8)
                df["lastFundingRate"] = df["lastFundingRate"].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 Premium Index data: {str(e)}")            
Behavior3/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions API request failures and data processing errors in the 'Raises' section, which adds useful context about potential errors. However, it doesn't cover other behavioral aspects like rate limits, authentication requirements, or whether this is a read-only operation.

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 perfectly structured and concise: a clear purpose statement followed by well-organized sections for Parameters, Returns, and Raises. Every sentence earns its place by providing essential information without redundancy.

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?

For a single-parameter tool with no output schema, the description provides excellent coverage of purpose, parameters, return format, and error conditions. The only gap is the lack of annotations, which means some behavioral aspects (like rate limits or authentication) remain unspecified, preventing a perfect score.

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 schema description coverage is 0%, so the description must fully compensate. It provides excellent parameter semantics: explains the 'symbol' parameter is optional, gives examples ('BTCUSDT', 'ETHUSDT'), specifies case-insensitivity, and describes the behavior when None (returns all symbols). 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 specific action ('Fetch Premium Index data'), source ('from Aster Finance API'), and output format ('return as Markdown table text'). It distinguishes this tool from siblings like get_funding_rate_history or get_mark_price_kline by focusing on current premium index data rather than historical or price data.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides clear context for when to use this tool (to fetch premium index data in markdown format) and implies when not to use it (e.g., for historical data or different formats). However, it doesn't explicitly name alternative tools or state exclusion criteria, which prevents a perfect score.

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