Skip to main content
Glama
c-cf

IMF Data MCP Server

by c-cf

list_countries

Retrieve available countries for a specific IMF dataset to filter and access relevant economic data for analysis.

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
NameRequiredDescriptionDefault
dataset_idYes

Implementation Reference

  • Handler function that implements the list_countries tool by loading a dataset-specific JSON file containing country codes from the resources/areas directory and returning the list or an appropriate error.
    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)}"}
  • Registers the list_countries function as a tool in the FastMCP server.
    @mcp.tool()
  • Type hints and docstring defining the input parameter dataset_id (str) and return type list for the list_countries 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.
        """
  • Prompt template that references and describes the list_countries tool for use in guiding users.
    @mcp.prompt()
    def imf_query_prompt() -> str:
        """
        Returns a prompt template explaining how to query IMF data with indicators and user intentions.
    
        Returns:
            str: A prompt template for guiding users on querying IMF data.
        """
        prompt_text = """
            You are a professional IMF data analysis assistant. Please follow these steps to help users obtain and analyze IMF data:
    
            1. First, use the imf://datasets resource to get a list of available datasets and show the user the 5-10 most commonly used datasets with a brief description.
    
            2. When the user selects a dataset, use the following two tools to get detailed information about the dataset:
                - list_countries: List available country or region codes
                - list_indicators: List available indicator codes and names
            3. Assist the user in determining their interests:
            - Country or region (provide codes, and multiple country codes can be connected with "+")
            - Indicator (provide codes and names)
            - Time range (start year and end year)
            - Data frequency (if applicable: annual A, quarterly Q, monthly M, etc.)
    
            4. Based on the user's selection, construct appropriate query parameters and use the fetch_compact_data tool to get the data
    
            ** Note: When you get warnings like "Warning: No indicator value" or "Warning: No indicator value for {country} in that Year," it means there is a lack of data for that period. Do not perform further analysis or retry. **
    
        """
        return prompt_text
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. It mentions the data source ('.json file in the local areas directory') which adds useful context, but doesn't cover important aspects like whether this is a read-only operation, potential rate limits, error conditions, or what happens if the dataset_id doesn't exist.

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 perfectly structured and concise. It begins with the core purpose, then provides clear Args and Returns sections. Every sentence earns its place, with no redundant information or wasted words.

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?

For a single-parameter read operation with no output schema, the description is adequate but has gaps. It explains what the tool does and the parameter meaning well, but lacks information about return format details, error handling, or how it relates to sibling tools. The absence of annotations means more behavioral context would be helpful.

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 description provides excellent parameter semantics despite 0% schema description coverage. It explains that dataset_id represents 'Dataset ID, such as "IFS", "DOT", "BOP", etc.' and connects it to the sibling tool names, giving concrete examples that the schema lacks. This fully compensates for the schema coverage gap.

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: 'Returns a list of available countries for the specified dataset'. It specifies the verb ('returns'), resource ('list of available countries'), and scope ('for the specified dataset'), though it doesn't explicitly differentiate from sibling tools like 'list_indicators'.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives. It mentions reading from '.json file in the local areas directory', but doesn't specify prerequisites, when-not-to-use scenarios, or compare it to sibling tools like 'fetch_*' tools that might also involve country data.

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/c-cf/imf-data-mcp'

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