get_udis_data
Retrieve current and historical UDIS (Investment Units) data from Banxico. Specify the number of recent data points to access accurate financial indicators for analysis or planning.
Instructions
Get UDIS (Investment Units) data from Banxico.
Args: limit: Maximum number of recent data points (default: 30)
Returns: Current and historical UDIS values
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No |
Implementation Reference
- banxico_mcp_server.py:483-509 (handler)The handler function for the 'get_udis_data' MCP tool. It is registered via the @mcp.tool() decorator. Fetches UDIS data from Banxico API endpoint for series SP68257, handles authentication with BANXICO_API_TOKEN, applies an optional limit to recent data points, and formats the output using format_exchange_rate_data.@mcp.tool() async def get_udis_data(limit: Optional[int] = 30) -> str: """ Get UDIS (Investment Units) data from Banxico. Args: limit: Maximum number of recent data points (default: 30) Returns: Current and historical UDIS values """ if not BANXICO_TOKEN: return "Error: BANXICO_API_TOKEN environment variable not set. Please configure your API token." endpoint = "series/SP68257/datos" data = await make_banxico_request(endpoint, BANXICO_TOKEN) if not data: return "Failed to retrieve UDIS data. Please check your API token and network connection." # Apply limit if specified if limit and data.get("bmx", {}).get("series"): for series in data["bmx"]["series"]: if "datos" in series and len(series["datos"]) > limit: series["datos"] = series["datos"][-limit:] return format_exchange_rate_data(data)