Skip to main content
Glama

get-markets

Retrieve all available markets for a specified cryptocurrency exchange using the CCXT MCP Server. Input the exchange ID to fetch market data with optional pagination for efficient results.

Instructions

Get all available markets for an exchange

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
exchangeYesExchange ID (e.g., binance, coinbase)
pageNoPage number
pageSizeNoItems per page

Implementation Reference

  • Full tool registration including schema, handler logic for fetching, caching, and paginating exchange markets using ccxt-like exchange instance.
    server.tool("get-markets", "Get all available markets for an exchange", { exchange: z.string().describe("Exchange ID (e.g., binance, coinbase)"), page: z.number().optional().default(1).describe("Page number"), pageSize: z.number().optional().default(100).describe("Items per page") }, async ({ exchange, page, pageSize }) => { try { return await rateLimiter.execute(exchange, async () => { const ex = getExchange(exchange); const cacheKey = `markets:${exchange}`; const allMarkets = await getCachedData(cacheKey, async () => { log(LogLevel.INFO, `Fetching all markets for ${exchange}`); await ex.loadMarkets(); return Object.values(ex.markets); }, 3600000); // Cache for 1 hour // Simple pagination const start = (page - 1) * pageSize; const end = start + pageSize; const pagedMarkets = allMarkets.slice(start, end); return { content: [{ type: "text", text: JSON.stringify({ total: allMarkets.length, page, pageSize, data: pagedMarkets }, null, 2) }] }; }); } catch (error) { log(LogLevel.ERROR, `Error fetching markets: ${error instanceof Error ? error.message : String(error)}`); return { content: [{ type: "text", text: `Error: ${error instanceof Error ? error.message : String(error)}` }], isError: true }; } });
  • Zod schema for get-markets tool parameters: exchange (required string), page and pageSize (optional numbers with defaults).
    exchange: z.string().describe("Exchange ID (e.g., binance, coinbase)"), page: z.number().optional().default(1).describe("Page number"), pageSize: z.number().optional().default(100).describe("Items per page") }, async ({ exchange, page, pageSize }) => {
  • Registration of the 'get-markets' tool with server.tool, including name and description.
    server.tool("get-markets", "Get all available markets for an exchange", {

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/doggybee/mcp-server-ccxt'

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