Skip to main content
Glama

get_data

Fetch time series data for specific economic indicators from the Banco Central de Reserva del Perú database using series codes and date ranges.

Instructions

Fetch time series data for specific BCRP series codes.

Args: series_codes: List of BCRP series codes (e.g., ["PN01652XM", "PD04638PD"]) period: Date range in format 'YYYY-MM/YYYY-MM' or single 'YYYY-MM'. If None, returns all available data.

Returns: JSON string with array of records containing 'time' and values.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
series_codesYes
periodNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The _get_data function is the internal helper function that performs the actual data fetching logic from the BCRP client.
    async def _get_data(series_codes: list[str], period: str = None) -> str:
        try:
            logger.info(f"Fetching data for: {series_codes} range: {period}")
            
            # Parse period if needed, but client handles basic string appending
            # We might need to handle the specific format "start_date/end_date" if provided as one string
            start = None
            end = None
            start = None
            end = None
            if period:
                parts = period.split('/')
                if len(parts) == 2:
                    start, end = parts
                elif len(parts) == 1:
                     # Check if it looks like a year "YYYY"
                     if len(period) == 4 and period.isdigit():
                         start = f"{period}-01"
                         end = f"{period}-12"
                     else:
                         start = period # fallback
                         # If only start is provided, client won't append it currently.
                         # We should probably set end to 'now' or similar if start is provided?
                         # Or rely on client update. But client needs start AND end.
                         # If only start provided, let's duplicate it? or leave end=None?
                         # If I set end=start, it fetches one month.
                         pass
            
            df = await bcrp_client.get_series(series_codes, start_date=start, end_date=end)
            
            if df.empty:
                return "No data found for the specified parameters."
                
            return df.to_json(orient='records', date_format='iso')
        except Exception as e:
            logger.error(f"Fetch failed: {e}")
            return f"Error fetching data: {str(e)}"
  • The get_data tool definition which is registered with FastMCP and calls the internal _get_data function.
    @mcp.tool()
    async def get_data(series_codes: list[str], period: str = None) -> str:
        """
        Fetch time series data for specific BCRP series codes.
        
        Args:
            series_codes: List of BCRP series codes (e.g., ["PN01652XM", "PD04638PD"])
            period: Date range in format 'YYYY-MM/YYYY-MM' or single 'YYYY-MM'.
                    If None, returns all available data.
        
        Returns:
            JSON string with array of records containing 'time' and values.
        """
        return await _get_data(series_codes, period)
Behavior3/5

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

With no annotations provided, the description carries the full burden. It successfully documents the return format (JSON string with array of records) and date range behavior (format specifications and null handling). However, it lacks information on safety (idempotency), performance (rate limits), or error conditions.

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 docstring-style format (Args/Returns) is structured and readable. Information is efficiently presented with minimal redundancy, though the formal structure is slightly less front-loaded than pure prose. Every sentence provides necessary detail about parameters or return values.

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

Completeness4/5

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

For a 2-parameter read operation with an output schema, the description adequately covers the input semantics despite zero schema coverage. It explains the BCRP domain context, parameter formats, and return structure. It could benefit from mentioning data frequency or timezone handling, but covers the essentials.

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

Parameters5/5

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

Excellent compensation for 0% schema description coverage. The description provides concrete examples for series_codes (e.g., 'PN01652XM') and detailed format specifications for the period parameter ('YYYY-MM/YYYY-MM' or single 'YYYY-MM'), plus null behavior. This adds critical semantic meaning absent from 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 action (Fetch), resource (time series data), and scope (specific BCRP series codes). However, it does not explicitly differentiate from sibling tools like 'search_series' (which likely finds codes) or 'get_table' (which likely returns tabular rather than time-series format).

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?

There is no guidance on when to use this tool versus alternatives. Given siblings include 'search_series' and 'get_table', the description should clarify that this requires known series codes and returns structured time-series data rather than search results or visualizations.

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/MaykolMedrano/mcp_bcrp'

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