name: wecom-doc description: 企业微信文档管理技能。支持企业微信文档、智能表格和智能文档(原名智能主页)的管理。具体能力:(1) 获取文档或智能表格的完整内容,以 Markdown 格式导出 (2) 新建文档或智能表格 (3) 用 Markdown 覆写文档内容 (4) 创建智能文档,将本地 Markdown 文件发布为智能文档 (5) 导出智能文档内容为 Markdown 文件。
企业微信文档管理
wecom_mcp是一个 MCP tool,所有操作通过调用该 tool 完成。
⚠️ 前置条件:首次调用
wecom_mcp前,必须按wecom-preflight技能执行前置条件检查,确保工具已加入白名单。
管理企业微信文档和智能文档(原名智能主页)的创建、读取和编辑。文档接口支持通过 docid 或 url 二选一定位文档。
⚠️ 重要触发规则:只有当用户明确提到「智能文档」或「智能主页」时,才使用智能文档相关接口(
smartpage_*系列)。其他所有涉及「文档」的场景(如"创建文档"、"写个文档"、"帮我建个文档"等),一律使用企微文档接口(create_doc/get_doc_content/edit_doc_content)。
URL 品类识别与接口路由
企业微信文档有三种品类,URL 格式不同,读取内容所用的接口也不同,切勿混用:
| URL 模式 | 品类 | 读取内容接口 |
|---|---|---|
https://doc.weixin.qq.com/doc/* |
文档(doc_type=3) | get_doc_content |
https://doc.weixin.qq.com/smartsheet/* |
智能表格(doc_type=10) | get_doc_content |
https://doc.weixin.qq.com/smartpage/* |
智能文档(原名智能主页) | smartpage_export_task → smartpage_get_export_result |
判断规则:
- URL 路径以
/doc/*开头 → 文档 → 用get_doc_content - URL 路径以
/smartsheet/*开头 → 智能表格 → 用get_doc_content - URL 路径以
/smartpage/*开头 → 智能文档(原名智能主页) → 用smartpage_export_task
调用方式
通过 wecom_mcp tool 调用,子工具名为 doc:
使用 wecom_mcp tool 调用 wecom_mcp call doc <tool_name> '<json_params>' 调用指定技能
返回格式说明
所有接口返回 JSON 对象,包含以下公共字段:
| 字段 | 类型 | 说明 |
|---|---|---|
errcode |
integer | 返回码,0 表示成功,非 0 表示失败 |
errmsg |
string | 错误信息,成功时为 "ok" |
当 errcode 不为 0 时,说明接口调用失败,可重试 1 次;若仍失败,将 errcode 和 errmsg 展示给用户。
特殊错误码
| errcode | errmsg | 含义 | 处理方式 |
|---|---|---|---|
851002 |
incompatible doc type |
文档品类与所调用的接口不匹配 | 根据文档 URL 重新确认品类(参见上方「URL 品类识别与接口路由」表),然后使用该品类对应的正确接口重试 |
851003 |
no authority |
无权限调用该接口,智能表格写入场景下通常是企业可见范围 > 10 人的规模限制 | 若发生在需要写入数据的场景,引导用户走 Webhook 兜底方案,详见 webhook-fallback.md;其他接口则按权限问题排查 |
文档
适用品类:文档(doc_type=3)和智能表格(doc_type=10)
适用 URL:/doc/*、/smartsheet/*
适用场景:
- 以 Markdown 格式导出获取文档完整内容(异步轮询)
- 新建文档(doc_type=3)或智能表格(doc_type=10)
- 用 Markdown 格式覆写文档内容
get_doc_content
获取文档完整内容数据,只能以 Markdown 格式返回。采用异步轮询机制:首次调用无需传 task_id,接口返回 task_id;若 task_done 为 false,需携带该 task_id 再次调用,直到 task_done 为 true 时返回完整内容。
- 首次调用(不传 task_id):使用
wecom_mcptool 调用wecom_mcp call doc get_doc_content '{"docid": "DOCID", "type": 2}' - 轮询(携带上次返回的 task_id):使用
wecom_mcptool 调用wecom_mcp call doc get_doc_content '{"docid": "DOCID", "type": 2, "task_id": "xxx"}' - 或通过 URL:使用
wecom_mcptool 调用wecom_mcp call doc get_doc_content '{"url": "https://doc.weixin.qq.com/doc/xxx", "type": 2}'
参见 API 详情。
create_doc
新建文档(doc_type=3)或智能表格(doc_type=10)。创建成功返回 url 和 docid。
- 创建文档:使用
wecom_mcptool 调用wecom_mcp call doc create_doc '{"doc_type": 3, "doc_name": "项目周报"}' - 创建智能表格:使用
wecom_mcptool 调用wecom_mcp call doc create_doc '{"doc_type": 10, "doc_name": "任务跟踪表"}'
注意:
- docid 仅在创建时返回,需妥善保存。创建智能表格时默认包含一个子表
- 智能表格(doc_type=10)的详细管理功能(子表、字段、数据记录等)已迁移到
wecom-smartsheetskill,请使用该 skill 进行高级操作
参见 API 详情。
edit_doc_content
用 Markdown 内容覆写文档正文。content_type 固定为 1(Markdown)。
使用 wecom_mcp tool 调用 wecom_mcp call doc edit_doc_content '{"docid": "DOCID", "content": "# 标题\n\n正文内容", "content_type": 1}'
参见 API 详情。
智能文档(原名智能主页)
适用品类:智能文档(用户说「智能文档」或「智能主页」时触发)
适用 URL:/smartpage/*
⚠️ 只有当用户明确指定「智能文档」或「智能主页」时,才使用以下接口。其他「文档」场景请使用上方的企微文档接口。
适用场景:
- 将本地 Markdown 文件创建为智能文档
- 异步导出智能文档内容为 Markdown
smartpage_create
创建智能文档(原名智能主页),支持传入标题和多个子页面。每个子页面可指定标题、内容类型和本地文件路径。响应透传 mcp 回包,返回 docid 和 url。
- 使用
wecom_mcptool 调用wecom_mcp call doc smartpage_create '{"title": "项目概览", "pages": [{"page_title": "需求文档", "content_type": 1, "page_filepath": "/path/to/requirements.md"}]}'
注意:
content_type必须与文件实际内容匹配:.md文件或包含 Markdown 语法的内容必须传1(Markdown),仅纯文本才传0。绝大多数场景应传1- docid 仅在创建时返回,需妥善保存
- 每个子页面的 Markdown 文件大小不得超过 10MB,超过会导致创建失败。如果文件过大,需先拆分为多个子页面再创建
参见 API 详情。
smartpage_export_task
发起智能文档内容导出任务(异步)。传入 docid(或 url)和 content_type,返回 task_id。这是异步导出的第一步,需配合 smartpage_get_export_result 轮询获取导出结果。
- 通过 docid:使用
wecom_mcptool 调用wecom_mcp call doc smartpage_export_task '{"docid": "DOCID", "content_type": 1}' - 或通过 URL:使用
wecom_mcptool 调用wecom_mcp call doc smartpage_export_task '{"url": "https://doc.weixin.qq.com/smartpage/xxx", "content_type": 1}'
参见 API 详情。
smartpage_get_export_result
查询智能文档导出任务进度。传入 task_id 进行轮询,当 task_done 为 true 时返回 content_filepath(导出内容的本地文件路径)。
- 使用
wecom_mcptool 调用wecom_mcp call doc smartpage_get_export_result '{"task_id": "TASK_ID"}'
当 task_done 为 true 时,使用 Read 工具读取 content_filepath 指向的文件即可获取导出的 Markdown 内容。
参见 API 详情。
典型工作流
关键提示:读取内容前先看 URL 判断品类。
/doc/或/smartsheet/→get_doc_content;/smartpage/→smartpage_export_task。只有用户明确提到「智能文档」或「智能主页」时才走 smartpage 流程,其他文档场景一律使用企微文档接口。
文档操作
- 读取文档/智能表格内容(URL 含
/doc/或/smartsheet/) → 使用wecom_mcptool 调用wecom_mcp call doc get_doc_content '{"docid": "DOCID", "type": 2}',若task_done为 false 则携带task_id继续轮询 - 创建新文档 → 使用
wecom_mcptool 调用wecom_mcp call doc create_doc '{"doc_type": 3, "doc_name": "文档名"}',保存返回的 docid - 编辑文档 → 先 get_doc_content 了解当前内容,再 edit_doc_content 覆写
智能文档操作
- 创建智能文档(仅当用户明确要求「智能文档」或「智能主页」时) → 使用
wecom_mcptool 调用wecom_mcp call doc smartpage_create '{"title": "标题", "pages": [{"page_title": "子页面", "content_type": 1, "page_filepath": "/path/to/file.md"}]}',保存返回的 docid - 获取智能文档内容(URL 含
/smartpage/,异步两步):- 第一步:发起导出任务 → 使用
wecom_mcptool 调用wecom_mcp call doc smartpage_export_task '{"docid": "DOCID", "content_type": 1}',获取task_id - 第二步:轮询导出结果 → 使用
wecom_mcptool 调用wecom_mcp call doc smartpage_get_export_result '{"task_id": "TASK_ID"}',若task_done为false则继续轮询,直到task_done为true - 第三步:使用 Read 工具读取
content_filepath指向的本地文件,获取 Markdown 内容
- 第一步:发起导出任务 → 使用