get_bitcoin_dominance
Calculate Bitcoin's market share percentage relative to all cryptocurrencies to analyze market trends and investment opportunities.
Instructions
Bitcoin (BTC) dominance is a metric used to measure the relative market share or dominance of Bitcoin in the overall cryptocurrency sector. It represents the percentage of Bitcoin's total market capitalization compared to the total market capitalization of all cryptocurrencies combined
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/desk3_service/server.py:154-163 (handler)The core handler function that implements the logic for the 'get_bitcoin_dominance' tool by fetching data from the external API endpoint.async def get_bitcoin_dominance() -> dict: """ Get Bitcoin (BTC) dominance metric. :return: Bitcoin dominance data """ url = 'https://mcp.desk3.io/v1/market/bitcoin/dominance' try: return request_api('get', url) except Exception as e: raise RuntimeError(f"Failed to fetch Bitcoin dominance data: {e}")
- src/desk3_service/server.py:627-635 (registration)Registration of the 'get_bitcoin_dominance' tool in the MCP server's list_tools handler, including name, description, and empty input schema.types.Tool( name="get_bitcoin_dominance", description="Bitcoin (BTC) dominance is a metric used to measure the relative market share or dominance of Bitcoin in the overall cryptocurrency sector. It represents the percentage of Bitcoin's total market capitalization compared to the total market capitalization of all cryptocurrencies combined", inputSchema={ "type": "object", "properties": {}, "required": [], }, ),
- src/desk3_service/server.py:631-635 (schema)JSON schema definition for the tool's input parameters (none required)."type": "object", "properties": {}, "required": [], }, ),
- src/desk3_service/server.py:817-827 (registration)Tool execution handler in the MCP server's call_tool method, which invokes the get_bitcoin_dominance function and formats the response.case "get_bitcoin_dominance": try: data = await get_bitcoin_dominance() return [ types.TextContent( type="text", text=json.dumps(data, indent=2), ) ] except Exception as e: raise RuntimeError(f"Failed to fetch Bitcoin dominance data: {e}")
- src/desk3_service/server.py:23-41 (helper)Shared helper function used by get_bitcoin_dominance to make 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