get-price
Retrieve the current price of any cryptocurrency trading pair from leading exchanges including Binance, Coinbase, and Kraken using market data integration.
Instructions
Get current price of a cryptocurrency pair from a specific exchange
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| exchange | No | Exchange to use (supported: binance, coinbase, kraken, kucoin, hyperliquid, huobi, bitfinex, bybit, okx, mexc) | binance |
| symbol | Yes | Trading pair symbol (e.g., BTC/USDT, ETH/USDT) |
Implementation Reference
- src/server.py:242-251 (handler)The handler logic for the 'get-price' tool. Fetches the ticker data for the specified symbol using ccxt and returns the current price in a formatted text content block.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]}" ) ]
- src/server.py:105-119 (registration)Registration of the 'get-price' tool in the list_tools handler, 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"], }, ),
- src/server.py:59-66 (schema)Schema definition helper function used in the inputSchema for 'get-price' tool to validate the exchange parameter.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" }
- src/server.py:31-41 (helper)Helper function to retrieve or initialize the 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]