Skip to main content
Glama
kukapay

crypto-pegmon-mcp

get_current_price

Fetch the current price of a USD-pegged stablecoin and calculate its peg deviation. Input the stablecoin symbol (e.g., 'usdt', 'usdc') to receive a Markdown-formatted response with price and deviation details.

Instructions

Fetch the current price of a USD-pegged stablecoin in USD and calculate peg deviation.

Args:
    coin (str): The symbol of the stablecoin (e.g., 'usdt', 'usdc', 'dai').

Returns:
    str: A string with the current price and peg deviation in Markdown format.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
coinYes

Implementation Reference

  • main.py:107-127 (handler)
    The handler function for the 'get_current_price' tool. It takes a stablecoin symbol, fetches its current USD price via CoinGecko API, computes the peg deviation from $1, and returns a formatted Markdown string with the price and deviation.
    def get_current_price(coin: str) -> str:
        """
        Fetch the current price of a USD-pegged stablecoin in USD and calculate peg deviation.
    
        Args:
            coin (str): The symbol of the stablecoin (e.g., 'usdt', 'usdc', 'dai').
    
        Returns:
            str: A string with the current price and peg deviation in Markdown format.
        """
        if coin.lower() not in STABLECOINS:
            return f"Error: Unsupported stablecoin. Choose from {list(STABLECOINS.keys())}"
        
        coin_id = STABLECOINS[coin.lower()]["id"]
        try:
            data = cg.get_price(ids=coin_id, vs_currencies="usd")
            price = data[coin_id]["usd"]
            deviation = (price - 1.0) * 100  # Calculate deviation as percentage
            return f"**{coin.upper()} Current Price**: ${price:.4f}, Peg Deviation: {deviation:.2f}%"
        except Exception as e:
            return f"Error fetching price for {coin}: {str(e)}"
  • main.py:106-106 (registration)
    The @mcp.tool() decorator registers the get_current_price function as an MCP tool. The tool name is the function name 'get_current_price'.
    @mcp.tool()
  • Docstring defining the input schema (coin: str parameter) and output format for the tool.
    """
    Fetch the current price of a USD-pegged stablecoin in USD and calculate peg deviation.
    
    Args:
        coin (str): The symbol of the stablecoin (e.g., 'usdt', 'usdc', 'dai').
    
    Returns:
        str: A string with the current price and peg deviation in Markdown format.
    """
  • main.py:15-83 (helper)
    Global STABLECOINS dictionary providing CoinGecko IDs for supported stablecoins, used by get_current_price to validate input and fetch data.
    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