Skip to main content
Glama

plot_series

Retrieve Consumer Price Index (CPI) time series data formatted for chart creation, enabling visualization of inflation trends from Bureau of Labor Statistics datasets.

Instructions

Get CPI All Items (CUUR0000SA0) data formatted for plotting. Returns time series data with dates and values that can be used to create charts on the client side. No parameters needed.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The `execute` method in `PlotSeriesTool` class implements the core handler logic: fetches hardcoded CPI series CUUR0000SA0 data, formats it for client-side plotting with dates and values, computes statistics, and returns structured JSON including plot instructions.
    async def execute(self, arguments: Dict[str, Any]) -> Dict[str, Any]:
        """Execute the plot series tool - returns data for CUUR0000SA0."""
        logger.info("Executing plot_series for CUUR0000SA0")
    
        # Hardcoded series
        series_id = "CUUR0000SA0"
    
        # Fetch ALL available data for this series
        try:
            series_data = await self.data_provider.get_series(series_id)
        except Exception as e:
            logger.error(f"Failed to fetch series: {e}")
            return {"status": "error", "error": str(e)}
    
        # Extract data points
        data_points = series_data.get("data", [])
        if not data_points:
            return {"status": "error", "error": "No data available"}
    
        # Sort data chronologically and format for plotting
        plot_data = []
        for point in data_points:
            year = point["year"]
            month = point["period"].replace("M", "").zfill(2)
            date_str = f"{year}-{month}"
            value = float(point["value"])
            plot_data.append({
                "date": date_str,
                "value": value,
                "year": year,
                "month": month,
                "period": point["period"]
            })
    
        # Sort oldest to newest
        plot_data.sort(key=lambda x: x["date"])
    
        # Calculate statistics
        values = [d["value"] for d in plot_data]
        min_value = min(values)
        max_value = max(values)
        avg_value = sum(values) / len(values)
    
        # Get metadata
        metadata = series_data.get("metadata", {})
    
        return {
            "status": "success",
            "series_id": series_id,
            "series_title": metadata.get("series_title", "CPI All Urban Consumers: All Items"),
            "data": plot_data,
            "statistics": {
                "count": len(plot_data),
                "min": round(min_value, 3),
                "max": round(max_value, 3),
                "average": round(avg_value, 3),
            },
            "date_range": {
                "start": plot_data[0]["date"],
                "end": plot_data[-1]["date"]
            },
            "plot_instructions": {
                "chart_type": "line",
                "x_axis": "date",
                "y_axis": "value",
                "title": metadata.get("series_title", "CPI All Urban Consumers: All Items"),
                "y_label": "Index Value",
                "x_label": "Date"
            }
        }
  • Pydantic `BaseModel` defining the input schema for the `plot_series` tool. It is empty since no input parameters are required.
    class PlotSeriesInput(BaseModel):
        """Input schema for plot_series tool - no parameters needed."""
        pass
  • Registration of the `PlotSeriesTool` instance in the BLS MCP server's `tools` dictionary under the key `'plot_series'`, making it available via the MCP protocol.
    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),
    }
  • Property providing the input schema for tool registration and MCP `list_tools` response.
    def input_schema(self) -> type[BaseModel]:
        return PlotSeriesInput
  • Property defining the tool name `'plot_series'` used for registration and identification.
    def name(self) -> str:
        return "plot_series"
Behavior3/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. It discloses that the tool returns time series data formatted for plotting and requires no parameters, which is useful. However, it doesn't mention potential behavioral aspects like rate limits, authentication requirements, data freshness, or error conditions. The description adds some value but lacks comprehensive behavioral context.

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 extremely concise and well-structured in three sentences. The first sentence states the purpose, the second explains the return format and usage, and the third clarifies the parameter situation. Every sentence earns its place with no wasted words, and the information is front-loaded appropriately.

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 simplicity (0 parameters, no output schema, no annotations), the description is reasonably complete for basic understanding. However, for a data retrieval tool with no annotations, it could benefit from mentioning response format details, potential limitations, or error handling. The description covers the essentials but leaves some contextual gaps.

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?

The tool has 0 parameters with 100% schema description coverage. The description explicitly states 'No parameters needed,' which aligns perfectly with the schema. This provides clear semantic understanding beyond the schema's structural definition. A baseline of 4 is appropriate for zero-parameter tools where the description confirms the absence of inputs.

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 clearly states the tool's purpose: 'Get CPI All Items (CUUR0000SA0) data formatted for plotting.' It specifies the exact resource (CPI All Items with specific identifier) and verb (get), and distinguishes it from sibling tools like get_series, get_series_info, and list_series by emphasizing the 'formatted for plotting' aspect and 'no parameters needed' constraint.

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

Usage Guidelines5/5

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

The description explicitly states when to use this tool: 'Returns time series data with dates and values that can be used to create charts on the client side.' It also specifies 'No parameters needed,' which differentiates it from parameter-requiring siblings. While it doesn't explicitly name alternatives, the context of sibling tools and the specific 'plotting' focus provides clear usage guidance.

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