md-lark-converter
Original:🇺🇸 English
Translated
Bidirectional conversion between Markdown and Feishu (Lark) documents using md2fs and fs2md CLI tools. Use this skill whenever the user mentions Feishu, Lark, 飞书, feishu.cn URLs, md2fs, fs2md, md-lark-converter, pasting documents to Feishu, exporting from Feishu, converting to/from Feishu format, syncing content with Feishu, setting up Feishu cookies, or any workflow involving Markdown and Feishu documents — even if they don't explicitly say 'convert'. Also trigger when the user shares a feishu.cn or lark link.
5installs
Added on
NPX Install
npx skill4agent add iceprosurface/md-lark-converter md-lark-converterTags
Translated version includes tags in frontmatterSKILL.md Content
View Translation Comparison →Markdown ↔ Feishu Converter
Two CLI commands handle the conversion:
- — Markdown → Feishu clipboard format (paste directly into Feishu docs)
md2fs - — Feishu → Markdown (fetch via URL, with automatic image download)
fs2md
Both are provided by .
@md-lark-converter/cliFirst: Check CLI Availability
Before running any command, verify the CLI is installed:
bash
which md2fs 2>/dev/null || echo "NOT_INSTALLED"If not installed, install it:
bash
npm install -g @md-lark-converter/cliMarkdown → Feishu (md2fs)
The most common use case — the user has Markdown content and wants it in Feishu.
bash
# Convert and copy to clipboard — user pastes directly into Feishu
md2fs <file.md> --copy
# Pipe content from stdin
echo "# Hello World" | md2fs --stdin --copy
# Save raw Lark JSON (for debugging or programmatic use)
md2fs <file.md> -o output.jsonAfter succeeds, tell the user: "Content copied to clipboard — paste into your Feishu document with Cmd+V / Ctrl+V."
md2fs --copyIf clipboard copy fails (common on headless/remote environments), falls back to printing HTML to stdout. In that case, suggest saving to a JSON file with instead.
md2fs-oFeishu → Markdown (fs2md)
Fetches a Feishu document by URL and converts to Markdown. Requires authentication — see Cookie Setup below.
bash
# Save to file (images auto-downloaded to ./images/ next to the output)
fs2md <feishu-url> -o output.md
# Copy Markdown to clipboard instead of saving
fs2md <feishu-url>
# Skip image downloading
fs2md <feishu-url> -o output.md --no-imagesSupported URL formats
Both document types are supported — wiki URLs are auto-resolved to the underlying docx:
https://xxx.feishu.cn/docx/TOKENhttps://xxx.feishu.cn/wiki/TOKEN
Image handling
By default, all images in the document are downloaded to an directory alongside the output file, and Markdown references are rewritten to . Use if you only need the text.
images/./images/filename.png--no-imagesCookie Setup (Required for fs2md)
fs2md- CLI flag (one-off use)
--cookie - environment variable
FEISHU_COOKIE - config file (recommended for persistent use)
~/.md-lark-converter.json
Check if cookie is already configured
bash
cat ~/.md-lark-converter.json 2>/dev/nullIf the config file exists and contains a cookie, try using it directly. Only proceed with cookie setup if it's missing or expired (authentication errors).
Obtaining the cookie
When a cookie is needed (missing or expired), proactively ask the user:
"I need a Feishu session cookie to fetch documents. Would you like me to automatically open a browser and extract it after you log in? Or would you prefer to copy it manually from DevTools?"
Option A: Automatic extraction via MCP browser tool
IMPORTANT: Do NOT write a Playwright/Puppeteer script file to implement this. Use an MCP browser tool.
If the user chooses automatic extraction:
- Check if an MCP browser tool (e.g. Playwright MCP) is available in the current session
- If not available, tell the user they need to configure one first, and suggest adding this to in the project root or
.mcp.jsonglobally:~/.claude/mcp.jsonThen ask the user to restart the session after adding the config.json{ "mcpServers": { "playwright": { "command": "npx", "args": ["@anthropic/mcp-playwright"] } } } - If available, use the MCP browser tool to:
- Launch a headed browser and navigate to
https://www.feishu.cn - Tell the user to log in within the browser window
- Poll the browser cookies every 2 seconds, checking for or
session_list_v5cookie names — their presence indicates a successful login_csrf_token - Once detected, collect all cookies whose domain includes or
feishu.cn, format them aslarkname=value; name=value; ... - Save to :
~/.md-lark-converter.jsonjson{ "cookie": "<collected-cookie-string>" } - Close the browser and confirm to the user that the cookie has been saved
- Launch a headed browser and navigate to
Key details:
- Use — the user needs to interact with the login page
headless: false - Set a generous timeout (5 minutes) for the polling loop — login may involve 2FA or SSO
- Do NOT rely on URL pattern matching after login; Feishu may redirect to various paths
Option B: Manual extraction from DevTools (default)
Guide the user through manual extraction:
- Open a Feishu document in the browser (e.g. )
https://xxx.feishu.cn/docx/... - Open DevTools — (Windows/Linux) or
F12(macOS)Cmd+Option+I - Switch to the Network tab, refresh the page
- Click any request to
feishu.cn - In the request headers, copy the entire Cookie header value (it's long — that's expected)
- Save to config file:
bash
cat > ~/.md-lark-converter.json << 'EOF'
{
"cookie": "YOUR_COOKIE_HERE"
}
EOFCookie expiration
The cookie expires periodically (typically after a few days). If returns authentication errors or empty results, the cookie needs to be refreshed. Ask the user again whether they'd like automatic or manual extraction.
fs2mdDecision Flow
When the user's request involves Feishu:
User has Markdown, wants it in Feishu →
- Identify the Markdown file path or content
- Run
md2fs <path> --copy - Confirm clipboard is ready for pasting
User wants Feishu content as Markdown →
- Get the Feishu document URL
- Check cookie:
cat ~/.md-lark-converter.json 2>/dev/null - If no cookie exists, ask the user whether to auto-extract via browser automation or manually copy from DevTools
- Run
fs2md <url> -o <output-path> - Report the saved file path and image count
User shares a feishu.cn link without explicit instructions →
Ask whether they want to export it as Markdown. If yes, follow the Feishu → Markdown flow.
User mentions Feishu cookie / authentication issues →
Check the existing config, then offer automatic browser extraction first, with manual DevTools as fallback.