@pipeworx/mcp-china-exchange-data 0.1.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.
@@ -0,0 +1,6 @@
1
+ {
2
+ "staged_at": "2026-09-23T19:12:57.975Z",
3
+ "publisher_blob": "da6994091dc9dcc6a7433084251ca4bbd58b4bed",
4
+ "publisher_commit": "1c417b2cfcdac06e2d9210e869265722ef013f20",
5
+ "note": "Written by scripts/publish-pack.sh as its LAST step. Its presence is the ONLY thing that lets stage-unpublished-packs.sh skip this pack. Deleting this dir is the correct way to force a rebuild."
6
+ }
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Mojibake Inc.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,142 @@
1
+ # @pipeworx/china-exchange-data
2
+
3
+ Live market data straight from the two Chinese mainland exchanges — SZSE (Shenzhen) and SSE (Shanghai), one pack because they are a single jurisdiction. Fills what `@pipeworx/china-stocks` doesn't cover: industry/sector turnover ranking, index daily/weekly bars, a full-market board snapshot for screens, and company bulletins (公告) by code.
4
+
5
+ Part of [Pipeworx](https://pipeworx.io) — an MCP gateway connecting AI agents to 1663+ live data sources.
6
+
7
+ 板块 主力资金 净流入 指数 日线 公告 — 深交所 上交所 A股行情数据接口
8
+
9
+ ## Tools
10
+
11
+ - `ashares_sector_flows({ date?, top? })` — SZSE-official per-industry (行业) turnover ranking: turnover amount (成交金额/亿元), volume, company count, market cap, weighted P/E. **This is turnover, not the vendor "主力资金净流入" (large-order net-inflow) metric** — see Data sources below for why.
12
+ - `ashares_index_bars({ index?, days?, weeks? })` — daily or weekly OHLC + volume + turnover bars for a major index: `000001` 上证指数 Shanghai Composite, `000016` 上证50, `000300` 沪深300 CSI 300, `000688` 科创50 STAR50 (all SSE), `399001` 深证成指 Shenzhen Component, `399006` 创业板指 ChiNext (both SZSE).
13
+ - `ashares_market_bars({ date?, limit?, sort? })` — full SSE-board latest-session snapshot (~2,358 stocks): code, name, last, change %, volume, turnover amount. SSE only — see limitations below.
14
+ - `ashares_bulletins({ code, since?, type?, limit? })` — SSE-listed company disclosure bulletins by 6-digit code: title, type, date, PDF URL. SSE only.
15
+
16
+ ## Auth
17
+
18
+ Keyless. All four upstreams are public, unauthenticated JSON/JSONP endpoints. Every one requires a same-site `Referer` header or 4xx-blocks the request.
19
+
20
+ ## Data sources
21
+
22
+ - **SZSE report API** — `https://www.szse.cn/api/report/ShowReport/data?SHOWTYPE=JSON&CATALOGID=<id>` with `Referer: https://www.szse.cn/market/trend/index.html`. `CATALOGID=1804_gptj_merge_after` (股票行业统计) is a per-industry turnover report; requires `txtQueryDate`. Catalog ids are undocumented by SZSE and were read out of the site's own network calls while browsing 市场数据 → 股票数据 → 行业统计 — `1804_gptj_merge_after` is the only one this pack uses; `1110` (A股列表, static company metadata — code/name/listing date/industry, no price data) and `1815_stock_snapshot` (per-code quote history, requires a specific security code, not a bulk snapshot) were probed and found not useful for a full-market bulk report.
23
+ - **SZSE quote history** — `https://www.szse.cn/api/market/ssjjhq/getHistoryData?cycleType=<32|33>&marketId=1&code=<code>`, same Referer. `cycleType=32` = daily, `cycleType=33` = weekly (empirically confirmed by testing 5/6/7/8/16/33/40/48 — 7/8/16 are intraday minute bars, 32/33 are the only two that returned clean day-spaced/week-spaced rows). `marketId=1` works for both SZSE stocks (e.g. `000001` 平安银行) and SZSE indices (e.g. `399001` 深证成指) — SZSE does not distinguish stock vs. index by market id, only by code. Row shape is **undocumented by SZSE** and was reverse-engineered from the data: `[date, open, close, low, high, change, change_pct, volume, amount]` (confirmed by checking `low <= open,close <= high` holds across every row, and that `close + (-change) ≈` the visible previous close).
24
+ - **SSE public quote system (yunhq)** — `http://yunhq.sse.com.cn:32041/v1/sh1/...`. **Plain HTTP only** — the documented TLS port did not respond from this environment; HTTP did. `/dayk/<code>?begin=-N&end=-1&period=day|week` gives OHLCV bars for any SSE code OR SSE index under the single `sh1` namespace (`000001` 上证指数 and `600519` 贵州茅台 both resolve through the same path — SSE doesn't separate stock/index namespaces either). Row = `[date(YYYYMMDD), open, high, low, close, volume, amount]`. `/list/exchange/equity?select=...&begin=&end=` returns the full SSE equity board (~2,358 rows) as one paged call: `[code, name, last, chg_rate_pct, volume, amount]` — no per-row OHLC, just last/change/volume/turnover, and it is a **live/latest-session snapshot**, not addressable by an arbitrary past date (tested: no date parameter changes the result).
25
+ - **SSE bulletins** — `https://query.sse.com.cn/security/stock/queryCompanyBulletinNew.do?productId=<code>` (JSONP, `Referer: https://www.sse.com.cn/disclosure/listedinfo/announcement/`). The working parameter is **`productId`** — `securityCode` / `SECURITY_CODE` (which the site's own `commonQuery.do?sqlId=COMMON_PL_SSGSXX_ZXGG_NUM_L` count-endpoint accepts) are silently ignored by this endpoint and return `total: 0`. Server-side `beginDate`/`endDate` also return `total: 0` regardless of format tried — the `since` filter in this pack is applied **client-side** against the returned `SSEDATE` field, paging back through `pageHelp.pageNo` until either enough rows are collected or the page's oldest date passes `since`.
26
+
27
+ ## What isn't built, and why
28
+
29
+ - **No literal 主力资金净流入 (large-order-classified net capital inflow).** Neither SZSE nor SSE publishes that computed metric — it's a vendor number (East Money / 同花顺-style trackers compute it from tick-level order classification). `push2.eastmoney.com` is confirmed empty from any non-China IP (see `docs/china-vertical-plan.md` and `project_china_ashares_pack` memory) and is out of scope for this SZSE/SSE-sourced pack regardless. `ashares_sector_flows` instead reports SZSE's own official per-industry **turnover** ranking — a real, live, exchange-published number that answers the same "which sectors are hot today" question, labeled honestly as turnover rather than inflow.
30
+ - **No full-market bar set for an arbitrary past date.** The only bulk full-market endpoint found (SSE yunhq's board list) is a live/latest-session snapshot. SZSE's per-stock snapshot report (`1815_stock_snapshot`) requires a specific security code per call, so reconstructing a market-wide set for a past date would mean ~2,900 SZSE calls plus the SSE side — not viable as a single tool call. `ashares_market_bars` always returns the latest available SSE session and says so explicitly (`date_note`) if the requested date doesn't match, rather than silently substituting or fabricating rows. SZSE is not covered by this tool at all (no equivalent single-call bulk endpoint was found within the research budget) — flagged in the tool description and in the fleet task close note as an open gap, not silently dropped.
31
+ - **`ashares_market_bars` and `ashares_bulletins` are SSE-only.** No SZSE equivalent of the bulk board list or the bulletin API was found in the time available; SZSE bulletins live under a different disclosure system (`www.szse.cn/disclosure/`) not yet probed for this pack.
32
+
33
+ ## Traps for the next person
34
+
35
+ - Every SZSE and SSE endpoint here 403s/400s without the exact `Referer` shown above.
36
+ - SSE's `queryCompanyBulletinNew.do` param name mismatch (`productId` not `securityCode`) is invisible from the metadata — the response happily echoes back whatever param name you send under `securityCode` in its JSON, even the wrong one, and still returns `total: 0`. Only `productId` actually filters.
37
+ - `yunhq.sse.com.cn:32041` is HTTP-only from this environment; don't waste a retry loop on HTTPS.
38
+ - SZSE's `ssjjhq/getHistoryData` field order is not documented anywhere public — re-verify with the `low <= min(open,close)` / `high >= max(open,close)` sanity check if SZSE ever changes their payload shape.
39
+
40
+ ## Quick Start
41
+
42
+ Add to your MCP client (Claude Desktop, Cursor, Windsurf, etc.):
43
+
44
+ ```json
45
+ {
46
+ "mcpServers": {
47
+ "china-exchange-data": {
48
+ "url": "https://gateway.pipeworx.io/china-exchange-data/mcp"
49
+ }
50
+ }
51
+ }
52
+ ```
53
+
54
+ ### What this endpoint actually serves
55
+
56
+ `tools/list` at `https://gateway.pipeworx.io/china-exchange-data/mcp` returns the tools in the table
57
+ above **plus the shared Pipeworx meta-tools** — `ask_pipeworx`,
58
+ `discover_tools`, `search_within`, `remember`/`recall` and the rest of the
59
+ gateway-wide set. So the tool count you see is larger than this table: a
60
+ single-pack endpoint currently lists roughly 30 shared tools alongside the
61
+ pack's own. The connection's `initialize` response states its exact scope, and
62
+ is the authoritative answer for a given day.
63
+
64
+ This is deliberate, not multiplexing by accident. The meta-tools are what let a
65
+ scoped connection answer a question this pack does not cover — via
66
+ `ask_pipeworx`, which routes across the whole catalog — without you adding a
67
+ second MCP server. There is currently no way to mount a pack endpoint without
68
+ them; if the extra schemas cost you more context than the routing is worth,
69
+ connect to the full gateway once rather than to several pack endpoints.
70
+
71
+ Or connect to the full Pipeworx gateway to get every pack's tools listed
72
+ directly, instead of just this one's:
73
+
74
+ ```json
75
+ {
76
+ "mcpServers": {
77
+ "pipeworx": {
78
+ "url": "https://gateway.pipeworx.io/mcp"
79
+ }
80
+ }
81
+ }
82
+ ```
83
+
84
+ Both URLs reach the same gateway and the same 1663+ data sources. The
85
+ only difference is which pack's tools are listed **directly**; `ask_pipeworx`
86
+ reaches all of them from either one.
87
+
88
+ ## No MCP client? Call it over HTTP
89
+
90
+ ```bash
91
+ curl -X POST https://gateway.pipeworx.io/v1/tools/ashares_sector_flows \
92
+ -H 'Content-Type: application/json' \
93
+ -d '{"top":10}'
94
+ ```
95
+
96
+ No account needed for the first calls. Inspect any tool: `GET https://gateway.pipeworx.io/v1/tools/ashares_sector_flows`. Find one: `POST https://gateway.pipeworx.io/v1/tools/search_packs` with `{"query":"..."}`.
97
+
98
+ ## Standalone (no gateway account)
99
+
100
+ This package also runs as a local stdio MCP server — no Pipeworx account, no
101
+ gateway round-trip:
102
+
103
+ ```json
104
+ {
105
+ "mcpServers": {
106
+ "china-exchange-data": {
107
+ "command": "npx",
108
+ "args": ["-y", "@pipeworx/mcp-china-exchange-data"]
109
+ }
110
+ }
111
+ }
112
+ ```
113
+
114
+ Or run it directly to confirm it starts:
115
+
116
+ ```bash
117
+ npx -y @pipeworx/mcp-china-exchange-data
118
+ ```
119
+
120
+ It speaks MCP over stdin/stdout and answers `initialize`/`tools/list`/`tools/call`
121
+ for **only** this pack's tools — none of the shared meta-tools the gateway
122
+ connection above adds. Same source, same tools, no ask_pipeworx routing.
123
+
124
+ ## Using with ask_pipeworx
125
+
126
+ Instead of calling tools directly, you can ask questions in plain English —
127
+ this works on the pack endpoint above as well as on the full gateway:
128
+
129
+ ```
130
+ ask_pipeworx({ question: "your question about China Exchange Data data" })
131
+ ```
132
+
133
+ The gateway picks the right tool and fills the arguments automatically.
134
+
135
+ ## More
136
+
137
+ - [Docs and guides](https://pipeworx.io/docs)
138
+ - [pipeworx.io](https://pipeworx.io)
139
+
140
+ ## License
141
+
142
+ MIT
package/bin/cli.js ADDED
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env node
2
+ //
3
+ // Entry point for `npx @pipeworx/mcp-<slug>`.
4
+ //
5
+ // Packs ship as raw TypeScript (no build step — see publish-pack.sh for why:
6
+ // tsx sidesteps every extensionless-import / bare-JSON-import edge case a
7
+ // per-pack tsc build would have to solve one pack at a time). This file
8
+ // registers tsx's ESM loader programmatically, then hands off to src/server.ts,
9
+ // which wraps the pack's {tools, callTool} export in a stdio MCP server.
10
+ //
11
+ // Copied verbatim into every published pack repo by scripts/publish-pack.sh —
12
+ // edit this file, not a per-pack copy.
13
+ import { register } from 'tsx/esm/api';
14
+
15
+ register();
16
+
17
+ await import('../src/server.ts');
package/package.json ADDED
@@ -0,0 +1,28 @@
1
+ {
2
+ "name": "@pipeworx/mcp-china-exchange-data",
3
+ "version": "0.1.0",
4
+ "description": "China Exchange Data MCP (SZSE + SSE). Keyless.",
5
+ "type": "module",
6
+ "main": "src/index.ts",
7
+ "types": "src/index.ts",
8
+ "bin": {
9
+ "mcp-china-exchange-data": "bin/cli.js"
10
+ },
11
+ "keywords": ["mcp", "mcp-server", "model-context-protocol", "pipeworx", "china-exchange-data"],
12
+ "license": "MIT",
13
+ "repository": {
14
+ "type": "git",
15
+ "url": "git+https://github.com/pipeworx-io/mcp-china-exchange-data.git"
16
+ },
17
+ "scripts": {
18
+ "typecheck": "tsc --noEmit"
19
+ },
20
+ "dependencies": {
21
+ "@modelcontextprotocol/sdk": "^1.30.0",
22
+ "tsx": "^4.19.0"
23
+ },
24
+ "devDependencies": {
25
+ "typescript": "^5.9.3",
26
+ "@cloudflare/workers-types": "^4.20260405.1"
27
+ }
28
+ }
package/server.json ADDED
@@ -0,0 +1,18 @@
1
+ {
2
+ "$schema": "https://static.modelcontextprotocol.io/schemas/2025-12-11/server.schema.json",
3
+ "name": "io.github.pipeworx-io/china-exchange-data",
4
+ "title": "China Exchange Data",
5
+ "description": "China Exchange Data MCP (SZSE + SSE). Keyless.",
6
+ "version": "0.1.0",
7
+ "websiteUrl": "https://pipeworx.io/packs/china-exchange-data",
8
+ "repository": {
9
+ "url": "https://github.com/pipeworx-io/mcp-china-exchange-data",
10
+ "source": "github"
11
+ },
12
+ "remotes": [
13
+ {
14
+ "type": "streamable-http",
15
+ "url": "https://gateway.pipeworx.io/china-exchange-data/mcp"
16
+ }
17
+ ]
18
+ }