get_btc_trend
Analyze Bitcoin market trends by retrieving historical data including price, active addresses, new addresses, and transaction addresses over a 3-month period.
Instructions
Get BTC trend chart for the past 3 months. Format: [[date, price, active addresses, new addresses, transaction addresses]]
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/desk3_service/server.py:121-130 (handler)The primary handler function for the 'get_btc_trend' tool. It performs an HTTP GET request to the external Desk3 API to retrieve BTC trend data for the past 3 months and returns it as a list of lists.async def get_btc_trend() -> list[list]: """ Get BTC trend chart for the past 3 months. :return: List of [date, price, active addresses, new addresses, transaction addresses] """ url = 'https://mcp.desk3.io/v1/market/btc/trend' try: return request_api('get', url) except Exception as e: raise RuntimeError(f"Failed to fetch BTC trend data: {e}")
- src/desk3_service/server.py:600-608 (registration)Registration of the 'get_btc_trend' tool in the MCP server's list_tools handler, including name, description, and empty input schema (no parameters required).types.Tool( name="get_btc_trend", description="Get BTC trend chart for the past 3 months. Format: [[date, price, active addresses, new addresses, transaction addresses]]", inputSchema={ "type": "object", "properties": {}, "required": [], }, ),
- src/desk3_service/server.py:603-607 (schema)Input JSON schema for the 'get_btc_trend' tool, defining an empty object with no properties or required fields.inputSchema={ "type": "object", "properties": {}, "required": [], },
- src/desk3_service/server.py:784-794 (handler)Tool execution dispatcher in the MCP server's call_tool handler. It invokes the get_btc_trend function and formats the result as TextContent for the MCP protocol.case "get_btc_trend": try: data = await get_btc_trend() return [ types.TextContent( type="text", text=json.dumps(data, indent=2), ) ] except Exception as e: raise RuntimeError(f"Failed to fetch BTC trend data: {e}")
- src/desk3_service/server.py:23-42 (helper)Shared helper function used by get_btc_trend (and other tools) 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