get_token_price
Retrieve real-time cryptocurrency token prices using trading pair symbols like BTCUSDT or ETHUSDT. Ideal for traders and crypto enthusiasts accessing accurate price data.
Instructions
Get real-time token price info, supports symbol parameter
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| symbol | No | Trading pair symbol in format like BTCUSDT, ETHUSDT, etc. Leave empty to get all symbols |
Implementation Reference
- src/desk3_service/server.py:82-95 (handler)Core handler function that implements the get_token_price tool logic by querying the Desk3 API for real-time token prices.async def get_token_price(symbol: str | None = None) -> dict[str, Any]: """ Get real-time token price information. :param symbol: Trading pair, comma separated for multiple, return all if not provided :return: Token price information """ url = 'https://mcp.desk3.io/v1/market/price' params = {} if symbol: params['symbol'] = symbol try: return request_api('get', url, params=params) except Exception as e: raise RuntimeError(f"Failed to fetch token price data: {e}")
- src/desk3_service/server.py:559-574 (schema)JSON Schema definition for the input parameters of the get_token_price tool.types.Tool( name="get_token_price", description="Get real-time token price info, supports symbol parameter", inputSchema={ "type": "object", "properties": { "symbol": { "type": "string", "description": "Trading pair symbol in format like BTCUSDT, ETHUSDT, etc. Leave empty to get all symbols", "examples": ["BTCUSDT", "ETHUSDT", "BNBUSDT"], "pattern": "^[A-Z0-9]+$" }, }, "required": [], }, ),
- src/desk3_service/server.py:747-758 (registration)Registration and dispatch logic for the get_token_price tool in the MCP server.call_tool handler.case "get_token_price": symbol = arguments.get("symbol") if arguments else None try: data = await get_token_price(symbol=symbol) return [ types.TextContent( type="text", text=json.dumps(data, indent=2), ) ] except Exception as e: raise RuntimeError(f"Failed to fetch token price data: {e}")
- src/desk3_service/server.py:23-41 (helper)Helper function used by get_token_price to make authenticated API requests to the Desk3 service.def request_api(method: str, url: str, params: dict = None, data: dict = None) -> any: headers = { 'Accepts': 'application/json', 'X-DESK3_PRO_API_KEY': API_KEY, } try: logging.info(f"Requesting {method.upper()} {url} params={params} data={data}") if method.lower() == 'get': response = requests.get(url, headers=headers, params=params) elif method.lower() == 'post': response = requests.post(url, headers=headers, json=data) else: raise ValueError(f"Unsupported HTTP method: {method}") response.raise_for_status() logging.info(f"Response {response.status_code} for {url}") return json.loads(response.text) except Exception as e: logging.error(f"Error during {method.upper()} {url}: {e}") raise