mcp-cnbs 1.0.2 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +324 -91
- package/README.zh-CN.md +338 -81
- package/dist/index.d.ts +0 -2
- package/dist/index.js +5805 -285
- package/dist/index.js.map +1 -1
- package/llms.txt +2 -2
- package/package.json +26 -12
- package/dist/constants/index.d.ts +0 -3
- package/dist/constants/index.d.ts.map +0 -1
- package/dist/constants/index.js +0 -3
- package/dist/constants/index.js.map +0 -1
- package/dist/constants/regions.d.ts +0 -16
- package/dist/constants/regions.d.ts.map +0 -1
- package/dist/constants/regions.js +0 -68
- package/dist/constants/regions.js.map +0 -1
- package/dist/constants.d.ts +0 -7
- package/dist/constants.d.ts.map +0 -1
- package/dist/constants.js +0 -7
- package/dist/constants.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/server.d.ts +0 -3
- package/dist/server.d.ts.map +0 -1
- package/dist/server.js +0 -44
- package/dist/server.js.map +0 -1
- package/dist/services/api.d.ts +0 -47
- package/dist/services/api.d.ts.map +0 -1
- package/dist/services/api.js +0 -434
- package/dist/services/api.js.map +0 -1
- package/dist/services/cache.d.ts +0 -48
- package/dist/services/cache.d.ts.map +0 -1
- package/dist/services/cache.js +0 -215
- package/dist/services/cache.js.map +0 -1
- package/dist/services/data.d.ts +0 -16
- package/dist/services/data.d.ts.map +0 -1
- package/dist/services/data.js +0 -90
- package/dist/services/data.js.map +0 -1
- package/dist/services/error.d.ts +0 -44
- package/dist/services/error.d.ts.map +0 -1
- package/dist/services/error.js +0 -171
- package/dist/services/error.js.map +0 -1
- package/dist/services/search.d.ts +0 -18
- package/dist/services/search.d.ts.map +0 -1
- package/dist/services/search.js +0 -39
- package/dist/services/search.js.map +0 -1
- package/dist/tools/index.d.ts +0 -3
- package/dist/tools/index.d.ts.map +0 -1
- package/dist/tools/index.js +0 -686
- package/dist/tools/index.js.map +0 -1
- package/dist/types/index.d.ts +0 -182
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/index.js +0 -16
- package/dist/types/index.js.map +0 -1
- package/dist/worker.d.ts +0 -17
- package/dist/worker.d.ts.map +0 -1
- package/dist/worker.js +0 -262
- package/dist/worker.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,225 +1,458 @@
|
|
|
1
1
|
# CNBS MCP Server
|
|
2
2
|
|
|
3
|
-
MCP server for querying China National Bureau of Statistics data.
|
|
3
|
+
MCP server for querying China National Bureau of Statistics (NBS) data and major international statistical databases. All data is fetched from real APIs — no mock data.
|
|
4
|
+
|
|
5
|
+
## Data Sources
|
|
6
|
+
|
|
7
|
+
| Source | Auth | Coverage |
|
|
8
|
+
|--------|------|----------|
|
|
9
|
+
| **China NBS** (data.stats.gov.cn) | None | Monthly/Quarterly/Yearly/Provincial domestic data |
|
|
10
|
+
| **World Bank** (api.worldbank.org) | None | 200+ countries — GDP, CPI, trade, population, FDI, Gini, etc. |
|
|
11
|
+
| **IMF DataMapper** | None | WEO forecasts — GDP growth, inflation, government debt, current account |
|
|
12
|
+
| **OECD SDMX** | None | Member-country quarterly GDP, employment, leading indicators |
|
|
13
|
+
| **BIS Statistics** | None | Effective exchange rates, credit gaps, property prices, cross-border banking |
|
|
14
|
+
| **FRED** (Federal Reserve) | `X-Fred-Api-Key` request header | US rates, CNY/USD, oil, gold, S&P 500, M2 |
|
|
15
|
+
| **NBS Census** | None | Population (2020), Economic (2018), Agriculture (2016) censuses |
|
|
16
|
+
| **NBS Departments** | None | Finance, Industry, Trade, Agriculture, PBoC monetary, Social Security, Housing, Energy |
|
|
17
|
+
|
|
18
|
+
> **FRED API Key:** Free registration at https://fred.stlouisfed.org/docs/api/api_key.html
|
|
19
|
+
> Add it to your MCP client config as the `X-Fred-Api-Key` request header (see configuration examples below).
|
|
20
|
+
> For stdio mode, `FRED_API_KEY` environment variable is supported as a fallback.
|
|
21
|
+
|
|
22
|
+
---
|
|
4
23
|
|
|
5
24
|
## Installation
|
|
6
25
|
|
|
7
26
|
### Use with npx (Recommended)
|
|
8
27
|
|
|
9
28
|
```bash
|
|
10
|
-
npx
|
|
29
|
+
npx mcp-cnbs
|
|
11
30
|
```
|
|
12
31
|
|
|
13
|
-
###
|
|
32
|
+
### HTTP transport
|
|
14
33
|
|
|
15
34
|
```bash
|
|
16
|
-
npx
|
|
35
|
+
npx mcp-cnbs --port 12345
|
|
17
36
|
```
|
|
18
37
|
|
|
19
38
|
### Install globally
|
|
20
39
|
|
|
21
40
|
```bash
|
|
22
|
-
npm install -g
|
|
41
|
+
npm install -g mcp-cnbs
|
|
23
42
|
mcp-cnbs
|
|
24
43
|
```
|
|
25
44
|
|
|
45
|
+
---
|
|
46
|
+
|
|
26
47
|
## MCP Client Configuration
|
|
27
48
|
|
|
28
|
-
### NPX
|
|
49
|
+
### NPX mode (local)
|
|
50
|
+
|
|
51
|
+
**Supported clients:** Claude Desktop, Cursor, Windsurf, Cherry Studio, Trae, Continue, and all MCP-compatible clients.
|
|
29
52
|
|
|
30
|
-
|
|
53
|
+
```json
|
|
54
|
+
{
|
|
55
|
+
"mcpServers": {
|
|
56
|
+
"cnbs": {
|
|
57
|
+
"command": "npx",
|
|
58
|
+
"args": ["mcp-cnbs"]
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
```
|
|
31
63
|
|
|
32
|
-
|
|
64
|
+
With FRED support (stdio mode — env var fallback):
|
|
33
65
|
|
|
34
66
|
```json
|
|
35
67
|
{
|
|
36
68
|
"mcpServers": {
|
|
37
69
|
"cnbs": {
|
|
38
70
|
"command": "npx",
|
|
39
|
-
"args": ["
|
|
71
|
+
"args": ["mcp-cnbs"],
|
|
72
|
+
"env": {
|
|
73
|
+
"FRED_API_KEY": "your_fred_api_key"
|
|
74
|
+
}
|
|
40
75
|
}
|
|
41
76
|
}
|
|
42
77
|
}
|
|
43
78
|
```
|
|
44
79
|
|
|
45
|
-
### HTTP
|
|
80
|
+
### HTTP mode (remote access)
|
|
81
|
+
|
|
82
|
+
**Supported clients:** Trae, Cherry Studio, and other clients with HTTP transport support.
|
|
46
83
|
|
|
47
|
-
**
|
|
84
|
+
**Free demo on ModelScope (no FRED):**
|
|
85
|
+
```json
|
|
86
|
+
{
|
|
87
|
+
"mcpServers": {
|
|
88
|
+
"cnbs": {
|
|
89
|
+
"url": "https://mcp.api-inference.modelscope.net/c2ca6ece4e9946/mcp"
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
```
|
|
48
94
|
|
|
49
|
-
**
|
|
95
|
+
**HTTP mode with FRED support** — pass your key as a request header:
|
|
50
96
|
```json
|
|
51
97
|
{
|
|
52
98
|
"mcpServers": {
|
|
53
99
|
"cnbs": {
|
|
54
|
-
"url": "https://
|
|
100
|
+
"url": "https://your-cnbs-server/mcp",
|
|
101
|
+
"headers": {
|
|
102
|
+
"X-Fred-Api-Key": "your_fred_api_key"
|
|
103
|
+
}
|
|
55
104
|
}
|
|
56
105
|
}
|
|
57
106
|
}
|
|
58
107
|
```
|
|
59
108
|
|
|
60
|
-
>
|
|
61
|
-
>
|
|
62
|
-
> Since free services may change, we recommend deploying your own instance: [Deploy on ModelScope](https://modelscope.cn/mcp/servers/thatcoder/cnbs)
|
|
109
|
+
> Free public demo by Alibaba Cloud ModelScope. No auth required.
|
|
110
|
+
> For production use, [deploy your own instance](https://modelscope.cn/mcp/servers/thatcoder/cnbs).
|
|
63
111
|
|
|
64
|
-
|
|
112
|
+
---
|
|
113
|
+
|
|
114
|
+
## HTTP Endpoints
|
|
65
115
|
|
|
66
116
|
| Endpoint | Method | Description |
|
|
67
117
|
|----------|--------|-------------|
|
|
68
|
-
| `/` | POST | Streamable HTTP
|
|
69
|
-
| `/` | GET | SSE stream
|
|
118
|
+
| `/` or `/mcp` | POST | Streamable HTTP — initialize session or send requests |
|
|
119
|
+
| `/` or `/mcp` | GET | SSE notification stream (requires `Mcp-Session-Id` header) |
|
|
120
|
+
| `/` or `/mcp` | DELETE | Terminate session (requires `Mcp-Session-Id` header) |
|
|
70
121
|
| `/sse` | GET | Legacy SSE mode |
|
|
71
122
|
| `/message` | POST | Legacy SSE messages |
|
|
72
123
|
|
|
124
|
+
---
|
|
125
|
+
|
|
73
126
|
## Tools
|
|
74
127
|
|
|
75
|
-
###
|
|
128
|
+
### NBS Core Query
|
|
76
129
|
|
|
77
130
|
| Tool | Description |
|
|
78
131
|
|------|-------------|
|
|
79
|
-
| `cnbs_search` | Search by keyword, returns latest
|
|
132
|
+
| `cnbs_search` | Search by keyword, returns latest value — **use this first** |
|
|
133
|
+
| `cnbs_batch_search` | Batch search multiple keywords at once |
|
|
80
134
|
| `cnbs_fetch_nodes` | Get category tree nodes |
|
|
81
135
|
| `cnbs_fetch_metrics` | Get indicator list for a dataset |
|
|
82
|
-
| `cnbs_fetch_series` | Get time series data |
|
|
136
|
+
| `cnbs_fetch_series` | Get time series data (value may be empty — use `cnbs_search` for latest) |
|
|
83
137
|
| `cnbs_fetch_end_nodes` | Recursively get all leaf nodes |
|
|
84
|
-
| `cnbs_batch_search` | Batch search multiple keywords |
|
|
85
138
|
| `cnbs_compare` | Compare data across regions or time periods |
|
|
86
139
|
|
|
87
|
-
### Reference
|
|
140
|
+
### NBS Reference & Sync
|
|
141
|
+
|
|
142
|
+
| Tool | Description |
|
|
143
|
+
|------|-------------|
|
|
144
|
+
| `cnbs_get_regions` | Get region codes and names |
|
|
145
|
+
| `cnbs_get_categories` | Get all NBS category codes |
|
|
146
|
+
| `cnbs_sync_data` | Sync data from NBS API |
|
|
147
|
+
| `cnbs_get_sync_status` | Get sync status |
|
|
148
|
+
| `cnbs_check_data_freshness` | Check data freshness for a dataset |
|
|
149
|
+
| `cnbs_list_data_sources` | List all available data sources |
|
|
150
|
+
| `cnbs_fetch_data_from_source` | Fetch data from any named source |
|
|
151
|
+
| `cnbs_get_source_categories` | Get categories for a source |
|
|
152
|
+
| `cnbs_search_in_source` | Search within a specific source |
|
|
153
|
+
|
|
154
|
+
### World Bank
|
|
155
|
+
|
|
156
|
+
| Tool | Description |
|
|
157
|
+
|------|-------------|
|
|
158
|
+
| `ext_world_bank` | Query a single indicator across countries and years |
|
|
159
|
+
| `ext_world_bank_multi` | Query multiple indicators at once for cross-country comparison |
|
|
160
|
+
| `ext_world_bank_indicators` | List all supported World Bank indicators |
|
|
161
|
+
|
|
162
|
+
### IMF
|
|
163
|
+
|
|
164
|
+
| Tool | Description |
|
|
165
|
+
|------|-------------|
|
|
166
|
+
| `ext_imf` | Query IMF WEO indicator data by country and period |
|
|
167
|
+
| `ext_imf_indicators` | List supported IMF indicators |
|
|
168
|
+
| `ext_imf_all_indicators` | Fetch the full IMF DataMapper indicator catalog |
|
|
169
|
+
|
|
170
|
+
### OECD
|
|
171
|
+
|
|
172
|
+
| Tool | Description |
|
|
173
|
+
|------|-------------|
|
|
174
|
+
| `ext_oecd` | Query OECD SDMX data by dataset and key |
|
|
175
|
+
| `ext_oecd_datasets` | List supported OECD datasets |
|
|
176
|
+
|
|
177
|
+
### BIS
|
|
178
|
+
|
|
179
|
+
| Tool | Description |
|
|
180
|
+
|------|-------------|
|
|
181
|
+
| `ext_bis` | Query BIS statistics (exchange rates, credit gaps, property prices, etc.) |
|
|
182
|
+
| `ext_bis_datasets` | List supported BIS datasets with key templates |
|
|
183
|
+
|
|
184
|
+
### FRED (Federal Reserve)
|
|
185
|
+
|
|
186
|
+
| Tool | Description |
|
|
187
|
+
|------|-------------|
|
|
188
|
+
| `ext_fred` | Query FRED series (rates, FX, commodities, US macro) |
|
|
189
|
+
| `ext_fred_series` | List all supported FRED series |
|
|
190
|
+
|
|
191
|
+
### China Extended Sources
|
|
192
|
+
|
|
193
|
+
| Tool | Description |
|
|
194
|
+
|------|-------------|
|
|
195
|
+
| `ext_cn_census` | Query NBS census data (population, economic, agriculture) |
|
|
196
|
+
| `ext_cn_department` | Query NBS department statistics by ministry |
|
|
197
|
+
| `ext_cn_department_list` | List all department categories and their indicator keywords |
|
|
198
|
+
|
|
199
|
+
### Cross-Source Comparison
|
|
200
|
+
|
|
201
|
+
| Tool | Description |
|
|
202
|
+
|------|-------------|
|
|
203
|
+
| `ext_global_compare` | Simultaneously query World Bank + IMF for the same indicator across countries |
|
|
204
|
+
|
|
205
|
+
### Data Analysis
|
|
206
|
+
|
|
207
|
+
| Tool | Description |
|
|
208
|
+
|------|-------------|
|
|
209
|
+
| `cnbs_analyze_trend` | Trend direction, change amount, slope |
|
|
210
|
+
| `cnbs_analyze_correlation` | Pearson correlation between two series |
|
|
211
|
+
| `cnbs_detect_anomalies` | Outlier detection (std-dev threshold) |
|
|
212
|
+
| `cnbs_analyze_statistics` | Mean, median, std dev, min, max |
|
|
213
|
+
| `cnbs_analyze_time_series` | Trend + seasonality decomposition |
|
|
214
|
+
| `cnbs_predict_data` | Linear extrapolation for future values |
|
|
215
|
+
| `cnbs_assess_data_quality` | Completeness, accuracy, consistency |
|
|
216
|
+
| `cnbs_generate_summary` | Summary of a data array |
|
|
217
|
+
|
|
218
|
+
### Data Transformation
|
|
219
|
+
|
|
220
|
+
| Tool | Description |
|
|
221
|
+
|------|-------------|
|
|
222
|
+
| `cnbs_normalize_data` | Min-max normalization to [0, 1] |
|
|
223
|
+
| `cnbs_standardize_data` | Z-score standardization |
|
|
224
|
+
| `cnbs_moving_average` | Simple moving average |
|
|
225
|
+
| `cnbs_exponential_smoothing` | Exponential smoothing |
|
|
226
|
+
|
|
227
|
+
### Visualization
|
|
88
228
|
|
|
89
229
|
| Tool | Description |
|
|
90
230
|
|------|-------------|
|
|
91
|
-
| `
|
|
92
|
-
|
|
231
|
+
| `cnbs_generate_chart` | Generate ECharts/Chart.js/D3.js chart config |
|
|
232
|
+
|
|
233
|
+
Supported chart types: `line` `bar` `pie` `scatter` `radar` `heatmap` `treemap` `gauge`
|
|
93
234
|
|
|
94
235
|
### Utilities
|
|
95
236
|
|
|
96
237
|
| Tool | Description |
|
|
97
238
|
|------|-------------|
|
|
98
|
-
| `cnbs_get_guide` | Get
|
|
99
|
-
| `cnbs_get_cache_stats` |
|
|
100
|
-
| `cnbs_format_number` | Format
|
|
239
|
+
| `cnbs_get_guide` | Get the full tool guide (useful for LLMs) |
|
|
240
|
+
| `cnbs_get_cache_stats` | Cache hit/miss statistics |
|
|
241
|
+
| `cnbs_format_number` | Format a number with precision |
|
|
242
|
+
| `cnbs_enhanced_format_number` | Format as fixed / compact / percent |
|
|
101
243
|
| `cnbs_transform_unit` | Unit conversion |
|
|
102
|
-
| `cnbs_compute_stats` |
|
|
244
|
+
| `cnbs_compute_stats` | Basic statistics for an array |
|
|
245
|
+
| `cnbs_validate_data` | Clean/validate a data value |
|
|
246
|
+
|
|
247
|
+
---
|
|
103
248
|
|
|
104
249
|
## Quick Examples
|
|
105
250
|
|
|
251
|
+
### NBS Domestic Data
|
|
252
|
+
|
|
106
253
|
```
|
|
107
|
-
//
|
|
254
|
+
// Latest GDP value
|
|
108
255
|
cnbs_search(keyword="GDP")
|
|
109
256
|
|
|
110
|
-
//
|
|
111
|
-
cnbs_search(keyword="
|
|
257
|
+
// Latest CPI
|
|
258
|
+
cnbs_search(keyword="CPI")
|
|
112
259
|
|
|
113
260
|
// Batch search
|
|
114
|
-
cnbs_batch_search(keywords=["GDP", "CPI", "
|
|
261
|
+
cnbs_batch_search(keywords=["GDP", "CPI", "出生率", "城镇化率"])
|
|
115
262
|
|
|
116
|
-
//
|
|
117
|
-
cnbs_compare(keyword="GDP", regions=["北京", "上海"], compareType="region")
|
|
263
|
+
// Regional comparison
|
|
264
|
+
cnbs_compare(keyword="GDP", regions=["北京", "上海", "广东"], compareType="region")
|
|
118
265
|
|
|
119
|
-
//
|
|
120
|
-
|
|
266
|
+
// Time series
|
|
267
|
+
cnbs_search(keyword="GDP") // get cid + indic_id first
|
|
268
|
+
cnbs_fetch_series(setId="...", metricIds=["..."], periods=["2015YY-2024YY"])
|
|
121
269
|
```
|
|
122
270
|
|
|
123
|
-
|
|
271
|
+
### World Bank
|
|
124
272
|
|
|
125
|
-
|
|
273
|
+
```
|
|
274
|
+
// China GDP growth
|
|
275
|
+
ext_world_bank(indicator="GDP_GROWTH", countries=["CHN"], startYear=2010)
|
|
126
276
|
|
|
127
|
-
|
|
277
|
+
// Multi-country GDP per capita comparison
|
|
278
|
+
ext_world_bank(indicator="GDP_PER_CAPITA", countries=["CHN","USA","DEU","JPN","IND"], startYear=2015)
|
|
128
279
|
|
|
129
|
-
|
|
280
|
+
// Multiple indicators for China
|
|
281
|
+
ext_world_bank_multi(indicators=["GDP_GROWTH","CPI","UNEMPLOYMENT"], countries=["CHN"], startYear=2010)
|
|
130
282
|
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
| 2 | Quarterly |
|
|
135
|
-
| 3 | Yearly |
|
|
136
|
-
| 5 | Provincial Quarterly |
|
|
137
|
-
| 6 | Provincial Yearly |
|
|
138
|
-
| 7 | Other |
|
|
139
|
-
| 8 | Major Cities Yearly |
|
|
140
|
-
| 9 | Hong Kong/Macau/Taiwan Monthly |
|
|
141
|
-
| 10 | Hong Kong/Macau/Taiwan Yearly |
|
|
283
|
+
// Available indicators
|
|
284
|
+
ext_world_bank_indicators(keyword="trade")
|
|
285
|
+
```
|
|
142
286
|
|
|
143
|
-
|
|
287
|
+
### IMF
|
|
144
288
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
289
|
+
```
|
|
290
|
+
// GDP growth forecast (includes projections)
|
|
291
|
+
ext_imf(indicator="GDP_GROWTH", countries=["CHN","USA","JPN"], periods=["2022","2023","2024","2025"])
|
|
148
292
|
|
|
149
|
-
|
|
293
|
+
// Government debt comparison
|
|
294
|
+
ext_imf(indicator="GOVT_DEBT", countries=["CHN","USA","JPN","DEU","ITA"])
|
|
150
295
|
|
|
151
|
-
|
|
296
|
+
// Full indicator catalog
|
|
297
|
+
ext_imf_all_indicators()
|
|
298
|
+
```
|
|
152
299
|
|
|
153
|
-
|
|
154
|
-
- Beijing: `110000000000`
|
|
155
|
-
- Shanghai: `310000000000`
|
|
156
|
-
- Guangdong: `440000000000`
|
|
300
|
+
### BIS
|
|
157
301
|
|
|
158
|
-
|
|
302
|
+
```
|
|
303
|
+
// China real effective exchange rate (last 3 years)
|
|
304
|
+
ext_bis(dataset="EER", country="CN", lastNObservations=36)
|
|
159
305
|
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
npm install
|
|
306
|
+
// Credit-to-GDP gap (systemic risk indicator)
|
|
307
|
+
ext_bis(dataset="CREDIT_GAP", country="CN", lastNObservations=20)
|
|
163
308
|
|
|
164
|
-
|
|
165
|
-
|
|
309
|
+
// Residential property prices
|
|
310
|
+
ext_bis(dataset="PROPERTY_PRICES", country="CN", lastNObservations=20)
|
|
311
|
+
```
|
|
166
312
|
|
|
167
|
-
|
|
168
|
-
npm run start
|
|
313
|
+
### FRED
|
|
169
314
|
|
|
170
|
-
# Development mode with watch
|
|
171
|
-
npm run dev
|
|
172
315
|
```
|
|
316
|
+
// WTI oil price (last 100 days)
|
|
317
|
+
ext_fred(series="OIL_PRICE_WTI", limit=100, sortOrder="desc")
|
|
318
|
+
|
|
319
|
+
// CNY/USD exchange rate since 2020
|
|
320
|
+
ext_fred(series="CNY_USD", observationStart="2020-01-01")
|
|
321
|
+
|
|
322
|
+
// Federal funds rate history
|
|
323
|
+
ext_fred(series="FED_FUNDS", limit=60)
|
|
324
|
+
|
|
325
|
+
// 10Y - 2Y yield spread (recession indicator)
|
|
326
|
+
ext_fred(series="US_10Y_YIELD", limit=60)
|
|
327
|
+
ext_fred(series="US_2Y_YIELD", limit=60)
|
|
328
|
+
```
|
|
329
|
+
|
|
330
|
+
### Cross-Source Comparison
|
|
331
|
+
|
|
332
|
+
```
|
|
333
|
+
// Compare World Bank + IMF GDP growth for G4
|
|
334
|
+
ext_global_compare(
|
|
335
|
+
wbIndicator="GDP_GROWTH",
|
|
336
|
+
imfIndicator="GDP_GROWTH",
|
|
337
|
+
countries=["CHN","USA","DEU","JPN"],
|
|
338
|
+
startYear=2015
|
|
339
|
+
)
|
|
340
|
+
```
|
|
341
|
+
|
|
342
|
+
### NBS Census & Department
|
|
343
|
+
|
|
344
|
+
```
|
|
345
|
+
// 2020 Population census data
|
|
346
|
+
ext_cn_census(type="population")
|
|
347
|
+
|
|
348
|
+
// PBoC monetary data (M2, credit)
|
|
349
|
+
ext_cn_department(department="monetary", indicator="M2货币供应量")
|
|
350
|
+
|
|
351
|
+
// All finance ministry indicators
|
|
352
|
+
ext_cn_department(department="finance", fetchAll=true)
|
|
353
|
+
|
|
354
|
+
// List all department categories
|
|
355
|
+
ext_cn_department_list()
|
|
356
|
+
```
|
|
357
|
+
|
|
358
|
+
---
|
|
359
|
+
|
|
360
|
+
## NBS Category Codes
|
|
361
|
+
|
|
362
|
+
| Code | Category | Typical Indicators |
|
|
363
|
+
|------|----------|--------------------|
|
|
364
|
+
| 1 | Monthly | CPI, PPI, Industrial Output, PMI |
|
|
365
|
+
| 2 | Quarterly | GDP quarterly growth |
|
|
366
|
+
| 3 | Annual | GDP, population, urbanization rate |
|
|
367
|
+
| 5 | Provincial Quarterly | Provincial GDP by quarter |
|
|
368
|
+
| 6 | Provincial Annual | Provincial GDP, population by year |
|
|
369
|
+
| 7 | Other / Surveys | Household surveys, special surveys |
|
|
370
|
+
|
|
371
|
+
## NBS Time Format
|
|
372
|
+
|
|
373
|
+
- Annual: `2024YY`, range `["2020YY-2024YY"]`
|
|
374
|
+
- Quarterly: `2024A/B/C/D` (A=Q1, B=Q2, C=Q3, D=Q4), shortcuts `LAST6/LAST12/LAST18`
|
|
375
|
+
- Monthly: `202401MM`, range `["202301MM-202412MM"]`
|
|
376
|
+
|
|
377
|
+
## NBS Region Codes
|
|
378
|
+
|
|
379
|
+
Follows GB/T 2260 standard. Use `cnbs_get_regions` for the full list.
|
|
380
|
+
|
|
381
|
+
| Region | Code |
|
|
382
|
+
|--------|------|
|
|
383
|
+
| National | `000000000000` |
|
|
384
|
+
| Beijing | `110000000000` |
|
|
385
|
+
| Shanghai | `310000000000` |
|
|
386
|
+
| Guangdong | `440000000000` |
|
|
387
|
+
| Zhejiang | `330000000000` |
|
|
388
|
+
| Jiangsu | `320000000000` |
|
|
389
|
+
|
|
390
|
+
---
|
|
173
391
|
|
|
174
392
|
## Authentication
|
|
175
393
|
|
|
176
|
-
|
|
394
|
+
No authentication is required by default. Enable Bearer token auth:
|
|
177
395
|
|
|
178
|
-
### Local / HTTP
|
|
396
|
+
### Local / HTTP mode
|
|
179
397
|
|
|
180
398
|
```bash
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
# Using environment variable
|
|
185
|
-
MCP_CNBS_AUTH_TOKEN=your-secret-token npx @icen.ai/mcp-cnbs --port 12345
|
|
399
|
+
npx mcp-cnbs --port 12345 --auth-token your-secret-token
|
|
400
|
+
# or via env var
|
|
401
|
+
MCP_CNBS_AUTH_TOKEN=your-secret-token npx mcp-cnbs --port 12345
|
|
186
402
|
```
|
|
187
403
|
|
|
188
|
-
|
|
404
|
+
Requests must then include:
|
|
189
405
|
```
|
|
190
406
|
Authorization: Bearer your-secret-token
|
|
191
407
|
```
|
|
192
408
|
|
|
193
409
|
### Cloudflare Workers
|
|
194
410
|
|
|
195
|
-
Set `MCP_CNBS_AUTH_TOKEN` in Cloudflare dashboard secrets:
|
|
196
|
-
|
|
197
411
|
```bash
|
|
198
|
-
# Deploy with secret
|
|
199
412
|
npx wrangler secret put MCP_CNBS_AUTH_TOKEN
|
|
200
|
-
# Enter your token when prompted
|
|
201
|
-
|
|
202
|
-
# Or use wrangler.toml
|
|
203
|
-
# (secrets cannot be set in wrangler.toml for security)
|
|
204
413
|
```
|
|
205
414
|
|
|
206
|
-
### MCP
|
|
415
|
+
### MCP client with auth
|
|
207
416
|
|
|
208
417
|
```json
|
|
209
418
|
{
|
|
210
419
|
"mcpServers": {
|
|
211
420
|
"cnbs": {
|
|
212
421
|
"command": "npx",
|
|
213
|
-
"args": ["
|
|
422
|
+
"args": ["mcp-cnbs", "--auth-token", "your-secret-token"],
|
|
423
|
+
"env": {
|
|
424
|
+
"FRED_API_KEY": "your_fred_api_key"
|
|
425
|
+
},
|
|
426
|
+
"headers": {
|
|
427
|
+
"X-Fred-Api-Key": "your_fred_api_key"
|
|
428
|
+
}
|
|
214
429
|
}
|
|
215
430
|
}
|
|
216
431
|
}
|
|
217
432
|
```
|
|
218
433
|
|
|
434
|
+
---
|
|
435
|
+
|
|
436
|
+
## Development
|
|
437
|
+
|
|
438
|
+
```bash
|
|
439
|
+
# Install dependencies
|
|
440
|
+
npm install
|
|
441
|
+
|
|
442
|
+
# Build
|
|
443
|
+
npm run build
|
|
444
|
+
|
|
445
|
+
# Run locally
|
|
446
|
+
npm run start
|
|
447
|
+
|
|
448
|
+
# Development mode (watch)
|
|
449
|
+
npm run dev
|
|
450
|
+
```
|
|
451
|
+
|
|
219
452
|
## Requirements
|
|
220
453
|
|
|
221
454
|
- Node.js >= 18.0.0
|
|
222
|
-
- Network access to `data.stats.gov.cn`
|
|
455
|
+
- Network access to `data.stats.gov.cn`, `api.worldbank.org`, `www.imf.org`, `sdmx.oecd.org`, `stats.bis.org`, `api.stlouisfed.org`
|
|
223
456
|
|
|
224
457
|
## License
|
|
225
458
|
|