SuperAPI AI Directory

feishu-automation

Office & productivity

View repository

Updated 10-15 07:58

About this skill

Lark Full-Channel Automation

Use the lark-mcp tool to achieve comprehensive automation operations on the Lark platform.

Core Features

1. Bitable

  • Create Bitable and data tables
  • Add, modify, and delete fields
  • Create, read, update, and delete record data
  • Batch import and export data
  • Data filtering and sorting

2. Message Sending

  • Send text, rich text, and card messages
  • Group messages and private chat messages
  • Message templates and interactive cards
  • Send files and images

3. Document Management

  • Search cloud documents
  • Create new documents
  • Edit document content
  • Document permission management
  • Document collaborator management

4. Group Management

  • Create groups
  • Add/remove members
  • Get group list
  • Group information query

5. Wiki

  • Search Wiki nodes
  • Get node details
  • Create and manage Wiki content

6. Calendar and Tasks

  • Create and query calendar events
  • Create and manage tasks
  • Task assignment and tracking

Quick Start

Check MCP Availability

// 检查 lark-mcp 工具是否可用
// 可用工具前缀:mcp__lark-mcp_

Send Test Message

// 发送文本消息到群组
await mcp__lark-mcp_sendMessage({
  receive_id: "oc_xxxxxxxxx",
  msg_type: "text",
  content: JSON.stringify({
    text: "Hello from Clawdbot!"
  })
});

Workflow

Data Sync Workflow

  1. Connect data source
  2. Transform data format
  3. Create/update Bitable
  4. Batch write data
  5. Send notification

Message Push Workflow

  1. Trigger event (scheduled/event-driven)
  2. Build message content
  3. Get recipient ID
  4. Send message
  5. Record logs

Document Automation Workflow

  1. Get document template
  2. Fill in content
  3. Create new document
  4. Set permissions
  5. Share with team

API Tool Reference

Bitable Related

  • createBitable - Create Bitable
  • createTable - Create data table
  • addRecord - Add record
  • updateRecord - Update record
  • deleteRecord - Delete record
  • searchRecords - Search records
  • getRecord - Get record details

Message Related

  • sendMessage - Send message
  • getMessages - Get message history
  • replyMessage - Reply to message

Document Related

  • searchDocs - Search documents
  • createDoc - Create document
  • getDoc - Get document content
  • updateDoc - Update document
  • setDocPermission - Set document permissions

📄 Import Markdown to Cloud Docs (Recommended)

Best Practice: Import local Markdown files directly as Lark cloud documents, with formatting fully preserved.

# 1. 获取 access_token
TOKEN=$(curl -s -X POST 'https://open.feishu.cn/open-apis/auth/v3/tenant_access_token/internal' \
  -H 'Content-Type: application/json' \
  -d '{"app_id":"YOUR_APP_ID","app_secret":"YOUR_APP_SECRET"}' \
  | python3 -c "import sys,json; print(json.load(sys.stdin).get('tenant_access_token',''))")

# 2. 上传 md 文件到飞书云盘
FILE_TOKEN=$(curl -s -X POST 'https://open.feishu.cn/open-apis/drive/v1/files/upload_all' \
  -H "Authorization: Bearer $TOKEN" \
  -F "file_name=document.md" \
  -F "parent_type=explorer" \
  -F "parent_node=" \
  -F "size=$(stat -c%s /path/to/document.md)" \
  -F "file=@/path/to/document.md" \
  | python3 -c "import sys,json; print(json.load(sys.stdin).get('data',{}).get('file_token',''))")

# 3. 导入为飞书云文档
TICKET=$(curl -s -X POST 'https://open.feishu.cn/open-apis/drive/v1/import_tasks' \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "file_extension": "md",
    "file_token": "'"$FILE_TOKEN"'",
    "type": "docx",
    "point": {"mount_type": 1, "mount_key": ""}
  }' | python3 -c "import sys,json; print(json.load(sys.stdin).get('data',{}).get('ticket',''))")

# 4. 等待导入完成,获取文档链接
sleep 2
curl -s -X GET "https://open.feishu.cn/open-apis/drive/v1/import_tasks/$TICKET" \
  -H "Authorization: Bearer $TOKEN" \
  | python3 -c "import sys,json; d=json.load(sys.stdin); print(d.get('data',{}).get('result',{}).get('url',''))"

Supported Import Formats:

  • md → Markdown
  • docx → Word document
  • xlsx → Excel spreadsheet

Notes:

  • Importing is an asynchronous operation; you need to poll import_tasks/{ticket} to get the result
  • mount_type: 1 means importing to "My Space"
  • URL format of the imported document:https://xxx.feishu.cn/docx/{token}

📤 Complete cloud document output process (standard procedure)

Each time you output a cloud document, you must complete the following steps:

  1. Generate a local Markdown file
  2. Upload to Feishu Drive → drive/v1/files/upload_all
  3. Import as a cloud document → drive/v1/import_tasks
  4. Set permissions to editable within the organization → drive/v1/permissions/{token}/public
  5. Send the link to the target group
# 完整流程脚本
TOKEN=$(curl -s -X POST 'https://open.feishu.cn/open-apis/auth/v3/tenant_access_token/internal' \
  -H 'Content-Type: application/json' \
  -d '{"app_id":"APP_ID","app_secret":"APP_SECRET"}' \
  | python3 -c "import sys,json; print(json.load(sys.stdin).get('tenant_access_token',''))")

# 1. 上传文件
FILE_TOKEN=$(curl -s -X POST 'https://open.feishu.cn/open-apis/drive/v1/files/upload_all' \
  -H "Authorization: Bearer $TOKEN" \
  -F "file_name=document.md" \
  -F "parent_type=explorer" \
  -F "parent_node=" \
  -F "size=$(stat -c%s document.md)" \
  -F "file=@document.md" \
  | python3 -c "import sys,json; print(json.load(sys.stdin).get('data',{}).get('file_token',''))")

# 2. 导入为云文档
TICKET=$(curl -s -X POST 'https://open.feishu.cn/open-apis/drive/v1/import_tasks' \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"file_extension":"md","file_token":"'"$FILE_TOKEN"'","type":"docx","point":{"mount_type":1,"mount_key":""}}' \
  | python3 -c "import sys,json; print(json.load(sys.stdin).get('data',{}).get('ticket',''))")

sleep 2

# 3. 获取文档 token
DOC_RESULT=$(curl -s -X GET "https://open.feishu.cn/open-apis/drive/v1/import_tasks/$TICKET" \
  -H "Authorization: Bearer $TOKEN")
DOC_TOKEN=$(echo "$DOC_RESULT" | python3 -c "import sys,json; print(json.load(sys.stdin).get('data',{}).get('result',{}).get('token',''))")
DOC_URL=$(echo "$DOC_RESULT" | python3 -c "import sys,json; print(json.load(sys.stdin).get('data',{}).get('result',{}).get('url',''))")

# 4. 设置权限:组织内可编辑
curl -s -X PATCH "https://open.feishu.cn/open-apis/drive/v1/permissions/$DOC_TOKEN/public?type=docx" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"external_access_entity":"open","security_entity":"anyone_can_view","comment_entity":"anyone_can_view","share_entity":"anyone","link_share_entity":"tenant_editable"}'

# 5. 发送到群
curl -s -X POST "https://open.feishu.cn/open-apis/im/v1/messages?receive_id_type=chat_id" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"receive_id":"CHAT_ID","msg_type":"text","content":"{\"text\":\"📄 文档已上传:\\n\\n'"$DOC_URL"'\"}"}'

Permission settings description:

  • link_share_entity: "tenant_editable" → Anyone in the organization with the link can edit
  • comment_entity: "anyone_can_view" → Anyone can comment
  • share_entity: "anyone" → Anyone can share

Group-related

  • createGroup - Create a group
  • addMember - Add members
  • getGroupList - Get the group list
  • getGroupInfo - Get group information

Practical scenarios

1. Automated daily report collection

  • Create a spreadsheet record on a daily schedule
  • Members fill in daily reports
  • Automatically aggregate and count
  • Send to the group

2. Approval process

  • Create an approval spreadsheet
  • Monitor status changes
  • Automatically notify approvers
  • Record approval history

3. Task management

  • Create a task spreadsheet
  • Assign tasks to members
  • Send task reminders
  • Track completion status

4. Customer management

  • Customer information spreadsheet
  • Follow-up records
  • Automatic reminders
  • Data visualization

5. Report generation

  • Extract data from the spreadsheet
  • Generate statistical reports
  • Create Feishu documents
  • Push updates regularly

Best practices

Authentication configuration

  • Use the provided App ID and App Secret
  • Comply with API call rate limits
  • Cache the access_token

Data operations

  • Use pagination for batch operations
  • Validate the format before writing data
  • Error handling and retries
  • Record operation logs

Message sending

  • Use interactive cards to improve the experience
  • Control the sending frequency reasonably
  • Avoid sending sensitive information
  • Support user interaction

Permission management

  • Principle of least privilege
  • Review permissions regularly
  • Collaborator lifecycle management

Error handling

Common errors

  • Insufficient permissions - Check the app permission configuration
  • Rate limit error - Implement retries and waiting
  • Invalid ID - Validate the user/group ID format
  • Network error - Implement a retry mechanism

Retry strategy

  • Exponential backoff algorithm
  • Maximum retry count limit
  • Record failed requests
  • Notify the administrator

Security considerations

  • Protect the App Secret
  • Do not record sensitive information in logs
  • Use environment variables to manage credentials
  • Rotate access tokens regularly
  • Comply with data privacy regulations

Example code

Create a multidimensional table and add data

// 创建多维表格
const bitable = await mcp__lark-mcp_createBitable({
  name: "项目管理",
  folder_token: "folder_token"
});

// 创建数据表
const table = await mcp__lark-mcp_createTable({
  app_token: bitable.app_token,
  table: {
    name: "任务列表",
    fields: [
      { field_name: "任务名称", type: 1 },
      { field_name: "负责人", type: 13 },
      { field_name: "状态", type: 3 },
      { field_name: "截止日期", type: 5 }
    ]
  }
});

// 添加记录
await mcp__lark-mcp_addRecord({
  app_token: bitable.app_token,
  table_id: table.table_id,
  fields: {
    "任务名称": "完成项目文档",
    "负责人": "user_id",
    "状态": "进行中",
    "截止日期": Date.now()
  }
});

Send a card message

await mcp__lark-mcp_sendMessage({
  receive_id: "chat_id",
  msg_type: "interactive",
  content: JSON.stringify({
    config: {
      wide_screen_mode: true
    },
    header: {
      template: "turquoise",
      title: {
        content: "重要通知",
        tag: "plain_text"
      }
    },
    elements: [
      {
        tag: "div",
        text: {
          content: "**项目里程碑已完成**",
          tag: "lark_md"
        }
      },
      {
        tag: "action",
        actions: [
          {
            tag: "button",
            text: {
              content: "查看详情",
              tag: "plain_text"
            },
            type: "primary",
            url: "https://example.com"
          }
        ]
      }
    ]
  })
});

Bulk import data

const data = [
  { name: "张三", phone: "13800138000" },
  { name: "李四", phone: "13900139000" }
];

for (const item of data) {
  await mcp__lark-mcp_addRecord({
    app_token: "app_token",
    table_id: "table_id",
    fields: {
      "姓名": item.name,
      "电话": item.phone
    }
  });

  // 避免限流
  await new Promise(resolve => setTimeout(resolve, 100));
}

Configuration verification

Check the MCP server

# 检查 .claude.json 中的 lark-mcp 配置
cat ~/.claude.json | grep -A 15 "lark-mcp"

Test the connection

// 发送测试消息验证连接
await mcp__lark-mcp_sendMessage({
  receive_id: "your_chat_id",
  msg_type: "text",
  content: JSON.stringify({
    text: "🎉 飞书 MCP 连接成功!"
  })
});

Advanced usage

Webhook integration

  • Listen for Feishu webhook events
  • Automatically trigger workflows
  • Real-time data synchronization

Automated scheduled tasks

  • Send reports on a schedule
  • Automatic data backup
  • Regular cleanup

Cross-platform integration

  • Integrate with GitHub (issue synchronization)
  • Integrate with email (notification push)
  • Integrate with calendar (schedule management)

Troubleshooting

MCP tool unavailable

  1. Restart Claude Desktop
  2. Check the network connection
  3. Verify whether the credentials are valid
  4. View the error logs

API call failed

  1. Check the application permission configuration
  2. Verify the user/group ID
  3. Check the rate limiting status
  4. Check the data format

Insufficient permissions

  1. Log in to the Feishu Open Platform
  2. Check the application permission scope
  3. Reauthorize
  4. Wait for the permissions to take effect