wecom-docs-mcp-server

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

Category
访问服务器

README

wecom-docs-mcp-server

MCP Python License: MIT

MCP server for WeCom (企业微信 / Enterprise WeChat) document operations — create, read, and edit WeCom Docs and Smartsheets from any MCP-compatible AI agent.

Gap this fills: Existing WeCom MCP servers (wecom-bot-mcp-server, wecom-mcp) only support sending messages via webhook. This server provides document CRUD operations via the @wecom/cli document API.

Compatible with: Claude Desktop · Hermes Agent · Cursor · any MCP client


Tools (9)

Tool Description
wecom_read_doc Read a WeCom Doc or Smartsheet → Markdown
wecom_create_doc Create a new Doc (type 3) or Smartsheet (type 10)
wecom_edit_doc Write Markdown content to a doc
wecom_smartsheet_setup_fields Initialize a smartsheet's column schema
wecom_smartsheet_add_records Append rows (auto cell-format conversion)
wecom_smartsheet_get_sheet List sheets in a smartsheet
wecom_smartsheet_get_fields Get column definitions
wecom_smartsheet_get_records Fetch all rows from a sheet
wecom_get_doc_content Async-poll full doc content as Markdown

Why This Exists (The Silent Failure Problem)

Calling wecom-cli from WSL via bash hits a three-layer failure:

  1. UNC path issuecmd.exe launches with wrong working directory under WSL
  2. Exit code lies — process returns 0 but writes nothing
  3. Chinese encoding — shell argument boundary corrupts multi-byte characters

Fix: call node.exe directly via subprocess.run([...], capture_output=True) — no shell, args pass through CreateProcessW, Chinese content works correctly.

# ❌ silently fails from WSL
os.system(f'wecom-cli doc edit_doc_content --json "{json_content}"')

# ✅ works
subprocess.run(["node.exe", WECOM_JS, "doc", "edit_doc_content", "--json", json_content],
               capture_output=True)

Requirements

  • Python 3.9+
  • Node.js 18+ (Windows-side if running from WSL)
  • @wecom/cli authenticated:
    npm install -g @wecom/cli
    npx @wecom/cli auth   # scan QR code with WeCom mobile app
    

Installation

Option A — pip

pip install wecom-docs-mcp-server

Option B — clone

git clone https://github.com/Beltran12138/wecom-docs-mcp-server
cd wecom-docs-mcp-server

Configuration

Environment Variables

Variable Default Description
WECOM_CLI_PATH auto-detected Full path to wecom.js (override if auto-detect fails)
NODE_EXE node.exe Node.js executable name (node on Linux/macOS)

Auto-detection order: WECOM_CLI_PATH env → npm root -g → common fallbacks.

Claude Desktop (claude_desktop_config.json)

{
  "mcpServers": {
    "wecom-docs": {
      "command": "python",
      "args": ["-m", "wecom_docs_mcp_server"]
    }
  }
}

Or if cloned:

{
  "mcpServers": {
    "wecom-docs": {
      "command": "python",
      "args": ["/path/to/wecom-docs-mcp-server/wecom_docs_mcp_server.py"]
    }
  }
}

Hermes Agent

hermes mcp add wecom-docs \
  --command python3 \
  --args /path/to/wecom_docs_mcp_server.py

WSL + Windows Node (non-standard path)

export WECOM_CLI_PATH="C:/Users/YOUR_USER/AppData/Roaming/npm/node_modules/@wecom/cli/bin/wecom.js"
export NODE_EXE="node.exe"

Usage Examples

Create a document and write content

User: Create a WeCom doc called "Q2 Market Report" and write a brief summary

Agent calls:
1. wecom_create_doc(doc_name="Q2 Market Report", doc_type=3)
   → {"url": "https://doc.weixin.qq.com/doc/xxx", "docid": "abc123"}

2. wecom_edit_doc(content="# Q2 Market Report\n\n...", docid="abc123")
   → {"errcode": 0, "errmsg": "ok"}

Create a smartsheet with structured data

User: Create a competitor tracking table with columns: Company, Product, Funding, Notes

Agent calls:
1. wecom_create_doc(doc_name="Competitor Tracker", doc_type=10)
   → {"url": "...", "docid": "xyz789"}

2. wecom_smartsheet_get_sheet(url="...")
   → {"sheet_list": [{"sheet_id": "s001", "title": "Sheet1"}]}

3. wecom_smartsheet_setup_fields(sheet_id="s001", field_names=["Company", "Product", "Funding", "Notes"])

4. wecom_smartsheet_add_records(sheet_id="s001", records=[
     {"Company": "HashKey", "Product": "HashKey Exchange", "Funding": "$200M", "Notes": "SFC licensed"},
     {"Company": "OSL", "Product": "OSL Exchange", "Funding": "$150M", "Notes": "SFC licensed"}
   ])

Read an existing document

User: What's in this doc? https://doc.weixin.qq.com/doc/abc?scode=xyz

Agent calls:
wecom_read_doc(url="https://doc.weixin.qq.com/doc/abc?scode=xyz")
→ Returns full Markdown content

Troubleshooting

node.exe not found

# WSL: ensure Windows Node is on PATH
export PATH=$PATH:/mnt/c/Program\ Files/nodejs

Empty doc after create+edit Set WECOM_CLI_PATH explicitly — auto-detection may have picked wrong wecom.js.

Error 851008 — Bot lacks "get member document content" permission. Re-authorize in WeCom admin console → Application Management → your app → Permissions.

Error 851014 — Document permission expired. Same re-authorization flow.


Related Projects

Project Focus
wecom-bot-mcp-server Bot messaging via webhook
wecom-mcp Send messages/files via webhook
wecom-docs-mcp-server (this) Document CRUD: create/read/edit Docs & Smartsheets

License

MIT


<details> <summary>中文说明</summary>

简介

wecom-docs-mcp-server 是一个 MCP stdio 服务器,将企业微信文档操作(创建、读取、编辑文档和智能表格)暴露为 MCP 工具,可在 Claude Desktop、Hermes Agent、Cursor 等任何 MCP 客户端中使用。

与已有企微 MCP 项目的区别:现有项目(wecom-bot-mcp-server、wecom-mcp)均只支持通过 Webhook 发送消息;本项目专注于文档 CRUD 操作,使用 @wecom/cli 文档 API。

核心技术问题

从 WSL 通过 bash 调用 wecom-cli静默失败(exit code 0,但文档为空)。原因是 UNC 路径问题 + cmd.exe 工作目录错误 + 中文编码失败三层叠加。

解决方案:直接用 subprocess.run(["node.exe", ...]) 调用,绕过 shell,通过 CreateProcessW 传参,中文内容完全正常。

安装

pip install wecom-docs-mcp-server

快速配置(Claude Desktop)

{
  "mcpServers": {
    "wecom-docs": {
      "command": "python",
      "args": ["-m", "wecom_docs_mcp_server"]
    }
  }
}

</details>

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选
mcp-server-qdrant

mcp-server-qdrant

这个仓库展示了如何为向量搜索引擎 Qdrant 创建一个 MCP (Managed Control Plane) 服务器的示例。

官方
精选
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选