feishu-docs

173
50
Source

飞书文档(Docx)API技能。用于创建、读取、更新和删除飞书文档。支持Markdown/HTML内容转换、文档权限管理。

Install

mkdir -p .claude/skills/feishu-docs && curl -L -o skill.zip "https://mcp.directory/api/skills/download/1764" && unzip -o skill.zip -d .claude/skills/feishu-docs && rm skill.zip

Installs to .claude/skills/feishu-docs

About this skill

飞书文档(Docx)技能

操作飞书新版文档(Docx)的openClaw技能,基于飞书开放平台 API 实现文档全生命周期管理。

功能特性

功能说明
文档 CRUD创建、获取、更新(全量替换)、删除文档
内容追加向已有文档末尾追加 Markdown/HTML 内容
内容转换通过飞书服务端 API 将 Markdown/HTML 转换为文档块
块操作获取文档块列表(自动分页)、插入子块、删除块
权限管理添加协作者、查看权限成员列表
文件管理按文件夹列出文件、按关键词搜索文档

环境变量

export FEISHU_APP_ID=cli_xxxxxx          # 飞书应用 App ID
export FEISHU_APP_SECRET=your_app_secret  # 飞书应用 App Secret

也可通过 .env 文件配置(项目使用 dotenv 自动加载)。

快速开始

# 安装依赖
npm install

# 查看帮助
node bin/cli.js --help

# 创建文档(含 Markdown 内容)
node bin/cli.js create -f fldxxxxxx -t "项目计划" -c "# 概述\n\n内容..."

# 获取文档
node bin/cli.js get -d dcnxxxxxx --format markdown --include-content

# 全量替换文档内容
node bin/cli.js update -d dcnxxxxxx --content-file new-content.md

# 追加内容
node bin/cli.js update -d dcnxxxxxx --append -c "## 补充\n\n新增内容"

# 删除文档
node bin/cli.js delete -d dcnxxxxxx

CLI 命令

命令说明必要参数
create创建文档(有内容时自动使用转换流程)-f文件夹token, -t标题
create-with-content创建文档并通过转换API插入内容-f文件夹token, -t标题
get获取文档信息-d文档ID
update替换或追加文档内容-d文档ID, -c内容或--content-file
delete删除文档-d文档ID
search搜索文档-q关键词
list列出文件夹中的文件-f文件夹token
share分享文档给用户-d文档ID, -u用户ID
permissions查看文档权限成员-d文档ID
convert将Markdown/HTML转换为文档块(预览)-t内容类型

所有命令均支持 --app-id--app-secret 参数覆盖环境变量。

API 方法

文档管理

方法说明
createDocument(folderToken, title)创建空文档
createDocumentWithContent(folderToken, title, content, contentType)创建文档并插入内容
getDocument(documentId)获取文档信息
getDocumentRawContent(documentId)获取文档纯文本内容
deleteDocument(documentId)删除文档(通过 Drive API)

文档块操作

方法说明
getDocumentBlocks(documentId, pageSize, pageToken)获取文档块列表(单页)
getAllDocumentBlocks(documentId)获取所有块(自动分页)
updateDocumentBlock(documentId, blockId, updateRequest)更新指定块
createDocumentBlocks(documentId, blockId, children, index)在指定块下插入子块
deleteDocumentBlock(documentId, blockId)删除指定块
batchDeleteBlocks(documentId, blockIds)批量删除块

内容操作

方法说明
appendToDocument(documentId, content, contentType)向文档末尾追加内容
replaceDocumentContent(documentId, content, contentType)全量替换文档内容
convertContent(contentType, content, userIdType)将 Markdown/HTML 转换为文档块

文件与搜索

方法说明
listFolderFiles(folderToken, type)列出文件夹下的文件
searchDocuments(query, folderToken)按关键词搜索文档

权限管理

方法说明
addPermissionMember(token, memberId, memberType, perm)添加权限成员
getPermissionMembers(token)获取权限成员列表

格式转换(本地)

方法说明
markdownToBlocks(markdown)Markdown → 飞书块结构(本地转换)
blocksToMarkdown(blocks)飞书块结构 → Markdown(支持数字/字符串 block_type)

飞书 API 端点

代码实际调用的飞书开放平台端点:

POST   /docx/v1/documents                                    # 创建文档
GET    /docx/v1/documents/{document_id}                      # 获取文档信息
GET    /docx/v1/documents/{document_id}/raw_content          # 获取文档纯文本
GET    /docx/v1/documents/{document_id}/blocks               # 获取文档块列表
PATCH  /docx/v1/documents/{document_id}/blocks/{block_id}    # 更新块
DELETE /docx/v1/documents/{document_id}/blocks/{block_id}    # 删除块
POST   /docx/v1/documents/{document_id}/blocks/{block_id}/children  # 插入子块
POST   /docx/v1/documents/blocks/convert                     # Markdown/HTML→块
DELETE /drive/v1/files/{file_token}?type=docx                # 删除文档
GET    /drive/v1/files?folder_token=xxx                      # 列出文件夹文件
POST   /drive/v1/permissions/{token}/members?type=docx       # 添加权限成员
GET    /drive/v1/permissions/{token}/members?type=docx       # 获取权限成员
POST   /auth/v3/tenant_access_token/internal/                # 获取 tenant_access_token

可靠性机制

  • Token 缓存与并发控制:access_token 缓存复用,多个并发请求不会重复刷新
  • 自动重试:401 未授权自动刷新 token 重试;429 限流和 5xx 错误指数退避重试(最多 2 次)
  • Token 过期码识别:检测飞书错误码 99991663/99991661 自动刷新 token
  • 安全错误处理:安全访问 error.response.data,避免非 JSON 响应导致崩溃

注意事项

  1. 应用权限:飞书应用需具备 docs:docdrive:drivedrive:file 等相关权限
  2. 内容插入create 命令含 content 时自动走 convertContentcreateDocumentBlocks 流程,确保文档结构正确
  3. 批量插入限制:每批最多插入 50 个块(飞书 API 限制)
  4. 表格处理:转换含表格的内容时自动去除 merge_info 字段;block_type 为 31/32 的表格块暂被过滤
  5. 内容大小:单次转换内容不超过 10MB

项目结构

├── src/api.js        # FeishuDocsAPI 类(所有 API 方法 + 格式转换)
├── bin/cli.js        # Commander 命令行工具
├── package.json      # 依赖:axios, commander, dotenv
├── test-convert.js   # 转换接口测试
├── SKILL.md          # 本文件
└── README.md         # 项目说明

a-stock-analysis

openclaw

A股实时行情与分时量能分析。获取沪深股票实时价格、涨跌、成交量,分析分时量能分布(早盘/尾盘放量)、主力动向(抢筹/出货信号)、涨停封单。支持持仓管理和盈亏分析。Use when: (1) 查询A股实时行情, (2) 分析主力资金动向, (3) 查看分时成交量分布, (4) 管理股票持仓, (5) 分析持仓盈亏。

703267

fivem

openclaw

Fix, create, or validate FiveM server resources for QBCore/ESX (config.lua, fxmanifest.lua, items, housing/furniture, scripts, MLOs). Use when asked to debug resource errors, convert ESX↔QB, update fxmanifest versions, add items, or source scripts from GitHub. Also use for SSH key generation for SFTP access.

331193

research-paper-writer

openclaw

Creates formal academic research papers following IEEE/ACM formatting standards with proper structure, citations, and scholarly writing style. Use when the user asks to write a research paper, academic paper, or conference paper on any topic.

74165

keyword-research

openclaw

Discovers high-value keywords with search intent analysis, difficulty assessment, and content opportunity mapping. Essential for starting any SEO or GEO content strategy.

429104

weread

openclaw

WeChat Reading (微信读书) CLI tool for fetching notes and highlights. Use when: (1) user asks about weread/微信读书 notes or highlights, (2) fetching today's or recent reading notes, (3) exporting book highlights, (4) managing reading bookshelf, (5) any task involving reading notes from WeChat Reading.

10384

html-to-ppt

openclaw

Convert HTML/Markdown to PowerPoint presentations using Marp

29679

You might also like

ui-ux-pro-max

nextlevelbuilder

"UI/UX design intelligence. 50 styles, 21 palettes, 50 font pairings, 20 charts, 8 stacks (React, Next.js, Vue, Svelte, SwiftUI, React Native, Flutter, Tailwind). Actions: plan, build, create, design, implement, review, fix, improve, optimize, enhance, refactor, check UI/UX code. Projects: website, landing page, dashboard, admin panel, e-commerce, SaaS, portfolio, blog, mobile app, .html, .tsx, .vue, .svelte. Elements: button, modal, navbar, sidebar, card, table, form, chart. Styles: glassmorphism, claymorphism, minimalism, brutalism, neumorphism, bento grid, dark mode, responsive, skeuomorphism, flat design. Topics: color palette, accessibility, animation, layout, typography, font pairing, spacing, hover, shadow, gradient."

2,6132,342

flutter-development

aj-geddes

Build beautiful cross-platform mobile apps with Flutter and Dart. Covers widgets, state management with Provider/BLoC, navigation, API integration, and material design.

2,1121,621

pdf-to-markdown

aliceisjustplaying

Convert entire PDF documents to clean, structured Markdown for full context loading. Use this skill when the user wants to extract ALL text from a PDF into context (not grep/search), when discussing or analyzing PDF content in full, when the user mentions "load the whole PDF", "bring the PDF into context", "read the entire PDF", or when partial extraction/grepping would miss important context. This is the preferred method for PDF text extraction over page-by-page or grep approaches.

3,4391,490

drawio-diagrams-enhanced

jgtolentino

Create professional draw.io (diagrams.net) diagrams in XML format (.drawio files) with integrated PMP/PMBOK methodologies, extensive visual asset libraries, and industry-standard professional templates. Use this skill when users ask to create flowcharts, swimlane diagrams, cross-functional flowcharts, org charts, network diagrams, UML diagrams, BPMN, project management diagrams (WBS, Gantt, PERT, RACI), risk matrices, stakeholder maps, or any other visual diagram in draw.io format. This skill includes access to custom shape libraries for icons, clipart, and professional symbols.

2,1961,420

godot

bfollington

This skill should be used when working on Godot Engine projects. It provides specialized knowledge of Godot's file formats (.gd, .tscn, .tres), architecture patterns (component-based, signal-driven, resource-based), common pitfalls, validation tools, code templates, and CLI workflows. The `godot` command is available for running the game, validating scripts, importing resources, and exporting builds. Use this skill for tasks involving Godot game development, debugging scene/resource files, implementing game systems, or creating new Godot components.

2,3151,175

nano-banana-pro

garg-aayush

Generate and edit images using Google's Nano Banana Pro (Gemini 3 Pro Image) API. Use when the user asks to generate, create, edit, modify, change, alter, or update images. Also use when user references an existing image file and asks to modify it in any way (e.g., "modify this image", "change the background", "replace X with Y"). Supports both text-to-image generation and image-to-image editing with configurable resolution (1K default, 2K, or 4K for high resolution). DO NOT read the image file first - use this skill directly with the --input-image parameter.

1,886941