Skip to main content
Glama

finance_forex_rate

Retrieve current exchange rates between currencies to calculate conversion amounts for financial planning or transactions.

Instructions

Get current exchange rate between two currencies

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
fromNoSource currency codeUSD
toNoTarget currency codeBRL
amountNoAmount to convert

Implementation Reference

  • Implementation of the finance_forex_rate tool handler and schema.
    server.tool("finance_forex_rate", "Get current exchange rate between two currencies", {
      from: z.string().default("USD").describe("Source currency code"),
      to: z.string().default("BRL").describe("Target currency code"),
      amount: z.number().default(1).describe("Amount to convert")
    }, async ({ from, to, amount }) => {
      try {
        const data = await safeFetch(`https://api.exchangerate-api.com/v4/latest/${from.toUpperCase()}`);
        const rate = data.rates[to.toUpperCase()];
        if (!rate) return { content: [{ type: "text", text: `Currency "${to}" not found` }] };
        return { content: [{ type: "text", text: `**${from.toUpperCase()} → ${to.toUpperCase()}**\nRate: 1 ${from} = ${rate.toFixed(4)} ${to}\nAmount: ${amount} ${from} = ${(amount * rate).toFixed(2)} ${to}\nUpdated: ${data.date}` }] };
      } catch {
        return { content: [{ type: "text", text: `Could not fetch rate for ${from}/${to}` }] };
      }
    });

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/ElromEvedElElyon/claw-mcp-toolkit'

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