Skip to main content
Glama
lcfranca

Frankfurter Forex MCP

by lcfranca

exchange_history

Retrieve historical exchange rate data for currency pairs over specified date ranges to analyze trends and track currency performance.

Instructions

Get an exchange-rate time series for a currency pair and date interval.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
startYes
endYes
from_currencyYes
to_currencyYes

Implementation Reference

  • The core execute function that implements the exchange_history tool logic. It fetches historical exchange rate data from the Frankfurter API, processes the response, and returns a structured HistoryOutput with date-rate pairs.
    async def execute(input_data: HistoryInput, client: FrankfurterClient) -> HistoryOutput:
        payload = await client.history(
            start_date=input_data.start_date.isoformat(),
            end_date=input_data.end_date.isoformat(),
            source_currency=input_data.from_currency,
            destination_currency=input_data.to_currency,
        )
        payload_rates = payload.get("rates", {})
        if not isinstance(payload_rates, dict):
            raise FrankfurterClientError("Frankfurter API returned malformed history payload")
    
        points: list[HistoryPoint] = []
        for point_date in sorted(payload_rates.keys()):
            point_rates = payload_rates[point_date]
            if not isinstance(point_rates, dict):
                raise FrankfurterClientError("Frankfurter API returned malformed history point")
            rate_value = point_rates.get(input_data.to_currency)
            if rate_value is None:
                continue
            points.append(HistoryPoint(date=point_date, rate=float(rate_value)))
    
        return HistoryOutput(
            from_currency=input_data.from_currency,
            to_currency=input_data.to_currency,
            start_date=input_data.start_date,
            end_date=input_data.end_date,
            points=points,
            total=len(points),
        )
  • Schema definitions for exchange_history tool: HistoryInput (input validation with date range and currency codes), HistoryPoint (individual date-rate data), and HistoryOutput (structured response with metadata and points list).
    class HistoryInput(BaseModel):
        model_config = ConfigDict(populate_by_name=True, str_strip_whitespace=True)
    
        start_date: date = Field(alias="start")
        end_date: date = Field(alias="end")
        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
    
        @model_validator(mode="after")
        def validate_range(self) -> HistoryInput:
            if self.end_date < self.start_date:
                raise ValueError("end date must be on or after start date")
            return self
    
    
    class HistoryPoint(BaseModel):
        date: date
        rate: float
    
    
    class HistoryOutput(BaseModel):
        from_currency: str
        to_currency: str
        start_date: date
        end_date: date
        points: list[HistoryPoint]
        total: int
  • MCP tool registration for exchange_history. The @mcp.tool decorator registers exchange_history_tool which validates input, calls the execute handler, and handles validation/upstream/internal errors with appropriate error responses.
    @mcp.tool(name="exchange_history")
    async def exchange_history_tool(start: str, end: str, from_currency: str, to_currency: str) -> dict:
        """Get an exchange-rate time series for a currency pair and date interval."""
        try:
            input_data = HistoryInput(
                start=start,
                end=end,
                from_currency=from_currency,
                to_currency=to_currency,
            )
            async with FrankfurterClient.from_env() as client:
                output = await exchange_history.execute(input_data, client)
            return output.model_dump(mode="json")
        except ValidationError as exc:
            return _to_error(str(exc), tool="exchange_history", error_code="validation_error")
        except FrankfurterClientError as exc:
            return _to_error(str(exc), tool="exchange_history", error_code="upstream_error")
        except Exception:
            return _to_error(
                "Unexpected internal error",
                tool="exchange_history",
                error_code="internal_error",
            )
  • Helper function _to_error that standardizes error responses across all tools by wrapping error messages in an ErrorResponse schema with tool name, error code, and trace ID.
    def _to_error(message: str, *, tool: str, error_code: str) -> dict:
        payload = ErrorResponse(message=message).model_dump(mode="json")
        payload["tool"] = tool
        payload["error_code"] = error_code
        payload["trace_id"] = str(uuid.uuid4())
        return payload
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the tool retrieves data ('Get'), implying a read-only operation, but doesn't mention any behavioral traits such as rate limits, authentication needs, data freshness, error conditions, or response format. This is inadequate for a tool with 4 parameters and no output schema.

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, well-structured sentence that efficiently conveys the core purpose without any wasted words. It's front-loaded with the main action and resource, making it easy to parse quickly.

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 (4 parameters, no annotations, no output schema), the description is incomplete. It lacks details on parameter usage, behavioral context, output format, and differentiation from siblings. This leaves significant gaps for an agent to understand how to invoke the tool effectively.

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?

The schema description coverage is 0%, so the description must compensate. It mentions 'currency pair and date interval', which hints at parameters like 'from_currency', 'to_currency', 'start', and 'end', but doesn't explain their semantics, formats (e.g., date strings like YYYY-MM-DD), or constraints. This adds minimal value beyond the bare parameter names in the schema.

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 ('Get') and resource ('exchange-rate time series'), specifying the target data (currency pair and date interval). It distinguishes from sibling tools like 'base_quote' and 'convert_currency' by focusing on historical time-series data rather than current rates or conversions. However, it doesn't explicitly contrast with siblings, so it's not a perfect 5.

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 like 'base_quote' or 'convert_currency'. It mentions the data type (time series) but doesn't specify use cases, prerequisites, or exclusions. This leaves the agent with minimal context for tool selection.

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