EU Parliament Monitor — API Documentation - v0.8.39
    Preparing search index...

    Native TypeScript client for the IMF SDMX 3.0 REST API.

    Despite the historical class name, no MCP server process is involved — the class keeps the name IMFMCPClient purely to avoid breaking the existing import surface (src/index.ts, test suites, documentation). New code is welcome to import it as IMFClient (alias below).

    Index

    Constructors

    Methods

    • Base URL currently in use (read-only — set at construction time).

      Returns string

      The fully-qualified IMF SDMX base URL (no trailing slash).

    • Per-request timeout in milliseconds.

      Returns number

      The timeout currently applied to every fetch() call.

    • Mark the client as ready. HTTP is stateless so there is no real connection, but callers historically invoke connect() before use — this is preserved for API compatibility and also exercises the base URL to catch misconfiguration early.

      Returns Promise<void>

      A resolved promise; never throws for valid URLs.

    • List every IMF database (dataflow) exposed by the SDMX 3.0 API.

      Virtual tool: imf-list-databases.

      Returns Promise<MCPToolResult>

      MCP-shaped result whose content[0].text carries a JSON array of { id, name, description } entries. Empty on error.

    • Search IMF databases by free-text keyword (case-insensitive substring match against id / name / description).

      Virtual tool: imf-search-databases. Runs client-side over the full dataflow list so a single SDMX round-trip serves every keyword query in a workflow run.

      Parameters

      • keyword: string

        Free-text keyword (e.g. "inflation", "trade").

      Returns Promise<MCPToolResult>

      Filtered list in MCP-shaped result; empty on error or when keyword is blank.

    • Fetch the dimension (parameter) definitions for a specific IMF dataflow. Essential before building an SDMX key for fetchData because each database has its own dimension set.

      Virtual tool: imf-get-parameter-defs.

      Parameters

      • databaseId: string

        IMF dataflow identifier (e.g. "WEO", "IFS").

      Returns Promise<MCPToolResult>

      MCP-shaped result whose content[0].text carries the ordered list of dimensions ([{ id, name }]). Empty on error.

    • List valid codes for a single dimension of an IMF dataflow, with an optional free-text filter to narrow the result.

      Virtual tool: imf-get-parameter-codes. The underlying SDMX /codelist/ endpoint is used, looked up from the datastructure so the caller does not need to know the codelist identifier ahead of time.

      Parameters

      • databaseId: string

        IMF dataflow identifier.

      • parameter: string

        Dimension name (e.g. "country", "indicator").

      • Optionalsearch: string

        Optional free-text search (case-insensitive substring).

      Returns Promise<MCPToolResult>

      MCP-shaped result with [{ id, name }] rows; empty on error.

    • Fetch a time-series slice from an IMF dataflow as SDMX-JSON.

      Virtual tool: imf-fetch-data. The response is already in SDMX-JSON format, so parseSDMXJSON (src/utils/imf-data.ts) can consume response.content[0]?.text directly without reshaping.

      Parameters

      • options: {
            databaseId: string;
            startYear: number;
            endYear: number;
            filters: Readonly<Record<string, readonly string[]>>;
            dimensionOrder?: readonly string[];
        }

        Fetch parameters.

        • databaseId: string

          IMF dataflow ID ("WEO", "IFS", ...).

        • startYear: number

          Inclusive start year (e.g. 2015).

        • endYear: number

          Inclusive end year (e.g. 2030 for WEO forecasts).

        • filters: Readonly<Record<string, readonly string[]>>

          Map of dimension → selected codes.

        • OptionaldimensionOrder?: readonly string[]

          Optional override of the dimension order used to build the SDMX key. Defaults to defaultDimensionOrder for the database.

      Returns Promise<MCPToolResult>

      MCP-shaped result whose content[0].text carries the raw SDMX-JSON response. Empty on error or invalid inputs.

    • Internal

      Build a full URL and GET it as text, enforcing the client-wide timeout.

      Parameters

      • path: string

        Path (already URL-encoded) to append to the base URL.

      Returns Promise<string>

      Response body (text/* or application/*) as a string.

      When the HTTP status is not 2xx, the request times out, or the network layer raises.

    • Internal

      GET a URL and parse the response body as JSON.

      Type Parameters

      • T

        Narrow response type declared by the caller.

      Parameters

      • path: string

        Path to append to the base URL.

      Returns Promise<T>

      Parsed JSON value.

      When the response is not JSON, not 2xx, or the request fails.

    Properties

    _apiBaseUrl: string
    _timeoutMs: number
    _fetchImpl: {
        (input: URL | RequestInfo, init?: RequestInit): Promise<Response>;
        (input: string | URL | Request, init?: RequestInit): Promise<Response>;
    }

    Type Declaration

      • (input: URL | RequestInfo, init?: RequestInit): Promise<Response>
      • Parameters

        • input: URL | RequestInfo
        • Optionalinit: RequestInit

        Returns Promise<Response>

      • (input: string | URL | Request, init?: RequestInit): Promise<Response>
      • Parameters

        • input: string | URL | Request
        • Optionalinit: RequestInit

        Returns Promise<Response>

    _connected: boolean = false