Skip to main content
Glama
lcfranca

Frankfurter Forex MCP

by lcfranca

convert_currency

Convert monetary amounts between currencies using accurate exchange rates from the Frankfurter Forex MCP server. Enter amount, source currency, and target currency to get converted value.

Instructions

Convert a monetary amount from one currency to another.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
amountYes
from_currencyYes
to_currencyYes

Implementation Reference

  • The main handler function that executes the currency conversion logic. It calls the FrankfurterClient.convert method, validates the response payload, extracts the conversion rate, and returns a ConvertCurrencyOutput with the original amount, currencies, converted amount, and date.
    async def execute(
        input_data: ConvertCurrencyInput,
        client: FrankfurterClient,
    ) -> ConvertCurrencyOutput:
        payload = await client.convert(
            amount=float(input_data.amount),
            source_currency=input_data.from_currency,
            destination_currency=input_data.to_currency,
        )
        rates = payload.get("rates", {})
        payload_date = payload.get("date")
    
        if not isinstance(rates, dict):
            raise FrankfurterClientError("Frankfurter API returned malformed rates payload")
        if not isinstance(payload_date, str):
            raise FrankfurterClientError("Frankfurter API returned malformed date payload")
    
        converted_amount = rates.get(input_data.to_currency)
        if converted_amount is None:
            raise FrankfurterClientError(
                "Frankfurter API returned no conversion rate for target currency"
            )
    
        return ConvertCurrencyOutput(
            original_amount=float(input_data.amount),
            source_currency=input_data.from_currency,
            destination_currency=input_data.to_currency,
            converted_amount=float(converted_amount),
            date=date.fromisoformat(payload_date),
        )
  • Pydantic schema definitions for convert_currency. ConvertCurrencyInput (lines 54-67) validates amount (PositiveFloat), from_currency, and to_currency (3-letter ISO 4217 codes with normalization). ConvertCurrencyOutput (lines 70-75) defines the response structure with original_amount, source_currency, destination_currency, converted_amount, and date.
    class ConvertCurrencyInput(BaseModel):
        model_config = ConfigDict(populate_by_name=True, str_strip_whitespace=True)
    
        amount: PositiveFloat
        from_currency: str = Field(alias="from", min_length=3, max_length=3)
        to_currency: str = Field(alias="to", min_length=3, max_length=3)
    
        @field_validator("from_currency", "to_currency")
        @classmethod
        def normalize_currency(cls, value: str) -> str:
            value = _normalize_currency(value)
            if len(value) != 3 or not value.isalpha():
                raise ValueError("currency must be a 3-letter ISO 4217 code")
            return value
    
    
    class ConvertCurrencyOutput(BaseModel):
        original_amount: float
        source_currency: str
        destination_currency: str
        converted_amount: float
        date: date
  • The tool registration function decorated with @mcp.tool(name="convert_currency"). It creates a ConvertCurrencyInput from the raw parameters, creates a FrankfurterClient, calls convert_currency.execute, and handles ValidationError, FrankfurterClientError, and unexpected exceptions with appropriate error responses.
    @mcp.tool(name="convert_currency")
    async def convert_currency_tool(amount: float, from_currency: str, to_currency: str) -> dict:
        """Convert a monetary amount from one currency to another."""
        try:
            input_data = ConvertCurrencyInput(
                amount=amount,
                from_currency=from_currency,
                to_currency=to_currency,
            )
            async with FrankfurterClient.from_env() as client:
                output = await convert_currency.execute(input_data, client)
            return output.model_dump(mode="json")
        except ValidationError as exc:
            return _to_error(str(exc), tool="convert_currency", error_code="validation_error")
        except FrankfurterClientError as exc:
            return _to_error(str(exc), tool="convert_currency", error_code="upstream_error")
        except Exception:
            return _to_error(
                "Unexpected internal error",
                tool="convert_currency",
                error_code="internal_error",
            )
  • The FrankfurterClient.convert helper method that makes the actual HTTP request to the Frankfurter API's /latest endpoint with amount, from, and to parameters. It returns the JSON response payload containing the conversion rates and date.
    async def convert(
        self,
        amount: float,
        source_currency: str,
        destination_currency: str,
    ) -> dict[str, Any]:
        params = {
            "amount": amount,
            "from": source_currency,
            "to": destination_currency,
        }
        return await self._request_json("/latest", params=params)
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the tool converts currency but doesn't add any context about rate sources, accuracy, limitations, or potential errors. For a tool with no annotations, this leaves significant gaps in understanding its operational behavior.

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, clear sentence with zero waste. It's appropriately sized and front-loaded, efficiently conveying the core purpose without unnecessary details.

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 complexity (currency conversion with 3 parameters), no annotations, no output schema, and 0% schema coverage, the description is incomplete. It lacks details on behavior, parameters, and output, making it inadequate for reliable agent use without additional context.

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

Parameters2/5

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

Schema description coverage is 0%, so the schema provides no parameter descriptions. The description mentions 'monetary amount' and 'currencies' but doesn't elaborate on parameter meanings, formats (e.g., currency codes like USD), or constraints. It adds minimal value beyond the schema's structure.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/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 with a specific verb ('convert') and resource ('monetary amount from one currency to another'). It distinguishes the core function well, though it doesn't explicitly differentiate from sibling tools like 'base_quote' or 'exchange_history', which might offer related currency functions.

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. It doesn't mention sibling tools, prerequisites, or specific contexts for use, leaving the agent to infer usage based on the generic purpose alone.

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/lcfranca/frankfurter-forex-mcp'

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