Skip to main content
Glama
rodcar

BCRP-MCP

by rodcar

get_time_series_data

Retrieve economic time series data from Peru's Central Reserve Bank database for specific codes within defined date ranges, returning formatted date-value pairs.

Instructions

Get the data for a specific time series within a date range.

This function retrieves time series data from the BCRP (Banco Central de Reserva del Perú) database for a specific time series code within the specified date range. The data is returned as a list of lists with dates formatted as 'YYYY-MM-DD'.

Args: time_series_code (str): The unique code identifier for the time series. start (str): The start date for the data retrieval. Format should be '2020-1' for monthly data or '2020-1-1' for daily data. end (str): The end date for the data retrieval. Format should be '2020-1' for monthly data or '2020-1-1' for daily data.

Returns: List[List[str]]: A list of lists where each inner list contains: [formatted_date, time_series_value] The date is formatted as 'YYYY-MM-DD' and the value is the corresponding data point for that date.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
time_series_codeYes
startYes
endYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • main.py:71-117 (handler)
    The @mcp.tool() decorator registers the function, and the function implements the core logic for fetching time series data from the BCRP API endpoint, parsing the JSON response, handling errors, formatting dates to YYYY-MM-DD, and returning a list of [date, value] pairs.
    @mcp.tool()
    def get_time_series_data(time_series_code: str, start: str, end: str) -> List[List[str]]:
        """
        Get the data for a specific time series within a date range.
        
        This function retrieves time series data from the BCRP (Banco Central de Reserva del Perú)
        database for a specific time series code within the specified date range. The data is
        returned as a list of lists with dates formatted as 'YYYY-MM-DD'.
        
        Args:
            time_series_code (str): The unique code identifier for the time series.
            start (str): The start date for the data retrieval. Format should be '2020-1' 
                        for monthly data or '2020-1-1' for daily data.
            end (str): The end date for the data retrieval. Format should be '2020-1' 
                      for monthly data or '2020-1-1' for daily data.
        
        Returns:
            List[List[str]]: A list of lists where each inner list contains:
                            [formatted_date, time_series_value]
                            The date is formatted as 'YYYY-MM-DD' and the value is the
                            corresponding data point for that date.
        """
        try:
            url = f"{API_ENDPOINT}/{time_series_code}/json/{start}/{end}/eng"
            
            response = requests.get(url)
            if response.status_code != 200:
                return []
            
            # Extract JSON from response that may contain HTML errors
            response_text = response.text
            json_start = response_text.find('{\n"config":')
            if json_start == -1:
                return []
            
            data = json.loads(response_text[json_start:])
            result = []
            
            for period in data["periods"]:
                date_formatted = pd.to_datetime(period["name"]).strftime('%Y-%m-%d')
                value = period["values"][0] if period["values"] else "n.d."
                result.append([date_formatted, str(value) if value != "n.d." else "n.d."])
                
            return result
            
        except Exception as e:
            return []
  • main.py:72-92 (schema)
    Type hints and docstring define the input schema (time_series_code: str, start: str, end: str) and output schema (List[List[str]] with [date, value]).
    def get_time_series_data(time_series_code: str, start: str, end: str) -> List[List[str]]:
        """
        Get the data for a specific time series within a date range.
        
        This function retrieves time series data from the BCRP (Banco Central de Reserva del Perú)
        database for a specific time series code within the specified date range. The data is
        returned as a list of lists with dates formatted as 'YYYY-MM-DD'.
        
        Args:
            time_series_code (str): The unique code identifier for the time series.
            start (str): The start date for the data retrieval. Format should be '2020-1' 
                        for monthly data or '2020-1-1' for daily data.
            end (str): The end date for the data retrieval. Format should be '2020-1' 
                      for monthly data or '2020-1-1' for daily data.
        
        Returns:
            List[List[str]]: A list of lists where each inner list contains:
                            [formatted_date, time_series_value]
                            The date is formatted as 'YYYY-MM-DD' and the value is the
                            corresponding data point for that date.
        """
  • main.py:71-71 (registration)
    The tool is registered via the @mcp.tool() decorator on the handler function.
    @mcp.tool()
Behavior3/5

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

With no annotations provided, the description carries full burden. It discloses the data source (BCRP database) and return format, but lacks information on rate limits, authentication requirements, error handling, or data freshness. It adequately describes the read-only nature but misses operational constraints.

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 well-structured with clear sections (purpose, args, returns) and avoids redundancy. However, the opening sentence could be more front-loaded with key distinctions from siblings, and some details about the BCRP source could be condensed.

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?

Given 3 parameters with 0% schema coverage and an output schema present, the description does an excellent job explaining parameter semantics and return format. It covers the essential 'what' and 'how', though it lacks context on when to use versus siblings and behavioral constraints like rate limits.

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?

Schema description coverage is 0%, so the description must compensate fully. It provides detailed semantics for all three parameters: explains what time_series_code is, specifies date format variations (monthly vs daily) for start and end, and clarifies their roles in data retrieval. This adds significant value beyond the bare 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 tool's purpose: 'Get the data for a specific time series within a date range' and specifies it retrieves from the BCRP database. It distinguishes from siblings by focusing on data retrieval for a specific code rather than searching by group, though the distinction could be more explicit.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage by specifying date ranges and time series codes, but does not explicitly state when to use this tool versus the sibling tools (search_time_series_by_group, search_time_series_groups). No guidance on prerequisites or alternative scenarios is provided.

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/rodcar/bcrp-mcp'

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