get_symbol_price
Fetch the current cryptocurrency pair price from Binance exchange to monitor market values and support trading decisions.
Instructions
Get the current price of a cryptocurrency pair.
Args: symbol: The cryptocurrency pair, e.g., BTCUSDT.
Returns: Price information from Binance.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| symbol | Yes |
Implementation Reference
- binance.py:26-44 (handler)The main handler function for the 'get_symbol_price' tool. It is decorated with @mcp.tool() for registration and @lru_cache for caching. Fetches the current price from Binance public API endpoint.@mcp.tool() @lru_cache(maxsize=100) def get_symbol_price(symbol: str) -> Any: """ Get the current price of a cryptocurrency pair. Args: symbol: The cryptocurrency pair, e.g., BTCUSDT. Returns: Price information from Binance. """ url = "https://api.binance.com/api/v3/ticker/price" params = {"symbol": symbol} response = requests.get(url, params=params) if response.status_code == 200: data = response.json() return {"price": data['price'], "symbol": symbol} return {"error": response.text}