get_token_price
Retrieve real-time cryptocurrency token prices by specifying trading pair symbols like BTCUSDT or ETHUSDT to monitor market values.
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)The core handler function implementing the get_token_price tool logic, fetching real-time token prices from the Desk3 API endpoint.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:562-573 (schema)JSON Schema defining the input parameters for the 'get_token_price' tool, with optional 'symbol' string 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)Tool execution registration in the MCP server's handle_call_tool method, dispatching calls to the get_token_price 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:559-574 (registration)Tool registration in the list_tools() method, defining name, description, and input schema for get_token_price.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:23-41 (helper)Supporting utility function used by get_token_price to perform authenticated HTTP requests to the Desk3 API.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