
Imf Mcp Server
io.github.cyanheadsv0.4.3更新於 Oct 8, 2026
Query IMF SDMX 3.0 macroeconomic dataflows — WEO, BOP, CPI, exchange rates, 190 countries.
概覽
查詢 IMF SDMX 3.0 總體經濟資料流——涵蓋 190 個國家的 WEO、國際收支、CPI、匯率與國民帳資料。
- 功能
- 透過 IMF SDMX 3.0 入口網站提供六個工具與一個資源。imf_list_databases 可用關鍵字篩選瀏覽資料流目錄,imf_get_database 將人類可讀詞彙解析為 SDMX 維度代碼並分頁檢視代碼清單,imf_query_dataset 依點分隔的維度鍵與時間範圍擷取時間序列。啟用 DuckDB 後端的 DataCanvas 後,大型多國結果會暫存,可透過 imf_dataframe_describe 與 imf_dataframe_query 以唯讀 SQL 檢視與查詢。
- 適用情境
- 適合助理需要官方總體經濟數據(成長、通膨、國際收支、匯率)進行分析、比較或報告的情境,也適合需要對多國或長時間跨度序列做 SQL 彙總而非單次查詢的情況。
- 執行需求
- 可作為公開託管的 Streamable HTTP 端點使用,也可透過 bunx/npx(需 Bun v1.4.0+ 或 Node.js v24+)或 Docker 在本機執行。不需要 API 金鑰。選用環境變數包括 CANVAS_PROVIDER_TYPE=duckdb(啟用 SQL 暫存)、IMF_ENABLE_DATAFRAME_DROP、MCP_TRANSPORT_TYPE、MCP_HTTP_PORT、MCP_AUTH_MODE 與 MCP_LOG_LEVEL。需要連線至 IMF SDMX 入口網站的網路存取。
安裝
在 SourceWeft 中
- 開啟 儀表板中的 Imf Mcp Server,將其新增到工作區。
- 為需要使用其工具的對話啟用該服務。
Web executable,透過 Streamable HTTP。 遠端服務在工作區中設定後即可從網頁執行環境執行。
其他 MCP 客戶端
把它新增到你客戶端的 mcpServers 設定中。
{
"mcpServers": {
"imf-mcp-server": {
"type": "http",
"url": "https://imf.caseyjhand.com/mcp"
}
}
}README
@cyanheads/imf-mcp-server
Query IMF SDMX 3.0 macroeconomic data — hundreds of dataflows across 190 countries, WEO projections, BOP, CPI, exchange rates, and national accounts via MCP. STDIO or Streamable HTTP.
Public Hosted Server: https://imf.caseyjhand.com/mcp
Overview
IMF SDMX 3.0 macroeconomic data — hundreds of dataflows spanning WEO projections, balance of payments, CPI, exchange rates, and national accounts across 190 countries. Browse the dataflow catalog, resolve dimension codes, and query time series from any MCP client, with large multi-country results staged to DataCanvas for SQL analysis. Runs as a stdio process, a local Streamable HTTP server, or the public hosted endpoint above.
Tools
Resources
Continuation beyond the resource's bounded codelist preview runs through imf_get_database.
Capability reference
imf_list_databases tool
filtersplits on spaces and commas and keeps a dataflow when every word appears, case-insensitively, in its ID, name, or description ("WEO outlook"finds WEO and the regional outlooks built on it), matched against the full text — not the shortened preview this tool returns- Vintage (historical snapshot) dataflows such as
WEO_2025_OCT_VINTAGEare excluded by default; setinclude_vintages=trueto include them - Paged:
limit(default 50, max 200) andoffset;total_countreports total matches,returned_countthe page size, and a notice names the nextoffsetwhile matches remain - Descriptions are cut to 200 characters here —
imf_get_databaseand theimf://database/{dataflow_id}resource return the full text
imf_get_database tool
- Resolves human-readable terms to SDMX dimension codes (e.g. "United States" →
USA) and returns each dimension's DSD concept-scheme label - Country codes are ISO 3-letter (
USA,GBR,DEU), not ISO 2-letter (US,GB,DE) key_formatnames the exact dot-separated dimension orderimf_query_datasetrequires- Codelist previews are capped at 50 entries by default; set
dimension_idto page one dimension withlimit/offset(max 200), andcodelist_filterapplies before paging codelist_filterkeeps codes whose ID or name contains every word given, in any order —"GDP constant prices"findsNGDP_RPCHand its constant-price siblings in WEO- Set
available_only=trueto page codes the dataflow actually publishes, with series count and time coverage, instead of the full codelist - A
codelist_filterthat matches nothing is reported distinctly from a codelist that could not be resolved — the two need opposite next steps
imf_query_dataset tool
- Dot-separated key in DSD keyPosition order;
+combines codes at one position,*matches every code there — every position needs a code or*, a blank segment is rejected - Codes are trimmed and matched case-insensitively (
usa.ngdp_rpch.aqueriesUSA.NGDP_RPCH.A), as isdataflow_id; a code missing from its dimension's codelist fails before the query asinvalid_key_code, naming the nearest valid codes (US→USA), and a*inside a+list fails aswildcard_in_code_list start_period/end_periodacceptYYYY,YYYY-SN,YYYY-QN,YYYY-MM, or a calendar-validYYYY-MM-DD; each bound covers its whole period (end_period: 2023includes2023-M12)last_n_observations(1–10,000) keeps each series' last N observations —1returns every series' latest value without downloading its history. "Latest" is per series, and a WEO series ends in projection years (2031); with a period bound, the last N inside the range- Returns
time_period,value,status, and series attributes (unit,scale,decimals); a key resolving to multiple series carries oneseries_metadataentry per series, since attributes can differ between them unit/scaleare upstream codes (PT,USD,XDC,IX,NUM); anullunit means the dataflow publishes none.valueis already in base units, andscaleis the power of ten the IMF publishes the series in —"9"renderspublished in units of 10^9,"0"renderspublished in units- A response is held to 100,000 serialized characters. With DataCanvas, larger multi-country or long-range results spill to it (
output_mode: "canvas"forces staging);stagedreports storage,truncatedreports only whetherobservationsis an incomplete preview — a staged result can still be untruncated - Without DataCanvas, a larger result returns its earliest observations with
truncated: true, fullseries_metadata, andretrieval_guidancenaming the lasttime_periodreturned and how to narrow: a narrower key,start_period/end_period,last_n_observations, orCANVAS_PROVIDER_TYPE=duckdb. A key whoseseries_metadataalone overflows fails asresponse_too_large no_dataerrors carry availability context naming codes that do have coverage; a key with data entirely outside the requested range fails asno_data_in_rangeand reports the range that does
imf_dataframe_describe tool
- Lists every table staged on a canvas, with row count and column schema (name + DuckDB type)
- Requires
canvas_idfrom a priorimf_query_datasetcall that returnedstaged: true - Call before
imf_dataframe_queryto confirm table and column names - Listed only with
CANVAS_PROVIDER_TYPE=duckdb, like the other dataframe tools; without it the landing page shows it disabled with that hint
imf_dataframe_query tool
- One read-only SQL
SELECTper call; a leadingWITH … SELECTcommon table expression is accepted, DML and DDL are rejected - Results are capped first by the canvas row limit (default 10,000), then by a 100,000-character serialized response budget —
row_countalways equals the returned rows, andtruncated: truemeans either cap trimmed the result - Page past a cap with a stable
ORDER BYplusLIMIT/OFFSET;response_too_largemeans even one row didn't fit and asks for fewer columns or aggregation - Listed only with
CANVAS_PROVIDER_TYPE=duckdb
imf_dataframe_drop tool
- Removes one named table or view from a canvas without affecting the others; requires the exact name from
imf_dataframe_describe - Idempotent — a repeated or absent drop returns
dropped: falserather than an error - Disabled by default; set
IMF_ENABLE_DATAFRAME_DROP=truealongsideCANVAS_PROVIDER_TYPE=duckdbto register it intools/list
imf://database/{dataflow_id} resource
- Bounded discovery metadata for one dataflow — every dimension with up to 50 codelist entries, counts,
key_format, name, description dataflow_idcomes fromimf_list_databases- Carries
continuationmetadata pointing toimf_get_database(withdimension_id/limit/offset) for a codelist beyond the preview
Features
Built on @cyanheads/mcp-ts-core: stdio and Streamable HTTP transports, pluggable auth (none / jwt / oauth), swappable storage (in-memory, filesystem, Supabase, Cloudflare KV/R2/D1), structured logging with optional OpenTelemetry tracing.
IMF-specific:
- Keyless access — no API key required; the IMF SDMX 3.0 portal is fully public
- Type-safe SDMX 3.0 compact JSON client with dimension/codelist parsing and DSD validation
- Key dimension count validated against the DSD before each query to catch format mismatches early
- Dataflow catalog and full availability constraints cached in-session to minimize round trips on multi-step workflows
- DuckDB-backed DataCanvas spill for large multi-country or long time-range observations
Agent-friendly output:
- Codelist entries carry both the machine code and human-readable label — agents can present meaningful names without a follow-up lookup
key_formatfield in every dataflow response explicitly states the dimension order, removing guesswork for key construction- Observations include each dataflow's own
statusflags (e.g.T,C,NA) so agents can communicate data quality caveats; a missing value flagged only as not available is dropped as padding - Canvas placement is explicit —
stageddistinguishes storage fromtruncatedpreview completeness, and staged results carrycanvas_id,table_name, and retrieval guidance
Getting started
Public Hosted Instance
A public instance is available at https://imf.caseyjhand.com/mcp — no installation required. Point any MCP client at it via Streamable HTTP:
Self-Hosted / Local
No API key required. Add the following to your MCP client configuration file.
Or with npx (no Bun required):
Or with Docker:
To enable SQL analytics over large result sets, add CANVAS_PROVIDER_TYPE=duckdb to the env block. Add IMF_ENABLE_DATAFRAME_DROP=true only when agents should be able to remove staged tables.
For Streamable HTTP, set the transport and start the server:
Prerequisites
- Bun v1.4.0 or higher (or Node.js v24+).
- No API key required.
Installation
- Clone the repository:
- Navigate into the directory:
- Install dependencies:
- Configure environment:
Configuration
See .env.example for the full list of optional overrides.
Running the server
Local development
-
Build and run:
-
Run checks and tests:
Docker
The Dockerfile defaults to HTTP transport, stateless session mode, and logs to /var/log/imf-mcp-server. OpenTelemetry peer dependencies are installed by default — build with --build-arg OTEL_ENABLED=false to omit them.
Project structure
Development guide
See CLAUDE.md/AGENTS.md for development guidelines and architectural rules. The short version:
- Handlers throw, framework catches — no
try/catchin tool logic - Use
ctx.logfor request-scoped logging,ctx.statefor tenant-scoped storage - Register new tools and resources via the barrels in
src/mcp-server/*/definitions/index.ts - Wrap external API calls: validate raw → normalize to domain type → return output schema; never fabricate missing fields
Data source
Data is sourced from the International Monetary Fund SDMX 3.0 portal under the IMF Copyright and Terms of Use. The IMF's terms permit redistribution of statistical data with attribution. Each data-returning tool response includes a source field with the required attribution: Source: International Monetary Fund, <dataflow name>, https://data.imf.org/.
Contributing
Issues are welcome. Run checks and tests before submitting:
License
Apache-2.0 — see LICENSE for details.
來源:README.md,提交 73fadb4
工具
0版本歷史
3- v0.4.3最新Sep 30, 2026
- v0.4.2Sep 20, 2026
- v0.4.1Sep 16, 2026


