
Treasury Fiscaldata Mcp Server
io.github.cyanheadsv0.2.0更新於 Oct 8, 2026
Query US Treasury national debt, interest rates, exchange rates, and fiscal datasets via MCP.
概覽
讓助理查詢美國財政部財政資料,包括國債、利率、匯率及其他財政資料集,並可選擇進行 DuckDB SQL 分析。
- 功能
- 透過公開的美國財政部 Fiscal Data API 提供八個工具。treasury_list_datasets 瀏覽內建的 17 個端點目錄;treasury_query_dataset 依路徑、欄位、篩選、排序與分頁查詢任一端點;treasury_get_debt、treasury_get_interest_rates 與 treasury_get_exchange_rates 涵蓋最常查詢的三個資料集。大量擷取可暫存為 DuckDB 資料框架,並透過 treasury_dataframe_describe、treasury_dataframe_query 以及需明確啟用的 treasury_dataframe_drop 以 SQL 分析。
- 適用情境
- 適合助理需要官方美國財政資料(例如國債、財政部利率或法定匯率)時,或需要將大量時間序列暫存後以 SQL 連接與聚合分析時。
- 執行需求
- 可作為遠端 Streamable HTTP 端點執行,也可透過 npx、bunx 或 Docker 在本機執行;本機使用需要 Node.js v24+ 或 Bun v1.4.0+。無需 API 金鑰。DataCanvas SQL 工具需要 CANVAS_PROVIDER_TYPE=duckdb;HTTP 選項包括 MCP_HTTP_PORT 與 MCP_AUTH_MODE。
安裝
在 SourceWeft 中
- 開啟 儀表板中的 Treasury Fiscaldata Mcp Server,將其新增到工作區。
- 為需要使用其工具的對話啟用該服務。
Web executable,透過 Streamable HTTP。 遠端服務在工作區中設定後即可從網頁執行環境執行。
其他 MCP 客戶端
把它新增到你客戶端的 mcpServers 設定中。
{
"mcpServers": {
"treasury-fiscaldata-mcp-server": {
"type": "http",
"url": "https://treasury-fiscaldata.caseyjhand.com/mcp"
}
}
}README
@cyanheads/treasury-fiscaldata-mcp-server
Query US Treasury national debt, interest rates, exchange rates, and fiscal datasets via MCP.
Public Hosted Server: https://treasury-fiscaldata.caseyjhand.com/mcp
Overview
US Treasury Fiscal Data — national debt, interest rates, exchange rates, and other fiscal datasets. Browse a curated catalog of 17 endpoints, query any endpoint directly, or stage large pulls as DuckDB dataframes for SQL analysis, from any MCP client. Runs as a stdio process, a local Streamable HTTP server, or the public hosted endpoint above.
Tools
Capability reference
treasury_list_datasets tool
- Filter by category (
debt,interest_rates,exchange_rates,revenue_spending,savings_bonds,securities,other) or keyword search. - Returns endpoint paths, fields, types, and update cadence from a bundled catalog, with no network call.
treasury_query_dataset tool
- Query an endpoint with
{ field, operator, value }filters (eq,gt,gte,lt,lte,in), sort, and pagination:page_size1–10000 (default 100),page_numberstarts at 1. - Returns rows, field labels,
total_count, andtotal_pages; error reasons areinvalid_endpoint,invalid_field,invalid_filter, andpage_out_of_range. - Pass
canvas_idto stage the page for SQL analysis; the returnedcanvas_idis the assigned table name.
treasury_get_debt tool
mode=latestreturns the newest business-day record;mode=dateaccepts a YYYY-MM-DD date;mode=seriesaccepts a date range. Coverage begins 1993-04-01.- Returns debt totals and a 20-row series preview; compare
retrieved_recordswithtotal_records. A missing date returnsno_data_for_date. - Series staging starts above 500 rows or on request via
canvas_id; paging stops at 50,000 rows.
treasury_get_interest_rates tool
mode=latestreturns the newest month's rates, optionally filtered bysecurity_type;mode=seriesaccepts a date range.- Rates are percentages, with available security types disclosed when a filter matches nothing; the series preview holds at most 20 rows.
- Series staging starts above 200 rows or on request via
canvas_id.
treasury_get_exchange_rates tool
- Quarterly official reporting rates in foreign currency units per 1 USD. Filter
countriesby exact name;mode=latestreturns one current row per currency andmode=seriesaccepts a date range. - Each row carries
record_dateandeffective_date;mixed_record_datesflags a result spanning quarters. Series previews hold 20 rows;retrieved_recordsdiscloses progress againsttotal_records. - Series staging starts above 500 rows or on request via
canvas_id; paging stops at 50,000 rows. country_not_founderror when a requested country has no records
treasury_dataframe_describe tool
- Omit
nameto list the tenant's active dataframes, or supply one exact table name. - Returns provenance, created/expiry timestamps, row count, and column schema;
truncated/max_rowsdisclose a capped source pull. - Table expiry defaults to 24h after staging, configurable with
CANVAS_TTL_MS.
treasury_dataframe_query tool
- Accepts one read-only SELECT;
row_limitdefaults to 1000 (max 10000) andpreviewmay not exceed it. System catalogs, external-file functions, and SQL mutations are denied. - Returns rows and
row_count_capped; errors distinguishcanvas_unavailable,system_catalog_access,invalid_sql,missing_table, andinvalid_query_bounds. register_asmaterializes the full result as a new dataframe with a fresh TTL.
treasury_dataframe_drop tool
- Accepts the exact
namefromtreasury_dataframe_describe, a data tool'scanvas_id, or query'sregistered_as; deletes that table and its provenance for the tenant. - Returns
nameanddropped: true; an absent or expired table returnsmissing_tablewith guidance to list active tables. - Disabled by default. Set
TREASURY_DATAFRAME_DROP_ENABLED=trueandCANVAS_PROVIDER_TYPE=duckdbto make it callable; the HTTP landing page shows the disabled tool and enable hint otherwise.
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.
Fiscal Data-specific:
- All API values are strings;
"null"means no value. Treasury dataframe columns are VARCHAR — CAST to DECIMAL or DATE for arithmetic and date comparisons. DataCanvas requiresCANVAS_PROVIDER_TYPE=duckdb; configured canvas tools reportcanvas_unavailableotherwise. - Curated catalog of 17 endpoints with field metadata — no discovery round-trip required; pass any endpoint path directly to
treasury_query_datasetfor datasets outside the catalog - Convenience tools for the three most-queried datasets — national debt, interest rates, exchange rates
- DataCanvas integration: large pulls register as
df_<id>dataframes queryable via DuckDB SQL, with automatic staging thresholds per tool - No API key required — the US Treasury Fiscal Data API is free and public
Agent-friendly output:
- Provenance: filter-expression echo (
applied_filters) and field-label maps (field_labels) let agents verify what was sent and read raw field names - Enrichment notices: empty-result guidance, partial-country mismatches, canvas staging confirmations, and truncated-series warnings all name the next tool call
- Graceful truncation: series and query results carry
truncated/retrieved_records/row_count_cappedfields instead of silently dropping rows - Canvas provenance: source tool, original query parameters, row count, and column schema surfaced by
treasury_dataframe_describe
Getting started
Public Hosted Instance
A public instance is available at https://treasury-fiscaldata.caseyjhand.com/mcp — no installation required. Point any MCP client at it via Streamable HTTP:
Self-Hosted / Local
Add the following to your MCP client configuration file.
Or with npx (no Bun required):
Or with Docker:
For Streamable HTTP, set the transport and start the server:
DataCanvas SQL workflow
For large time-series pulls or multi-dataset analysis, use the DataCanvas SQL workflow:
- Set
CANVAS_PROVIDER_TYPE=duckdbin your server environment. - Call a data tool with a
canvas_id— e.g.,treasury_get_debtwithmode=seriesand acanvas_idvalue, ortreasury_query_datasetwithcanvas_id. The tool registers the results as adf_XXXXX_XXXXXdataframe and returns the table name. - Inspect the schema with
treasury_dataframe_describe— lists column names, types (all VARCHAR for Treasury data), row count, and TTL. - Query with SQL via
treasury_dataframe_query— standard DuckDB SELECT with joins, aggregates, window functions, and CTEs. CAST VARCHAR columns to DECIMAL or DATE for arithmetic.
Prerequisites
- Bun v1.4.0 or higher (or Node.js v24+).
- No API key required — the US Treasury Fiscal Data API is free and public.
- For DataCanvas SQL:
CANVAS_PROVIDER_TYPE=duckdb(DuckDB is bundled as@duckdb/node-api).
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:
verify:catalogmakes live Fiscal Data requests and runs separately fromdevcheckand the test suite. Run it after editingsrc/services/fiscal-data/datasets.tsand before a release.Builds type-check and emit declarations with TypeScript, then use Bun to bundle server code as Node-compatible ESM in
dist/index.js. Package dependencies remain external, including the framework and DuckDB native bindings. The installed server runs on Node or Bun; building from source requires Bun. Dependency checks useknip.jsoncto cover source, scripts, and tests.
Docker
The Dockerfile defaults to HTTP transport, stateless session mode, and logs to /var/log/treasury-fiscaldata-mcp-server. A native build-host dependency stage cross-installs DuckDB bindings for the target architecture, preserves the release-age and security checks, and removes unused musl bindings. OpenTelemetry peers are installed at the framework's declared ranges — build with --build-arg OTEL_ENABLED=false to omit them.
Project structure
Development guide
See CLAUDE.md and 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 - All Treasury API values are strings — validate and CAST in downstream SQL; never fabricate missing fields
- Register new tools via the arrays in
src/index.ts
Contributing
Issues are welcome. Run checks and tests before submitting:
License
Apache-2.0 — see LICENSE for details.
來源:README.md,提交 523602b
工具
0版本歷史
3- v0.2.0最新Oct 4, 2026
- v0.1.11Sep 21, 2026
- v0.1.10Sep 16, 2026


