Skip to main content
Glama

get_series

Fetch Bureau of Labor Statistics time series data by ID with optional date range filtering to retrieve economic indicators like CPI and employment statistics.

Instructions

Fetch BLS data series by ID with optional date range filtering. Returns time series data points with values, periods, and metadata.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
series_idYesBLS series ID (e.g., 'CUUR0000SA0' for CPI All Items)
start_yearNoStart year for data range (optional)
end_yearNoEnd year for data range (optional)

Implementation Reference

  • The `execute` method in `GetSeriesTool` class implements the core logic of the "get_series" tool: input validation using schema and helpers, data fetching from provider, error handling, and returning results.
    async def execute(self, arguments: Dict[str, Any]) -> Dict[str, Any]:
        """Execute get_series tool."""
        logger.info(f"Executing get_series with arguments: {arguments}")
    
        # Validate input
        try:
            input_data = GetSeriesInput(**arguments)
        except Exception as e:
            logger.error(f"Input validation failed: {e}")
            return {"error": f"Invalid input: {str(e)}"}
    
        # Validate series ID format
        if not validate_series_id(input_data.series_id):
            return {"error": f"Invalid series ID format: {input_data.series_id}"}
    
        # Validate year range
        is_valid, error_msg = validate_year_range(
            input_data.start_year, input_data.end_year
        )
        if not is_valid:
            return {"error": error_msg}
    
        # Fetch data
        try:
            result = await self.data_provider.get_series(
                series_id=input_data.series_id,
                start_year=input_data.start_year,
                end_year=input_data.end_year,
            )
            logger.info(
                f"Successfully fetched {result['count']} data points for {input_data.series_id}"
            )
            return result
        except ValueError as e:
            logger.warning(f"Series not found: {e}")
            return {"error": str(e)}
        except Exception as e:
            logger.error(f"Error fetching series: {e}")
            return {"error": f"Failed to fetch series: {str(e)}"}
  • Pydantic `BaseModel` defining the input schema for the get_series tool, including series_id, optional start_year and end_year with descriptions.
    class GetSeriesInput(BaseModel):
        """Input schema for get_series tool."""
    
        series_id: str = Field(
            description="BLS series ID (e.g., 'CUUR0000SA0' for CPI All Items)"
        )
        start_year: Optional[int] = Field(
            default=None, description="Start year for data range (optional)"
        )
        end_year: Optional[int] = Field(
            default=None, description="End year for data range (optional)"
        )
  • Registration of the GetSeriesTool instance in the server's tools dictionary, which is used by list_tools and call_tool handlers.
    self.tools = {
        "get_series": GetSeriesTool(self.data_provider),
        "list_series": ListSeriesTool(self.data_provider),
        "get_series_info": GetSeriesInfoTool(self.data_provider),
        "plot_series": PlotSeriesTool(self.data_provider),
    }
  • The `get_series` method in `MockDataProvider` that loads mock data from fixtures, filters by year range if provided, attaches metadata, and returns the series data. Called by the tool handler.
    async def get_series(
        self,
        series_id: str,
        start_year: int | None = None,
        end_year: int | None = None,
    ) -> dict[str, Any]:
        """
        Get data for a specific series.
    
        Args:
            series_id: BLS series ID (e.g., 'CUUR0000SA0')
            start_year: Optional start year filter
            end_year: Optional end year filter
    
        Returns:
            Dictionary with series data
    
        Raises:
            ValueError: If series not found
        """
        historical = self._load_historical_data()
    
        if series_id not in historical:
            raise ValueError(f"Series '{series_id}' not found in mock data")
    
        series_data = historical[series_id]
        data_points = series_data["data"]
    
        # Filter by year range if specified
        if start_year is not None or end_year is not None:
            filtered_points = []
            for point in data_points:
                year = int(point["year"])
                if start_year and year < start_year:
                    continue
                if end_year and year > end_year:
                    continue
                filtered_points.append(point)
            data_points = filtered_points
    
        # Get series metadata
        catalog = self._load_series_catalog()
        metadata: dict[str, Any] = next(
            (s for s in catalog["series"] if s["series_id"] == series_id), {}
        )
    
        return {
            "series_id": series_id,
            "data": data_points,
            "metadata": metadata,
            "count": len(data_points),
        }
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It mentions that the tool 'returns time series data points with values, periods, and metadata', which gives some insight into output behavior. However, it lacks critical details such as rate limits, authentication requirements, error handling, or data freshness (e.g., update frequency). For a data-fetching tool with no annotation coverage, this is a significant gap in transparency.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is front-loaded and efficiently structured in two sentences: the first states the core action and parameters, and the second describes the return value. Every sentence earns its place by providing essential information without redundancy, making it appropriately sized for the tool's complexity.

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

Completeness3/5

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

Given the tool's moderate complexity (3 parameters, no output schema, no annotations), the description is partially complete. It covers the purpose and output structure but lacks details on behavioral aspects like error cases, rate limits, or data sources. Without an output schema, the description should ideally explain return values more thoroughly, though it does mention 'time series data points with values, periods, and metadata'. This leaves gaps for an agent to operate effectively.

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

Parameters3/5

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

Schema description coverage is 100%, with clear descriptions for all parameters (series_id, start_year, end_year). The description adds minimal value beyond the schema by mentioning 'optional date range filtering', which aligns with the optional start_year and end_year parameters but doesn't provide additional semantics like format examples beyond 'CUUR0000SA0' or constraints. Baseline 3 is appropriate since the schema does the heavy lifting.

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 with specific verbs ('fetch') and resources ('BLS data series by ID'), and mentions optional date range filtering. It distinguishes itself from siblings like 'get_series_info' (likely metadata) and 'list_series' (likely listing multiple series) by focusing on fetching time series data points. However, it doesn't explicitly differentiate from 'plot_series', which might involve visualization of the same data.

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 mentioning 'optional date range filtering', suggesting it's for retrieving specific series data. However, it doesn't provide explicit guidance on when to use this tool versus alternatives like 'get_series_info' for metadata or 'plot_series' for visualization. No exclusions or prerequisites are stated, leaving the agent to infer context from sibling tool names alone.

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/kovashikawa/bls_mcp'

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