Use lark-mcp tools to achieve comprehensive automation of the Feishu 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 messages
- Message templates and interactive cards
- File and image sending
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
- Connect data source
- Transform data format
- Create/update Bitable
- Batch write data
- Send notification
Message Push Workflow
- Trigger event (scheduled/event-driven)
- Build message content
- Get recipient ID
- Send message
- Record logs
Document Automation Workflow
- Get document template
- Fill in content
- Create new document
- Set permissions
- Share with team
API Tool Reference
Bitable Related
createBitable- Create BitablecreateTable- Create data tableaddRecord- Add recordupdateRecord- Update recorddeleteRecord- Delete recordsearchRecords- Search recordsgetRecord- Get record details
Message Related
sendMessage- Send messagegetMessages- Get message historyreplyMessage- Reply to message
Document Related
searchDocs- Search documentscreateDoc- Create documentgetDoc- Get document contentupdateDoc- Update documentsetDocPermission- Set document permissions
📄 Import Markdown to cloud documents (recommended method)
Best Practice: Import local Markdown files directly as Feishu cloud documents, with complete formatting 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→ Markdowndocx→ Word documentxlsx→ Excel spreadsheet
Notes:
- Importing is an asynchronous operation; you need to poll
import_tasks/{ticket}to get the result mount_type: 1indicates importing to "My Space"- URL format of the imported document:
https://xxx.feishu.cn/docx/{token}
📤 Complete cloud document output process (standard operation)
Each time you output a cloud document, you must complete the following steps:
- Generate a local Markdown file
- Upload to Feishu Drive →
drive/v1/files/upload_all - Import as a cloud document →
drive/v1/import_tasks - Set permissions to editable within the organization →
drive/v1/permissions/{token}/public - 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 setting description:
link_share_entity: "tenant_editable"→ People in the organization who obtain the link can editcomment_entity: "anyone_can_view"→ Anyone can commentshare_entity: "anyone"→ Anyone can share
Group-related
createGroup- Create a groupaddMember- Add membersgetGroupList- Get group listgetGroupInfo- Get group information
Practical scenarios
1. Automated daily report collection
- Create a table record on a daily schedule
- Members fill in the daily report
- Automatically aggregate statistics
- Send to the group
2. Approval process
- Create an approval table
- Monitor status changes
- Automatically notify approvers
- Record approval history
3. Task management
- Create a task table
- Assign tasks to members
- Send task reminders
- Track completion status
4. Customer management
- Customer information table
- Follow-up records
- Automatic reminders
- Data visualization
5. Report generation
- Extract data from the table
- Generate statistical reports
- Create a Feishu document
- Regularly push updates
Best practices
Authentication configuration
- Use the provided App ID and App Secret
- Comply with API call rate limits
- Cache 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
- Regularly review permissions
- Collaborator lifecycle management
Error handling
Common errors
- Insufficient permissions - check the application permission configuration
- Rate limit error - implement retries and waiting
- Invalid ID - verify 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 validation
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 scheduled reports
- 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
- Restart Claude Desktop
- Check the network connection
- Verify whether the credentials are valid
- Check the error logs
API call failed
- Check the application permission configuration
- Verify the user/group ID
- Check the rate limiting status
- Check the data format
Insufficient permissions
- Log in to the Feishu Open Platform
- Check the application permission scope
- Reauthorize
- Wait for permissions to take effect