Skip to main content
Glama

get_btc_price

Retrieve the current Bitcoin price in USD through the Lightning Enable MCP server. This tool provides real-time BTC pricing data for use in automated Lightning Network payment calculations and transactions.

Instructions

Get the current Bitcoin price in USD. Only available with Strike wallet.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The handler function for the 'get_btc_price' MCP tool. It verifies the Strike wallet and calls the wallet's own get_btc_price method.
    async def get_btc_price(
        wallet: "StrikeWallet | None" = None,
    ) -> str:
        """
        Get the current Bitcoin price in USD.
    
        Uses Strike's rate ticker API to get the current BTC/USD exchange rate.
        Only available with Strike wallet.
    
        Args:
            wallet: Strike wallet instance
    
        Returns:
            JSON with current BTC price in USD
        """
        if not wallet:
            return json.dumps({
                "success": False,
                "error": "Wallet not configured. Set STRIKE_API_KEY environment variable for price data."
            })
    
        # Verify it's a Strike wallet
        from ..strike_wallet import StrikeWallet
        if not isinstance(wallet, StrikeWallet):
            provider_name = type(wallet).__name__.replace("Wallet", "")
            return json.dumps({
                "success": False,
                "error": f"Price ticker is only available with Strike wallet. Current wallet: {provider_name}",
                "errorCode": "NOT_SUPPORTED",
                "hint": "Set STRIKE_API_KEY environment variable for price data."
            })
    
        try:
            result = await wallet.get_btc_price()
    
            if not result.success:
                return json.dumps({
                    "success": False,
                    "error": result.error_message,
                    "errorCode": result.error_code,
                })
    
            return json.dumps({
                "success": True,
                "provider": "Strike",
                "ticker": {
                    "btcUsd": float(result.btc_usd_price),
                },
                "message": f"Current BTC price: ${result.btc_usd_price:,.2f} USD"
            }, indent=2)
    
        except Exception as e:
            logger.exception("Error getting BTC price")
            return json.dumps({
                "success": False,
                "error": sanitize_error(str(e))
            })
  • Registration of the 'get_btc_price' tool in the MCP server's list_tools handler.
        name="get_btc_price",
        description=(
            "Get the current Bitcoin price in USD. "
            "Only available with Strike wallet."
        ),
        inputSchema={
            "type": "object",
            "properties": {},
        },
    ),
    Tool(
  • Invocation of the 'get_btc_price' tool handler in the MCP server's call_tool handler.
    elif name == "get_btc_price":
        result = await get_btc_price(
            wallet=self.strike_wallet,
        )

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/refined-element/lightning-enable-mcp'

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