Skip to main content
Glama
cfocoder

Banxico MCP Server

get_unemployment_data

Retrieve current and historical unemployment rate data from Banxico. Specify a limit to fetch recent data points, defaulting to 24 (2 years of monthly data).

Instructions

Get unemployment rate data from Banxico.

Args: limit: Maximum number of recent data points (default: 24 for 2 years of monthly data)

Returns: Current and historical unemployment rate data

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
limitNo

Implementation Reference

  • The handler function for the 'get_unemployment_data' tool. It fetches unemployment data from Banxico SIE API using series ID 'SL1', handles optional limit on recent data points, and formats the response using a helper function. Registered via @mcp.tool() decorator.
    @mcp.tool() async def get_unemployment_data(limit: Optional[int] = 24) -> str: """ Get unemployment rate data from Banxico. Args: limit: Maximum number of recent data points (default: 24 for 2 years of monthly data) Returns: Current and historical unemployment rate data """ if not BANXICO_TOKEN: return "Error: BANXICO_API_TOKEN environment variable not set. Please configure your API token." endpoint = "series/SL1/datos" data = await make_banxico_request(endpoint, BANXICO_TOKEN) if not data: return "Failed to retrieve unemployment 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_unemployment_data(data)
  • Supporting helper function specifically for formatting the unemployment data response from the Banxico API, adding percentage formatting, emojis, and displaying recent trends.
    def format_unemployment_data(data: dict[str, Any]) -> str: """ Format unemployment data with percentage symbols and labor market formatting. Args: data: Raw JSON response from Banxico API Returns: Formatted string with unemployment rate data """ if not data or "bmx" not in data: return "No unemployment data available" series_list = data["bmx"].get("series", []) if not series_list: return "No unemployment series found" result = [] for series in series_list: title = series.get("titulo", "Unknown Series") series_id = series.get("idSerie", "Unknown ID") unit = series.get("unidad", "") result.append(f"👥 {title} (ID: {series_id})") if unit: result.append(f" Unit: {unit}") datos = series.get("datos", []) if not datos: result.append(" No data points available") else: result.append(f" Total data points: {len(datos)}") # Show recent data points with percentage formatting display_count = min(len(datos), 12) # Show more for unemployment trends for dato in datos[-display_count:]: fecha = dato.get("fecha", "Unknown date") valor = dato.get("dato", "N/A") # Add percentage symbol for unemployment rate if valor != "N/A" and valor is not None: try: valor_num = float(valor) valor = f"{valor_num}%" except (ValueError, TypeError): pass result.append(f" {fecha}: {valor}") result.append("") # Empty line between series return "\n".join(result)

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/cfocoder/banxico_mcp'

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