Skip to main content
Glama
gtorreal
by gtorreal

compare_markets

Compare ticker data for any base currency across all Buda.com markets, showing side-by-side prices, changes, and volumes in CLP, COP, PEN, BTC, USDC, and ETH.

Instructions

Returns side-by-side ticker data for all trading pairs of a given base currency across Buda.com's supported quote currencies (CLP, COP, PEN, BTC, USDC, ETH). All prices are floats; price_change_24h and price_change_7d are floats in percent (e.g. 1.23 means +1.23%). Example: 'In which country is Bitcoin currently most expensive on Buda?'

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
base_currencyYesBase currency to compare across all available markets (e.g. 'BTC', 'ETH', 'XRP').

Implementation Reference

  • Main handler function that fetches all tickers, filters by base_currency, and returns side-by-side market comparison data (last price, bid/ask, volume, price changes).
    export async function handleCompareMarkets(
      args: { base_currency: string },
      client: BudaClient,
      cache: MemoryCache,
    ): Promise<{ content: Array<{ type: "text"; text: string }>; isError?: boolean }> {
      const { base_currency } = args;
    
      const currencyError = validateCurrency(base_currency);
      if (currencyError) {
        return {
          content: [{ type: "text", text: JSON.stringify({ error: currencyError, code: "INVALID_CURRENCY" }) }],
          isError: true,
        };
      }
    
      try {
        const base = base_currency.toUpperCase();
        const data = await cache.getOrFetch<AllTickersResponse>(
          "tickers:all",
          CACHE_TTL.TICKER,
          () => client.get<AllTickersResponse>("/tickers"),
        );
    
        const matching = data.tickers.filter((t) => {
          const [tickerBase] = t.market_id.split("-");
          return tickerBase === base;
        });
    
        if (matching.length === 0) {
          return {
            content: [
              {
                type: "text",
                text: JSON.stringify({
                  error: `No markets found for base currency '${base}'.`,
                  code: "NOT_FOUND",
                }),
              },
            ],
            isError: true,
          };
        }
    
        const result = {
          base_currency: base,
          markets: matching.map((t) => ({
            market_id: t.market_id,
            last_price: parseFloat(t.last_price[0]),
            last_price_currency: t.last_price[1],
            best_bid: t.max_bid ? parseFloat(t.max_bid[0]) : null,
            best_ask: t.min_ask ? parseFloat(t.min_ask[0]) : null,
            volume_24h: t.volume ? parseFloat(t.volume[0]) : null,
            price_change_24h: t.price_variation_24h
              ? parseFloat((parseFloat(t.price_variation_24h) * 100).toFixed(4))
              : null,
            price_change_7d: t.price_variation_7d
              ? parseFloat((parseFloat(t.price_variation_7d) * 100).toFixed(4))
              : null,
          })),
        };
    
        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,
        };
      }
    }
  • Schema definition for the compare_markets tool, including name, description, and input schema with required base_currency parameter.
    export const toolSchema = {
      name: "compare_markets",
      description:
        "Returns side-by-side ticker data for all trading pairs of a given base currency across Buda.com's " +
        "supported quote currencies (CLP, COP, PEN, BTC, USDC, ETH). All prices are floats; " +
        "price_change_24h and price_change_7d are floats in percent (e.g. 1.23 means +1.23%). " +
        "Example: 'In which country is Bitcoin currently most expensive on Buda?'",
      inputSchema: {
        type: "object" as const,
        properties: {
          base_currency: {
            type: "string",
            description:
              "Base currency to compare across all available markets (e.g. 'BTC', 'ETH', 'XRP').",
          },
        },
        required: ["base_currency"],
      },
    };
  • Registration function that calls server.tool() to register compare_markets with the MCP server, using zod validation for the base_currency parameter.
    export function register(server: McpServer, client: BudaClient, cache: MemoryCache): void {
      server.tool(
        toolSchema.name,
        toolSchema.description,
        {
          base_currency: z
            .string()
            .describe(
              "Base currency to compare across all available markets (e.g. 'BTC', 'ETH', 'XRP').",
            ),
        },
        (args) => handleCompareMarkets(args, client, cache),
      );
    }
  • src/http.ts:87-87 (registration)
    Registration call in the HTTP server entry point.
    compareMarkets.register(server, client, reqCache);
  • src/index.ts:42-42 (registration)
    Registration call in the stdio server entry point.
    compareMarkets.register(server, client, cache);
Behavior4/5

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

With no annotations, the description explains return types (floats, percentages). No mention of authentication or rate limits, but for a read operation it is sufficiently transparent.

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?

Three sentences: function, data format, example. No superfluous text, front-loaded with key information.

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?

Given no output schema, description explains return types and gives an example. Could be slightly more explicit about the structure of the 'side-by-side' data, but largely complete for a simple tool.

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

Parameters5/5

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

Schema already describes the parameter well (100% coverage). Description adds context by listing supported quote currencies and providing an example, adding meaning beyond the schema.

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?

Clearly states that it returns side-by-side ticker data for a base currency across supported quote currencies. Distinguishes from siblings like get_ticker or get_markets by focusing on cross-market comparison.

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

Usage Guidelines4/5

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

Provides an example question that guides when to use. Does not explicitly exclude alternatives or mention when not to use, but the purpose is well-defined.

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