SuperAPI AI Directory

wecom-doc

General & other

View repository

Updated 10-16 09:28

About this skill

WeCom document management

wecom_mcp is an MCP tool; all operations are completed by calling this tool.

⚠️ Prerequisites: Before calling wecom_mcp for the first time, you must follow the wecom-preflight skill to perform the prerequisite check to ensure the tool has been added to the whitelist.

Manage the creation, reading, and editing of WeCom documents and smart documents (formerly known as smart homepages). The document interface supports locating a document by either docid or url .

⚠️ Important trigger rules: Only when the user explicitly mentions "smart document" or "smart homepage" should the smart document-related interfaces (smartpage_* series) be used. In all other scenarios involving "documents" (such as "create a document", "write a document", "help me create a document", etc.), always use the WeCom document interface (create_doc / get_doc_content / edit_doc_content)。

URL category identification and interface routing

WeCom documents have three categories,the URL formats are different, and the interfaces used to read content are also different, do not mix them up:

URL pattern Category Content reading interface
https://doc.weixin.qq.com/doc/* Document(doc_type=3) get_doc_content
https://doc.weixin.qq.com/smartsheet/* Smart sheet(doc_type=10) get_doc_content
https://doc.weixin.qq.com/smartpage/* Smart document(formerly known as smart homepage) smartpage_export_task → smartpage_get_export_result

Judgment rules:

  • URL path starts with /doc/* → Document → use get_doc_content
  • URL path starts with /smartsheet/* → Smart sheet → use get_doc_content
  • URL path starts with /smartpage/* → Smart document (formerly known as smart homepage) → use smartpage_export_task

How to call

Call via the wecom_mcp tool, the subtool name is doc:

Use the wecom_mcp tool to call wecom_mcp call doc <tool_name> '<json_params>' to invoke the specified skill

Return format description

All interfaces return a JSON object containing the following common fields:

Field Type Description
errcode integer Return code,0 indicates success, non- 0 indicates failure
errmsg string Error message, on success it is "ok"

When errcode is not 0 , it indicates the interface call failed, and you may retry once; if it still fails, display errcode and errmsg to the user.

Special error codes

errcode errmsg Meaning Handling method
851002 incompatible doc type The document category does not match the interface being called Reconfirm the category based on the document URL (see the "URL category identification and interface routing" table above), then retry using the correct interface for that category
851003 no authority No permission to call this interface;in smart sheet write scenariosthis is usually due to the enterprise visibility scope being > 10 people If it occurs in a scenario requiring data writing, guide the user to use the Webhook fallback solution, see webhook-fallback.md; for other interfaces, troubleshoot as a permission issue

Documentation

Applicable categories: Documents (doc_type=3) and Smart Sheets (doc_type=10) Applicable URL:/doc/*、/smartsheet/*

Applicable scenarios:

  1. Export in Markdown format to get the full document content (asynchronous polling)
  2. Create a document (doc_type=3) or Smart Sheet (doc_type=10)
  3. Overwrite document content in Markdown format

get_doc_content

Get the full document content data; it can only be returned in Markdown format. Uses anasynchronous polling mechanism: The first call does not require passing task_id, and the interface returns task_id; if task_done is false, you need to carry that task_id and call again until task_done is true, at which point the full content is returned.

  • First call (without passing task_id): use the wecom_mcp tool to call wecom_mcp call doc get_doc_content '{"docid": "DOCID", "type": 2}'
  • Polling (carrying the task_id returned last time): use the wecom_mcp tool to call wecom_mcp call doc get_doc_content '{"docid": "DOCID", "type": 2, "task_id": "xxx"}'
  • Or via URL: use the wecom_mcp tool to call wecom_mcp call doc get_doc_content '{"url": "https://doc.weixin.qq.com/doc/xxx", "type": 2}'

See API details。

create_doc

Create a document (doc_type=3) or Smart Sheet (doc_type=10). On successful creation, returns url and docid.

  • Create document: use the wecom_mcp tool to call wecom_mcp call doc create_doc '{"doc_type": 3, "doc_name": "项目周报"}'
  • Create Smart Sheet: use the wecom_mcp tool to call wecom_mcp call doc create_doc '{"doc_type": 10, "doc_name": "任务跟踪表"}'

Note:

  • docid is only returned at creation time and must be saved properly. When creating a Smart Sheet, a subtable is included by default
  • The detailed management features of Smart Sheets (doc_type=10) (subtables, fields, data records, etc.) have been migrated to the wecom-smartsheet skill; please use that skill for advanced operations

See API details。

edit_doc_content

Overwrite the document body with Markdown content.content_type is fixed to 1(Markdown)。

Use the wecom_mcp tool to call wecom_mcp call doc edit_doc_content '{"docid": "DOCID", "content": "# 标题\n\n正文内容", "content_type": 1}'

See API details。


Smart Document (formerly Smart Homepage)

Applicable categories: Smart Document (triggered when the user says "Smart Document" or "Smart Homepage") Applicable URL:/smartpage/*

⚠️ Only when the user explicitly specifies "Smart Document" or "Smart Homepage" should the following interfaces be used. For other "document" scenarios, please use the WeCom document interfaces above.

Applicable scenarios:

  1. Create a local Markdown file as a Smart Document
  2. Asynchronously export Smart Document content as Markdown

smartpage_create

Create a Smart Document (formerly Smart Homepage), supporting passing a title and multiple subpages. Each subpage can specify a title, content type, and local file path. The response passes through the mcp response packet, returning docid and url.

  • Use the wecom_mcp tool to call wecom_mcp call doc smartpage_create '{"title": "项目概览", "pages": [{"page_title": "需求文档", "content_type": 1, "page_filepath": "/path/to/requirements.md"}]}'

Note:

  • content_type must match the actual file content:.md file or content containing Markdown syntax must pass 1(Markdown); only plain text passes 0. In the vast majority of scenarios, pass 1
  • docid is only returned at creation time and must be saved properly
  • The Markdown file size of each subpage must not exceed 10MB, otherwise creation will fail. If the file is too large, split it into multiple subpages before creating

See API details。

smartpage_export_task

Initiate a Smart Document content export task (asynchronous). Pass in docid (or url) and content_type, and return task_id. This is the first step of asynchronous export and must be used with smartpage_get_export_result Poll to get the export result.

  • Via docid: use the wecom_mcp tool to call wecom_mcp call doc smartpage_export_task '{"docid": "DOCID", "content_type": 1}'
  • or via URL: use the wecom_mcp tool to call wecom_mcp call doc smartpage_export_task '{"url": "https://doc.weixin.qq.com/smartpage/xxx", "content_type": 1}'

See API details。

smartpage_get_export_result

Query the progress of the smart document export task. Pass in task_id to poll; when task_done is true return content_filepath(the local file path of the exported content).

  • Use the wecom_mcp tool to call wecom_mcp call doc smartpage_get_export_result '{"task_id": "TASK_ID"}'

When task_done is true , use the Read tool to read the file pointed to by content_filepath to get the exported Markdown content.

See API details。


Typical workflow

Key tips: before reading the content, look at the URL to determine the category./doc/ or /smartsheet/ → get_doc_content;/smartpage/ → smartpage_export_task. Only when the user explicitly mentions "smart document" or "smart homepage" should the smartpage flow be used; for all other document scenarios, use the WeCom document interface.

Document operations

  1. Read document/smart sheet content(URL contains /doc/ or /smartsheet/) → use the wecom_mcp tool to call wecom_mcp call doc get_doc_content '{"docid": "DOCID", "type": 2}', if task_done is false, carry task_id and continue polling
  2. Create a new document → use the wecom_mcp tool to call wecom_mcp call doc create_doc '{"doc_type": 3, "doc_name": "文档名"}', save the returned docid
  3. Edit document → first use get_doc_content to understand the current content, then use edit_doc_content to overwrite

Smart document operations

  1. Create a smart document(only when the user explicitly requests "smart document" or "smart homepage") → use the wecom_mcp tool to call wecom_mcp call doc smartpage_create '{"title": "标题", "pages": [{"page_title": "子页面", "content_type": 1, "page_filepath": "/path/to/file.md"}]}', save the returned docid
  2. Get smart document content(URL contains /smartpage/, two asynchronous steps):
    • Step 1: initiate an export task → use the wecom_mcp tool to call wecom_mcp call doc smartpage_export_task '{"docid": "DOCID", "content_type": 1}', get task_id
    • Step 2: poll the export result → use the wecom_mcp tool to call wecom_mcp call doc smartpage_get_export_result '{"task_id": "TASK_ID"}', if task_done is false continue polling until task_done is true
    • Step 3: use the Read tool to read the local file pointed to by content_filepath to get the Markdown content