Skip to main content
Glama

search_time_series_groups

Search Peru's central bank economic data by keywords to find relevant time series groups for analysis.

Instructions

Search for time series groups using one or multiple keywords.

This function searches the BCRP (Banco Central de Reserva del Perú) database for time series groups that match the provided keywords. It returns a list of unique time series group names that contain or relate to the search terms.

Args: keywords (List[str]): A list containing one or more keywords to search for. Each keyword should be a single word without spaces.

Returns: List[str]: A list of unique time series group names that match the search criteria. Returns an empty list if no matches are found.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
keywordsYes

Implementation Reference

  • main.py:17-42 (handler)
    The main handler function for the 'search_time_series_groups' tool. It is decorated with @mcp.tool(), which registers it in the FastMCP server. The function fetches metadata from BCRP, searches for matching time series groups using fuzzy matching with difflib.get_close_matches, and returns unique group names.
    @mcp.tool() def search_time_series_groups(keywords: List[str]) -> List[str]: """ Search for time series groups using one or multiple keywords. This function searches the BCRP (Banco Central de Reserva del Perú) database for time series groups that match the provided keywords. It returns a list of unique time series group names that contain or relate to the search terms. Args: keywords (List[str]): A list containing one or more keywords to search for. Each keyword should be a single word without spaces. Returns: List[str]: A list of unique time series group names that match the search criteria. Returns an empty list if no matches are found. """ try: df = pd.read_csv(METADATA_ENDPOINT, delimiter=';', encoding='latin-1') # index 3 is the column index for the time series group # search based on wordsearch from bcrpy matches = df[df.iloc[:, 3].apply(lambda x: any(get_close_matches(k, str(x).split(), n=1, cutoff=CUTOFF) for k in keywords))] return list(set(matches[TIME_SERIES_GROUP])) except Exception as e: return [f"error: {e}"]
  • main.py:17-17 (registration)
    Registration of the 'search_time_series_groups' tool using the FastMCP @mcp.tool() decorator.
    @mcp.tool()
  • main.py:14-16 (helper)
    Constants used by the search_time_series_groups handler: column name for time series group and fuzzy matching cutoff.
    TIME_SERIES_GROUP = "Grupo de serie" CUTOFF = 0.65

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