
bank-of-japan-mcp-server
io.github.cyanheads/bank-of-japan-mcp-server
Search Bank of Japan statistics and retrieve time series, Tankan surveys, and policy rates.
Documentation
@cyanheads/bank-of-japan-mcp-server
Search Bank of Japan statistics and retrieve time series, Tankan surveys, and policy rates via MCP. STDIO or Streamable HTTP.
Public Hosted Server: https://bank-of-japan.caseyjhand.com/mcp
Overview
Statistics from the Bank of Japan's Time-Series Data Search, across all 50 of its databases. Search series metadata in English or Japanese, pull observations at each series' published frequency, select Tankan survey series by industry and firm size, and read realized overnight call rates alongside the basic discount and loan rate. Large observation windows can be staged as DuckDB tables and queried with SQL. Runs as a stdio process, a local Streamable HTTP server, or the public hosted endpoint above, with no API key.
Tools
| Tool | Description |
|---|---|
boj_search_series | Find series by code or English and Japanese keywords, filtered by database and frequency |
boj_get_series_observations | Fetch observations by series code or database branch, at each series' native frequency |
boj_get_tankan | Retrieve Tankan survey observations by item, industry, firm size, and horizon |
boj_get_policy_rates | Get realized overnight call rates and the basic discount and loan rate with its change history |
boj_list_reference | Browse databases, layer paths, period formats, Tankan codes, policy-rate series, coverage gaps, and attribution |
boj_dataframe_describe | List staged tables, their columns, and each series' recorded and staged ranges |
boj_dataframe_query | Run one read-only SQL SELECT over staged tables |
boj_dataframe_drop | Remove a staged table. Opt-in via BOJ_DATAFRAME_DROP_ENABLED=true |
Capability reference
The Bank of Japan guide covers catalog discovery, Tankan selections, and SQL across staged series. MCP clients can read it at skill://bank-of-japan-guide/SKILL.md.
boj_search_series tool
- Each word in
querycan match part of a series code or its English or Japanese metadata. An exact bare code ranks first. Filter withdb,frequency(a native code such asMor a BOJ label such asMONTHLY), andactive_only(defaulttrue, which drops discontinued series). Up to 100 series per page (default 25), continued withnext_cursor - Pass a returned
qualified_code, such asFM08'FXERD01, directly toboj_get_series_observations. Both tools accept the typographic separators’and'in qualified codes. - Unscoped searches leave out the Tankan database (
CO) and report its matches inexcluded_co_matches; setdb: "CO"to search it, or useboj_get_tankan - On a cold catalog, a
db-scoped search loads only that database, while an unscoped search returnsstatus: "catalog_loading"with thereadyandmissingdatabases until they finish.stalelists databases answered from an older catalog generation
boj_get_series_observations tool
- Exactly one of
codes(bare or qualifiedDB'CODEidentifiers; the first 250 unique are resolved and the rest returned inunprocessed_codes) orbranch(db,layerpath, andfrequencyfromboj_list_reference). Codes the catalog lacks land innot_found; a bare code shared by several databases fails asambiguous_codewith its qualified candidates start_date/end_datetakeYYYY,YYYY-Hn,YYYY-Qn,YYYY-MM, orYYYY-MM-DD, including lowercaseqandh. Returned periods use each series' native frequency and calendar convention.series_limitsets series per roster page (default 1, cap 250) andlimitthe newest observations returned per series (default 25, cap 1,000)- A long collection returns
status: "collecting"and acursorto resend with the same inputs. DuckDB automatically stages a finished roster page when it overflows the inline preview. Setstage: trueto stage a smaller window for SQL. Pass the returnedstaged.canvas_idto add another table to that canvas. - Without DuckDB, use
next_cursorto read earlier observations inline. Usenext_selection_cursorto move to the next roster page.
boj_get_tankan tool
{}returns the business conditions DI (item601) for large manufacturers and nonmanufacturers, actual and forecast.item,industries,sizes,horizons,series_type,frequency,aggregation, anddetail_itemtake BOJ codes or the published labels fromboj_list_referencetopictankan_codes- Same date window, cursors, and staging as
boj_get_series_observations, withseries_limitdefaulting to 4 (cap 25); each series carries its decodeddimensions - For an unavailable selection, use a complete
aggregation,frequency, andseries_typetuple fromavailableCombinations.availableAggregationslists choices when changing aggregation alone resolves the selection. CheckdiscontinuedFrequenciesfor historical coverage andavailableSeriesTypesfor alternatives at the requested frequency. For example, the predicted USD/JPY survey rate uses series typeD(Average). Setinclude_discontinued: trueto include discontinued series.
boj_get_policy_rates tool
- The latest daily uncollateralized overnight call rate (average, high, low), the latest monthly average, and the latest basic discount and loan rate, each with its own latest date and
qualified_codefor observation lookup - Basic-rate changes newest first, with the first observed rate as
baseline; up to 100 per page (default 25), continued withnext_cursor. Reads BOJ directly, so it answers before the catalog has loaded
boj_list_reference tool
topic:databases(codes, names, categories, and per-database catalog status and counts),layers(requiresdb; the bilingual hierarchy headers abranchis built from),frequencies,tankan_codes(optionaldimension),policy_rates,coverage_gaps, orattribution- Each header includes BOJ's five
layercoordinates and a trimmedpath. Passpathaslayerto browse its immediate children or asbranch.layerto retrieve observations. For example,{"topic":"layers","db":"PR01","layer":[1,1]}lists the children of[1,1]. Omitlayerto page all headers in source order. - Up to 100 entries per page (default 25), continued with
next_cursor;dbapplies only tolayersanddimensiononly totankan_codes
boj_dataframe_describe tool
canvas_idfrom astagedresult, optionally narrowed to onetable_name- Columns, row and series counts, expiry, and a manifest with each series'
qualified_codeand recorded and staged ranges. Manifests page at up to 100 entries (default 25), continued with the table'snext_cursorand itstable_name.
boj_dataframe_query tool
canvas_idand one read-onlySELECT(CTEs allowed), up to 65,536 UTF-16 code units, under a 30-second deadline that includes waiting for the canvas- Up to 1,000 rows per page (default 25). Paging needs a top-level
ORDER BYwith unique tie-breakers; an unordered result that overflows comes backtruncatedwith ahintin place ofnext_cursor
boj_dataframe_drop tool
canvas_idandtable_name; returnsremoved- Not registered unless
BOJ_DATAFRAME_DROP_ENABLED=true, and needs DuckDB
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.
BOJ-specific:
- A local catalog of series metadata for all 50 databases, kept in SQLite (or a flat-file cache where no SQLite binding loads) and filled one database at a time on first use. Disk use grows with the databases loaded: a SQLite catalog holding FM01, FM08, and CO measured about 580 MB, most of it CO
- One queue paces every BOJ request, catalog downloads included, at least 2 seconds apart, so loading the whole catalog cold takes a while
- BOJ republishes its catalog at 09:00 JST (00:00 UTC). The HTTP server refreshes the local copy daily at 00:01 UTC, and a result answered from a copy older than the current BOJ day names those databases in
stale - Native installs (npm, Docker) stage observation windows in DuckDB for SQL; the Claude Desktop
.mcpbbundle runs with the canvas off and continues observations inline - BOJ's API carries no Japanese Government Bond yields and no announced policy target.
boj_list_referencetopiccoverage_gapspoints to the Ministry of Finance JGB yield series and the BOJ Monetary Policy Meetings archive
Agent-friendly output:
- Provenance: every result carries BOJ's required
attribution; series rows add theirlastUpdaterevision and catalogpublicationstamp, and observation results theexport_datesof the BOJ exports they read - Exact counts and explicit gaps:
window_count,null_count, andreturned_countper series and per page; dated nulls stay in staged tables and come back inline withinclude_nulls;not_foundholds only codes the catalog confirms absent - Disclosed caps: observation and dataframe results report requested and applied limits, and search, reference, and policy results add a notice when a page size is capped
- Typed states:
status(ready,collecting,catalog_loading,catalog_unavailable), with the collectioncursor, inlinenext_cursor, and rosternext_selection_cursorkept separate
Getting started
Connect to the hosted instance, no install:
claude mcp add --transport http bank-of-japan-mcp-server https://bank-of-japan.caseyjhand.com/mcp
Or run it locally:
claude mcp add bank-of-japan-mcp-server -- npx -y @cyanheads/bank-of-japan-mcp-server
For other clients, add this to the MCP config file:
{
"mcpServers": {
"bank-of-japan-mcp-server": {
"command": "npx",
"args": ["-y", "@cyanheads/bank-of-japan-mcp-server"]
}
}
}
No API key is needed; the package runs on Node.js 24 or later. Setting BOJ_DATAFRAME_DROP_ENABLED=true (-e BOJ_DATAFRAME_DROP_ENABLED=true, or an env entry) adds boj_dataframe_drop. For Docker or a source build, see Running the server.
Configuration
| Variable | Description | Default |
|---|---|---|
BOJ_CATALOG_DIR | Writable directory for the persisted series catalog. Use the same one for the server and boj-catalog. | $XDG_CACHE_HOME/bank-of-japan-mcp-server, else ~/.cache/bank-of-japan-mcp-server |
BOJ_DATAFRAME_DROP_ENABLED | Set true to register boj_dataframe_drop. | false |
CANVAS_PROVIDER_TYPE | SQL staging engine. none turns staging off; observations then continue inline and the dataframe tools report canvas_unavailable. | duckdb (none in the .mcpb bundle) |
MCP_TRANSPORT_TYPE | Transport: stdio or http. | stdio |
MCP_HTTP_PORT | HTTP server port. | 3010 |
MCP_SESSION_MODE | HTTP session mode: stateless, stateful, or auto. | auto (stateless in the Docker image) |
MCP_AUTH_MODE | Authentication: none, jwt, or oauth. | none |
MCP_LOG_LEVEL | Log level (debug, info, warning, error, etc.). | info |
LOGS_DIR | Directory for log files (Node.js only). | <app-root>/logs |
STORAGE_PROVIDER_TYPE | Storage backend: in-memory, filesystem, supabase, cloudflare-kv/r2/d1. | in-memory |
OTEL_ENABLED | Enable OpenTelemetry. | false |
MCP_USAGE_REPORTING | Set true to send daily and shutdown summaries of tool-call counts, failure kinds, and latency buckets to https://telemetry.cyanheads.com/v1/reports. Set DO_NOT_TRACK=1 to turn reporting off, or set MCP_USAGE_REPORTING_ENDPOINT to use a different receiver. | false |
See .env.example for every server setting and the common framework overrides.
Running the server
Local development
Requires Bun v1.4.4 or higher (or Node.js v24+).
-
Clone and install:
git clone https://github.com/cyanheads/bank-of-japan-mcp-server.git cd bank-of-japan-mcp-server && bun install -
Build and run the production version:
# One-time build bun run rebuild # Run the built server bun run start:http # or bun run start:stdio -
Run checks and tests:
bun run devcheck # Lints, formats, type-checks, and more bun run test # Runs the test suite
Catalog
Each database's catalog downloads from BOJ the first time a call needs it. To load or check all 50 ahead of time, run the package's boj-catalog command with the same BOJ_CATALOG_DIR as the server:
npx -y -p @cyanheads/bank-of-japan-mcp-server boj-catalog init # load missing or out-of-date databases
npx -y -p @cyanheads/bank-of-japan-mcp-server boj-catalog refresh # reload every database
npx -y -p @cyanheads/bank-of-japan-mcp-server boj-catalog verify # exit non-zero if any database is missing
From a source build, bun run mirror:init, bun run mirror:refresh, and bun run mirror:verify do the same.
Docker
docker run --rm -p 127.0.0.1:3010:3010 -v boj-catalog:/usr/src/app/.mirror ghcr.io/cyanheads/bank-of-japan-mcp-server:latest
The image defaults to HTTP transport and stateless session mode, logs to /var/log/bank-of-japan-mcp-server, and keeps its catalog in /usr/src/app/.mirror, which the volume above persists across restarts. To run it over stdio from an MCP client, use "command": "docker" with "args": ["run", "-i", "--rm", "-e", "MCP_TRANSPORT_TYPE=stdio", "-v", "boj-catalog:/usr/src/app/.mirror", "ghcr.io/cyanheads/bank-of-japan-mcp-server:latest"]. To build locally, docker build -t bank-of-japan-mcp-server .; OpenTelemetry peer dependencies are installed by default — build with --build-arg OTEL_ENABLED=false to omit them.
Project structure
| Directory | Purpose |
|---|---|
src/index.ts | createApp() entry point: tool registration, canvas setup, the daily HTTP catalog refresh, and shutdown. |
src/catalog-cli.ts | The boj-catalog command: init, refresh, and verify. |
src/mcp-server/tools | Tool definitions (definitions/*.tool.ts) and the catalog and observation schemas they share. |
src/services | Paced BOJ client, SQLite and flat-file catalogs, observation collection, Tankan codebook, policy-rate history, and DuckDB staging. |
tests/ | Unit and fixture-backed integration tests. |
Development guide
See CLAUDE.md for development guidelines and architectural rules, and docs/design.md for the design notes. The short version:
- Handlers throw, framework catches — no
try/catchin tool logic - Use
ctx.logfor logging,ctx.statefor storage - Register new tools in the
createApp()toolsarray insrc/index.ts - Wrap external API calls: validate raw → normalize to domain type → return output schema; never fabricate missing fields
Contributing
Issues are welcome. Run checks and tests before submitting:
bun run devcheck
bun run test
License
This project is licensed under the Apache 2.0 License. See the LICENSE file for details.
The Bank of Japan's terms govern reuse of its data. Its site notice requires source credit when copying data, and prior permission for commercial reproduction, designated materials, and images. See the Time-Series Data Search site notice, API notice, API manual, and Tankan codebook.
This service uses the API provided by the "Bank of Japan Time-Series Data Search." The Bank of Japan does not guarantee the content of the service.
@cyanheads/bank-of-japan-mcp-servernpm install @cyanheads/bank-of-japan-mcp-server@cyanheads/bank-of-japan-mcp-servernpm install @cyanheads/bank-of-japan-mcp-serverRemote
Related Servers
io.github.cyanheads/anime-mcp-server
Search anime/manga, franchise relations, schedule, characters, rankings, studio filmography.
io.github.cyanheads/art-institute-chicago-mcp-server
Search the Art Institute of Chicago collection: artworks, artists, exhibitions, and audio guides.
io.github.cyanheads/arxiv-mcp-server
Search arXiv, fetch paper metadata, and read full-text content.