list_indicators
Retrieve available economic indicators for a specific IMF dataset to identify relevant metrics for analysis.
Instructions
Returns a list of indicators for the specified dataset, read from the corresponding .json file in the local indicators directory.
Args:
dataset_id (str): Dataset ID, such as "IFS", "DOT", "BOP", etc.
Returns:
list: List of indicators.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| dataset_id | Yes |
Implementation Reference
- imf_data_mcp/__init__.py:289-310 (handler)The handler function for the 'list_indicators' MCP tool, registered via @mcp.tool(). It loads a JSON file from resources/indicators/{dataset_id}.json and returns the list of indicators, handling errors appropriately. The function signature and docstring define the input schema (dataset_id: str) and output (list).def list_indicators(dataset_id: str) -> list: """ Returns a list of indicators for the specified dataset, read from the corresponding .json file in the local indicators directory. Args: dataset_id (str): Dataset ID, such as "IFS", "DOT", "BOP", etc. Returns: list: List of indicators. """ file_path = os.path.join(os.path.dirname(__file__), "resources", "indicators", f"{dataset_id.lower()}.json") try: with open(file_path, 'r', encoding='utf-8') as file: data = json.load(file) return data except FileNotFoundError: return {"error": f"File not found: {file_path}"} except json.JSONDecodeError: return {"error": f"Error decoding JSON from file: {file_path}"} except Exception as e: return {"error": f"Error reading file: {str(e)}"}