Skip to main content
Glama
dan1d

dolar-mcp

convert

Convert Argentine pesos to any currency or dollar type, or vice versa, using real-time exchange rates. Choose between buy or sell rates for accurate conversion.

Instructions

Convert an amount between ARS and any currency or dollar type. At least one side must be ARS.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
amountYesAmount to convert
fromYesSource currency/dollar type (e.g. USD, blue, EUR, ARS)
toNoTarget currency (default: ARS)
use_buyNoUse buy rate instead of sell rate (default: false)

Implementation Reference

  • The main convert function that handles currency conversion logic between ARS and any dollar type or foreign currency. It fetches the appropriate rate from the DolarApi API, then either divides (ARS -> other) or multiplies (other -> ARS) the amount.
    export async function convert(
      client: DolarApiClient,
      params: ConvertParams
    ): Promise<unknown> {
      const fromUpper = params.from.toUpperCase();
      const toUpper = (params.to ?? "ARS").toUpperCase();
    
      // Determine which rate to fetch
      let rate: number;
    
      if (fromUpper === "ARS" || toUpper === "ARS") {
        // One side is ARS — fetch the other side's rate
        const nonArs = fromUpper === "ARS" ? toUpper : fromUpper;
    
        // Check if it's a dollar type (blue, oficial, etc.) or a currency (EUR, BRL)
        const dollarTypes = ["blue", "oficial", "bolsa", "contadoconliqui", "cripto", "mayorista", "tarjeta"];
        const isDollarType = dollarTypes.includes(nonArs.toLowerCase());
    
        if (isDollarType) {
          const data = await client.get<DollarRate>(`/v1/dolares/${nonArs.toLowerCase()}`);
          rate = params.use_buy ? data.compra : data.venta;
        } else {
          const data = await client.get<CurrencyRate>(`/v1/cotizaciones/${nonArs}`);
          rate = params.use_buy ? data.compra : data.venta;
        }
    
        // Convert
        if (fromUpper === "ARS") {
          // ARS → other: divide by rate
          return {
            from: fromUpper,
            to: nonArs,
            rate,
            amount: params.amount,
            converted: Number((params.amount / rate).toFixed(2)),
          };
        } else {
          // other → ARS: multiply by rate
          return {
            from: nonArs,
            to: "ARS",
            rate,
            amount: params.amount,
            converted: Number((params.amount * rate).toFixed(2)),
          };
        }
      }
    
      throw new Error("At least one side of the conversion must be ARS. Use 'from' or 'to' as ARS.");
    }
  • TypeScript interface ConvertParams defining the input shape: amount (number), from (string), optional to (string, default ARS), and optional use_buy (boolean).
    export interface ConvertParams {
      amount: number;
      from: string;
      to?: string;
      use_buy?: boolean;
    }
  • MCP server tool registration for 'convert' using server.tool(), with Zod schema definitions for parameters and a handler that calls tools.convert().
    server.tool(
      "convert",
      "Convert an amount between ARS and any currency or dollar type. At least one side must be ARS.",
      {
        amount: z.number().describe("Amount to convert"),
        from: z.string().describe("Source currency/dollar type (e.g. USD, blue, EUR, ARS)"),
        to: z.string().optional().describe("Target currency (default: ARS)"),
        use_buy: z.boolean().optional().describe("Use buy rate instead of sell rate (default: false)"),
      },
      async (params) => {
        try {
          const result = await tools.convert(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 };
        }
      },
    );
  • The 'convert' tool is wired up in the createDolarTools() factory function, wrapping the action with the client instance.
    convert: (params: ConvertParams) => convert(client, params),
Behavior2/5

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

No annotations are provided, and the description does not disclose any behavioral traits such as idempotence, rate limits, error handling, or side effects. This is a significant gap for a conversion tool.

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 with two sentences, front-loading the core purpose and constraint. No unnecessary information is included.

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

Completeness3/5

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

The tool has 4 parameters, no output schema, and no annotations. The description does not mention return values, error conditions, or supported currency types beyond examples in the schema. While functional, it leaves gaps in completeness.

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 input schema has full description coverage (100%), so the description adds minimal extra meaning beyond the constraint 'at least one side must be ARS'. This meets the baseline for high schema coverage.

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 the tool's purpose: converting an amount between ARS and other currencies/dollar types. It specifies that at least one side must be ARS, which distinguishes it from sibling tools that retrieve currency data without conversion.

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 provides a clear constraint (at least one side must be ARS) but does not explicitly guide when to use this tool over alternatives. However, siblings are query tools, so the conversion purpose is inherently distinct.

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

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