Skip to main content
Glama
desk3
by desk3

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
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • 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}")
  • 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": [],
        },
    ),
  • Input JSON schema for the 'get_btc_trend' tool, defining an empty object with no properties or required fields.
    inputSchema={
        "type": "object",
        "properties": {},
        "required": [],
    },
  • 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}")
  • 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

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