get_quotes
Fetch cryptocurrency quotes by providing a slug or symbol. Integrates with Coinmarket API to retrieve accurate pricing data for crypto assets.
Instructions
Get cryptocurrency quotes
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_quotes"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| slug | No | ||
| symbol | No |
Implementation Reference
- src/coinmarket_service/server.py:37-54 (handler)Main handler function that executes the get_quotes tool logic - makes API calls to CoinMarketCap to fetch cryptocurrency quotes
async def get_quotes(slug: str | None, symbol: str | None) -> dict[str, Any]: url = 'https://pro-api.coinmarketcap.com/v1/cryptocurrency/quotes/latest' parameters = { 'convert':'USD' } if slug: parameters['slug'] = slug if symbol: parameters['symbol'] = symbol headers = { 'Accepts': 'application/json', 'X-CMC_PRO_API_KEY': API_KEY, } response = requests.get(url, headers=headers, params=parameters) response.raise_for_status() data = json.loads(response.text) return data - Tool registration schema defining get_quotes tool with slug and symbol parameters as optional strings
types.Tool( name="get_quotes", description="Get cryptocurrency quotes", inputSchema={ "type": "object", "properties": { "slug": {"type": "string"}, "symbol": {"type": "string"}, }, "required": [], }, ), - src/coinmarket_service/server.py:154-170 (registration)Tool execution handler that processes get_quotes calls and returns formatted results
case "get_quotes": if not arguments: slug = None symbol = None else: slug = arguments.get("slug") symbol = arguments.get("symbol") try: data = await get_quotes(slug=slug, symbol=symbol) return [ types.TextContent( type="text", text=json.dumps(data, indent=2), ) ] except Exception as e: raise RuntimeError(f"Failed to fetch data: {e}")