Skip to main content
Glama

exchangeAssets

Retrieve detailed asset and token holdings of an exchange using CoinMarketCap MCP's API. Ideal for tracking cryptocurrency exchange inventories and managing blockchain data.

Instructions

Returns the assets/token holdings of an exchange.

Input Schema

NameRequiredDescriptionDefault
idNo
slugNo

Input Schema (JSON Schema)

{ "$schema": "http://json-schema.org/draft-07/schema#", "additionalProperties": false, "properties": { "id": { "type": "string" }, "slug": { "type": "string" } }, "type": "object" }

Implementation Reference

  • Inline handler function for the 'exchangeAssets' tool. It uses handleEndpoint to wrap a call to makeApiRequest on the CoinMarketCap '/v1/exchange/assets' endpoint specific to the tool, followed by formatting the response.
    async (params) => { return handleEndpoint(async () => { const data = await makeApiRequest(apiKey, '/v1/exchange/assets', params) return formatResponse(data) }) }
  • Zod input schema defining optional 'id' or 'slug' parameters for specifying the exchange.
    { id: z.string().optional(), slug: z.string().optional() },
  • index.js:439-451 (registration)
    Registration of the 'exchangeAssets' MCP tool using server.tool(), including description, Zod schema, and inline handler function.
    server.tool("exchangeAssets", "Returns the assets/token holdings of an exchange.", { id: z.string().optional(), slug: z.string().optional() }, async (params) => { return handleEndpoint(async () => { const data = await makeApiRequest(apiKey, '/v1/exchange/assets', params) return formatResponse(data) }) } )
  • Shared helper function that constructs and executes the HTTP request to CoinMarketCap Pro API endpoints, used by all tools including exchangeAssets.
    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() }
  • Shared wrapper helper for handling API calls and errors, used in the exchangeAssets handler.
    async function handleEndpoint(apiCall) { try { return await apiCall() } catch (error) { return formatErrorResponse(error.message, error.status || 403) } }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/shinzo-labs/coinmarketcap-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server