Skip to main content
Glama

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
NameRequiredDescriptionDefault
symbolNoTrading pair symbol in format like BTCUSDT, ETHUSDT, etc. Leave empty to get all symbols

Implementation Reference

  • 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}")
  • 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": [], }, ),
  • 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}")
  • 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

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/desk3/cryptocurrency-mcp-server'

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