get_currency_listings
Fetch up-to-date cryptocurrency listings from the Coinmarket API. Use this tool to retrieve comprehensive data on available digital currencies for analysis or integration.
Instructions
Get latest cryptocurrency listings
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/coinmarket_service/server.py:19-34 (handler)Core handler function that fetches the latest cryptocurrency listings from the CoinMarketCap API, limited to 5 entries in USD.
async def get_currency_listings() -> dict[str, Any]: url = 'https://pro-api.coinmarketcap.com/v1/cryptocurrency/listings/latest' parameters = { 'start':'1', 'limit':'5', 'convert':'USD' } 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 - src/coinmarket_service/server.py:110-118 (registration)Registration of the 'get_currency_listings' tool in the list_tools handler, including name, description, and empty input schema.
types.Tool( name="get_currency_listings", description="Get latest cryptocurrency listings", inputSchema={ "type": "object", "properties": {}, "required": [], }, ), - src/coinmarket_service/server.py:143-153 (handler)Tool execution handler within @server.call_tool() that invokes get_currency_listings and returns the JSON-formatted result as TextContent.
case "get_currency_listings": try: data = await get_currency_listings() return [ types.TextContent( type="text", text=json.dumps(data, indent=2), ) ] except Exception as e: raise RuntimeError(f"Failed to fetch data: {e}") - Input schema definition for the get_currency_listings tool: an empty object with no required properties.
inputSchema={ "type": "object", "properties": {}, "required": [], },