keyInfo
Check API key status and usage statistics to manage your account permissions and monitor request counts.
Instructions
Returns API key details and usage stats.
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": "keyInfo"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- index.js:607-616 (registration)Registration of the 'keyInfo' tool with the MCP server, including its description and schema (no inputs needed). The handler is inline.
server.tool("keyInfo", "Returns API key details and usage stats.", {}, async () => { return handleEndpoint(async () => { const data = await makeApiRequest(apiKey, '/v1/key/info') return formatResponse(data) }) } ) - index.js:610-615 (handler)Handler function for keyInfo: makes a GET request to /v1/key/info and formats the response.
async () => { return handleEndpoint(async () => { const data = await makeApiRequest(apiKey, '/v1/key/info') return formatResponse(data) }) } - index.js:608-609 (schema)Schema for keyInfo: description string and empty input schema (no parameters).
"Returns API key details and usage stats.", {}, - index.js:82-88 (helper)Wrapper function that catches errors from endpoint handlers and formats error responses.
async function handleEndpoint(apiCall) { try { return await apiCall() } catch (error) { return formatErrorResponse(error.message, error.status || 403) } } - index.js:50-72 (helper)Helper that makes authenticated GET requests to the CoinMarketCap Pro API.
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()