Skip to main content
Glama
gtorreal
by gtorreal

get_trades

Retrieve recent trade history for any Buda.com market, including timestamp, amount, price, and direction (buy or sell).

Instructions

Returns recent trade history for a Buda.com market as typed objects. Each entry has timestamp_ms (integer), amount (float, base currency), price (float, quote currency), and direction ('buy' or 'sell'). Example: 'What was the last executed price for BTC-CLP and was it a buy or sell?'

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
market_idYesMarket ID (e.g. 'BTC-CLP', 'ETH-BTC').
limitNoNumber of trades to return (default: 50, max: 100).
timestampNoUnix timestamp (seconds) to paginate from. Returns trades older than this timestamp.

Implementation Reference

  • The async handler function that executes the get_trades tool logic: validates market_id, builds request params, calls the Buda API /markets/{market_id}/trades endpoint, maps the response entries (timestamp_ms, amount, price, direction), and returns the result.
    async ({ market_id, limit, timestamp }) => {
      try {
        const validationError = validateMarketId(market_id);
        if (validationError) {
          return {
            content: [{ type: "text", text: JSON.stringify({ error: validationError, code: "INVALID_MARKET_ID" }) }],
            isError: true,
          };
        }
    
        const params: Record<string, string | number> = {};
        if (limit !== undefined) params.limit = limit;
        if (timestamp !== undefined) params.timestamp = timestamp;
    
        const data = await client.get<TradesResponse>(
          `/markets/${market_id.toLowerCase()}/trades`,
          Object.keys(params).length > 0 ? params : undefined,
        );
    
        const t = data.trades;
        const result = {
          timestamp: t.timestamp,
          last_timestamp: t.last_timestamp,
          market_id: t.market_id,
          entries: t.entries.map(([tsMs, amount, price, direction]) => ({
            timestamp_ms: parseInt(tsMs, 10),
            amount: parseFloat(amount),
            price: parseFloat(price),
            direction,
          })),
        };
    
        return {
          content: [{ type: "text", text: JSON.stringify(result, null, 2) }],
        };
      } catch (err) {
        const msg = formatApiError(err);
        return {
          content: [{ type: "text", text: JSON.stringify(msg) }],
          isError: true,
        };
      }
    },
  • The JSON schema and Zod definitions for the get_trades tool, defining input parameters: market_id (required string), limit (optional number, 1-100), and timestamp (optional number, Unix seconds).
    export const toolSchema = {
      name: "get_trades",
      description:
        "Returns recent trade history for a Buda.com market as typed objects. Each entry has " +
        "timestamp_ms (integer), amount (float, base currency), price (float, quote currency), " +
        "and direction ('buy' or 'sell'). " +
        "Example: 'What was the last executed price for BTC-CLP and was it a buy or sell?'",
      inputSchema: {
        type: "object" as const,
        properties: {
          market_id: {
            type: "string",
            description: "Market ID (e.g. 'BTC-CLP', 'ETH-BTC').",
          },
          limit: {
            type: "number",
            description: "Number of trades to return (default: 50, max: 100).",
          },
          timestamp: {
            type: "number",
            description:
              "Unix timestamp (seconds) to paginate from. Returns trades older than this timestamp.",
          },
        },
        required: ["market_id"],
      },
    };
  • src/index.ts:39-39 (registration)
    Registration of the get_trades tool: calls trades.register(server, client, cache) to wire the tool into the MCP server.
    trades.register(server, client, cache);
  • The register() function that calls server.tool() with the schema and handler, registering get_trades on the MCP server.
    export function register(server: McpServer, client: BudaClient, _cache: MemoryCache): void {
      server.tool(
        toolSchema.name,
        toolSchema.description,
        {
          market_id: z
            .string()
            .describe("Market ID (e.g. 'BTC-CLP', 'ETH-BTC')."),
          limit: z
            .number()
            .int()
            .min(1)
            .max(100)
            .optional()
            .describe("Number of trades to return (default: 50, max: 100)."),
          timestamp: z
            .number()
            .int()
            .optional()
            .describe(
              "Unix timestamp (seconds) to paginate from. Returns trades older than this timestamp.",
            ),
        },
        async ({ market_id, limit, timestamp }) => {
          try {
            const validationError = validateMarketId(market_id);
            if (validationError) {
              return {
                content: [{ type: "text", text: JSON.stringify({ error: validationError, code: "INVALID_MARKET_ID" }) }],
                isError: true,
              };
            }
    
            const params: Record<string, string | number> = {};
            if (limit !== undefined) params.limit = limit;
            if (timestamp !== undefined) params.timestamp = timestamp;
    
            const data = await client.get<TradesResponse>(
              `/markets/${market_id.toLowerCase()}/trades`,
              Object.keys(params).length > 0 ? params : undefined,
            );
    
            const t = data.trades;
            const result = {
              timestamp: t.timestamp,
              last_timestamp: t.last_timestamp,
              market_id: t.market_id,
              entries: t.entries.map(([tsMs, amount, price, direction]) => ({
                timestamp_ms: parseInt(tsMs, 10),
                amount: parseFloat(amount),
                price: parseFloat(price),
                direction,
              })),
            };
    
            return {
              content: [{ type: "text", text: JSON.stringify(result, null, 2) }],
            };
          } catch (err) {
            const msg = formatApiError(err);
            return {
              content: [{ type: "text", text: JSON.stringify(msg) }],
              isError: true,
            };
          }
        },
      );
    }
  • Type definitions: Trades interface (timestamp, last_timestamp, market_id, entries tuple) and TradesResponse wrapper interface used by the handler.
    export interface Trades {
      timestamp: string;
      last_timestamp: string;
      market_id: string;
      /** Each entry: [timestamp_ms, amount, price, direction] */
      entries: [string, string, string, string][];
    }
    
    export interface TradesResponse {
      trades: Trades;
    }
Behavior2/5

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

No annotations are provided, so the description carries the full burden. It describes the output fields but does not disclose behavioral traits such as data freshness, rate limits, authentication requirements, or pagination behavior (timestamp parameter is not fully explained). The term 'recent' is vague.

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?

Two sentences plus an example, with no wasted words. The purpose and output structure are front-loaded. The example is practical and adds value without redundancy.

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

Completeness4/5

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

For a simple list tool with no output schema, the description covers the key return fields and provides a concrete example. It lacks details on error handling, edge cases (e.g., empty trades), or pagination behavior, but is sufficient for typical use.

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?

Schema coverage is 100%, so baseline is 3. The description does not add significant meaning beyond the schema's parameter descriptions. The example illustrates usage but does not elaborate on parameter constraints or formats.

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

Purpose5/5

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

The description clearly states it returns 'recent trade history for a Buda.com market as typed objects' and specifies the exact fields (timestamp_ms, amount, price, direction). This distinguishes it from siblings like get_ticker or get_market_summary.

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

Usage Guidelines3/5

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

The description implies usage for retrieving trade history but provides no explicit guidance on when to use this tool versus alternatives like get_ticker or get_price_history. No exclusions or when-not-to-use scenarios are given.

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

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/gtorreal/buda-mcp'

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