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
Input Schema
TableJSON 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 quotesasync 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 stringstypes.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 resultscase "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}")