Skip to main content
Glama

get-market-types

Identify supported market types for a specific cryptocurrency exchange using the CCXT MCP Server. Input the exchange ID to receive detailed market type information for seamless integration.

Instructions

Get market types supported by an exchange

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
exchangeYesExchange ID (e.g., binance, coinbase)

Implementation Reference

  • The handler function for the 'get-market-types' tool. It rate-limits the request, retrieves the exchange instance, determines supported market types by checking for leverage tiers, existing markets, and attempting to load future and swap markets, then returns a JSON string of the unique market types.
    }, async ({ exchange }) => { try { return await rateLimiter.execute(exchange, async () => { const ex = getExchange(exchange); // Get markets and group by contract type let marketTypes = ['spot']; // Spot is always available // Try to access exchange's market type property if available if (ex.has && ex.has.fetchMarketLeverageTiers) { marketTypes.push('future'); } // Some exchanges have specific markets property if (ex.markets) { const markets = Object.values(ex.markets); for (const market of markets) { const type = (market as any).type; if (type && !marketTypes.includes(type)) { marketTypes.push(type); } } } // Manually check for common market types try { const futureEx = getExchangeWithMarketType(exchange, 'future'); await futureEx.loadMarkets(); if (Object.keys(futureEx.markets).length > 0) { if (!marketTypes.includes('future')) marketTypes.push('future'); } } catch (e) { // Future markets not available } try { const swapEx = getExchangeWithMarketType(exchange, 'swap'); await swapEx.loadMarkets(); if (Object.keys(swapEx.markets).length > 0) { if (!marketTypes.includes('swap')) marketTypes.push('swap'); } } catch (e) { // Swap markets not available } return { content: [{ type: "text", text: JSON.stringify({ exchange, marketTypes: [...new Set(marketTypes)], // Remove duplicates }, null, 2) }] }; }); } catch (error) { log(LogLevel.ERROR, `Error fetching market types: ${error instanceof Error ? error.message : String(error)}`); return { content: [{ type: "text", text: `Error: ${error instanceof Error ? error.message : String(error)}` }], isError: true }; } });
  • Zod schema definition for the input parameter 'exchange' of the get-market-types tool.
    exchange: z.string().describe("Exchange ID (e.g., binance, coinbase)"),
  • Registration of the 'get-market-types' tool with server.tool, including description and linking to schema and inline handler.
    server.tool("get-market-types", "Get market types supported by 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