Feishu MCP Stable Writer
Use this workflow to keep Feishu MCP doc output readable and deterministic.
Rules
- Always use Feishu MCP (
mcporter call lark.*) for create/update/read in this flow. - Never pass markdown as escaped
\\ntext. - Always send real multiline markdown.
- Always run
fetch-docafter write and verify structure.
Standard Flow
- Draft content in chat and get user confirmation.
- Create doc (or use given doc URL).
- Write/update with real multiline markdown.
- Read back and verify headings/lists/order.
- Report concise result + doc URL.
Command Patterns
A) Create doc
mcporter call lark.create-doc \
title='文档标题' \
wiki_space='my_library' \
markdown='# 占位\n\n准备写入' \
--output json
B) Safe overwrite with real multiline markdown
cat > /tmp/doc.md <<'MD'
# 标题
## 1. 背景
正文
## 2. 目标
- A
- B
MD
python3 - <<'PY'
import json, shlex, subprocess
from pathlib import Path
md = Path('/tmp/doc.md').read_text()
args = json.dumps({
'doc_id': 'https://www.feishu.cn/wiki/xxxxx',
'mode': 'overwrite',
'markdown': md
}, ensure_ascii=False)
cmd = f"mcporter call lark.update-doc --args {shlex.quote(args)} --output json"
print(subprocess.check_output(cmd, shell=True, text=True))
PY
C) Append + precise replace
mcporter call lark.update-doc doc_id='https://www.feishu.cn/wiki/xxxxx' \
mode='append' \
markdown='## 新章节
内容' \
--output json
mcporter call lark.update-doc doc_id='https://www.feishu.cn/wiki/xxxxx' \
mode='replace_range' \
selection_with_ellipsis='## 2. 目标...- B' \
markdown='## 2. 目标
- A(修订)
- B(修订)
- C(新增)' \
--output json
Validation Checklist
fetch-docoutput does not contain literal\\nin body text.- Heading hierarchy is preserved.
- Lists render as lists (not plain joined text).
- No missing section after update.
Failure Handling
- If
selection_by_titlefails, usefetch-docthen switch toselection_with_ellipsis. - If format drifts, rebuild markdown in
/tmp/*.mdand overwrite once. - If permissions fail, confirm MCP URL/auth and retry with same user identity.