Skip to main content
Glama
guilhermelirio

Brasil API MCP

cambio-rate

Retrieve currency exchange rates for specific dates using Brazilian public data. Enter a currency symbol and date to get the corresponding rate.

Instructions

Get exchange rates for a specific currency on a specific date

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
currencyYesCurrency symbol (e.g., USD, EUR, GBP)
dateYesDate in YYYY-MM-DD format. For weekends and holidays, the returned date will be the last available business day.

Implementation Reference

  • The main execution logic for the 'cambio-rate' tool. Fetches exchange rate data from the Brasil API endpoint `/cambio/v1/cotacao/{currency}/{date}`, processes the response, formats quotations, and returns a structured text content response. Handles errors using formatErrorResponse.
        async ({ currency, date }) => {
          console.error(`Getting exchange rates for ${currency} on ${date}`);
          
          const result = await getBrasilApiData(`/cambio/v1/cotacao/${currency}/${date}`);
          
          if (!result.success) {
            return formatErrorResponse(`Error getting exchange rates: ${result.message}`);
          }
          
          // Format the response data
          const exchangeData = result.data;
          
          // Format the quotations
          const formattedQuotations = exchangeData.cotacoes.map((quotation: any) => 
            `Time: ${quotation.data_hora_cotacao} - Type: ${quotation.tipo_boletim}
      Buy Rate: ${quotation.cotacao_compra}
      Sell Rate: ${quotation.cotacao_venda}
      Buy Parity: ${quotation.paridade_compra}
      Sell Parity: ${quotation.paridade_venda}`
          ).join("\n\n");
          
          return {
            content: [{ 
              type: "text" as const, 
              text: `
    Exchange Rate Information:
    Currency: ${exchangeData.moeda}
    Date: ${exchangeData.data}
    
    Quotations:
    ${formattedQuotations}
    ` 
            }]
          };
        }
  • Input schema using Zod for validating the tool parameters: currency (string, e.g., USD) and date (string, YYYY-MM-DD format).
    {
      currency: z.string()
        .describe("Currency symbol (e.g., USD, EUR, GBP)"),
      date: z.string()
        .describe("Date in YYYY-MM-DD format. For weekends and holidays, the returned date will be the last available business day.")
    },
  • Direct registration of the 'cambio-rate' tool using McpServer.tool(), providing name, description, input schema, and handler function within registerCambioTools.
      server.tool(
        "cambio-rate",
        "Get exchange rates for a specific currency on a specific date",
        {
          currency: z.string()
            .describe("Currency symbol (e.g., USD, EUR, GBP)"),
          date: z.string()
            .describe("Date in YYYY-MM-DD format. For weekends and holidays, the returned date will be the last available business day.")
        },
        async ({ currency, date }) => {
          console.error(`Getting exchange rates for ${currency} on ${date}`);
          
          const result = await getBrasilApiData(`/cambio/v1/cotacao/${currency}/${date}`);
          
          if (!result.success) {
            return formatErrorResponse(`Error getting exchange rates: ${result.message}`);
          }
          
          // Format the response data
          const exchangeData = result.data;
          
          // Format the quotations
          const formattedQuotations = exchangeData.cotacoes.map((quotation: any) => 
            `Time: ${quotation.data_hora_cotacao} - Type: ${quotation.tipo_boletim}
      Buy Rate: ${quotation.cotacao_compra}
      Sell Rate: ${quotation.cotacao_venda}
      Buy Parity: ${quotation.paridade_compra}
      Sell Parity: ${quotation.paridade_venda}`
          ).join("\n\n");
          
          return {
            content: [{ 
              type: "text" as const, 
              text: `
    Exchange Rate Information:
    Currency: ${exchangeData.moeda}
    Date: ${exchangeData.data}
    
    Quotations:
    ${formattedQuotations}
    ` 
            }]
          };
        }
      );
  • src/index.ts:30-30 (registration)
    Top-level call to registerCambioTools on the main McpServer instance, which in turn registers the 'cambio-rate' tool.
    registerCambioTools(server);
  • Shared helper utility for making API requests to brasilapi.com.br, returning structured success/error responses. Used by the 'cambio-rate' handler to fetch data.
    export async function getBrasilApiData(endpoint: string, params: Record<string, any> = {}) {
      try {
        const url = `${BASE_URL}${endpoint}`;
        console.error(`Making request to: ${url}`);
        
        const response = await axios.get(url, { params });
        return { 
          data: response.data,
          success: true
        };
      } catch (error: any) {
        console.error(`Error in API request: ${error.message}`);
        
        // Handle API errors in a structured format
        if (error.response) {
          return {
            success: false,
            statusCode: error.response.status,
            message: error.response.data?.message || error.message,
            error: error.response.data
          };
        }
        
        return {
          success: false,
          message: error.message,
          error
        };
      }
    }
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. It states the basic function but lacks critical details: whether this requires authentication, rate limits, what happens with invalid inputs, the format/scope of returned rates (e.g., against a base currency), or weekend/holiday behavior (though the schema hints at this). For a data retrieval tool with zero annotation coverage, this is insufficient.

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 a single, efficient sentence with zero wasted words. It's front-loaded with the core purpose and appropriately sized for this straightforward tool.

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

Completeness2/5

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

Given the tool's moderate complexity (currency exchange data retrieval) and absence of both annotations and output schema, the description is incomplete. It doesn't explain what 'exchange rates' means (rates against what?), doesn't mention error conditions, and provides no information about the return format. The description should compensate for these gaps but doesn't.

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 description coverage is 100%, with both parameters clearly documented in the schema itself. The description adds no additional parameter semantics beyond what's already in the schema (currency symbol format, date format with weekend/holiday behavior). This meets the baseline expectation when schema does the heavy lifting.

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 specific action ('Get exchange rates'), target resource ('for a specific currency'), and temporal scope ('on a specific date'). It distinguishes this tool from all sibling tools, which handle banking, location, registration, and other data - none involve currency exchange rates.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives. While it's clearly the only currency rate tool among siblings, there's no mention of prerequisites, limitations, or comparison to hypothetical alternatives like historical rate trends or multi-currency lookups.

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/guilhermelirio/brasil-api-mcp'

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