SuperAPI AI Directory

wecom-doc-manager

General & other

View repository

Updated 10-16 08:43

About this skill

WeCom document management

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

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

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

⚠️ Important trigger rule: Only when the user explicitly mentions "smart doc" or "smart homepage" should the smart doc-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 interfaces (create_doc / get_doc_content / edit_doc_content)。

URL category identification and interface routing

WeCom documents have three categories,the URL formats differ, and the interfaces used to read content also differ. 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 doc(formerly known as smart homepage) smartpage_export_task → smartpage_get_export_result

Judgment rule:

  • 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 doc (formerly known as smart homepage) → Use smartpage_export_task

Calling method

Call via the wecom_mcp tool, and the sub-tool name is doc:

Use the wecom_mcp tool to call wecom_mcp call doc <tool_name> '<json_params>' Call 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, which is "ok"

When errcode is not 0 , it indicates the interface call failed and can be retried once; if it still fails, show errcode and errmsg to the user.

Special error code

errcode errmsg Meaning Handling method
851002 incompatible doc type The document category does not match the interface being called Reconfirm the category according to 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;Smart sheet writing scenariothis is usually the scale limit of an enterprise-visible scope > 10 people If this occurs in a scenario that requires writing data, guide the user to use the Webhook fallback solution; see webhook-fallback.md; for other interfaces, troubleshoot based on permission issues

Documentation

Applicable types: 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, which can only be returned in Markdown format. Usesasynchronous polling mechanism: the first call does not require passing task_id, and the interface returns task_idif task_done is false, you need to carry that task_id and call again until task_done is true, then 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, url and docid are returned.

  • Use the wecom_mcp tool to call wecom_mcp call doc create_doc '{"doc_type": 3, "doc_name": "项目周报"}'
  • 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, so save it properly. When creating a Smart Sheet, a sub-sheet is included by default, and its sheet_id can be queried via smartsheet_get_sheet See

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 Page)

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

⚠️ Only use the following interface when the user explicitly specifies "Smart Document" or "Smart Page". For other "document" scenarios, 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 a Markdown file

smartpage_create

Create a Smart Document (formerly Smart Page), 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 and returns 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 Files or content containing Markdown syntax must pass 1(Markdown); only plain text passes 0. In most scenarios, pass 1
  • docid is only returned at creation time, so save it 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 docid and content_type, and task_id is returned. This is the first step of asynchronous export and must be combined with smartpage_get_export_result polling to obtain the export result.

  • Use the wecom_mcp tool to call wecom_mcp call doc smartpage_export_task '{"docid": "DOCID", "content_type": 1}'

See API details。

smartpage_get_export_result

Query the progress of the smart document export task. Pass in task_id for polling; 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 obtain the exported Markdown content.

See API details。

Typical workflow

Key tips: Before reading the content, first 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 workflow be used; for all other document scenarios, use the WeCom document interface.

  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": "文档名"}', and save the returned docid
  3. Edit document → First use get_doc_content to understand the current content, then use edit_doc_content to overwrite
  4. Create a smart document(only when the user explicitly requests a "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"}]}', and save the returned docid
  5. Get smart document content(URL contains /smartpage/, asynchronous two-step):
    • Step 1: Use the wecom_mcp tool to call wecom_mcp call doc smartpage_export_task '{"docid": "DOCID", "content_type": 1}', to obtain task_id
    • Step 2: 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 obtain the Markdown content