Skip to main content
Glama
Nayshins

Cryptocurrency Market Data MCP Server

by Nayshins

get-price

Fetch current cryptocurrency prices from major exchanges like Binance, Coinbase, and Kraken by specifying trading pairs such as BTC/USDT or ETH/USDT.

Instructions

Get current price of a cryptocurrency pair from a specific exchange

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
symbolYesTrading pair symbol (e.g., BTC/USDT, ETH/USDT)
exchangeNoExchange to use (supported: binance, coinbase, kraken, kucoin, hyperliquid, huobi, bitfinex, bybit, okx, mexc)binance

Implementation Reference

  • src/server.py:105-119 (registration)
    Registration of the 'get-price' tool in the handle_list_tools function, defining its name, description, and input schema.
    types.Tool(
        name="get-price",
        description="Get current price of a cryptocurrency pair from a specific exchange",
        inputSchema={
            "type": "object",
            "properties": {
                "symbol": {
                    "type": "string",
                    "description": "Trading pair symbol (e.g., BTC/USDT, ETH/USDT)",
                },
                "exchange": get_exchange_schema()
            },
            "required": ["symbol"],
        },
    ),
  • The core handler logic for the 'get-price' tool within the handle_call_tool function. It retrieves the ticker data using ccxt and returns the current last price.
    if name == "get-price":
        symbol = arguments.get("symbol", "").upper()
        ticker = await exchange.fetch_ticker(symbol)
    
        return [
            types.TextContent(
                type="text",
                text=f"Current price of {symbol} on {exchange_id.upper()}: {ticker['last']} {symbol.split('/')[1]}"
            )
        ]
  • Input schema definition for the 'get-price' tool, specifying required 'symbol' parameter and optional 'exchange'.
    inputSchema={
        "type": "object",
        "properties": {
            "symbol": {
                "type": "string",
                "description": "Trading pair symbol (e.g., BTC/USDT, ETH/USDT)",
            },
            "exchange": get_exchange_schema()
        },
        "required": ["symbol"],
    },
  • Helper function that generates the JSON schema for selecting supported exchanges, referenced in the 'get-price' tool's input schema.
    def get_exchange_schema() -> Dict[str, Any]:
        """Get the JSON schema for exchange selection."""
        return {
            "type": "string",
            "description": f"Exchange to use (supported: {', '.join(SUPPORTED_EXCHANGES.keys())})",
            "enum": list(SUPPORTED_EXCHANGES.keys()),
            "default": "binance"
        }
  • Helper function to retrieve or initialize a CCXT exchange instance, used by the 'get-price' handler.
    async def get_exchange(exchange_id: str) -> ccxt.Exchange:
        """Get or create an exchange instance."""
        exchange_id = exchange_id.lower()
        if exchange_id not in SUPPORTED_EXCHANGES:
            raise ValueError(f"Unsupported exchange: {exchange_id}")
    
        if exchange_id not in exchange_instances:
            exchange_class = SUPPORTED_EXCHANGES[exchange_id]
            exchange_instances[exchange_id] = exchange_class()
    
        return exchange_instances[exchange_id]

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/Nayshins/mcp-server-ccxt'

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