Skip to main content
Glama
gtorreal
by gtorreal

get_spread

Retrieves best bid, best ask, absolute spread, and spread percentage from Buda.com to evaluate market liquidity before placing large orders. Assess whether a market is liquid enough to avoid significant slippage.

Instructions

Returns the best bid, best ask, absolute spread, and spread percentage for a Buda.com market. All prices are floats in the quote currency (e.g. CLP). spread_percentage is a float in percent (e.g. 0.15 means 0.15%). Use this to evaluate liquidity before placing a large order. Example: 'Is BTC-CLP liquid enough to buy 10M CLP without significant slippage?'

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
market_idYesMarket ID (e.g. 'BTC-CLP', 'ETH-BTC', 'BTC-COP').

Implementation Reference

  • The register() function defines the get_spread tool handler. It fetches ticker data via cache, extracts bid/ask from the ticker, computes spread_absolute and spread_percentage, and returns the result.
    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', 'BTC-COP')."),
        },
        async ({ market_id }) => {
          try {
            const validationError = validateMarketId(market_id);
            if (validationError) {
              return {
                content: [{ type: "text", text: JSON.stringify({ error: validationError, code: "INVALID_MARKET_ID" }) }],
                isError: true,
              };
            }
    
            const id = market_id.toLowerCase();
            const data = await cache.getOrFetch<TickerResponse>(
              `ticker:${id}`,
              CACHE_TTL.TICKER,
              () => client.get<TickerResponse>(`/markets/${id}/ticker`),
            );
    
            const ticker = data.ticker;
            const bid = parseFloat(ticker.max_bid[0]);
            const ask = parseFloat(ticker.min_ask[0]);
            const currency = ticker.max_bid[1];
    
            if (isNaN(bid) || isNaN(ask) || ask === 0) {
              return {
                content: [
                  {
                    type: "text",
                    text: JSON.stringify({ error: "Unable to calculate spread: invalid bid/ask values" }),
                  },
                ],
                isError: true,
              };
            }
    
            const spreadAbs = ask - bid;
            const spreadPct = (spreadAbs / ask) * 100;
    
            const result = {
              market_id: ticker.market_id,
              price_currency: currency,
              best_bid: bid,
              best_ask: ask,
              spread_absolute: parseFloat(spreadAbs.toFixed(2)),
              spread_percentage: parseFloat(spreadPct.toFixed(4)),
              last_price: parseFloat(ticker.last_price[0]),
            };
    
            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 toolSchema defines get_spread's name, description, and inputSchema (requires market_id string).
    export const toolSchema = {
      name: "get_spread",
      description:
        "Returns the best bid, best ask, absolute spread, and spread percentage for a Buda.com market. " +
        "All prices are floats in the quote currency (e.g. CLP). spread_percentage is a float in percent " +
        "(e.g. 0.15 means 0.15%). Use this to evaluate liquidity before placing a large order. " +
        "Example: 'Is BTC-CLP liquid enough to buy 10M CLP without significant slippage?'",
      inputSchema: {
        type: "object" as const,
        properties: {
          market_id: {
            type: "string",
            description: "Market ID (e.g. 'BTC-CLP', 'ETH-BTC', 'BTC-COP').",
          },
        },
        required: ["market_id"],
      },
    };
  • src/index.ts:41-41 (registration)
    Tool is registered in the main stdio entry point via spread.register(server, client, cache).
    spread.register(server, client, cache);
  • src/http.ts:86-86 (registration)
    Tool is also registered in the HTTP entry point via spread.register(server, client, reqCache).
    spread.register(server, client, reqCache);
  • liquidityBadge() returns an emoji badge (✅/🟡/🔴) based on spread percentage — used by output formatters.
    export function liquidityBadge(spreadPct: number): string {
      if (spreadPct < 0.5) return "✅";
      if (spreadPct < 2.0) return "🟡";
      return "🔴";
    }
Behavior4/5

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

With no annotations, the description carries full weight. It explains return fields (best bid, ask, spread percentage) and their types (floats, percent). It does not mention permissions or data freshness, but for a read-only data fetch, this is sufficient. No destructive behavior implied.

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 three sentences plus an example, all front-loaded with what the tool returns, then usage guidance. Every sentence adds value with no redundancy.

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

Completeness5/5

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

For a simple tool with one parameter and no annotations or output schema, the description covers return values, units, and use case. It is fully adequate for an agent to understand and invoke correctly.

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

Parameters4/5

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

The only parameter 'market_id' has 100% schema coverage. The description adds context beyond the schema by specifying that prices are in quote currency (e.g., CLP) and that spread_percentage is a float in percent. This clarifies the format and units.

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 best bid, best ask, spread, and spread percentage for a Buda.com market. It uses specific verbs ('Returns') and resource ('spread'), and differentiates from siblings like get_ticker or get_orderbook by focusing on liquidity evaluation.

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?

The description advises using the tool to evaluate liquidity before placing a large order and provides an example question. It implies when to use it but does not explicitly contrast with siblings like get_orderbook or get_market_summary. Still, context is clear enough.

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