Skip to main content
Glama

get-trades

Fetch recent trades for specific cryptocurrency trading pairs across exchanges using the CCXT MCP Server. Specify exchange, symbol, and limit to retrieve trade data efficiently.

Instructions

Get recent trades for a trading pair

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
exchangeYesExchange ID (e.g., binance, coinbase)
limitNoNumber of trades to fetch
symbolYesTrading pair symbol (e.g., BTC/USDT)

Implementation Reference

  • Executes the tool logic: fetches recent trades from the exchange using fetchTrades, with rate limiting via rateLimiter, caching via getCachedData, logging, and error handling.
    }, async ({ exchange, symbol, limit }) => { try { return await rateLimiter.execute(exchange, async () => { const ex = getExchange(exchange); const cacheKey = `trades:${exchange}:${symbol}:${limit}`; const trades = await getCachedData(cacheKey, async () => { log(LogLevel.INFO, `Fetching trades for ${symbol} on ${exchange}, limit: ${limit}`); return await ex.fetchTrades(symbol, undefined, limit); }); return { content: [{ type: "text", text: JSON.stringify(trades, null, 2) }] }; }); } catch (error) { log(LogLevel.ERROR, `Error fetching trades: ${error instanceof Error ? error.message : String(error)}`); return { content: [{ type: "text", text: `Error: ${error instanceof Error ? error.message : String(error)}` }], isError: true }; }
  • Zod input schema defining parameters: exchange (string), symbol (string), limit (number, optional, default 50).
    exchange: z.string().describe("Exchange ID (e.g., binance, coinbase)"), symbol: z.string().describe("Trading pair symbol (e.g., BTC/USDT)"), limit: z.number().optional().default(50).describe("Number of trades to fetch")
  • Registers the 'get-trades' tool on the MCP server with name, description, input schema, and inline handler function.
    server.tool("get-trades", "Get recent trades for a trading pair", { exchange: z.string().describe("Exchange ID (e.g., binance, coinbase)"), symbol: z.string().describe("Trading pair symbol (e.g., BTC/USDT)"), limit: z.number().optional().default(50).describe("Number of trades to fetch") }, async ({ exchange, symbol, limit }) => { try { return await rateLimiter.execute(exchange, async () => { const ex = getExchange(exchange); const cacheKey = `trades:${exchange}:${symbol}:${limit}`; const trades = await getCachedData(cacheKey, async () => { log(LogLevel.INFO, `Fetching trades for ${symbol} on ${exchange}, limit: ${limit}`); return await ex.fetchTrades(symbol, undefined, limit); }); return { content: [{ type: "text", text: JSON.stringify(trades, null, 2) }] }; }); } catch (error) { log(LogLevel.ERROR, `Error fetching trades: ${error instanceof Error ? error.message : String(error)}`); return { content: [{ type: "text", text: `Error: ${error instanceof Error ? error.message : String(error)}` }], isError: true }; } });

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