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)}"
Behavior4/5

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

With no annotations provided, the description carries the full burden and discloses key behavioral traits: 'deterministic search with fuzzy matching' explains the algorithm, and 'ambiguity error if multiple matches are equally scored' documents error conditions. It also specifies the return structure containing 'codigo_serie and confidence'.

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 Args/Returns structure is slightly formal but efficiently organizes information. Every section serves a purpose: the opening defines scope, the algorithm sentence explains behavior, and the Returns section documents output despite the presence of an output schema.

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

Completeness5/5

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

For a single-parameter search tool with an existing output schema, the description is complete. It covers the search mechanism, error behaviors, return format, and parameter semantics without unnecessary verbosity.

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?

Schema description coverage is 0%, requiring the description to compensate. It successfully does so by defining the query parameter as a 'Search term' and providing concrete Spanish-language examples ('tipo de cambio', 'inflacion', 'PBI') that clarify expected input format.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description states a specific verb ('Search'), resource ('BCRP economic indicators'), and mechanism ('by keyword'), clearly distinguishing it from siblings like get_data (retrieval) and plot_chart (visualization).

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 examples ('tipo de cambio', 'inflacion') provide implied usage context for finding series codes, but there is no explicit guidance on when to use this versus get_data directly or workflow prerequisites (e.g., 'use this first to obtain codigo_serie').

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