get_latest_usd_mxn_rate
Retrieve the current USD to MXN exchange rate from Mexico's central bank (Banxico) with the date of the rate.
Instructions
Get the latest USD/MXN exchange rate from Banxico.
Returns: The most recent USD/MXN exchange rate with date
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- banxico_mcp_server.py:323-340 (handler)The handler function decorated with @mcp.tool() that implements the get_latest_usd_mxn_rate tool. It checks for the API token, fetches timely USD/MXN exchange rate data from Banxico's SIE API using the endpoint 'series/SF63528/datos/oportuno', handles errors, and formats the response using format_exchange_rate_data.async def get_latest_usd_mxn_rate() -> str: """ Get the latest USD/MXN exchange rate from Banxico. Returns: The most recent USD/MXN exchange rate with date """ if not BANXICO_TOKEN: return "Error: BANXICO_API_TOKEN environment variable not set. Please configure your API token." endpoint = "series/SF63528/datos/oportuno" data = await make_banxico_request(endpoint, BANXICO_TOKEN) if not data: return "Failed to retrieve exchange rate data. Please check your API token and network connection." return format_exchange_rate_data(data)