Skip to main content
Glama
dan1d

mercadolibre-mcp

get_currency_conversion

Convert currency amounts between ARS, BRL, MXN, USD and other currencies using MercadoLibre exchange rates for financial calculations.

Instructions

Convert between currencies using MercadoLibre exchange rates (ARS, BRL, MXN, USD, etc.).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
fromYesSource currency code (e.g. USD)
toYesTarget currency code (e.g. ARS)
amountNoAmount to convert (default: 1)

Implementation Reference

  • The getCurrencyConversion function that executes the currency conversion logic by calling the MercadoLibre API and calculating the converted amount
    export async function getCurrencyConversion(
      client: MercadoLibreClient,
      params: GetCurrencyConversionParams
    ): Promise<unknown> {
      const result = await client.get<{ ratio: number }>(
        `/currency_conversions/search`,
        { from: params.from, to: params.to }
      );
      const amount = params.amount ?? 1;
      return {
        from: params.from,
        to: params.to,
        rate: result.ratio,
        amount,
        converted: Number((amount * result.ratio).toFixed(4)),
      };
    }
  • TypeScript interface defining the input parameters for currency conversion (from, to, and optional amount)
    export interface GetCurrencyConversionParams {
      from: string;
      to: string;
      amount?: number;
    }
  • MCP server tool registration for get_currency_conversion with Zod schema validation and error handling
    server.tool(
      "get_currency_conversion",
      "Convert between currencies using MercadoLibre exchange rates (ARS, BRL, MXN, USD, etc.).",
      {
        from: z.string().describe("Source currency code (e.g. USD)"),
        to: z.string().describe("Target currency code (e.g. ARS)"),
        amount: z.number().optional().describe("Amount to convert (default: 1)"),
      },
      async (params) => {
        try {
          const result = await tools.get_currency_conversion(params);
          return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
        } catch (error) {
          const message = error instanceof Error ? error.message : String(error);
          return { content: [{ type: "text", text: message }], isError: true };
        }
      },
    );
  • src/index.ts:35-35 (registration)
    Tool export mapping get_currency_conversion to the getCurrencyConversion handler function
    get_currency_conversion: (params: GetCurrencyConversionParams) => getCurrencyConversion(client, params),

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/dan1d/mercadolibre-mcp'

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