Skip to main content
Glama
cfocoder

Banxico MCP Server

get_series_metadata

Retrieve metadata for Bank of Mexico economic data series including title, description, and date range to understand data structure and availability.

Instructions

Get metadata for a Banxico series.

Args: series_id: The series ID to get metadata for (default: SF63528 for USD/MXN)

Returns: Series metadata including title, description, and date range

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
series_idNoSF63528

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The handler function for the get_series_metadata tool. Decorated with @mcp.tool() which registers it as an MCP tool. Fetches and formats metadata for the specified Banxico economic series.
    @mcp.tool()
    async def get_series_metadata(series_id: str = "SF63528") -> str:
        """
        Get metadata for a Banxico series.
        
        Args:
            series_id: The series ID to get metadata for (default: SF63528 for USD/MXN)
            
        Returns:
            Series metadata including title, description, and date range
        """
        if not BANXICO_TOKEN:
            return "Error: BANXICO_API_TOKEN environment variable not set. Please configure your API token."
        
        endpoint = f"series/{series_id}"
        data = await make_banxico_request(endpoint, BANXICO_TOKEN)
        
        if not data:
            return f"Failed to retrieve metadata for series {series_id}. Please check your API token and network connection."
        
        if "bmx" not in data or "series" not in data["bmx"]:
            return "No series metadata found"
        
        result = []
        for series in data["bmx"]["series"]:
            title = series.get("titulo", "Unknown title")
            series_id = series.get("idSerie", "Unknown ID")
            fecha_inicio = series.get("fechaInicio", "Unknown")
            fecha_fin = series.get("fechaFin", "Unknown")
            periodicidad = series.get("periodicidad", "Unknown")
            cifra = series.get("cifra", "Unknown")
            unidad = series.get("unidad", "Unknown")
            
            result.append(f"Series ID: {series_id}")
            result.append(f"Title: {title}")
            result.append(f"Start Date: {fecha_inicio}")
            result.append(f"End Date: {fecha_fin}")
            result.append(f"Frequency: {periodicidad}")
            result.append(f"Type: {cifra}")
            result.append(f"Unit: {unidad}")
            result.append("")
        
        return "\n".join(result)
  • Helper function used by get_series_metadata to make authenticated HTTP requests to the Banxico SIE API.
    async def make_banxico_request(endpoint: str, token: str) -> dict[str, Any] | None:
        """
        Make a request to the Banxico SIE API with proper error handling.
        
        Args:
            endpoint: The API endpoint to call (without base URL)
            token: The Banxico API token
            
        Returns:
            JSON response data or None if request failed
        """
        url = f"{BANXICO_API_BASE}/{endpoint}"
        headers = {"User-Agent": USER_AGENT}
        params = {"token": token}
        
        try:
            async with httpx.AsyncClient() as client:
                response = await client.get(url, headers=headers, params=params, timeout=30.0)
                response.raise_for_status()
                return response.json()
        except httpx.HTTPError as e:
            logger.error(f"HTTP error occurred: {e}")
            return None
        except Exception as e:
            logger.error(f"An error occurred: {e}")
            return None
  • The @mcp.tool() decorator registers the get_series_metadata function as an MCP tool.
    @mcp.tool()
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. It states this is a 'Get' operation but doesn't mention whether it requires authentication, has rate limits, returns errors for invalid series IDs, or has any side effects. The return format is mentioned but without details about structure or potential null values.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is appropriately sized with clear sections (Args, Returns). The first sentence states the core purpose, followed by parameter and return details. No wasted words, though the structure could be more integrated rather than sectioned.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the simple single-parameter tool with output schema, the description covers the basics but has gaps. It explains what the tool does and the parameter, but doesn't address authentication needs, error conditions, or how this metadata tool relates to the sibling data retrieval tools. The presence of an output schema reduces the need to detail return values.

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

Parameters4/5

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

With 0% schema description coverage, the description provides crucial context about the series_id parameter - explaining it's 'The series ID to get metadata for' and providing a specific default example ('SF63528 for USD/MXN'). This adds meaningful semantics beyond what the bare schema provides, though it doesn't explain what constitutes a valid series ID format.

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 action ('Get metadata') and resource ('for a Banxico series'), making the purpose immediately understandable. However, it doesn't explicitly differentiate this metadata retrieval tool from sibling data retrieval tools like 'get_banxico_reserves_data' or 'get_usd_mxn_historical_data'.

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. With multiple sibling tools for Banxico data, there's no indication whether this should be used before/after other tools, or how it complements them. The default parameter hint is useful but doesn't constitute usage guidance.

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

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