Skip to main content
Glama

search_series

Search for BCRP economic indicators by keyword using deterministic search with fuzzy matching to identify relevant macroeconomic data series.

Instructions

Search for BCRP economic indicators by keyword.

Uses deterministic search with fuzzy matching. Returns the best match or an ambiguity error if multiple matches are equally scored.

Args: query: Search term (e.g., "tipo de cambio", "inflacion", "PBI")

Returns: JSON string with match result containing codigo_serie and confidence, or error details if ambiguous or not found.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The MCP tool registration for `search_series` which delegates to the `_search_series` function.
    @mcp.tool()
    async def search_series(query: str) -> str:
        """
        Search for BCRP economic indicators by keyword.
        
        Uses deterministic search with fuzzy matching. Returns the best match
        or an ambiguity error if multiple matches are equally scored.
        
        Args:
            query: Search term (e.g., "tipo de cambio", "inflacion", "PBI")
        
        Returns:
            JSON string with match result containing codigo_serie and confidence,
            or error details if ambiguous or not found.
        """
        return await _search_series(query)
  • The core implementation logic of the search functionality used by the `search_series` tool.
    async def _search_series(query: str) -> str:
        """
        Uses robust local metadata search.
        Now returns deterministic result via SearchEngine.solve().
        """
        try:
            await metadata_client.load()
            
            logger.info(f"Searching for: {query}")
            
            # First try deterministic solve
            result = metadata_client.solve(query)
            
            if "error" not in result:
                # Success - return JSON with the match
                return json.dumps(result, ensure_ascii=False)
            
            if result.get("error") == "ambiguedad":
                # Return ambiguity info for user to refine
                return json.dumps(result, ensure_ascii=False)
            
            # Fallback to fuzzy search for exploratory queries
            df = metadata_client.search(query)
            
            if df.empty:
                return "No series found matching that query."
            return df.to_json(orient='records')
        except Exception as e:
            logger.error(f"Search failed: {e}")
            return f"Search failed: {str(e)}"
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