get_bitcoin_price
Retrieve current Bitcoin price in USD from the CoinGecko API for real-time cryptocurrency tracking and financial analysis.
Instructions
Gets current Bitcoin price in USD from CoinGecko API
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "get_bitcoin_price"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- tools/get_bitcoin_price.py:2-10 (handler)The handler function that executes the tool logic: fetches the current Bitcoin price in USD from CoinGecko API using urllib and json, formats it, and returns the result or an error message if fetch fails.
def get_bitcoin_price(): from urllib import request, error import json try: with request.urlopen('https://api.coingecko.com/api/v3/simple/price?ids=bitcoin&vs_currencies=usd') as response: data = json.loads(response.read()) return f"Current Bitcoin price: ${data['bitcoin']['usd']:,.2f}" except: return "Error: Unable to fetch Bitcoin price"