Repository avatar
Search & Data Extraction
v0.3.0
active

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.

7 Tools (+1 opt-in) · 1 Skill

Version License Docker MCP SDK npm TypeScript Bun

Install in Claude Desktop Install in Cursor Install in VS Code

Framework


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

ToolDescription
boj_search_seriesFind series by code or English and Japanese keywords, filtered by database and frequency
boj_get_series_observationsFetch observations by series code or database branch, at each series' native frequency
boj_get_tankanRetrieve Tankan survey observations by item, industry, firm size, and horizon
boj_get_policy_ratesGet realized overnight call rates and the basic discount and loan rate with its change history
boj_list_referenceBrowse databases, layer paths, period formats, Tankan codes, policy-rate series, coverage gaps, and attribution
boj_dataframe_describeList staged tables, their columns, and each series' recorded and staged ranges
boj_dataframe_queryRun one read-only SQL SELECT over staged tables
boj_dataframe_dropRemove 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 query can match part of a series code or its English or Japanese metadata. An exact bare code ranks first. Filter with db, frequency (a native code such as M or a BOJ label such as MONTHLY), and active_only (default true, which drops discontinued series). Up to 100 series per page (default 25), continued with next_cursor
  • Pass a returned qualified_code, such as FM08'FXERD01, directly to boj_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 in excluded_co_matches; set db: "CO" to search it, or use boj_get_tankan
  • On a cold catalog, a db-scoped search loads only that database, while an unscoped search returns status: "catalog_loading" with the ready and missing databases until they finish. stale lists databases answered from an older catalog generation

boj_get_series_observations tool

  • Exactly one of codes (bare or qualified DB'CODE identifiers; the first 250 unique are resolved and the rest returned in unprocessed_codes) or branch (db, layer path, and frequency from boj_list_reference). Codes the catalog lacks land in not_found; a bare code shared by several databases fails as ambiguous_code with its qualified candidates
  • start_date / end_date take YYYY, YYYY-Hn, YYYY-Qn, YYYY-MM, or YYYY-MM-DD, including lowercase q and h. Returned periods use each series' native frequency and calendar convention. series_limit sets series per roster page (default 1, cap 250) and limit the newest observations returned per series (default 25, cap 1,000)
  • A long collection returns status: "collecting" and a cursor to resend with the same inputs. DuckDB automatically stages a finished roster page when it overflows the inline preview. Set stage: true to stage a smaller window for SQL. Pass the returned staged.canvas_id to add another table to that canvas.
  • Without DuckDB, use next_cursor to read earlier observations inline. Use next_selection_cursor to move to the next roster page.

boj_get_tankan tool

  • {} returns the business conditions DI (item 601) for large manufacturers and nonmanufacturers, actual and forecast. item, industries, sizes, horizons, series_type, frequency, aggregation, and detail_item take BOJ codes or the published labels from boj_list_reference topic tankan_codes
  • Same date window, cursors, and staging as boj_get_series_observations, with series_limit defaulting to 4 (cap 25); each series carries its decoded dimensions
  • For an unavailable selection, use a complete aggregation, frequency, and series_type tuple from availableCombinations. availableAggregations lists choices when changing aggregation alone resolves the selection. Check discontinuedFrequencies for historical coverage and availableSeriesTypes for alternatives at the requested frequency. For example, the predicted USD/JPY survey rate uses series type D (Average). Set include_discontinued: true to 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_code for observation lookup
  • Basic-rate changes newest first, with the first observed rate as baseline; up to 100 per page (default 25), continued with next_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 (requires db; the bilingual hierarchy headers a branch is built from), frequencies, tankan_codes (optional dimension), policy_rates, coverage_gaps, or attribution
  • Each header includes BOJ's five layer coordinates and a trimmed path. Pass path as layer to browse its immediate children or as branch.layer to retrieve observations. For example, {"topic":"layers","db":"PR01","layer":[1,1]} lists the children of [1,1]. Omit layer to page all headers in source order.
  • Up to 100 entries per page (default 25), continued with next_cursor; db applies only to layers and dimension only to tankan_codes

boj_dataframe_describe tool

  • canvas_id from a staged result, optionally narrowed to one table_name
  • Columns, row and series counts, expiry, and a manifest with each series' qualified_code and recorded and staged ranges. Manifests page at up to 100 entries (default 25), continued with the table's next_cursor and its table_name.

boj_dataframe_query tool

  • canvas_id and one read-only SELECT (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 BY with unique tie-breakers; an unordered result that overflows comes back truncated with a hint in place of next_cursor

boj_dataframe_drop tool

  • canvas_id and table_name; returns removed
  • 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 .mcpb bundle 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_reference topic coverage_gaps points 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 their lastUpdate revision and catalog publication stamp, and observation results the export_dates of the BOJ exports they read
  • Exact counts and explicit gaps: window_count, null_count, and returned_count per series and per page; dated nulls stay in staged tables and come back inline with include_nulls; not_found holds 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 collection cursor, inline next_cursor, and roster next_selection_cursor kept 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

VariableDescriptionDefault
BOJ_CATALOG_DIRWritable 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_ENABLEDSet true to register boj_dataframe_drop.false
CANVAS_PROVIDER_TYPESQL 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_TYPETransport: stdio or http.stdio
MCP_HTTP_PORTHTTP server port.3010
MCP_SESSION_MODEHTTP session mode: stateless, stateful, or auto.auto (stateless in the Docker image)
MCP_AUTH_MODEAuthentication: none, jwt, or oauth.none
MCP_LOG_LEVELLog level (debug, info, warning, error, etc.).info
LOGS_DIRDirectory for log files (Node.js only).<app-root>/logs
STORAGE_PROVIDER_TYPEStorage backend: in-memory, filesystem, supabase, cloudflare-kv/r2/d1.in-memory
OTEL_ENABLEDEnable OpenTelemetry.false
MCP_USAGE_REPORTINGSet 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

DirectoryPurpose
src/index.tscreateApp() entry point: tool registration, canvas setup, the daily HTTP catalog refresh, and shutdown.
src/catalog-cli.tsThe boj-catalog command: init, refresh, and verify.
src/mcp-server/toolsTool definitions (definitions/*.tool.ts) and the catalog and observation schemas they share.
src/servicesPaced 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/catch in tool logic
  • Use ctx.log for logging, ctx.state for storage
  • Register new tools in the createApp() tools array in src/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.

NPM
@cyanheads/bank-of-japan-mcp-server
Install Command
npm install @cyanheads/bank-of-japan-mcp-server
Runtime: npx
NPM
@cyanheads/bank-of-japan-mcp-server
Install Command
npm install @cyanheads/bank-of-japan-mcp-server
Runtime: npx