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
        };
      }
    });
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden for behavioral disclosure. It states 'Get recent trades' but doesn't specify what 'recent' means (time window), whether there are rate limits, authentication requirements, or what format the trades come in. For a data retrieval tool with zero annotation coverage, this leaves significant behavioral gaps.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is extremely concise at just 6 words, front-loading the essential information with zero wasted words. Every element ('Get', 'recent trades', 'for a trading pair') serves a clear purpose in communicating the tool's function.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a data retrieval tool with 3 parameters, no annotations, and no output schema, the description is insufficient. It doesn't explain what 'recent' means, what data format to expect, whether there are limitations or constraints, or how this differs from similar market data tools. The context signals indicate this tool needs more complete documentation.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The description doesn't add any parameter information beyond what's already in the schema (which has 100% coverage). It mentions 'trading pair' which aligns with the 'symbol' parameter, but provides no additional context about parameter interactions, constraints, or usage patterns. With complete schema coverage, the baseline score of 3 is appropriate.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Get recent trades') and resource ('for a trading pair'), making the purpose immediately understandable. However, it doesn't differentiate from potential sibling tools like 'get-ohlcv' or 'get-orderbook' that also retrieve market data, which prevents a perfect score.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives like 'get-ohlcv' for historical data or 'get-orderbook' for depth information. There's no mention of prerequisites, timing considerations, or specific use cases for trade data versus other market data tools.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Related Tools

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