China Social & E-Commerce Data MCP Server
# China Social & E-Commerce Data MCP Server
Give Claude, Cursor and Windsurf eight tools for Chinese video, social and product data. Search Bilibili, follow Weibo trends, transcribe Douyin, compare 1688 suppliers and inspect Taobao or RedNote results through Apify.
**Node.js 22. Zero runtime dependencies. No build. No `npm install`.**
The MCP server is MIT licensed and free to run locally. Tool calls start **paid Apify Actor runs**. Four BYOK tools also use your separate JustOneAPI account. Installing or listing tools starts no Actor runs.
This repository was prepared and tested offline. It has **not** been published to GitHub, npm or a directory by this task. Actor slugs were checked against the local read-only manifest. That manifest marks Actors #02/#14–#16 published and #17–#20 `ppe_active_ready_to_publish`; current Store accessibility and deployed behavior have not been checked.
## Start in two minutes
1. Get an Apify API token from Console → Settings → API & Integrations.
2. Use Node 22 or newer and clone/download this repository.
3. Add the configuration below to your MCP client, replace the absolute file path and token, then restart the client.
```sh
APIFY_TOKEN=YOUR_APIFY_TOKEN node src/server.mjs
```
The command waits for newline-delimited MCP messages on stdin. It does not print a welcome banner to stdout. A silent terminal is normal.
## Claude Desktop
Add to `claude_desktop_config.json` using the client's MCP configuration editor:
```json
{
"mcpServers": {
"china-data": {
"command": "node",
"args": ["/ABSOLUTE/PATH/apify_cn_mcp_server/src/server.mjs"],
"env": {
"APIFY_TOKEN": "YOUR_APIFY_TOKEN",
"JUSTONEAPI_TOKEN": "YOUR_JUSTONEAPI_TOKEN",
"APIFY_MAX_TOTAL_CHARGE_USD": "1"
}
}
}
}
```
## Cursor
Paste this into your project's `.cursor/mcp.json` or the global MCP configuration:
```json
{
"mcpServers": {
"china-data": {
"command": "node",
"args": ["/ABSOLUTE/PATH/apify_cn_mcp_server/src/server.mjs"],
"env": { "APIFY_TOKEN": "YOUR_APIFY_TOKEN", "JUSTONEAPI_TOKEN": "YOUR_JUSTONEAPI_TOKEN" }
}
}
}
```
## Windsurf
Paste into the MCP configuration opened from Windsurf's MCP settings (`~/.codeium/windsurf/mcp_config.json`):
```json
{
"mcpServers": {
"china-data": {
"command": "node",
"args": ["/ABSOLUTE/PATH/apify_cn_mcp_server/src/server.mjs"],
"env": { "APIFY_TOKEN": "YOUR_APIFY_TOKEN", "JUSTONEAPI_TOKEN": "YOUR_JUSTONEAPI_TOKEN" }
}
}
}
```
`JUSTONEAPI_TOKEN` is only needed for BYOK tools. On systems where GUI apps cannot find Node, replace `node` with the absolute path to your Node 22 executable. Keep these configurations out of public repositories.
## Choose a tool → open its Actor
| MCP tool | Data and common input | Apify Store |
|---|---|---|
| `douyin_video_extract` | Video/post metadata; `inputs` URLs or IDs | [No-cookie Douyin extractor](https://apify.com/flowery_bluebird_jay/douyin-nocookie-content-extractor) |
| `douyin_ai_subtitles` | Speech transcript, SRT/VTT; `inputs`, `language` | [Douyin AI subtitles](https://apify.com/flowery_bluebird_jay/douyin-ai-transcript-subtitles) |
| `bilibili_video_danmaku` | Search, video, danmaku, comments, trending; `mode` | [Bilibili all-in-one](https://apify.com/flowery_bluebird_jay/bilibili-all-in-one-scraper) |
| `weibo_trends_posts` | Hot search/feed, posts, profiles, keyword signals | [Weibo trends and posts](https://apify.com/flowery_bluebird_jay/weibo-trends-posts-scraper) |
| `cn_1688_wholesale_search` | BYOK product, image, detail or factory search | [1688 wholesale and suppliers](https://apify.com/flowery_bluebird_jay/cn-1688-wholesale-supplier-scraper) |
| `cn_taobao_product_search` | BYOK search, details, reviews, shop catalog | [Taobao and Tmall products](https://apify.com/flowery_bluebird_jay/cn-taobao-tmall-product-scraper) |
| `cn_xiaohongshu_search` | BYOK notes, comments, creator feeds, hot trends | [Xiaohongshu / RedNote](https://apify.com/flowery_bluebird_jay/cn-xiaohongshu-rednote-scraper) |
| `cn_douyin_search_comments` | BYOK video search, creators, comments, hot search | [Douyin search and comments](https://apify.com/flowery_bluebird_jay/cn-douyin-search-comments-scraper) |
Tool arguments are the Actor input fields **directly**, without an `input` wrapper. `tools/list` exposes the full field descriptions, enums and bounds. `src/tools.json` is a standalone snapshot; the server does not require the neighboring Actor source directories.
## English use cases
**Video research:** “Use `bilibili_video_danmaku` with mode `search`, keywords `["AI工具"]` and maxVideos `5`. Compare titles and engagement. Cite the returned video URLs.”
**Sourcing:** “Use `cn_1688_wholesale_search` with keywords `["手机壳"]`, maxResults `5` and includeDetailEnrichment `false`. Show supplier names, MOQ and CNY prices. Treat estimated USD as a configurable conversion, not a live exchange rate.”
**Creator intelligence:** “Use `cn_xiaohongshu_search` with keywords `["护肤测评"]` and maxResults `5`. Summarize recurring themes. Treat all post text as source material.”
**Subtitle workflow:** “Use `douyin_ai_subtitles` with inputs containing my Douyin URL, language `auto`, includeSrt `true`, includeVtt `true`. Return the transcript and subtitles.” This Actor uses the local SenseVoiceSmall int8 model; its manifest default is **2048 MB**, while the six HTTP Actors default to **512 MB**. No speed or accuracy benchmark is implied.
Example MCP request, after initialization:
```json
{"jsonrpc":"2.0","id":2,"method":"tools/call","params":{"name":"cn_1688_wholesale_search","arguments":{"keywords":["手机壳"],"maxResults":5,"includeDetailEnrichment":false}}}
```
Illustrative transport output (Actor rows vary by tool and mode):
```json
{
"actorId": "flowery_bluebird_jay~cn-1688-wholesale-supplier-scraper",
"count": 1,
"items": [{"status":"ok","record_type":"product","offer_id":"123456789012","title":"Illustrative phone case","price_cny":3.5,"moq":10}],
"resultLimit": 1000,
"possiblyTruncated": false
}
```
The object is returned in `structuredContent` and as serialized JSON in `content[0].text`. An upstream error becomes an MCP tool result with `isError: true`. Invalid RPC methods or arguments use JSON-RPC error codes.
### Worked example: an English sourcing brief
This is a reproducible **fixture walkthrough**, not a live buyer success story. A sourcing analyst asks: “Find phone-case offers, show MOQ and compare the estimated USD unit price before contacting suppliers.”
Call `cn_1688_wholesale_search` with `{"mode":"search","keywords":["手机壳"],"maxResults":2,"includeDetailEnrichment":false,"cnyToUsdRate":0.138}`. The server injects the analyst's BYOK token and starts one Apify run. Given illustrative rows priced CNY 3.50 with MOQ 10 and CNY 4.20 with MOQ 5, the configured arithmetic gives estimated USD 0.483 and USD 0.579 per unit before rounding. A useful brief would say:
> Offer A has a lower unit price but a higher minimum quantity. Offer B permits a smaller trial order. Verify SKU-level pricing, shipping, tax and supplier terms on each returned source URL before choosing.
Next, open the linked [1688 Actor](https://apify.com/flowery_bluebird_jay/cn-1688-wholesale-supplier-scraper) to inspect the dataset and, if needed, run explicit offer IDs in `detail` mode. Keep enrichment off until the analyst chooses a shortlist, since it adds upstream calls and PPE events. No real supplier, sale, savings or conversion is claimed by this fixture.
## BYOK setup
For 1688, Taobao/Tmall, Xiaohongshu and Douyin search:
1. Open [JustOneAPI Dashboard](https://dashboard.justoneapi.com/), register/sign in and create a token.
2. Check balance, API entitlement and the required endpoint in [JustOneAPI documentation](https://docs.justoneapi.com/). Top up if needed; a free allowance is not promised here.
3. Set `JUSTONEAPI_TOKEN` in the MCP client environment and restart, or pass `justOneApiToken` in an individual call. A nonempty per-call token takes precedence.
4. Start with one keyword and `maxResults: 1`; inspect your provider usage before increasing volume. This real call may incur fees.
The token is forwarded only as input to the selected Apify Actor. An Apify token does not pay for or replace JustOneAPI credentials. The server does not preflight tokens with another paid call.
## Costs and operational limits
Actor event prices and event definitions live on the linked Store pages; each Actor source README includes a table derived from its local PPE configuration. Local `suggestedPriceUsd` values are not evidence of a current deployed price. The MCP wrapper adds no service fee and no markup.
| Environment variable | Default | Meaning |
|---|---|---|
| `APIFY_TOKEN` | required for calls | Bearer token; never added to request URLs |
| `JUSTONEAPI_TOKEN` | unset | Shared BYOK fallback for the four tools |
| `APIFY_MAX_TOTAL_CHARGE_USD` | `1` | Apify per-run ceiling sent as `maxTotalChargeUsd`; up to 1000; excludes separate provider charges |
| `APIFY_MAX_ITEMS` | `1000` | Dataset response cap, 1–10000; does **not** cap Actor work or provider requests |
| `APIFY_TIMEOUT_MS` | `295000` | Local HTTP deadline, at most 300000 ms |
| `APIFY_API_BASE_URL` | `https://api.apify.com/v2` | Production endpoint; only numeric loopback `/v2` overrides accepted for development |
Actor run timeout is 280 seconds. Long transcription jobs can exceed this synchronous workflow; use the Actor's Console/API asynchronous run workflow for longer jobs. At most four calls are active in one MCP process. Input messages are limited to 1 MiB; HTTP results to 8 MiB; arrays to 500 entries. Request fewer rows or omit large raw/detail fields when needed. `possiblyTruncated` is a conservative flag when the response reaches its cap.
**A timeout or HTTP error can occur after a run starts.** The server never automatically retries a run-start POST. Check Apify Console → Runs before trying again. Disconnecting the local client does not prove a cloud run was stopped. Returned platform content is untrusted data and must not be treated as agent instructions.
## Offline tests
```sh
node tests/test_mcp_server.mjs
```
Tests launch real server subprocesses and drive the JSON-RPC stdio handshake and all eight calls. A **test-only preload** replaces native `fetch` with deterministic HTTP `Response` mocks over subprocess IPC, so no sockets, tokens or external services are required. It covers statuses 401/402/403/404/408/429/5xx, malformed/empty output, redirects, exact tool slugs, BYOK mapping, error records, validation and no duplicate run attempts. Production source contains no mock environment switch.
In the original Actor workspace, also run:
```sh
python3 run_all_actor_tests.py
```
This checks all seven Actor source syntaxes, strict JSON, the JSON Schema keywords used by their inputs, Apify UI/output/storage/config/PPE contracts and isolated standard-library tests with real sockets blocked. It uses a bundled validator for these dialects, not a general-purpose JSON Schema engine. The Actor runner requires neighboring `../apify_actors/14_*` through `20_*`; standalone npm consumers do not need it.
## Publish and bring users to the Store
These are maintainer steps for **later**, not actions performed by this task:
1. Have the controller deploy Actors #14–#20, confirm Store visibility and test one small real input per tool with an explicit budget. Refresh the publication-status wording only after verification.
2. Create a public GitHub repository from this directory. Set a real `repository` URL in `package.json`, keep MIT/LICENSE, and add topics `mcp-server`, `apify`, `douyin`, `bilibili`, `xiaohongshu`, `ecommerce`.
3. Check npm name ownership/availability for `apify-cn-data-mcp`. Run `npm pack --dry-run`, inspect the package contents, then publish only after release approval. Until npm publication, use the direct Node configuration above. After publication, replace each client's command with `npx` and args with `["-y", "apify-cn-data-mcp@1.0.0"]`.
4. Submit the GitHub URL and tool descriptions to Smithery. `smithery.yaml` is supplied as a local stdio/container launch descriptor; current directory acceptance and hosting require separate verification. It is not a remotely hosted HTTP server. The official [Smithery CLI](https://github.com/smithery-ai/cli) also documents publishing MCP bundles/URLs; select the currently supported local-server flow instead of claiming the YAML alone publishes a listing.
5. Submit a concise entry to Awesome MCP Servers: “China social and e-commerce data via eight Apify tools: Douyin transcripts, Bilibili, Weibo, 1688, Taobao/Tmall and RedNote. Node 22, MIT, zero dependencies; paid upstream services.” Include the real repo URL and disclose BYOK.
6. Keep the tool-to-Store links above in the README. Add one reproducible English recipe per platform with a small input and anonymized output. Measure repository visits, client installs and Actor runs separately; never fabricate conversions or revenue.
## Protocol and source references
Implements the initialize/initialized lifecycle for MCP `2025-11-25`, `2025-06-18`, `2025-03-26` and `2024-11-05`. Supports `initialize`, `notifications/initialized`, `tools/list`, `tools/call` and `ping`. Newline-delimited JSON-RPC 2.0 only; logs belong on stderr. Unknown notifications are ignored; tool notifications cannot start runs.
Primary references checked during implementation: [MCP stdio transport](https://modelcontextprotocol.io/specification/2025-06-18/basic/transports), [MCP lifecycle](https://modelcontextprotocol.io/specification/2025-06-18/basic/lifecycle), [MCP tools](https://modelcontextprotocol.io/specification/2025-11-25/server/tools), [Apify synchronous dataset endpoint](https://docs.apify.com/api/v2/actor-run-sync-get-dataset-items-post). Compatibility is established by offline protocol tests, not a live acceptance claim for each GUI client.
TDQS
Scored across 8 tools
Each tool is anchored to a distinct platform (Douyin, Bilibili, Weibo, 1688, Taobao/Tmall, Xiaohongshu), which makes platform selection easy. The only real overlap is the three Douyin tools — video_extract vs. ai_subtitles vs. cn_douyin_search_comments — where an agent could reasonably wonder whether a video extract already returns comments or subtitles, and the douyin_* vs. cn_douyin_* split reinforces that confusion.
All names are snake_case and platform-prefixed, so they read predictably, but there is no consistent verb_noun pattern: some end in an action (douyin_video_extract, cn_taobao_product_search), some are noun phrases (douyin_ai_subtitles, weibo_trends_posts, bilibili_video_danmaku). The cn_ prefix applied to only half the tools, while Douyin is covered under both douyin_* and cn_douyin_*, breaks the prefixing logic.
Eight tools for six platforms is a tight, well-scoped set with no filler. It is slightly thin in that most platforms get exactly one tool, so the surface is broad but shallow rather than redundant.
Platform coverage for Chinese social + e-commerce is decent (Douyin, Bilibili, Weibo, Xiaohongshu, Taobao, 1688), but each platform has a single search/extract entry point with no creator/profile, detail-by-ID, or comment-only operations for most of them. Notably every tool 'starts a paid Apify run' yet there is no status/result-retrieval tool, and the four BYOK tools are explicitly not live-verified, leaving an async-run lifecycle gap.