cmc100IndexLatest
Obtain the current CoinMarketCap 100 Index value, constituents, and their weights.
Instructions
Returns the lastest CoinMarketCap 100 Index value, constituents, and constituent weights.
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": "cmc100IndexLatest"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- index.js:519-529 (registration)The tool 'cmc100IndexLatest' is registered via server.tool() with the description 'Returns the lastest CoinMarketCap 100 Index value, constituents, and constituent weights.' and an empty schema object (no parameters).
// /index/quotes/latest server.tool("cmc100IndexLatest", "Returns the lastest CoinMarketCap 100 Index value, constituents, and constituent weights.", {}, async () => { return handleEndpoint(async () => { const data = await makeApiRequest(apiKey, '/v3/index/cmc100-latest') return formatResponse(data) }) } ) - index.js:523-528 (handler)The handler function calls handleEndpoint which wraps an API request to '/v3/index/cmc100-latest' via makeApiRequest, then formats the response with formatResponse.
async () => { return handleEndpoint(async () => { const data = await makeApiRequest(apiKey, '/v3/index/cmc100-latest') return formatResponse(data) }) } - index.js:82-88 (helper)handleEndpoint is a wrapper that executes the provided async API call and returns the result, catching errors and returning a formatted error response.
async function handleEndpoint(apiCall) { try { return await apiCall() } catch (error) { return formatErrorResponse(error.message, error.status || 403) } } - index.js:50-73 (helper)makeApiRequest is the helper that sends GET requests to the CoinMarketCap API using the provided endpoint and parameters, using the API key for authentication.
async function makeApiRequest(apiKey, endpoint, params = {}) { const queryParams = new URLSearchParams() Object.entries(params).forEach(([key, value]) => { if (value !== undefined) { queryParams.append(key, value.toString()) } }) const url = `https://pro-api.coinmarketcap.com${endpoint}${queryParams.toString() ? `?${queryParams.toString()}` : ''}` const response = await fetch(url, { method: 'GET', headers: { 'Accept': 'application/json', 'X-CMC_PRO_API_KEY': apiKey, } }) if (!response.ok) { throw new Error(`Error fetching data from CoinMarketCap: ${response.statusText}`) } return await response.json() } - index.js:30-37 (helper)formatResponse wraps the API data into the standard MCP text content format.
function formatResponse(data) { return { content: [{ type: "text", text: JSON.stringify(data) }] } }