Skip to main content
Glama
c-cf

IMF Data MCP Server

by c-cf

fetch_fsi_data

Retrieve time series data from the IMF Financial Soundness Indicators database by specifying frequency, country, indicator, and date range.

Instructions

Retrieves compact format time series data from the FSI database based on the input parameters.

Args:
    freq (str): Frequency (e.g., "A" for annual).
    country (str): Country code, multiple country codes can be connected with "+".
    indicator (str): Indicator code.
    start (str | int): Start year.
    end (str | int): End year.

Returns:
    str: Description of the queried data. Do not perform further analysis or retry if the query fails.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
freqYes
countryYes
indicatorYes
startYes
endYes

Implementation Reference

  • The handler function for the 'fetch_fsi_data' tool, decorated with @mcp.tool() for registration. It constructs the IMF API URL for FSI dataset, fetches JSON data, processes it using process_imf_data, and returns a string summary or error.
    @mcp.tool()
    def fetch_fsi_data(freq: str, country: str, indicator: str, start: str | int, end: str | int) -> str:
        """
        Retrieves compact format time series data from the FSI database based on the input parameters.
    
        Args:
            freq (str): Frequency (e.g., "A" for annual).
            country (str): Country code, multiple country codes can be connected with "+".
            indicator (str): Indicator code.
            start (str | int): Start year.
            end (str | int): End year.
    
        Returns:
            str: Description of the queried data. Do not perform further analysis or retry if the query fails.
        """
        dimensions = f"{freq}.{country}.{indicator}"
        url = f"http://dataservices.imf.org/REST/SDMX_JSON.svc/CompactData/FSI/{dimensions}?startPeriod={start}&endPeriod={end}"
        try:
            response = requests.get(url)
            response.raise_for_status()
            data = response.json()
    
            return process_imf_data(data)
        except Exception as e:
            return f"Error fetching FSI data: {str(e)}"
  • Supporting utility function used by fetch_fsi_data (and other fetch tools) to parse the IMF JSON response into a human-readable string format, extracting time periods, countries, and observation values.
    def process_imf_data(json_data: dict) -> str:
        """
        Process IMF data and return a string with the information.
        :param:
            json_data(dict): JSON data from the IMF API
        :return:
            (str) A string with the information from the JSON data
        """
        try:
           
            json_data = json_data["CompactData"]
            dataset = json_data["DataSet"]
    
            series_list = dataset["Series"]
            if isinstance(series_list, dict):
                series_list = [series_list]
            elif not isinstance(series_list, list):
                return f"Error: Expected series_list to be a list but got {type(series_list)}"
    
            output_texts = []
            
            for series in series_list:
                if series is None:
                    output_texts.append("Warning: No indicator value.")
                    continue
                country = series.get("@REF_AREA", None)
                obs = series.get("Obs", {})
                if isinstance(obs, dict):
                    obs = [obs]
                elif not isinstance(obs, list):
                    return f"Error: Expected obs to be a list but got {type(obs)}"
                for _obs in obs:
                    if _obs is None:
                        output_texts.append(
                            f"Warning: No indicator value for {country} in that Year, You should not try to access the data of this country."
                        )
                        continue
                    time_period = _obs.get("@TIME_PERIOD", "that Year")
                    obs_value = _obs.get("@OBS_VALUE")
                    
                    if obs_value is not None:
                        text = f"In {time_period}, {country} had an indicator value of {float(obs_value):.2f}."
                        output_texts.append(text)
                    else:
                        output_texts.append(f"Warning: No indicator value for {country} in {time_period}.")
            
            return "\n".join(output_texts)
        except KeyError as e:
            return f"Error processing IMF data: Missing key {str(e)}"
        except Exception as e:
            return f"Error processing IMF data: {str(e)}"
Behavior3/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the tool retrieves data (implying read-only) and specifies 'Do not perform further analysis or retry if the query fails,' which adds important behavioral context about error handling. However, it doesn't mention rate limits, authentication requirements, data format details, or what constitutes a 'compact format.'

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is well-structured with clear sections (purpose, Args, Returns). Each sentence earns its place by providing essential information. The Args section is particularly efficient in explaining multiple parameters concisely. The only minor improvement would be integrating the purpose statement more seamlessly with the parameter explanations.

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 5-parameter tool with no annotations and no output schema, the description provides adequate but incomplete coverage. It explains parameters well and gives behavioral guidance about error handling, but doesn't describe the return format ('compact format' is vague) or provide examples of valid indicator/country codes. Given the complexity and lack of structured documentation, it should do more to compensate.

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?

With 0% schema description coverage, the description must compensate for the lack of parameter documentation. It provides clear explanations for all 5 parameters: frequency format examples, country code concatenation syntax, and start/end year formats. The only gap is that 'indicator' lacks examples of valid codes, but overall the description adds substantial value beyond the bare schema.

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: 'Retrieves compact format time series data from the FSI database based on the input parameters.' It specifies the verb ('retrieves'), resource ('time series data'), and source ('FSI database'). However, it doesn't explicitly differentiate from sibling tools like fetch_bop_data or fetch_ifs_data, which likely retrieve different datasets from similar databases.

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 doesn't mention sibling tools or explain what makes FSI data distinct from other datasets like BOP or CPI data. The only usage hint is in the Returns section about not retrying on failure, but this doesn't help with tool selection.

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