Skip to main content
Glama
desk3
by desk3

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

Implementation Reference

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

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