Optional overrides for base URL, timeout, fetch impl, and the optional fetch-proxy gateway used for restricted networks.
Base URL currently in use (read-only — set at construction time).
The fully-qualified IMF SDMX base URL (no trailing slash).
Per-request timeout in milliseconds.
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.
A resolved promise; never throws for valid URLs.
Whether connect has been called successfully.
true after a successful connect; reset by disconnect.
Reset the connected flag. No real socket to close.
List every IMF database (dataflow) exposed by the SDMX 3.0 API.
Virtual tool: imf-list-databases. Hits the umbrella
/structure/dataflow endpoint which returns every published
dataflow across all IMF sub-agencies (IMF.RES, IMF.STA,
IMF.FAD, IMF.WHD, IMF.MCM, …) — typically ~190 entries.
Each row includes the publishing agency so callers know which
agency to use when calling getParameterDefs or fetchData.
MCP-shaped result whose content[0].text carries a JSON
array of { id, name, description, agency, version } 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.
Free-text keyword (e.g. "inflation", "trade").
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. Uses the
/structure/dataflow/{agency}/{id}/+?references=datastructure
endpoint because the legacy /structure/datastructure/IMF/{id}/+
shape returns 204 on api.imf.org after the September-2025 IMF
Data Portal migration retired the umbrella IMF agency.
IMF dataflow identifier (e.g. "WEO", "FM").
OptionalagencyId: stringOptional override; defaults to resolveAgency.
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. Uses
/structure/dataflow/{agency}/{id}/+?references=all to fetch the
DSD plus its referenced conceptSchemes and codelists in one
round-trip — SDMX 3.0 binds the codelist on the concept
(coreRepresentation.enumeration), so resolving codes requires
walking dim → conceptIdentity → conceptScheme → concept → codelist.
IMF dataflow identifier.
Dimension name (e.g. "COUNTRY", "INDICATOR";
matched case-insensitively).
Optionalsearch: stringOptional free-text search (case-insensitive substring).
OptionalagencyId: stringOptional agency override; defaults to resolveAgency.
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; callers read the series under data.dataSets[0].series
using any standard SDMX-JSON reader. (The earlier helper
parseSDMXJSON in src/utils/imf-data.ts was purged in the
April-2026 aggregator-pipeline migration.)
Fetch parameters.
IMF dataflow ID ("WEO", "FM", ...).
Inclusive start year (e.g. 2015).
Inclusive end year (e.g. 2030 for WEO forecasts).
Map of dimension → selected codes. Filter
keys are matched case-insensitively against the DSD dimensions
(legacy lowercase country/indicator/frequency continue to work).
OptionaldimensionOrder?: readonly string[]Optional override of the dimension order
used to build the SDMX key. Defaults to
defaultDimensionOrder for the database.
OptionalagencyId?: stringOptional SDMX agency override (e.g. "IMF.RES",
"IMF.STA"). Defaults to resolveAgency.
MCP-shaped result whose content[0].text carries the raw
SDMX-JSON response. Empty on error or invalid inputs.
Private_Build an IMFHttpContext adapter for http-transport.ts helpers.
Context adapter for IMF HTTP transport helpers
Private Readonly_Private Readonly_Private Readonly_Optionalinit: RequestInitOptionalinit: RequestInitPrivate Readonly_Private Readonly_Private Readonly_Private_
Create a new IMF SDMX 3.0 client.
Resolves the API base URL, timeout, fetch implementation, and Azure-APIM subscription keys from the explicit
options, then from environment variables (IMF_API_BASE_URL,IMF_API_TIMEOUT_MS,IMF_API_PRIMARY_KEY,IMF_API_SECONDARY_KEY,FETCH_MCP_GATEWAY_URL,EP_MCP_GATEWAY_API_KEY), and finally module-level defaults.