Skip to main content
Glama
kukapay

crypto-pegmon-mcp

get_historical_data

Fetch historical price data for USD-pegged stablecoins, displaying date, price, and deviation in a Markdown table. Specify the stablecoin symbol and optional days for analysis.

Instructions

Fetch historical price data for a USD-pegged stablecoin and return as a Markdown table.

Args:
    coin (str): The symbol of the stablecoin (e.g., 'usdt', 'usdc', 'dai').
    days (int, optional): Number of days for historical data. Defaults to 7.

Returns:
    str: A Markdown table with date, price, and deviation.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
coinYes
daysNo

Implementation Reference

  • main.py:130-160 (handler)
    The handler function for the 'get_historical_data' tool. It fetches historical price data from CoinGecko API, computes deviations from $1 peg, and returns a Markdown table. Registered via @mcp.tool() decorator.
    @mcp.tool()
    def get_historical_data(coin: str, days: int = 7) -> str:
        """
        Fetch historical price data for a USD-pegged stablecoin and return as a Markdown table.
    
        Args:
            coin (str): The symbol of the stablecoin (e.g., 'usdt', 'usdc', 'dai').
            days (int, optional): Number of days for historical data. Defaults to 7.
    
        Returns:
            str: A Markdown table with date, price, and deviation.
        """
        if coin.lower() not in STABLECOINS:
            return f"Error: Unsupported stablecoin. Choose from {list(STABLECOINS.keys())}"
        
        coin_id = STABLECOINS[coin.lower()]["id"]
        try:
            # Fetch historical data for the specified number of days
            data = cg.get_coin_market_chart_by_id(id=coin_id, vs_currency="usd", days=days)
            prices = [(datetime.fromtimestamp(item[0]/1000).strftime("%Y-%m-%d"), item[1]) 
                      for item in data["prices"]]
            
            # Create DataFrame for prices and deviations
            df = pd.DataFrame(prices, columns=["Date", "Price"])
            df["Deviation (%)"] = (df["Price"] - 1.0) * 100
            
            # Convert to Markdown table
            markdown_table = df.to_markdown(index=False, floatfmt=".4f")
            return f"**{coin.upper()} Historical Data (Last {days} Days)**:\n\n{markdown_table}"
        except Exception as e:
            return f"Error fetching historical data for {coin}: {str(e)}"
  • main.py:15-84 (helper)
    Global dictionary mapping stablecoin symbols to their CoinGecko IDs and descriptions. Used by get_historical_data for validation and ID lookup.
    STABLECOINS = {
        "usdt": {
            "id": "tether",
            "description": "Tether's USD-pegged stablecoin, centrally issued."
        },
        "usdc": {
            "id": "usd-coin",
            "description": "Circle's USD-backed stablecoin, widely used in DeFi."
        },
        "dai": {
            "id": "dai",
            "description": "Decentralized stablecoin by MakerDAO, collateralized by crypto."
        },
        "busd": {
            "id": "binance-usd",
            "description": "Binance's USD-pegged stablecoin, centrally managed."
        },
        "tusd": {
            "id": "true-usd",
            "description": "TrueUSD, a USD-backed stablecoin by TrustToken."
        },
        "frax": {
            "id": "frax",
            "description": "Fractional-algorithmic USD stablecoin by Frax Finance."
        },
        "usdd": {
            "id": "usdd",
            "description": "TRON's USD-pegged stablecoin, centrally issued."
        },
        "usds": {
            "id": "usds",
            "description": "USD-pegged stablecoin, focused on stability."
        },
        "susds": {
            "id": "susds",
            "description": "Staked USDS, yield-bearing stablecoin."
        },
        "eusde": {
            "id": "ethena-staked-usde",
            "description": "Ethena's staked USD stablecoin, yield-bearing."
        },
        "usdy": {
            "id": "ondo-us-dollar-yield",
            "description": "Ondo's USD yield stablecoin, designed for returns."
        },
        "pyusd": {
            "id": "paypal-usd",
            "description": "PayPal's USD-pegged stablecoin for payments."
        },
        "gusd": {
            "id": "gemini-dollar",
            "description": "Gemini Dollar, USD-backed by Gemini Trust."
        },
        "usdp": {
            "id": "paxos-standard",
            "description": "Paxos Standard, a regulated USD stablecoin."
        },
        "aave-usdc": {
            "id": "aave-usdc",
            "description": "Aave's USD-pegged stablecoin for lending."
        },
        "curve-usd": {
            "id": "curve-usd",
            "description": "Curve Finance's USD stablecoin for DeFi pools."
        },
        "mim": {
            "id": "magic-internet-money",
            "description": "Magic Internet Money, a decentralized USD stablecoin."
        }
    }
Install Server

Other Tools

Related 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/crypto-pegmon-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server