get_series_info
Retrieve detailed metadata for Bureau of Labor Statistics data series including title, description, category, and data availability using the series ID.
Instructions
Get detailed metadata information about a specific BLS series. Returns series title, description, category, and data availability.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| series_id | Yes | BLS series ID (e.g., 'CUUR0000SA0') |
Implementation Reference
- The execute method implements the core logic of the get_series_info tool: parses input, validates series ID, fetches series metadata from data_provider, and handles errors.async def execute(self, arguments: Dict[str, Any]) -> Dict[str, Any]: """Execute get_series_info tool.""" logger.info(f"Executing get_series_info with arguments: {arguments}") # Validate input try: input_data = GetSeriesInfoInput(**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}"} # Get series info try: info = await self.data_provider.get_series_info( series_id=input_data.series_id ) logger.info(f"Successfully retrieved info for {input_data.series_id}") return info except ValueError as e: logger.warning(f"Series not found: {e}") return {"error": str(e)} except Exception as e: logger.error(f"Error getting series info: {e}") return {"error": f"Failed to get series info: {str(e)}"}
- Pydantic BaseModel defining the input schema for the tool, specifying the required series_id parameter.class GetSeriesInfoInput(BaseModel): """Input schema for get_series_info tool.""" series_id: str = Field(description="BLS series ID (e.g., 'CUUR0000SA0')")
- src/bls_mcp/server.py:47-52 (registration)Registers all tools including get_series_info by instantiating GetSeriesInfoTool and adding it to the server's tools dictionary.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), }
- src/bls_mcp/server.py:14-14 (registration)Imports the GetSeriesInfoTool class required for registration.from .tools.get_series_info import GetSeriesInfoTool
- The GetSeriesInfoTool class defines the tool's name, description, input_schema property, and delegates execution to the execute method (included separately).class GetSeriesInfoTool(BaseTool): """Tool for getting BLS series metadata.""" def __init__(self, data_provider: MockDataProvider) -> None: """Initialize tool with data provider.""" self.data_provider = data_provider @property def name(self) -> str: return "get_series_info" @property def description(self) -> str: return ( "Get detailed metadata information about a specific BLS series. " "Returns series title, description, category, and data availability." ) @property def input_schema(self) -> type[BaseModel]: return GetSeriesInfoInput async def execute(self, arguments: Dict[str, Any]) -> Dict[str, Any]: """Execute get_series_info tool.""" logger.info(f"Executing get_series_info with arguments: {arguments}") # Validate input try: input_data = GetSeriesInfoInput(**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}"} # Get series info try: info = await self.data_provider.get_series_info( series_id=input_data.series_id ) logger.info(f"Successfully retrieved info for {input_data.series_id}") return info except ValueError as e: logger.warning(f"Series not found: {e}") return {"error": str(e)} except Exception as e: logger.error(f"Error getting series info: {e}") return {"error": f"Failed to get series info: {str(e)}"}