list_countries
Retrieve a list of available countries for a specific dataset from the IMF Data MCP Server. Input a dataset ID to access the corresponding country list stored in local JSON files.
Instructions
Returns a list of available countries for the specified dataset, read from the corresponding .json file in the local areas directory.
Args:
dataset_id (str): Dataset ID, such as "IFS", "DOT", "BOP", etc.
Returns:
list: List of countries.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| dataset_id | Yes |
Implementation Reference
- imf_data_mcp/__init__.py:312-334 (handler)The handler function decorated with @mcp.tool() that implements the list_countries tool by loading country data from a JSON file specific to the given dataset_id.@mcp.tool() def list_countries(dataset_id: str) -> list: """ Returns a list of available countries for the specified dataset, read from the corresponding .json file in the local areas directory. Args: dataset_id (str): Dataset ID, such as "IFS", "DOT", "BOP", etc. Returns: list: List of countries. """ file_path = os.path.join(os.path.dirname(__file__), "resources", "areas", 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)}"}