Beltran12138/wecom-docs-mcp-server
๐ ๐ ๐ช ๐ง - WeCom (Enterprise WeChat) document operations via MCP: create, read, and edit Docs and Smartsheets (9 tools). Fills the doc-CRUD gap โ existing WeCom MCP servers only support webhook messaging.
Quick Install
{
"mcpServers": {
"beltran12138-wecom-docs-mcp-server": {
"command": "npx",
"args": [
"-y",
"beltran12138-wecom-docs-mcp-server"
]
}
}
}Using an AI coding agent (Claude Code, Cursor, etc.)? Copy a ready-made prompt that tells it to fetch the setup instructions and install this server for you.
Documentation Overview
wecom-docs-mcp-server
An ergonomic stdio MCP facade over WeCom's official robot-doc MCP backend. It proxies all 25 backend tools verbatim and adds a transform layer that makes the raw output usable by LLM agents:
- Schema passthrough โ the tool list is fetched from the backend at startup, so it auto-tracks official updates. Zero schema maintenance.
- Cell unwrap โ smartsheet
values[field] = [{"type":"text","text":...}]cells become plain scalars (in a_rowsview). - ms โ ISO โ 13-digit ms-epoch timestamps (
create_time,update_time) convert to ISO 8601. - Chinese error hints โ
errcode851003 etc. get_error_summary+_error_hintso the agent learns the fix, not just the code.
Relationship to the backend: This server requires the official robot-doc MCP backend (an apikey from WeCom admin โ ๆบ่ฝๆๆกฃๆบๅจไบบ โ API). It is a thin proxy + ergonomics layer, not a replacement.
Why this exists
The official robot-doc backend is an HTTP (StreamableHttp) MCP server. Two friction points: (1) many MCP clients and dev workflows prefer stdio; (2) its raw output is agent-hostile โ nested cell format, ms-epoch strings, opaque error codes. This server bridges both:
| official robot-doc | this server | |
|---|---|---|
| Transport | HTTP (StreamableHttp) | stdio |
| Tool schema | raw 25 tools | same 25, passthrough |
| Cell format | [{"type":"text",...}] | unwrapped scalars (_rows) |
| Timestamps | ms-epoch strings | ISO 8601 |
| Error codes | 851003 only | + Chinese summary + fix hint |
| apikey | required | required (proxied) |
Requirements
- Python 3.9+
- A WeCom ๆบ่ฝๆๆกฃๆบๅจไบบ (Smart Doc Bot) with its API key โ available to enterprises (โฅ10 members) via WeCom admin โ ๅบ็จ็ฎก็ โ ๆบ่ฝๆๆกฃๆบๅจไบบ โ API.
Install
pip install wecom-docs-mcp-server
Or clone + editable:
git clone https://github.com/Beltran12138/wecom-docs-mcp-server
cd wecom-docs-mcp-server
pip install -e .
Configuration
| Variable | Required | Description |
|---|---|---|
WECOM_MCP_APIKEY | yes | robot-doc apikey |
WECOM_MCP_BASE_URL | no | override backend URL (default https://qyapi.weixin.qq.com/mcp/robot-doc) |
Claude Desktop (claude_desktop_config.json)
{
"mcpServers": {
"wecom-doc": {
"command": "wecom-docs-mcp-server",
"env": { "WECOM_MCP_APIKEY": "your_apikey_here" }
}
}
}
Tools
All 25 backend tools are exposed verbatim (fetched live at startup). By domain:
| Domain | Read | Write |
|---|---|---|
| doc | get_doc_content | create_doc, edit_doc_content, upload_doc_image, upload_doc_file |
| smartsheet (ๆบ่ฝ่กจ) | get_sheet, get_fields, get_records | add/update/delete ร sheet/fields/records |
| sheet (็ตๅญ่กจๆ ผ) | get_info | add_sub, delete_sub, update_range_data, append_data |
| smartpage (ๆบ่ฝ้กต้ข) | get_export_result | create, export_task |
Permission model (empirically observed 2026-07):
get_doc_contentandsmartsheet_get_*use independent permission scopes. A bot may read a smartsheet viasmartsheet_get_records(errcode 0) yet get851003 no authorityfromget_doc_contenton the same doc. Route reads by doc type.
Transforms (the value-add)
Applied automatically on every tools/call response:
_rowsonsmartsheet_get_recordsโ a flattened view where cells are unwrapped to scalars and top-level record fields (record_id,create_time, โฆ) are preserved. The originalrecordsarray is kept intact.- ms โ ISO on all successful dict payloads โ 13-digit ms-epoch strings โ ISO 8601. Alphanumeric IDs (
q979lj) are untouched. _error_summary+_error_hinton any non-zero errcode โ Chinese explanation + concrete fix.
Usage
Read a smartsheet end-to-end:
User: read https://doc.weixin.qq.com/smartsheet/s3_xxx?scode=yyy
Agent:
1. smartsheet_get_sheet(url=...) โ sheet_id (e.g. "q979lj")
2. smartsheet_get_fields(sheet_id, url) โ field schema (types, IDs)
3. smartsheet_get_records(sheet_id, url) โ records + _rows (cells unwrapped, timestamps ISO)
Pass the full
url(with?scode=) rather than guessingdocidโ the backend resolves it. Manually extracting docid by stripping prefixes is error-prone (empirically:301085 invalid docid).
Troubleshooting
| errcode | meaning | fix |
|---|---|---|
| 851000 | ๆๆกฃ้พๆฅๆ่ฏฏ | check url + scode, or use docid |
| 851002 | ๆๆกฃ็ฑปๅไธๅทฅๅ ทไธๅ ผๅฎน | smartsheet โ use smartsheet_get_* |
| 851003 | ๆ ๆๆกฃๆ้ | smartsheet ็จ smartsheet_get_*๏ผๆฎ้ๆๆกฃๆฅๅๅฐๆ้ |
| 851008 | ็ผบๆๆกฃๅ ๅฎน่ฏปๅๆ้ | ไผๅพฎๅๅฐ โ ๆบๅจไบบ โ API ๆ้ |
| 301085 | ๆ ๆ docid | ็จๅฎๆด url ๅซ scode |
| 40058 | ๅๆฐ็ผบๅคฑ | smartsheet ้ sheet_id๏ผๅ get_sheet๏ผ |
Related
| Project | Focus |
|---|---|
| official robot-doc MCP | backend (HTTP, โฅ10 ไบบไผไธ) |
| wecom-bot-mcp-server | bot messaging via webhook |
| this server | robot-doc stdio proxy + ergonomics |
Tests
pip install -e ".[dev]" # or: pip install pytest httpx
pytest
25 unit tests cover SSE/JSON parsing, ms-timestamp normalization, cell unwrap, error humanizing, and server routing/post-processing โ all offline (httpx mocked).
License
MIT