@cyanheads/bls-labor-mcp-server
Enables SQL querying of BLS time-series data stored in DuckDB dataframes, supporting SELECT, joins, aggregates, window functions, and CTEs on data fetched via bls_get_series.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@@cyanheads/bls-labor-mcp-serverget the latest unemployment rate"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Public Hosted Server: https://bls-labor.caseyjhand.com/mcp
Overview
US labor statistics from the Bureau of Labor Statistics public API v2 and LABSTAT flat-file catalog. Resolve opaque SeriesIDs from natural language, fetch historical time-series or the latest observation, and query large multi-series results with SQL through an optional DataCanvas. Runs as a stdio process, a local Streamable HTTP server, or the public hosted endpoint above.
Tools
Tool | Description |
| List BLS survey programs (CPI, CPS, CES, JOLTS, PPI, OEWS, …) with codes, descriptions, and calculation-support flags. |
| Search the BLS series catalog by natural language, survey, area, or keywords to resolve cryptic SeriesIDs. |
| Fetch time-series data for 1–50 BLS series by SeriesID, with optional year range and period-over-period calculations. |
| Return the single most recent observation for one or more BLS series. |
| List canvas dataframes registered by |
| Run a SELECT against canvas dataframes registered by |
| Drop a canvas dataframe by name. Available when |
Related MCP server: BLS MCP
Capability reference
bls_list_surveys tool
Optional
categoryfilters survey programs by subject; returns codes, names, and calculation-support flags (allowsNetChange,allowsPercentChange,hasAnnualAverages).Backed by the BLS surveys API with monthly caching. Annual-average support is advisory; read
bls_get_series'sannualAverageRowsfor the rows actually returned.
bls_search_series tool
Search by text or SeriesID, with optional
survey,area(substring of area, title, or SeriesID), andseasonal_adjustment; blank filters are omitted.limitis 1–50 (default 10), withoffsetpagination; without an area filter, equally matching national series rank first.Returns decoded SeriesIDs, titles, and
frequency. FollownextOffsetwhiletruncatedis true;capped: truemakestotalCounta lower bound, and paging stops at the FTS candidate pool.Searches the offline LABSTAT index without using API quota; OE/OEWS is opt-in through
BLS_CATALOG_INCLUDE_OES. Unindexed surveys remain fetchable by SeriesID.
bls_get_series tool
Fetch 1–50 SeriesIDs per call, with a
start_year/end_yearwindow of up to 20 years, optionalcalculations, andannual_average. A start alone resolves the end to the current year capped at start + 19; an end alone is rejected. One batch consumes one API query; calculations depend on survey support (CPI/PPI return percent change only).Returns observations with
available, preserves the raw-missing-value sentinel, and keeps valid series in mixed batches. Enrichment reports the applied year window, calculations, and annual-average rows.Large results spill to
dataset.namewhenCANVAS_PROVIDER_TYPE=duckdb; otherwisecanvas_unavailableasks for a narrower window.
bls_get_latest tool
Fetch the latest observation for up to 50 SeriesIDs (recommended ≤10). Each ID consumes one API query; use
bls_get_seriesfor a more efficient multi-series batch.Returns successful
results[]beside per-seriesfailed[]entries.latestObservation.availabledistinguishes a published value from BLS's missing-value sentinel.
bls_dataframe_describe tool
Optional
namedescribes one registered dataframe; omit it to list active dataframes for the tenant. RequiresCANVAS_PROVIDER_TYPE=duckdb.Returns source tool, query params, row count, TTL (
created_at/expires_at), andcolumn_schema; BLS columns are nullable. Registered-query types outside the canvas set (DECIMAL,HUGEINT,SMALLINT, lists) report asVARCHAR. Expired entries are removed when their canvas drop succeeds.
bls_dataframe_query tool
Run one SELECT against registered tables, with JOINs, aggregates, window functions, or CTEs.
row_limitdefaults to 1000 and caps at 10000; writes, external-file reads, and system catalogs are denied.Returns rows without consuming BLS API quota. Optional
register_asstages the result with a fresh TTL for chained analysis; requiresCANVAS_PROVIDER_TYPE=duckdb.
bls_dataframe_drop tool
Required
nameidentifies the dataframe to drop. Available only withCANVAS_PROVIDER_TYPE=duckdbandBLS_DATAFRAME_DROP_ENABLED=true; TTL handles cleanup by default.Returns
dropped: falsefor a missing table. A failed drop returns retryablecanvas_drop_failedand leaves the dataframe registered.
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.
BLS-specific:
BLS API v2 client with retry/backoff and daily quota tracking
Offline series catalog search against LABSTAT flat files, indexed as an on-disk SQLite/FTS5 store — zero API quota for discovery; the OES/OEWS wage survey (~6M series) is opt-in via
BLS_CATALOG_INCLUDE_OESTyped error contracts for BLS-specific failure modes — quota exhaustion, locked database, calculations not supported
Period-over-period net/percent-change calculations via BLS's own server-side flag, consistent with BLS's published numbers
Optional DataCanvas spillover (DuckDB) for large multi-series result sets — schema discovery and SQL access without re-querying the API
Agent-friendly output:
Provenance — canvas-spilled results carry a
dataset.namehandle plus row count and expiry;bls_search_seriesechoeseffectiveQuery,catalogSize, and whether the FTS candidate pool wascappedGraceful partial failure —
bls_get_latestreturns per-itemfailed[](seriesId + error) alongside successfulresults[]instead of failing the whole batch;bls_get_serieskeeps valid series when another SeriesID in the same batch is invalid or emptyDiscriminated outputs — every observation carries an
availableboolean for BLS's-missing-value sentinel, so callers branch on a typed field instead of parsing raw valuesActionable notices —
enrichment.noticeexplains empty results, canvas spillover, and unavailable data with concrete next steps (e.g. usingbls_search_seriesto verify a SeriesID)
Getting started
Public Hosted Instance
A public instance is available at https://bls-labor.caseyjhand.com/mcp — no installation required. Point any MCP client at it via Streamable HTTP:
{
"mcpServers": {
"bls-labor-mcp-server": {
"type": "streamable-http",
"url": "https://bls-labor.caseyjhand.com/mcp"
}
}
}Self-Hosted / Local
Add the following to your MCP client configuration file. A free BLS API key unlocks 500 queries/day — register at bls.gov/developers. The server works without a key at 25 req/day.
{
"mcpServers": {
"bls-labor-mcp-server": {
"type": "stdio",
"command": "bunx",
"args": ["@cyanheads/bls-labor-mcp-server@latest"],
"env": {
"MCP_TRANSPORT_TYPE": "stdio",
"MCP_LOG_LEVEL": "info",
"BLS_API_KEY": "your-key-here"
}
}
}
}Or with npx (no Bun required):
{
"mcpServers": {
"bls-labor-mcp-server": {
"type": "stdio",
"command": "npx",
"args": ["-y", "@cyanheads/bls-labor-mcp-server@latest"],
"env": {
"MCP_TRANSPORT_TYPE": "stdio",
"MCP_LOG_LEVEL": "info",
"BLS_API_KEY": "your-key-here"
}
}
}
}Or with Docker:
{
"mcpServers": {
"bls-labor-mcp-server": {
"type": "stdio",
"command": "docker",
"args": ["run", "-i", "--rm", "-e", "MCP_TRANSPORT_TYPE=stdio", "-e", "BLS_API_KEY=your-key-here", "ghcr.io/cyanheads/bls-labor-mcp-server:latest"]
}
}
}For Streamable HTTP, set the transport and start the server:
MCP_TRANSPORT_TYPE=http MCP_SESSION_MODE=stateless MCP_HTTP_PORT=3010 BLS_API_KEY=... bun run start:http
# Server listens at http://localhost:3010/mcpPrerequisites
Bun v1.4.0 or higher (or Node.js v24+).
A free BLS API v2 key — register at bls.gov/developers. Grants 500 queries/day; the server also works without a key at 25 req/day.
Installation
Clone the repository:
git clone https://github.com/cyanheads/bls-labor-mcp-server.gitNavigate into the directory:
cd bls-labor-mcp-serverInstall dependencies:
bun installConfigure environment:
cp .env.example .env
# edit .env and set BLS_API_KEYConfiguration
All configuration is validated at startup via Zod schemas in src/config/server-config.ts.
Variable | Description | Default |
| BLS v2 API key. Optional — 25 req/day without, 500 req/day with. Register free at bls.gov/developers. | — |
| BLS API v2 base URL. |
|
| LABSTAT flat-file base URL. Override to point at a local mirror. |
|
| On-disk SQLite catalog index — queried on demand and persisted across restarts. Empty uses an in-memory DB (re-harvested each boot). Mount a volume here in containers. |
|
| Catalog freshness window in hours — re-harvest once the index is older, checked at startup and hourly while running. |
|
| Include the OES/OEWS wage survey (~6M series / ~1.2 GB; multi-minute first harvest). Off by default — OES series stay fetchable by ID. |
|
| Serve observations from a local SQLite mirror instead of the live API (requires a one-time bootstrap — see below). |
|
| Per-dataframe TTL for canvas-registered tables, in seconds. |
|
| Expose |
|
| Set to |
|
| Transport: |
|
| HTTP server port. |
|
| Session mode. This server uses |
|
| Auth mode: |
|
| Log level (RFC 5424). |
|
| Directory for log files (Node.js only). |
|
| Enable OpenTelemetry instrumentation. |
|
| Base OTLP URL for traces and metrics; signal-specific endpoints override it. | — |
| Opt-in OTLP log endpoint. The base URL never enables log export. | — |
| Log failed-call arguments and results, redacted by key name; secrets in free-form values remain. |
|
| UTF-8 byte cap per logged failure payload. |
|
See .env.example for the full list of optional overrides.
Observation mirror (optional)
For high-volume workloads, an opt-in local mirror serves bls_get_series / bls_get_latest from an embedded SQLite store instead of the BLS API — eliminating the 500/day quota cap. It is off by default. To enable:
Set
BLS_OBSERVATIONS_MIRROR_ENABLED=true(and review theBLS_OBSERVATIONS_MIRROR_*vars in.env.example).Run the one-time bootstrap out-of-band — it downloads the full LABSTAT observation set and can take a while:
node dist/services/bls-observations/subprocess.js --init
The mirror harvests every survey in the catalog's survey list — OE included, whatever BLS_CATALOG_INCLUDE_OES says — so it covers CM and CI too (about 55 MB of cm.data.* / ci.data.* files). An incremental refresh reads only files published after the mirror's last one, so a mirror bootstrapped before CM and CI joined picks each file up at its next BLS publication; until then those series come from the live API when fallback is on. Until the bootstrap completes, requests fall back to the live API (unless BLS_OBSERVATIONS_MIRROR_FALLBACK_LIVE=false). When a live fallback fails — quota exhausted, BLS unreachable — the series the mirror served are still returned, and enrichment.notice names each unserved SeriesID with the failure's reason and recovery. Mirror rows carry no BLS calculations: with calculations: true, a mirror-served series comes back without calculation fields, enrichment.calculationsApplied is false, and the notice names it. On HTTP transport, an incremental refresh runs on the BLS_OBSERVATIONS_MIRROR_REFRESH_CRON schedule. In containers, mount a persistent volume at BLS_OBSERVATIONS_MIRROR_PATH.
Upgrading an existing mirror. A mirror bootstrapped before sentinel rows were stored is missing the periods BLS publishes with its - missing-value marker. Opening such a mirror clears its sync checkpoint once, so the next refresh re-reads every LABSTAT file and fills them in — no operator action beyond letting that refresh run, and it takes as long as a full read. The mirror keeps serving throughout.
Running the server
Local development
Build and run:
# One-time build bun run rebuild # Run the built server bun run start:stdio # or bun run start:httpRun checks and tests:
bun run devcheck # Lint, format, typecheck, security bun run test # Vitest test suite bun run lint:mcp # Validate MCP definitions against spec
Docker
docker build -t bls-labor-mcp-server .
docker run --rm -e BLS_API_KEY=your-key -e MCP_TRANSPORT_TYPE=http -p 3010:3010 bls-labor-mcp-serverThe Dockerfile defaults to HTTP transport, stateless session mode, and logs to /var/log/bls-labor-mcp-server. OpenTelemetry peer dependencies are installed by default — build with --build-arg OTEL_ENABLED=false to omit them.
Project structure
Directory | Purpose |
|
|
| Server-specific environment variable parsing and validation with Zod. |
| Tool definitions ( |
| BLS API v2 service — batch fetch, latest-value GET, surveys metadata. |
| LABSTAT flat-file catalog — offline series index and search. |
| Optional LABSTAT observation mirror — embedded SQLite store, ingester, and refresh subprocess. |
| Annual-average period semantics ( |
| DataCanvas bridge — dataframe registration, SQL gate, lifecycle management. |
| Full tool surface specification, service architecture, and error contracts. |
| Unit and integration tests mirroring |
Development guide
See CLAUDE.md for development guidelines and architectural rules. The short version:
Handlers throw, framework catches — no
try/catchin tool logicUse
ctx.logfor request-scoped logging,ctx.statefor tenant-scoped storagebls_search_seriesis the anchor tool — design workflows to call it before the API toolsWrap BLS 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 testLicense
Apache-2.0 — see LICENSE for details.
This server cannot be deployed
Maintenance
Related MCP Connectors
BLS MCP — Bureau of Labor Statistics public data API (v2)
Econdata MCP — wraps BLS (Bureau of Labor Statistics) public API v2
Public MCP server for discovering open jobs. Search, filter, and get application links.
CareerOneStop MCP — wraps the CareerOneStop Web API (U.S. Dept. of Labor)
Related MCP Servers
- AlicenseAqualityDmaintenanceEnables access to Bureau of Labor Statistics (BLS) economic data including Consumer Price Index, employment statistics, and other labor market indicators. Supports fetching data series, listing available datasets, and retrieving metadata through natural language queries.4MIT
- AlicenseAqualityCmaintenanceEnables users to query U.S. labor statistics, including employment, CPI, and wages, directly from the Bureau of Labor Statistics Public Data API. It provides tools to retrieve real-time economic time series data, browse popular series, and access survey metadata through natural language.6110 npm1MIT
- FlicenseNot gradedqualityDmaintenanceEconomic data MCP server that connects FRED, BLS, BEA, IMF, World Bank, and ECB to any MCP-compatible client, with built-in methodology rules to guide LLMs in selecting appropriate economic indicators.-
- AlicenseAqualityBmaintenanceMCP server providing official US economic data including CPI inflation, famous prices, national debt, and Treasury interest rates. Enables AI agents to query historical and latest economic statistics via natural language.827 npmMIT